diff --git a/src/status_im/ethereum/json_rpc.cljs b/src/status_im/ethereum/json_rpc.cljs index fbc7a3e9c1a6..38a83c3620bd 100644 --- a/src/status_im/ethereum/json_rpc.cljs +++ b/src/status_im/ethereum/json_rpc.cljs @@ -4,15 +4,18 @@ [status-im.ethereum.decode :as decode] [status-im.native-module.core :as status] [status-im.utils.ethereum.abi-spec :as abi-spec] + [status-im.utils.money :as money] [status-im.utils.types :as types] [taoensso.timbre :as log])) (def json-rpc-api {"eth_call" {} "eth_getBalance" - {:on-result decode/uint} + {:on-result money/bignumber} "eth_estimateGas" - {:on-result decode/uint} + {:on-result money/bignumber} + "eth_gasPrice" + {:on-result money/bignumber} "eth_getBlockByHash" {:on-result #(-> (update % :number decode/uint) (update :timestamp decode/uint))} diff --git a/src/status_im/ethereum/transactions/core.cljs b/src/status_im/ethereum/transactions/core.cljs index 64d3220f8be5..3ad90681631e 100644 --- a/src/status_im/ethereum/transactions/core.cljs +++ b/src/status_im/ethereum/transactions/core.cljs @@ -111,7 +111,7 @@ (doseq [[block-hash block-transfers] transfers-by-block] (json-rpc/call {:method "eth_getBlockByHash" - :params [block-hash] + :params [block-hash false] :on-success (fn [{:keys [timestamp number]}] (let [timestamp (str (* timestamp 1000))] @@ -124,7 +124,7 @@ (json-rpc/call {:method "eth_getTransactionReceipt" :params [hash] - :on-sucess + :on-success (fn [{:keys [gasUsed]}] (re-frame/dispatch [:ethereum.transactions/new diff --git a/src/status_im/wallet/core.cljs b/src/status_im/wallet/core.cljs index f7b52aa823fc..d815a1b9597b 100644 --- a/src/status_im/wallet/core.cljs +++ b/src/status_im/wallet/core.cljs @@ -85,7 +85,7 @@ (fn [{:keys [success-event edit?]}] (json-rpc/call {:method "eth_gasPrice" - :on-sucess + :on-success #(re-frame/dispatch [success-event % edit?])}))) (re-frame/reg-fx @@ -172,7 +172,7 @@ :outputs ["uint256"] :on-success (fn [[balance]] - (on-success symbol balance)) + (on-success symbol (money/bignumber balance))) :on-error #(on-error symbol %)})))) (def min-gas-price-wei (money/bignumber 1)) @@ -253,7 +253,8 @@ (assoc :nonce nonce)))) ;; SEND TRANSACTION -> RPC TRANSACTION -(defn prepare-send-transaction [from {:keys [amount to gas gas-price data nonce]}] +(defn prepare-send-transaction + [from {:keys [amount to gas gas-price data nonce]}] (cond-> {:from (ethereum/normalized-address from) :to (ethereum/normalized-address to) :value (str "0x" (abi-spec/number-to-hex amount)) @@ -333,6 +334,9 @@ (fx/defn handle-transaction-error [{:keys [db] :as cofx} {:keys [code message]}] (let [{:keys [on-error]} (get-in db [:wallet :send-transaction])] + (log/error :wallet/transaction-error + :code code + :message message) (case code ;;WRONG PASSWORD constants/send-transaction-err-decrypt