fixes #5699
gas estimation sets original-gas when nil Signed-off-by: Goran Jovic <goranjovic@gmail.com>
This commit is contained in:
parent
17f74ff2f6
commit
c363c06a17
|
@ -223,7 +223,9 @@
|
|||
(defn open-modal-wallet-for-transaction [db transaction tx-object]
|
||||
(let [{:keys [gas gas-price]} transaction
|
||||
{:keys [wallet-set-up-passed?]} (:account/account db)]
|
||||
{:db (assoc-in db [:wallet :send-transaction] transaction)
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :send-transaction] transaction)
|
||||
(assoc-in [:wallet :send-transaction :original-gas] gas))
|
||||
:dispatch-n [[:update-wallet]
|
||||
(when-not gas
|
||||
[:wallet/update-estimated-gas tx-object])
|
||||
|
|
|
@ -238,7 +238,11 @@
|
|||
:wallet/update-estimated-gas-success
|
||||
(fn [{:keys [db]} [_ gas]]
|
||||
(when gas
|
||||
{:db (assoc-in db [:wallet :send-transaction :gas] (money/bignumber (int (* gas 1.2))))})))
|
||||
(let [adjusted-gas (money/bignumber (int (* gas 1.2)))
|
||||
db-with-adjusted-gas (assoc-in db [:wallet :send-transaction :gas] adjusted-gas)]
|
||||
{:db (if (some? (-> db :wallet :send-transaction :original-gas))
|
||||
db-with-adjusted-gas
|
||||
(assoc-in db-with-adjusted-gas [:wallet :send-transaction :original-gas] adjusted-gas))}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet-setup-navigate-back
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
(spec/def ::to (spec/nilable string?))
|
||||
(spec/def ::amount (spec/nilable money/valid?))
|
||||
(spec/def ::gas (spec/nilable money/valid?))
|
||||
(spec/def ::original-gas (spec/nilable money/valid?))
|
||||
(spec/def ::gas-price (spec/nilable money/valid?))
|
||||
; dapp transaction
|
||||
(spec/def ::data (spec/nilable string?))
|
||||
|
@ -38,4 +39,4 @@
|
|||
::password ::show-password-input? ::id ::from ::data ::nonce
|
||||
::camera-flashlight ::in-progress? ::on-result ::on-error
|
||||
::wrong-password? ::from-chat? ::symbol ::advanced?
|
||||
::gas ::gas-price ::public-key ::method ::tx-hash]))
|
||||
::gas ::gas-price ::original-gas ::public-key ::method ::tx-hash]))
|
||||
|
|
|
@ -251,12 +251,14 @@
|
|||
(handlers/register-handler-fx
|
||||
:wallet.send/reset-gas-default
|
||||
(fn [{:keys [db] :as cofx}]
|
||||
(let [gas-estimate (money/to-fixed
|
||||
(ethereum/estimate-gas
|
||||
(-> db :wallet :send-transaction :symbol)))]
|
||||
(let [gas-default (if-some [original-gas (-> db :wallet :send-transaction :original-gas)]
|
||||
(money/to-fixed original-gas)
|
||||
(money/to-fixed
|
||||
(ethereum/estimate-gas
|
||||
(-> db :wallet :send-transaction :symbol))))]
|
||||
(assoc (models.wallet/edit-value
|
||||
:gas
|
||||
gas-estimate
|
||||
gas-default
|
||||
cofx)
|
||||
:dispatch [:wallet/update-gas-price true]))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue