From b754092710f69f3b956482a3caab46f6f93c152b Mon Sep 17 00:00:00 2001 From: Andrey Shovkoplyas Date: Mon, 27 Aug 2018 11:26:05 +0300 Subject: [PATCH] update status js api according to latest changes in web3 opt-in EIP Signed-off-by: Andrey Shovkoplyas --- resources/js/web3_init.js | 5 +++-- src/status_im/models/browser.cljs | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/resources/js/web3_init.js b/resources/js/web3_init.js index d9ef2031fb..675e663594 100644 --- a/resources/js/web3_init.js +++ b/resources/js/web3_init.js @@ -20,8 +20,9 @@ WebViewBridge.onMessage = function (message) { } else { - window.STATUS_API = data.data; - window.postMessage({ type: 'STATUS_API_SUCCESS', permissions: data.keys }, "*"); + window.dispatchEvent(new CustomEvent('statusapi', { detail: { permissions: data.keys, + data: data.data + } })); } } diff --git a/src/status_im/models/browser.cljs b/src/status_im/models/browser.cljs index d1397a4607..b1cccb69ba 100644 --- a/src/status_im/models/browser.cljs +++ b/src/status_im/models/browser.cljs @@ -78,14 +78,17 @@ {:db (assoc-in db [:browser/options :show-permission] {:requested-permission requested-permission :params params})}) {:dispatch [:next-dapp-permission params]})) - (assoc (update-dapp-permissions-fx cofx {:dapp dapp-name - :permissions (vec (set (concat (keys permissions-allowed) - user-permissions)))}) - :send-to-bridge-fx [{:type constants/status-api-success - :data permissions-allowed - :keys (keys permissions-allowed)} - (:webview-bridge db)] - :dispatch [:check-permissions-queue]))) + (cond-> (update-dapp-permissions-fx cofx {:dapp dapp-name + :permissions (vec (set (concat (keys permissions-allowed) + user-permissions)))}) + (not (zero? (count permissions-allowed))) + (assoc :send-to-bridge-fx [{:type constants/status-api-success + :data permissions-allowed + :keys (keys permissions-allowed)} + (:webview-bridge db)]) + + true + (assoc :dispatch [:check-permissions-queue])))) (defn next-permission [{:keys [params permission permissions-data]} cofx] (request-permission