diff --git a/src/cljs/status_dapp/components.cljs b/src/cljs/status_dapp/components.cljs index ae73177..9c1cf81 100644 --- a/src/cljs/status_dapp/components.cljs +++ b/src/cljs/status_dapp/components.cljs @@ -27,6 +27,8 @@ [tab-button "ETH" :eth tab-view] [tab-button "Version" :version tab-view] [tab-button "Status API" :api tab-view] + (when js/ethereumBeta + [tab-button "Beta Provider" :beta tab-view]) [tab-button "About" :about tab-view]] [react/view {:style {:height 1 :margin-top 10 :background-color "#4360df33"}}]]) diff --git a/src/cljs/status_dapp/db.cljs b/src/cljs/status_dapp/db.cljs index f414ec1..e38c721 100644 --- a/src/cljs/status_dapp/db.cljs +++ b/src/cljs/status_dapp/db.cljs @@ -2,6 +2,13 @@ (:require [re-frame.core :as re-frame])) (def web3 (or (when (exists? js/web3) js/web3) + (when js/ethereumBeta + (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 js/ethereum (js/setTimeout (fn [] (.then (.enable js/ethereum) #(re-frame/dispatch [:set-default-account])) diff --git a/src/cljs/status_dapp/events.cljs b/src/cljs/status_dapp/events.cljs index 3b550d8..f3a42d9 100644 --- a/src/cljs/status_dapp/events.cljs +++ b/src/cljs/status_dapp/events.cljs @@ -110,14 +110,16 @@ (fn [{{:keys [web3] :as db} :db} _] (println "WEB3" web3) (when web3 - {:db (update db :web3-async-data - assoc - :api (.-api (.-version web3)) - :network (.-network (.-version web3)) - :accounts (.-accounts (.-eth web3)) - :default-account (.-defaultAccount (.-eth web3)) - :coinbase (.-coinbase (.-eth web3)) - :default-block (.-defaultBlock (.-eth web3))) + {:db (if js/window.ethereumBeta + db + (update db :web3-async-data + assoc + :api (.-api (.-version web3)) + :network (.-network (.-version web3)) + :accounts (.-accounts (.-eth web3)) + :default-account (.-defaultAccount (.-eth web3)) + :coinbase (.-coinbase (.-eth web3)) + :default-block (.-defaultBlock (.-eth web3)))) :web3-node-fx web3 :web3-coinbase-fx web3 :web3-ethereum-fx web3 diff --git a/src/cljs/status_dapp/views.cljs b/src/cljs/status_dapp/views.cljs index a7df55a..88733c6 100644 --- a/src/cljs/status_dapp/views.cljs +++ b/src/cljs/status_dapp/views.cljs @@ -137,6 +137,10 @@ (when gas-price [ui/label "gasPrice" (str (.toString gas-price 10) " wei")])]) + (when (= :beta tab-view) + [react/view + [ui/button "Subscribe logs" + (fn [] (.send js/window.ethereumBeta "eth_subscribe" (clj->js ["syncing" {}])))]]) (when (= :api tab-view) [react/view (when (exists? js/window.ethereum.status)