Use promise resolve value instead of global var
This commit is contained in:
parent
3210411a4c
commit
0dd2ecbf7a
|
@ -3,17 +3,12 @@
|
||||||
|
|
||||||
(def dapp-store? (re-find #"#dapp-store" (-> js/window .-location .-href)))
|
(def dapp-store? (re-find #"#dapp-store" (-> js/window .-location .-href)))
|
||||||
|
|
||||||
(def web3 (or dapp-store? (when (exists? js/web3) js/web3)
|
(def web3 (or dapp-store? (when (exists? js/web3)
|
||||||
#_(when (exists? js/ethereumBeta)
|
js/web3)
|
||||||
(js/setTimeout (fn []
|
|
||||||
(.then (.send js/ethereumBeta "eth_requestAccounts") #(re-frame/dispatch [:set-default-account]))
|
|
||||||
(when js/ethereumBeta
|
|
||||||
(.then (.getContactCode js/ethereumBeta.status) #(re-frame/dispatch [:on-status-api :contact %]))))
|
|
||||||
100)
|
|
||||||
(js/Web3. js/ethereumBeta))
|
|
||||||
(when (exists? js/ethereum)
|
(when (exists? js/ethereum)
|
||||||
(js/setTimeout (fn []
|
(js/setTimeout (fn []
|
||||||
(.then (.enable js/ethereum) #(re-frame/dispatch [:set-default-account]))
|
(.then (.enable js/ethereum)
|
||||||
|
#(re-frame/dispatch [:set-default-account (first %1)]))
|
||||||
(when js/ethereum.status
|
(when js/ethereum.status
|
||||||
(.then (.getContactCode js/ethereum.status) #(re-frame/dispatch [:on-status-api :contact %]))))
|
(.then (.getContactCode js/ethereum.status) #(re-frame/dispatch [:on-status-api :contact %]))))
|
||||||
100)
|
100)
|
||||||
|
|
|
@ -292,6 +292,6 @@
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
:set-default-account
|
:set-default-account
|
||||||
(fn [{db :db} _]
|
(fn [{db :db} [_ current-account-address]]
|
||||||
(set! (.-defaultAccount (.-eth (:web3 db))) js/currentAccountAddress)
|
(set! (.-defaultAccount (.-eth (:web3 db))) current-account-address)
|
||||||
{:dispatch [:request-web3-async-data]}))
|
{:dispatch [:request-web3-async-data]}))
|
Loading…
Reference in New Issue