two permissions in a row

This commit is contained in:
Andrey Shovkoplyas 2018-10-01 11:28:09 +02:00
parent 6d936786c6
commit 6bee2ea3c3
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
4 changed files with 14 additions and 16 deletions

View File

@ -6,9 +6,6 @@
[status-dapp.views :as views]
[status-dapp.config :as config]))
(js/window.addEventListener "statusapi"
#(re-frame/dispatch [:on-status-api (js->clj (.-detail %) :keywordize-keys true)]))
(defn dev-setup []
(when config/debug?
(enable-console-print!)

View File

@ -3,8 +3,11 @@
(def web3 (or (when (exists? js/web3) js/web3)
(when js/ethereum
(js/setTimeout (fn [] (.then (.enable js/ethereum) #(do
(re-frame/dispatch [:set-default-account]))) 100))
(js/setTimeout (fn []
(.then (.enable js/ethereum) #(re-frame/dispatch [:set-default-account]))
(when js/ethereum.status
(.then (.getContactCode js/ethereum.status) #(re-frame/dispatch [:on-status-api :contact %]))))
100)
(js/Web3. js/ethereum))))
(def default-db

View File

@ -246,9 +246,8 @@
(re-frame/reg-event-fx
:on-status-api
(fn [{db :db} [_ {:keys [data permissions]}]]
(println "ON MESSAGE DATA" data)
{:db (assoc-in db [:api :contact] (:CONTACT_CODE data))}))
(fn [{db :db} [_ api data]]
{:db (assoc-in db [:api api] data)}))
(re-frame/reg-event-fx
:set-default-account

View File

@ -139,14 +139,13 @@
(when (= :api tab-view)
[react/view
[ui/button "Request contact code (public key)"
#(js/window.postMessage
(clj->js {:type "STATUS_API_REQUEST" :permissions ["CONTACT_CODE" "CONTACTS"]})
"*")]
[react/view {:style {:margin-bottom 10}}
[ui/label "Contact code: " ""]
[react/text (:contact status-api)]]
(when (exists? js/window.ethereum.status)
[react/view
[ui/button "Request contact code (public key)"
(fn [] (.then (.getContactCode js/window.ethereum.status) #(re-frame/dispatch [:on-status-api :contact %])))]
[react/view {:style {:margin-bottom 10}}
[ui/label "Contact code: " ""]
[react/text (:contact status-api)]]])
[ui/button "Scan QR"
(fn [] (if (and web3 (.-currentProvider web3) (.-scanQRCode (.-currentProvider web3)))