diff --git a/src/cljs/status_dapp/events.cljs b/src/cljs/status_dapp/events.cljs index 6f2ca33..ad0c269 100644 --- a/src/cljs/status_dapp/events.cljs +++ b/src/cljs/status_dapp/events.cljs @@ -53,9 +53,6 @@ (fn [[web3 address]] (.getBalance (.-eth web3) (str address) #(re-frame/dispatch [:set-in [:balances address] (str (.toString %2 10))])))) -(defn waiting-for-mining [web3 tx-hash] - (.getTransactionReceipt (.-eth web3) tx-hash #(re-frame/dispatch [:verify-reciept %2]))) - (def abi (js/JSON.parse "[{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]")) (re-frame/reg-fx @@ -65,7 +62,7 @@ (.new contract (clj->js {:from address :data "0x6060604052341561000f57600080fd5b60d38061001d6000396000f3006060604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c14606e575b600080fd5b3415605857600080fd5b606c60048080359060200190919050506094565b005b3415607857600080fd5b607e609e565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a7230582087e84161fdd2e7143a7ef1adc914230c9751de6d8abb28fce70837c6d45694c90029"}) - #(re-frame/dispatch [:new-contact-sent (.-transactionHash %2) (.-address %2)]))))) + #(re-frame/dispatch [:new-contact-callback (.-transactionHash %2) (.-address %2)]))))) (re-frame/reg-fx :call-set-contract-fx @@ -114,13 +111,16 @@ {: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-network-fx web3 + ;:web3-network-fx web3 :web3-ethereum-fx web3 :web3-whisper-fx web3 - :web3-accounts-fx web3 + ;:web3-accounts-fx web3 :web3-syncyng-fx web3 :web3-gas-price-fx web3}))) @@ -173,28 +173,13 @@ :on-success [:good-request-ropsten-eth] :on-failure [:bad-request-ropsten-eth]}})) -;;TODO Should be fixed on go side soon (re-frame/reg-event-fx - :verify-reciept - (fn [{{:keys [web3 contract] :as db} :db} [_ reciept]] - (let [{:keys [tx-hash]} contract] - (println "Verify-reciept " tx-hash " " reciept) - (if reciept - (do - (println "MINED " reciept " " (.-contractAddress reciept) " " (.-status reciept) " " (= (.-status reciept) "0x1")) - {:db (assoc db :contract (when (= (.-status reciept) "0x1") - {:address (.-contractAddress reciept)}))}) - (do - (js/setTimeout waiting-for-mining 5000 web3 tx-hash) - nil))))) - -(re-frame/reg-event-fx - :new-contact-sent - (fn [{{:keys [web3] :as db} :db} [_ tx-hash address]] - (println "new-contact-sent " address) - (waiting-for-mining web3 tx-hash) - {:db (assoc db :contract {:tx-hash tx-hash - :mining? true})})) + :new-contact-callback + (fn [{db :db} [_ tx-hash address]] + (println ":new-contact-callback tx-hash: " tx-hash " address: " address) + {:db (assoc db :contract (if address + {:address address} + {:tx-hash tx-hash}))})) (re-frame/reg-event-fx :sign-message diff --git a/src/cljs/status_dapp/views.cljs b/src/cljs/status_dapp/views.cljs index a53714f..da99faf 100644 --- a/src/cljs/status_dapp/views.cljs +++ b/src/cljs/status_dapp/views.cljs @@ -45,7 +45,7 @@ (defview web3-view [] (letsubs [{:keys [api node network ethereum whisper accounts syncing gas-price - default-account default-block]} + default-account coinbase default-block]} [:get :web3-async-data] tab-view [:get :tab-view] balances [:get :balances]] @@ -87,6 +87,8 @@ [react/text {:style {:font-weight :bold :margin-top 20}} "Accounts"] [ui/label "defaultAccount" ""] [react/text default-account] + [ui/label "coinbase" ""] + [react/text coinbase] [ui/label "accounts" ""] (for [account accounts] ^{:key account}