fixed Empty Gas limit and Gas price
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
f4799184c5
commit
1faa35bfd9
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
(def default-network config/default-network)
|
(def default-network config/default-network)
|
||||||
|
|
||||||
|
(def contract-address "0x0000000000000000000000000000000000000000")
|
||||||
|
|
||||||
(def default-wallet-transactions
|
(def default-wallet-transactions
|
||||||
{:filters
|
{:filters
|
||||||
{:type [{:id :inbound :label (i18n/label :t/incoming) :checked? true}
|
{:type [{:id :inbound :label (i18n/label :t/incoming) :checked? true}
|
||||||
|
|
|
@ -438,6 +438,7 @@
|
||||||
:receive-transaction "Receive transaction"
|
:receive-transaction "Receive transaction"
|
||||||
:new-transaction "New Transaction"
|
:new-transaction "New Transaction"
|
||||||
:transaction-history "Transaction History"
|
:transaction-history "Transaction History"
|
||||||
|
:new-contract "New Contract"
|
||||||
|
|
||||||
;; Wallet Send
|
;; Wallet Send
|
||||||
:wallet-choose-recipient "Choose Recipient"
|
:wallet-choose-recipient "Choose Recipient"
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
[status-im.utils.prices :as prices]
|
[status-im.utils.prices :as prices]
|
||||||
[status-im.utils.transactions :as transactions]
|
[status-im.utils.transactions :as transactions]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
status-im.ui.screens.wallet.request.events))
|
status-im.ui.screens.wallet.request.events
|
||||||
|
[status-im.utils.money :as money]))
|
||||||
|
|
||||||
(defn get-balance [{:keys [web3 account-id on-success on-error]}]
|
(defn get-balance [{:keys [web3 account-id on-success on-error]}]
|
||||||
(if (and web3 account-id)
|
(if (and web3 account-id)
|
||||||
|
@ -84,6 +85,11 @@
|
||||||
(fn [{:keys [web3 success-event edit?]}]
|
(fn [{:keys [web3 success-event edit?]}]
|
||||||
(ethereum/gas-price web3 #(re-frame/dispatch [success-event %2 edit?]))))
|
(ethereum/gas-price web3 #(re-frame/dispatch [success-event %2 edit?]))))
|
||||||
|
|
||||||
|
(reg-fx
|
||||||
|
:update-estimated-gas
|
||||||
|
(fn [{:keys [web3 obj success-event]}]
|
||||||
|
(ethereum/estimate-gas-web3 web3 (clj->js obj) #(re-frame/dispatch [success-event %2]))))
|
||||||
|
|
||||||
;; Handlers
|
;; Handlers
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
|
@ -220,6 +226,18 @@
|
||||||
(fn [db [_ price edit?]]
|
(fn [db [_ price edit?]]
|
||||||
(assoc-in db [:wallet (if edit? :edit :send-transaction) :gas-price] price)))
|
(assoc-in db [:wallet (if edit? :edit :send-transaction) :gas-price] price)))
|
||||||
|
|
||||||
|
(handlers/register-handler-fx
|
||||||
|
:wallet/update-estimated-gas
|
||||||
|
(fn [{:keys [db]} [_ obj]]
|
||||||
|
{:update-estimated-gas {:web3 (:web3 db)
|
||||||
|
:obj obj
|
||||||
|
:success-event :wallet/update-estimated-gas-success}}))
|
||||||
|
|
||||||
|
(handlers/register-handler-db
|
||||||
|
:wallet/update-estimated-gas-success
|
||||||
|
(fn [db [_ gas]]
|
||||||
|
(assoc-in db [:wallet :send-transaction :gas] (money/bignumber gas))))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:wallet/show-error
|
:wallet/show-error
|
||||||
(fn []
|
(fn []
|
||||||
|
|
|
@ -106,22 +106,31 @@
|
||||||
transaction {:id id
|
transaction {:id id
|
||||||
:from from
|
:from from
|
||||||
:to to
|
:to to
|
||||||
|
:to-name (when (= to constants/contract-address)
|
||||||
|
(i18n/label :t/new-contract))
|
||||||
:symbol symbol
|
:symbol symbol
|
||||||
:value (money/bignumber (or value 0))
|
:value (money/bignumber (or value 0))
|
||||||
:data data
|
:data data
|
||||||
:gas (money/bignumber (money/to-decimal gas))
|
:gas (when (seq gas)
|
||||||
:gas-price (money/bignumber (money/to-decimal gasPrice))
|
(money/bignumber (money/to-decimal gas)))
|
||||||
|
:gas-price (when (seq gasPrice)
|
||||||
|
(money/bignumber (money/to-decimal gasPrice)))
|
||||||
:timestamp now
|
:timestamp now
|
||||||
:message-id message_id}
|
:message-id message_id}
|
||||||
sending-from-chat? (not (get-in db [:wallet :send-transaction :waiting-signal?]))
|
sending-from-bot-or-dapp? (not (get-in db [:wallet :send-transaction :waiting-signal?]))
|
||||||
new-db (assoc-in db [:wallet :transactions-unsigned id] transaction)
|
new-db (assoc-in db [:wallet :transactions-unsigned id] transaction)
|
||||||
sending-db {:id id
|
sending-db {:id id
|
||||||
:from-chat? sending-from-chat?}]
|
:from-chat? sending-from-bot-or-dapp?}]
|
||||||
(if sending-from-chat?
|
(if sending-from-bot-or-dapp?
|
||||||
;;SENDING FROM CHAT
|
;;SENDING FROM BOT (CHAT) OR DAPP
|
||||||
{:db (assoc-in new-db [:wallet :send-transaction] sending-db) ; we need to completely reset sending state here
|
{:db (assoc-in new-db [:wallet :send-transaction] sending-db) ; we need to completely reset sending state here
|
||||||
:dispatch-n [[:update-wallet (map :symbol (tokens/tokens-for (ethereum/network->chain-keyword (:network db))))] [:navigate-to-modal :wallet-send-transaction-modal]]}
|
:dispatch-n [[:update-wallet (map :symbol (tokens/tokens-for (ethereum/network->chain-keyword (:network db))))]
|
||||||
;;SEND SCREEN WAITING SIGNAL
|
[:navigate-to-modal :wallet-send-transaction-modal]
|
||||||
|
(when-not (seq gas)
|
||||||
|
[:wallet/update-estimated-gas transaction])
|
||||||
|
(when-not (seq gasPrice)
|
||||||
|
[:wallet/update-gas-price])]}
|
||||||
|
;;WALLET SEND SCREEN WAITING SIGNAL
|
||||||
(let [{:keys [later? password]} (get-in db [:wallet :send-transaction])
|
(let [{:keys [later? password]} (get-in db [:wallet :send-transaction])
|
||||||
new-db' (update-in new-db [:wallet :send-transaction] merge sending-db)] ; just update sending state as we are in wallet flow
|
new-db' (update-in new-db [:wallet :send-transaction] merge sending-db)] ; just update sending state as we are in wallet flow
|
||||||
(if later?
|
(if later?
|
||||||
|
|
|
@ -58,7 +58,9 @@
|
||||||
(when-let [unsigned-transaction (get unsigned-transactions
|
(when-let [unsigned-transaction (get unsigned-transactions
|
||||||
(:id send-transaction))]
|
(:id send-transaction))]
|
||||||
(merge send-transaction
|
(merge send-transaction
|
||||||
unsigned-transaction))))
|
unsigned-transaction
|
||||||
|
{:gas (or (:gas unsigned-transaction) (:gas send-transaction))
|
||||||
|
:gas-price (or (:gas-price unsigned-transaction) (:gas-price send-transaction))}))))
|
||||||
|
|
||||||
(re-frame/reg-sub :wallet/edit
|
(re-frame/reg-sub :wallet/edit
|
||||||
:<- [:wallet]
|
:<- [:wallet]
|
||||||
|
|
|
@ -87,6 +87,9 @@
|
||||||
(defn gas-price [web3 cb]
|
(defn gas-price [web3 cb]
|
||||||
(.getGasPrice (.-eth web3) cb))
|
(.getGasPrice (.-eth web3) cb))
|
||||||
|
|
||||||
|
(defn estimate-gas-web3 [web3 obj cb]
|
||||||
|
(.estimateGas (.-eth web3) obj cb))
|
||||||
|
|
||||||
(defn estimate-gas [symbol]
|
(defn estimate-gas [symbol]
|
||||||
(if (tokens/ethereum? symbol)
|
(if (tokens/ethereum? symbol)
|
||||||
default-transaction-gas
|
default-transaction-gas
|
||||||
|
|
Loading…
Reference in New Issue