[#12476] Re-enable amount/fee validation on tx signing

This commit is contained in:
Roman Volosovskyi 2021-09-02 11:58:10 +03:00
parent 1aa0d930fb
commit 031d44c554
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 35 additions and 32 deletions

View File

@ -39,7 +39,6 @@
[status-im.chat.models.mentions :as mentions]
[status-im.notifications.core :as notifications]
[status-im.utils.currency :as currency]
[status-im.signing.eip1559 :as eip1559]
[clojure.set :as clojure.set]
[status-im.ui.components.colors :as colors]))
@ -2686,14 +2685,14 @@
(fn [[_ address] _]
[(re-frame/subscribe [:signing/tx])
(re-frame/subscribe [:balance address])])
(fn [[{:keys [amount token gas gasPrice approve? gas-error-message]} balance]]
(when-not (eip1559/sync-enabled?)
(fn [[{:keys [amount token gas gasPrice maxFeePerGas approve? gas-error-message]} balance]]
(let [gas-price (or maxFeePerGas gasPrice)]
(if (and amount token (not approve?))
(let [amount-bn (money/formatted->internal (money/bignumber amount) (:symbol token) (:decimals token))
amount-error (or (get-amount-error amount (:decimals token))
(get-sufficient-funds-error balance (:symbol token) amount-bn))]
(merge amount-error (get-sufficient-gas-error gas-error-message balance (:symbol token) amount-bn gas gasPrice)))
(get-sufficient-gas-error gas-error-message balance nil nil gas gasPrice)))))
(merge amount-error (get-sufficient-gas-error gas-error-message balance (:symbol token) amount-bn gas gas-price)))
(get-sufficient-gas-error gas-error-message balance nil nil gas gas-price)))))
(re-frame/reg-sub
:wallet.send/prepare-transaction-with-balance

View File

@ -113,6 +113,7 @@
:margin-bottom 26}
[quo/text-input
{:label (i18n/label :t/gas-amount-limit)
:accessibility-label :gas-amount-limit
:error (:error gas-edit)
:default-value (:value gas-edit)
:on-change-text #(re-frame/dispatch [:signing.edit-fee.ui/edit-value :gas %])
@ -123,6 +124,7 @@
:margin-bottom 26}
[quo/text-input
{:label (i18n/label :t/per-gas-tip-limit)
:accessibility-label :per-gas-tip-limit
:error (or (:error max-priority-fee-per-gas-edit)
(get-in max-priority-fee-per-gas-edit [:fee-error :label]))
:default-value (str (:value max-priority-fee-per-gas-edit))
@ -137,6 +139,7 @@
:margin-bottom 12}
[quo/text-input
{:label (i18n/label :t/per-gas-price-limit)
:accessibility-label :per-gas-price-limit
:error (or (:error max-fee-per-gas-edit)
(get-in max-fee-per-gas-edit [:fee-error :label]))
:default-value (str (:value max-fee-per-gas-edit))
@ -188,6 +191,7 @@
"" #_(i18n/label :t/see-suggestions)]
[quo/button
{:type :primary
:accessibility-label :save-fees
:disabled error?
:on-press #(re-frame/dispatch [:signing.edit-fee.ui/submit])
:theme :accent}