[#12666] Allow overriding nonce when sending transaction
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
fe1cc2dc23
commit
de373d0511
|
@ -93,7 +93,7 @@
|
||||||
{:events [:signing.ui/sign-is-pressed]}
|
{:events [:signing.ui/sign-is-pressed]}
|
||||||
[{{:signing/keys [sign tx] :as db} :db :as cofx}]
|
[{{:signing/keys [sign tx] :as db} :db :as cofx}]
|
||||||
(let [{:keys [in-progress? password]} sign
|
(let [{:keys [in-progress? password]} sign
|
||||||
{:keys [tx-obj gas gasPrice maxPriorityFeePerGas maxFeePerGas message]} tx
|
{:keys [tx-obj gas gasPrice maxPriorityFeePerGas maxFeePerGas message nonce]} tx
|
||||||
hashed-password (ethereum/sha3 (security/safe-unmask-data password))]
|
hashed-password (ethereum/sha3 (security/safe-unmask-data password))]
|
||||||
(if message
|
(if message
|
||||||
(sign-message cofx)
|
(sign-message cofx)
|
||||||
|
@ -102,6 +102,8 @@
|
||||||
{:gas (str "0x" (abi-spec/number-to-hex gas))})
|
{:gas (str "0x" (abi-spec/number-to-hex gas))})
|
||||||
(when gasPrice
|
(when gasPrice
|
||||||
{:gasPrice (str "0x" (abi-spec/number-to-hex gasPrice))})
|
{:gasPrice (str "0x" (abi-spec/number-to-hex gasPrice))})
|
||||||
|
(when nonce
|
||||||
|
{:nonce (str "0x" (abi-spec/number-to-hex nonce))})
|
||||||
(when maxPriorityFeePerGas
|
(when maxPriorityFeePerGas
|
||||||
{:maxPriorityFeePerGas (str "0x" (abi-spec/number-to-hex
|
{:maxPriorityFeePerGas (str "0x" (abi-spec/number-to-hex
|
||||||
(js/parseInt maxPriorityFeePerGas)))})
|
(js/parseInt maxPriorityFeePerGas)))})
|
||||||
|
|
|
@ -275,6 +275,13 @@
|
||||||
:maxPriorityFeePerGas (money/->wei :gwei (:value-number maxPriorityFeePerGas)))}
|
:maxPriorityFeePerGas (money/->wei :gwei (:value-number maxPriorityFeePerGas)))}
|
||||||
(bottom-sheet/hide-bottom-sheet)))))
|
(bottom-sheet/hide-bottom-sheet)))))
|
||||||
|
|
||||||
|
(fx/defn submit-nonce
|
||||||
|
{:events [:signing.nonce/submit]}
|
||||||
|
[{db :db :as cofx} nonce]
|
||||||
|
(fx/merge cofx
|
||||||
|
{:db (assoc-in db [:signing/tx :nonce] nonce)}
|
||||||
|
(bottom-sheet/hide-bottom-sheet)))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:signing/update-gas-price
|
:signing/update-gas-price
|
||||||
(fn [{:keys [success-callback error-callback network-id] :as params}]
|
(fn [{:keys [success-callback error-callback network-id] :as params}]
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
[status-im.utils.money :as money]
|
[status-im.utils.money :as money]
|
||||||
[status-im.ui.components.icons.icons :as icons]
|
[status-im.ui.components.icons.icons :as icons]
|
||||||
[clojure.string :as clojure.string]
|
[clojure.string :as clojure.string]
|
||||||
[status-im.signing.gas :as gas]))
|
[status-im.signing.gas :as gas]
|
||||||
|
[reagent.core :as reagent]))
|
||||||
|
|
||||||
(views/defview fee-bottom-sheet [fee-display-symbol]
|
(views/defview fee-bottom-sheet [fee-display-symbol]
|
||||||
(views/letsubs [{gas-edit :gas gas-price-edit :gasPrice max-fee :max-fee} [:signing/edit-fee]]
|
(views/letsubs [{gas-edit :gas gas-price-edit :gasPrice max-fee :max-fee} [:signing/edit-fee]]
|
||||||
|
@ -377,3 +378,25 @@
|
||||||
:on-press #(do (re-frame/dispatch [:hide-popover])
|
:on-press #(do (re-frame/dispatch [:hide-popover])
|
||||||
(re-frame/dispatch [:signing.edit-fee.ui/submit true]))}
|
(re-frame/dispatch [:signing.edit-fee.ui/submit true]))}
|
||||||
(i18n/label :t/continue-anyway)]]]))
|
(i18n/label :t/continue-anyway)]]]))
|
||||||
|
|
||||||
|
(defn advanced []
|
||||||
|
(let [nonce (reagent/atom nil)
|
||||||
|
default-nonce (:nonce @(re-frame/subscribe [:signing/tx]))]
|
||||||
|
(fn []
|
||||||
|
[react/view {:padding 20}
|
||||||
|
[quo/text-input
|
||||||
|
{:label (i18n/label :t/nonce)
|
||||||
|
:accessibility-label :nonce
|
||||||
|
:keyboard-type :numeric
|
||||||
|
:default-value default-nonce
|
||||||
|
:on-change-text #(reset! nonce %)
|
||||||
|
:show-cancel false
|
||||||
|
:container-style {:margin-bottom 20}}]
|
||||||
|
[react/view {:align-items :flex-end}
|
||||||
|
[quo/button
|
||||||
|
{:type :primary
|
||||||
|
:accessibility-label :save-nonce
|
||||||
|
:theme :accent
|
||||||
|
:disabled (clojure.string/blank? @nonce)
|
||||||
|
:on-press #(re-frame/dispatch [:signing.nonce/submit @nonce])}
|
||||||
|
(i18n/label :t/save)]]])))
|
||||||
|
|
|
@ -402,6 +402,15 @@
|
||||||
:accessory :text
|
:accessory :text
|
||||||
:accessory-text network-name}]))
|
:accessory-text network-name}]))
|
||||||
|
|
||||||
|
(defn advanced-item []
|
||||||
|
[:<>
|
||||||
|
[separator]
|
||||||
|
[quo/list-item
|
||||||
|
{:size :small
|
||||||
|
:title (i18n/label :t/advanced)
|
||||||
|
:chevron true
|
||||||
|
:on-press #(re-frame/dispatch [:bottom-sheet/show-sheet {:content sheets/advanced}])}]])
|
||||||
|
|
||||||
(views/defview sheet
|
(views/defview sheet
|
||||||
[{:keys [from contact amount token cancel?] :as tx}]
|
[{:keys [from contact amount token cancel?] :as tx}]
|
||||||
(views/letsubs [fee [:signing/fee]
|
(views/letsubs [fee [:signing/fee]
|
||||||
|
@ -413,7 +422,8 @@
|
||||||
prices [:prices]
|
prices [:prices]
|
||||||
wallet-currency [:wallet/currency]
|
wallet-currency [:wallet/currency]
|
||||||
mainnet? [:mainnet?]
|
mainnet? [:mainnet?]
|
||||||
prices-loading? [:prices-loading?]]
|
prices-loading? [:prices-loading?]
|
||||||
|
management-enabled? [:wallet/transactions-management-enabled?]]
|
||||||
(let [display-symbol (wallet.utils/display-symbol token)
|
(let [display-symbol (wallet.utils/display-symbol token)
|
||||||
fee-display-symbol (wallet.utils/display-symbol (tokens/native-currency chain))]
|
fee-display-symbol (wallet.utils/display-symbol (tokens/native-currency chain))]
|
||||||
[react/view (styles/sheet)
|
[react/view (styles/sheet)
|
||||||
|
@ -438,6 +448,8 @@
|
||||||
[amount-item prices wallet-currency amount amount-error display-symbol fee-display-symbol prices-loading?])
|
[amount-item prices wallet-currency amount amount-error display-symbol fee-display-symbol prices-loading?])
|
||||||
[separator]
|
[separator]
|
||||||
[fee-item prices wallet-currency fee-display-symbol fee gas-error gas-error-state prices-loading?]
|
[fee-item prices wallet-currency fee-display-symbol fee gas-error gas-error-state prices-loading?]
|
||||||
|
(when management-enabled?
|
||||||
|
[advanced-item])
|
||||||
(when (= :gas-is-set gas-error-state)
|
(when (= :gas-is-set gas-error-state)
|
||||||
[react/text {:style {:color colors/gray :margin-horizontal 32 :text-align :center}}
|
[react/text {:style {:color colors/gray :margin-horizontal 32 :text-align :center}}
|
||||||
(i18n/label :t/tx-fail-description1)])
|
(i18n/label :t/tx-fail-description1)])
|
||||||
|
|
Loading…
Reference in New Issue