Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a870eb7c55 | ||
|
|
168afba00b | ||
|
|
f135a76551 | ||
|
|
617051cba4 | ||
|
|
7832a3a24d | ||
|
|
e22b6dd88a | ||
|
|
9c90775a1d | ||
|
|
4d0c29f72d | ||
|
|
3ed35a023f | ||
|
|
8fe8bafc2c | ||
|
|
d22b8e03c8 | ||
|
|
3b1b4a989c | ||
|
|
34e5b8b426 |
@@ -6,17 +6,28 @@
|
||||
[{:keys [status theme blur?]}]
|
||||
{:flex-direction :row
|
||||
:align-self :flex-start
|
||||
:background-color (when (= status :error)
|
||||
(colors/theme-colors
|
||||
(colors/override-color :danger 10 50)
|
||||
(colors/override-color :danger 10 60)
|
||||
theme))
|
||||
:background-color (cond (= status :error)
|
||||
(colors/theme-colors
|
||||
(colors/override-color :danger 10 50)
|
||||
(colors/override-color :danger 10 60)
|
||||
theme)
|
||||
(= status :warning)
|
||||
(colors/theme-colors
|
||||
(colors/override-color :warning 10 50)
|
||||
(colors/override-color :warning 10 60)
|
||||
theme))
|
||||
:border-width 1
|
||||
:border-color (cond (= status :error)
|
||||
(colors/theme-colors
|
||||
(colors/override-color :danger 20 50)
|
||||
(colors/override-color :danger 20 60)
|
||||
theme)
|
||||
|
||||
(= status :warning)
|
||||
(colors/theme-colors
|
||||
(colors/override-color :warning 20 50)
|
||||
(colors/override-color :warning 20 60)
|
||||
theme)
|
||||
(and blur? (= status :default)) (colors/theme-colors
|
||||
colors/neutral-80-opa-5
|
||||
colors/white-opa-5
|
||||
@@ -35,5 +46,7 @@
|
||||
[{:keys [status theme networks-shown?]}]
|
||||
{:padding-left (if networks-shown? 4 0)
|
||||
:margin-top -1
|
||||
:color (when (= status :error)
|
||||
(colors/resolve-color :danger theme))})
|
||||
:color (cond (= status :error)
|
||||
(colors/resolve-color :danger theme)
|
||||
(= status :warning)
|
||||
(colors/resolve-color :warning theme))})
|
||||
|
||||
@@ -443,7 +443,10 @@
|
||||
(def ^:const wallet-account-name-max-length 20)
|
||||
|
||||
|
||||
(def ^:const gas-rate-low 0)
|
||||
(def ^:const gas-rate-medium 1)
|
||||
(def ^:const gas-rate-high 2)
|
||||
(def ^:const gas-rate-custom 3)
|
||||
(def ^:const send-type-transfer 0)
|
||||
(def ^:const send-type-bridge 5)
|
||||
(def ^:const send-type-erc-721-transfer 6)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
[{:type :select
|
||||
:key :status
|
||||
:options [{:key :error}
|
||||
{:key :warning}
|
||||
{:key :default}]}
|
||||
{:type :text
|
||||
:key :title}
|
||||
|
||||
@@ -231,9 +231,22 @@
|
||||
|
||||
(def ^:private precision 6)
|
||||
|
||||
(defn from-wei
|
||||
[wei-amount]
|
||||
(send-utils/convert-to-gwei wei-amount precision))
|
||||
|
||||
(defn new->old-route-path
|
||||
[new-path]
|
||||
(let [to-bignumber (fn [k] (-> new-path k money/bignumber))]
|
||||
(tap> {:in :new->old-route-path
|
||||
:new-path new-path
|
||||
:suggested-tx-nonce (-> new-path
|
||||
:suggested-tx-nonce
|
||||
money/from-hex
|
||||
money/to-string
|
||||
js/parseInt)
|
||||
:suggested-tx-gas-amount (:suggested-tx-gas-amount new-path)})
|
||||
(let [to-bignumber (fn [k] (-> new-path k money/bignumber))
|
||||
suggested-levels-for-max-fees-per-gas (:suggested-levels-for-max-fees-per-gas new-path)]
|
||||
{:approval-fee (to-bignumber :approval-fee)
|
||||
:approval-l-1-fee (to-bignumber :approval-l-1-fee)
|
||||
:bonder-fees (to-bignumber :tx-bonder-fees)
|
||||
@@ -242,35 +255,27 @@
|
||||
:amount-in-locked (:amount-in-locked new-path)
|
||||
:amount-in (:amount-in new-path)
|
||||
:max-amount-in (:max-amount-in new-path)
|
||||
:gas-fees {:gas-price "0"
|
||||
:base-fee (send-utils/convert-to-gwei (:tx-base-fee
|
||||
new-path)
|
||||
precision)
|
||||
:max-priority-fee-per-gas (send-utils/convert-to-gwei (:tx-priority-fee
|
||||
new-path)
|
||||
precision)
|
||||
:max-fee-per-gas-low (send-utils/convert-to-gwei
|
||||
(get-in
|
||||
new-path
|
||||
[:suggested-levels-for-max-fees-per-gas
|
||||
:low])
|
||||
precision)
|
||||
:max-fee-per-gas-medium (send-utils/convert-to-gwei
|
||||
(get-in
|
||||
new-path
|
||||
[:suggested-levels-for-max-fees-per-gas
|
||||
:medium])
|
||||
precision)
|
||||
:max-fee-per-gas-high (send-utils/convert-to-gwei
|
||||
(get-in
|
||||
new-path
|
||||
[:suggested-levels-for-max-fees-per-gas
|
||||
:high])
|
||||
precision)
|
||||
:l-1-gas-fee (send-utils/convert-to-gwei (:tx-l-1-fee
|
||||
new-path)
|
||||
precision)
|
||||
:eip-1559-enabled true}
|
||||
:gas-fees {:gas-price "0"
|
||||
:base-fee (from-wei (:tx-base-fee new-path))
|
||||
:tx-priority-fee (from-wei (:tx-priority-fee new-path))
|
||||
:l-1-gas-fee (from-wei (:tx-l-1-fee new-path))
|
||||
:eip-1559-enabled true
|
||||
:tx-max-fees-per-gas (from-wei (:tx-max-fees-per-gas new-path))
|
||||
:current-base-fee (from-wei (:current-base-fee new-path))
|
||||
:suggested-min-priority-fee (from-wei (:suggested-min-priority-fee
|
||||
new-path))
|
||||
:suggested-max-priority-fee (from-wei (:suggested-max-priority-fee
|
||||
new-path))
|
||||
:suggested-gas-fees-for-setting
|
||||
{:transaction-setting/normal (from-wei
|
||||
(:low
|
||||
suggested-levels-for-max-fees-per-gas))
|
||||
:transaction-setting/fast (from-wei
|
||||
(:medium
|
||||
suggested-levels-for-max-fees-per-gas))
|
||||
:transaction-setting/urgent (from-wei
|
||||
(:high
|
||||
suggested-levels-for-max-fees-per-gas))}}
|
||||
:bridge-name (:processor-name new-path)
|
||||
:amount-out (:amount-out new-path)
|
||||
:approval-contract-address (:approval-contract-address new-path)
|
||||
@@ -278,8 +283,19 @@
|
||||
:estimated-time (:estimated-time new-path)
|
||||
:to (:to-chain new-path)
|
||||
:approval-amount-required (:approval-amount-required new-path)
|
||||
;; :cost () ;; tbd not used on desktop
|
||||
:gas-amount (:tx-gas-amount new-path)}))
|
||||
:gas-amount (:tx-gas-amount new-path)
|
||||
:router-input-params-uuid (:router-input-params-uuid new-path)
|
||||
:nonce (-> new-path
|
||||
:tx-nonce
|
||||
money/from-hex
|
||||
money/to-string
|
||||
js/parseInt)
|
||||
:suggested-tx-nonce (-> new-path
|
||||
:suggested-tx-nonce
|
||||
money/from-hex
|
||||
money/to-string
|
||||
js/parseInt)
|
||||
:suggested-tx-gas-amount (:suggested-tx-gas-amount new-path)}))
|
||||
|
||||
(defn tokens-never-loaded?
|
||||
[db]
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||
[status-im.contexts.wallet.data-store :as data-store]
|
||||
[status-im.contexts.wallet.send.transaction-settings.core :as transaction-settings]
|
||||
[status-im.contexts.wallet.send.utils :as send-utils]
|
||||
[status-im.contexts.wallet.sheets.network-selection.view :as network-selection]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.address]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.money :as utils.money]
|
||||
[utils.number]
|
||||
[utils.re-frame :as rf]
|
||||
@@ -90,7 +92,8 @@
|
||||
:receiver-network-values receiver-network-values
|
||||
:network-links network-links
|
||||
:loading-suggested-routes? false
|
||||
:enough-assets? true)}))))
|
||||
:enough-assets? true)
|
||||
:fx [#_[:dispatch [:wallet/clear-user-tx-settings]]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/suggested-routes-error
|
||||
@@ -384,16 +387,100 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet/set-token-amount-to-send
|
||||
(fn [{:keys [db]} [{:keys [amount stack-id start-flow?]}]]
|
||||
{:db (assoc-in db [:wallet :ui :send :amount] amount)
|
||||
:fx [[:dispatch
|
||||
[:wallet/wizard-navigate-forward
|
||||
{:current-screen stack-id
|
||||
:start-flow? start-flow?
|
||||
:flow-id :wallet-send-flow}]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet.send/auth-slider-completed
|
||||
(fn [{:keys [db]}]
|
||||
(let [last-request-uuid (get-in db [:wallet :ui :send :last-request-uuid])]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :ui :send :amount] amount)
|
||||
(update-in [:wallet :ui :send] dissoc :transaction-for-signing))
|
||||
{:db (update-in db [:wallet :ui :send] dissoc :transaction-for-signing)
|
||||
:fx [[:dispatch [:wallet/build-transactions-from-route {:request-uuid last-request-uuid}]]
|
||||
[:dispatch
|
||||
[:wallet/wizard-navigate-forward
|
||||
{:current-screen stack-id
|
||||
:start-flow? start-flow?
|
||||
:flow-id :wallet-send-flow}]]]})))
|
||||
[:wallet.send/set-sign-transactions-callback-fx
|
||||
[:dispatch
|
||||
[:wallet/prepare-signatures-for-transactions :send]]]]]})))
|
||||
|
||||
(defn log-transaction-signature-error
|
||||
[error]
|
||||
(log/error
|
||||
"failed to prepare signatures for transactions"
|
||||
{:event :wallet/prepare-signatures-for-transactions
|
||||
:error error})
|
||||
(rf/dispatch
|
||||
[:toasts/upsert
|
||||
{:id :prepare-signatures-for-transactions-error
|
||||
:type :negative
|
||||
:text (:message error)}]))
|
||||
|
||||
(defn- send-transactions-with-signatures
|
||||
[tx-type signatures]
|
||||
(rf/dispatch
|
||||
[:wallet/send-router-transactions-with-signatures tx-type
|
||||
signatures]))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/send-router-transactions-with-signatures
|
||||
(fn [{:keys [db]} [tx-type signatures]]
|
||||
(let [transaction-for-signing (get-in db [:wallet :ui tx-type :transaction-for-signing])
|
||||
signatures-map (reduce (fn [acc {:keys [message signature]}]
|
||||
(assoc acc
|
||||
message
|
||||
(send-utils/signature-rsv signature)))
|
||||
{}
|
||||
signatures)]
|
||||
{:json-rpc/call [{:method "wallet_sendRouterTransactionsWithSignatures"
|
||||
:params [{:uuid (get-in transaction-for-signing [:sendDetails :uuid])
|
||||
:signatures signatures-map}]
|
||||
:on-success (fn []
|
||||
(rf/dispatch [:hide-bottom-sheet]))
|
||||
:on-error (fn [error]
|
||||
(log/error "failed to send router transactions with signatures"
|
||||
{:event :wallet/send-router-transactions-with-signatures
|
||||
:error error})
|
||||
(rf/dispatch [:toasts/upsert
|
||||
{:id :send-router-transactions-with-signatures-error
|
||||
:type :negative
|
||||
:text (:message error)}]))}]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/prepare-signatures-for-transactions
|
||||
(fn [{:keys [db]} [tx-type]]
|
||||
(let [transaction-for-signing (get-in db
|
||||
[:wallet :ui tx-type :transaction-for-signing])
|
||||
signing-details (:signingDetails transaction-for-signing)
|
||||
{:keys [hashes address signOnKeycard]} signing-details
|
||||
send-tx-fn (partial send-transactions-with-signatures tx-type)]
|
||||
(if signOnKeycard
|
||||
{:fx [[:dispatch
|
||||
[:standard-auth/authorize-with-keycard
|
||||
{:on-complete (fn [pin]
|
||||
(rf/dispatch [:keycard/connect-and-sign-hashes
|
||||
{:keycard-pin pin
|
||||
:address address
|
||||
:hashes hashes
|
||||
:on-success send-tx-fn
|
||||
:on-failure log-transaction-signature-error}]))}]]]}
|
||||
{:fx [[:dispatch
|
||||
[:standard-auth/authorize
|
||||
{:on-auth-success (fn [sha3-pwd]
|
||||
(rf/dispatch [:wallet/standard-auth-autorization-success hashes
|
||||
address sha3-pwd send-tx-fn]))
|
||||
:auth-button-label (i18n/label :t/confirm)}]]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/standard-auth-autorization-success
|
||||
(fn [_ [hashes address sha3-pwd send-tx-fn]]
|
||||
{:fx [[:effects.wallet/sign-transaction-hashes
|
||||
{:hashes hashes
|
||||
:address address
|
||||
:password (security/safe-unmask-data sha3-pwd)
|
||||
:on-success send-tx-fn
|
||||
:on-error log-transaction-signature-error}]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/build-transaction-for-collectible-route
|
||||
@@ -409,16 +496,14 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet/set-token-amount-to-bridge
|
||||
(fn [{:keys [db]} [{:keys [amount stack-id start-flow?]}]]
|
||||
(let [last-request-uuid (get-in db [:wallet :ui :send :last-request-uuid])]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :ui :send :amount] amount)
|
||||
(update-in [:wallet :ui :send] dissoc :transaction-for-signing))
|
||||
:fx [[:dispatch [:wallet/build-transactions-from-route {:request-uuid last-request-uuid}]]
|
||||
[:dispatch
|
||||
[:wallet/wizard-navigate-forward
|
||||
{:current-screen stack-id
|
||||
:start-flow? start-flow?
|
||||
:flow-id :wallet-bridge-flow}]]]})))
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :ui :send :amount] amount)
|
||||
(update-in [:wallet :ui :send] dissoc :transaction-for-signing))
|
||||
:fx [[:dispatch
|
||||
[:wallet/wizard-navigate-forward
|
||||
{:current-screen stack-id
|
||||
:start-flow? start-flow?
|
||||
:flow-id :wallet-bridge-flow}]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/clean-bridge-to-selection
|
||||
@@ -669,66 +754,6 @@
|
||||
:type :negative
|
||||
:text (:message error)}]))}]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/prepare-signatures-for-transactions
|
||||
(fn [{:keys [db]} [type sha3-pwd]]
|
||||
(let [{:keys [hashes address signOnKeycard]} (get-in db
|
||||
[:wallet :ui type :transaction-for-signing
|
||||
:signingDetails])
|
||||
on-success (fn [signatures]
|
||||
(rf/dispatch
|
||||
[:wallet/send-router-transactions-with-signatures type
|
||||
signatures]))
|
||||
on-error (fn [error]
|
||||
(log/error
|
||||
"failed to prepare signatures for transactions"
|
||||
{:event :wallet/prepare-signatures-for-transactions
|
||||
:error error})
|
||||
(rf/dispatch
|
||||
[:toasts/upsert
|
||||
{:id :prepare-signatures-for-transactions-error
|
||||
:type :negative
|
||||
:text (:message error)}]))]
|
||||
(if signOnKeycard
|
||||
{:fx [[:dispatch
|
||||
[:standard-auth/authorize-with-keycard
|
||||
{:on-complete #(rf/dispatch [:keycard/connect-and-sign-hashes
|
||||
{:keycard-pin %
|
||||
:address address
|
||||
:hashes hashes
|
||||
:on-success on-success
|
||||
:on-failure on-error}])}]]]}
|
||||
{:fx [[:effects.wallet/sign-transaction-hashes
|
||||
{:hashes hashes
|
||||
:address address
|
||||
:password (security/safe-unmask-data sha3-pwd)
|
||||
:on-success on-success
|
||||
:on-error on-error}]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/send-router-transactions-with-signatures
|
||||
(fn [{:keys [db]} [type signatures]]
|
||||
(let [transaction-for-signing (get-in db [:wallet :ui type :transaction-for-signing])
|
||||
signatures-map (reduce (fn [acc {:keys [message signature]}]
|
||||
(assoc acc
|
||||
message
|
||||
(send-utils/signature-rsv signature)))
|
||||
{}
|
||||
signatures)]
|
||||
{:json-rpc/call [{:method "wallet_sendRouterTransactionsWithSignatures"
|
||||
:params [{:uuid (get-in transaction-for-signing [:sendDetails :uuid])
|
||||
:signatures signatures-map}]
|
||||
:on-success (fn []
|
||||
(rf/dispatch [:hide-bottom-sheet]))
|
||||
:on-error (fn [error]
|
||||
(log/error "failed to send router transactions with signatures"
|
||||
{:event :wallet/send-router-transactions-with-signatures
|
||||
:error error})
|
||||
(rf/dispatch [:toasts/upsert
|
||||
{:id :send-router-transactions-with-signatures-error
|
||||
:type :negative
|
||||
:text (:message error)}]))}]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/select-from-account
|
||||
(fn [{db :db} [{:keys [address stack-id network-details network start-flow?] :as params}]]
|
||||
@@ -815,37 +840,68 @@
|
||||
:fx [[:dispatch [:navigate-back]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/init-tx-settings
|
||||
:wallet/clear-user-tx-settings
|
||||
(fn [{db :db}]
|
||||
{:db (assoc-in db
|
||||
[:wallet :ui :send :tx-settings]
|
||||
{:max-base-fee {:low 5
|
||||
:current 8.2
|
||||
:high 9}
|
||||
:priority-fee {:low 0.6
|
||||
:high 5.1
|
||||
:current 1.1}
|
||||
:max-gas-amount {:low 30000
|
||||
:current 31000}
|
||||
:nonce {:last-transaction 21
|
||||
:current 22}})}))
|
||||
{:db (update-in db [:wallet :ui :send] dissoc :user-tx-settings)}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/set-max-base-fee
|
||||
(fn [{db :db} [value]]
|
||||
{:db (assoc-in db [:wallet :ui :send :tx-settings :max-base-fee :current] value)}))
|
||||
{:db (assoc-in db [:wallet :ui :send :user-tx-settings :max-base-fee] value)}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/set-priority-fee
|
||||
(fn [{db :db} [value]]
|
||||
{:db (assoc-in db [:wallet :ui :send :tx-settings :priority-fee :current] value)}))
|
||||
{:db (assoc-in db [:wallet :ui :send :user-tx-settings :priority-fee] value)}))
|
||||
(rf/reg-event-fx
|
||||
|
||||
:wallet/set-max-gas-amount
|
||||
(fn [{db :db} [value]]
|
||||
{:db (assoc-in db [:wallet :ui :send :tx-settings :max-gas-amount :current] value)}))
|
||||
{:db (assoc-in db [:wallet :ui :send :user-tx-settings :gas-amount] value)}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/set-nonce
|
||||
(fn [{db :db} [value]]
|
||||
{:db (assoc-in db [:wallet :ui :send :tx-settings :nonce :current] value)}))
|
||||
{:db (assoc-in db [:wallet :ui :send :user-tx-settings :nonce] value)}))
|
||||
|
||||
(rf/reg-event-fx :wallet/quick-transaction-settings-confirmed
|
||||
(fn [{db :db} [confirmed-setting]]
|
||||
(let [gas-rate (transaction-settings/transaction-setting->gas-rate confirmed-setting)
|
||||
route (first (get-in db [:wallet :ui :send :route]))
|
||||
path-tx-identity (send-utils/path-identity route)
|
||||
params [path-tx-identity gas-rate]]
|
||||
{:db (assoc-in db [:wallet :ui :send :confirmed-quick-tx-setting] confirmed-setting)
|
||||
:json-rpc/call [{:method "wallet_setFeeMode"
|
||||
:params params
|
||||
:on-error (fn [error]
|
||||
(log/error "failed to set quick transaction settings"
|
||||
{:event :wallet/quick-transaction-settings-confirmed
|
||||
:error (:message error)
|
||||
:params params}))}]})))
|
||||
|
||||
|
||||
|
||||
(rf/reg-event-fx :wallet/custom-transaction-settings-confirmed
|
||||
(fn [{db :db}]
|
||||
(let [route (first (get-in db [:wallet :ui :send :route]))
|
||||
user-tx-settings (get-in db [:wallet :ui :send :user-tx-settings])
|
||||
path-tx-identity (send-utils/path-identity route)
|
||||
custom-tx-params (send-utils/path-tx-custom-params user-tx-settings route)
|
||||
params [path-tx-identity custom-tx-params]]
|
||||
(tap> {:in :wallet/custom-transaction-settings-confirmed
|
||||
:custom-tx-params custom-tx-params})
|
||||
{:json-rpc/call [{:method "wallet_setCustomTxDetails"
|
||||
:params params
|
||||
:on-error (fn [error]
|
||||
(log/error "failed to set custom tx settings"
|
||||
{:event :wallet/custom-transaction-settings-confirmed
|
||||
:error (:message error)
|
||||
:params params}))}]}))
|
||||
)
|
||||
|
||||
|
||||
(rf/reg-event-fx :wallet.send/set-sign-transactions-callback-fx
|
||||
(fn [{:keys [db]} [callback-fx]]
|
||||
{:db (assoc-in db
|
||||
[:wallet :ui :send :sign-transactions-callback-fx]
|
||||
callback-fx)}))
|
||||
|
||||
@@ -65,9 +65,8 @@
|
||||
:to {:chain-id 1
|
||||
:native-currency-symbol "ETH"}
|
||||
:gas-amount "23487"
|
||||
:gas-fees {:base-fee "32.325296406"
|
||||
:max-priority-fee-per-gas "0.011000001"
|
||||
:eip1559-enabled true}}]
|
||||
:gas-fees {:base-fee "32.325296406"
|
||||
:eip1559-enabled true}}]
|
||||
:wallet/wallet-send-suggested-routes nil
|
||||
:wallet/wallet-send-receiver-networks [1]
|
||||
:view-id :screen/wallet.send-input-amount
|
||||
|
||||
@@ -72,11 +72,6 @@
|
||||
|
||||
:else (rf/dispatch [:wallet/stop-and-clean-suggested-routes])))
|
||||
|
||||
(defn- get-fee-formatted
|
||||
[route]
|
||||
(when-let [native-currency-symbol (-> route first :from :native-currency-symbol)]
|
||||
(rf/sub [:wallet/wallet-send-fee-fiat-formatted native-currency-symbol])))
|
||||
|
||||
(defn- insufficient-asset-amount?
|
||||
[{:keys [token-symbol owned-eth-token input-state limit-exceeded? enough-assets?]}]
|
||||
(let [eth-selected? (= token-symbol (string/upper-case constants/mainnet-short-name))
|
||||
@@ -172,7 +167,7 @@
|
||||
(empty? route)
|
||||
(not valid-input?))
|
||||
fee-formatted (when (or (not confirm-disabled?) not-enough-asset?)
|
||||
(get-fee-formatted route))
|
||||
(rf/sub [:wallet/wallet-send-fee-fiat-formatted]))
|
||||
handle-on-confirm (fn [amount]
|
||||
(rf/dispatch [:wallet/set-token-amount-to-send
|
||||
{:amount amount
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.common.biometric.utils :as biometric]
|
||||
[status-im.common.events-helper :as events-helper]
|
||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||
[status-im.common.standard-authentication.core :as standard-auth]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.send.transaction-confirmation.style :as style]
|
||||
[status-im.contexts.wallet.send.transaction-settings.view :as transaction-settings]
|
||||
@@ -168,10 +169,9 @@
|
||||
:subtitle subtitle}])
|
||||
|
||||
(defn- transaction-details
|
||||
[{:keys [estimated-time-min max-fees to-network route
|
||||
transaction-type]}]
|
||||
(let [route-loaded? (and route (seq route))
|
||||
loading-suggested-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])
|
||||
[{:keys [estimated-time-min max-fees to-network
|
||||
transaction-type route-loaded?]}]
|
||||
(let [loading-suggested-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])
|
||||
amount (rf/sub [:wallet/send-total-amount-formatted])]
|
||||
[rn/view
|
||||
{:style (style/details-container
|
||||
@@ -225,11 +225,7 @@
|
||||
estimated-time-min (reduce + (map :estimated-time route))
|
||||
token-symbol (or token-display-name
|
||||
(-> send-transaction-data :token :symbol))
|
||||
first-route (first route)
|
||||
native-currency-symbol (get-in first-route
|
||||
[:from :native-currency-symbol])
|
||||
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted
|
||||
native-currency-symbol])
|
||||
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted])
|
||||
account (rf/sub [:wallet/current-viewing-account])
|
||||
account-color (:color account)
|
||||
bridge-to-network (when bridge-to-chain-id
|
||||
@@ -237,7 +233,6 @@
|
||||
bridge-to-chain-id]))
|
||||
loading-suggested-routes? (rf/sub
|
||||
[:wallet/wallet-send-loading-suggested-routes?])
|
||||
transaction-for-signing (rf/sub [:wallet/wallet-send-transaction-for-signing])
|
||||
from-account-props {:customization-color account-color
|
||||
:size 32
|
||||
:emoji (:emoji account)
|
||||
@@ -249,24 +244,9 @@
|
||||
user-props {:full-name to-address
|
||||
:address (utils/get-shortened-address
|
||||
to-address)}
|
||||
sign-on-keycard? (get-in transaction-for-signing
|
||||
[:signingDetails :signOnKeycard])]
|
||||
biometric-auth? (= (rf/sub [:auth-method]) constants/auth-method-biometric)
|
||||
biometric-type (rf/sub [:biometrics/supported-type])]
|
||||
(hot-reload/use-safe-unmount #(rf/dispatch [:wallet/clean-route-data-for-collectible-tx]))
|
||||
;; In token send flow we already have transaction built when
|
||||
;; we reach confirmation screen. But in send collectible flow
|
||||
;; routes request happens at the same time with navigation to
|
||||
;; confirmation screen. So we need to build the transaction as soon
|
||||
;; as route is available.
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
(when (and (send-utils/tx-type-collectible? transaction-type)
|
||||
first-route)
|
||||
(rf/dispatch [:wallet/build-transaction-for-collectible-route])))
|
||||
[first-route])
|
||||
(rn/use-mount
|
||||
(fn []
|
||||
(when (ff/enabled? ::ff/wallet.transaction-params)
|
||||
(rf/dispatch [:wallet/init-tx-settings]))))
|
||||
[rn/view {:style {:flex 1}}
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
@@ -283,27 +263,21 @@
|
||||
:to-network bridge-to-network
|
||||
:theme theme
|
||||
:route route
|
||||
:transaction-type transaction-type}]
|
||||
:transaction-type transaction-type
|
||||
:route-loaded? (and route (seq route))}]
|
||||
(when (and (not loading-suggested-routes?) route (seq route))
|
||||
[standard-auth/slide-button
|
||||
{:size :size-48
|
||||
:track-text (if (= transaction-type :tx/bridge)
|
||||
(i18n/label :t/slide-to-bridge)
|
||||
(i18n/label :t/slide-to-send))
|
||||
:container-style {:z-index 2}
|
||||
:disabled? (not transaction-for-signing)
|
||||
[quo/slide-button
|
||||
{:size :size-48
|
||||
:track-text (if (= transaction-type :tx/bridge)
|
||||
(i18n/label :t/slide-to-bridge)
|
||||
(i18n/label :t/slide-to-send))
|
||||
:container-style {:z-index 2}
|
||||
:customization-color account-color
|
||||
:auth-button-label (i18n/label :t/confirm)
|
||||
:on-complete (when sign-on-keycard?
|
||||
#(rf/dispatch
|
||||
[:wallet/prepare-signatures-for-transactions
|
||||
:send
|
||||
""]))
|
||||
:on-auth-success
|
||||
(fn [psw]
|
||||
(rf/dispatch
|
||||
[:wallet/prepare-signatures-for-transactions :send
|
||||
psw]))}])]
|
||||
:track-icon (if biometric-auth?
|
||||
(biometric/get-icon-by-type biometric-type)
|
||||
:password)
|
||||
:on-complete #(rf/dispatch
|
||||
[:wallet.send/auth-slider-completed])}])]
|
||||
:gradient-cover? true
|
||||
:customization-color (:color account)}
|
||||
[rn/view
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
(ns status-im.contexts.wallet.send.transaction-settings.core
|
||||
(:require
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
(def default-transaction-setting :transaction-setting/fast)
|
||||
|
||||
(defn transaction-setting->gas-rate
|
||||
[transaction-setting]
|
||||
(case transaction-setting
|
||||
:transaction-setting/normal constants/gas-rate-low
|
||||
:transaction-setting/fast constants/gas-rate-medium
|
||||
:transaction-setting/urgent constants/gas-rate-high
|
||||
:transaction-setting/custom constants/gas-rate-custom
|
||||
constants/gas-rate-medium))
|
||||
@@ -6,25 +6,36 @@
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn gas-amount-hint-text
|
||||
[{:keys [current]} lower-limit-exceeded? _upper-limit-exceeded?]
|
||||
[current {:keys [low high]} _entered-value lower-limit-exceeded? upper-limit-exceeded?]
|
||||
(cond
|
||||
lower-limit-exceeded? (i18n/label :t/gas-amount-lower {:current current})
|
||||
lower-limit-exceeded? (i18n/label :t/gas-amount-lower {:low low})
|
||||
upper-limit-exceeded? (i18n/label :t/gas-amount-higher {:high high})
|
||||
:else (i18n/label :t/current-units {:current current})))
|
||||
|
||||
(defn gas-amount-hint-status
|
||||
[_entered-value lower-limit-exceeded? upper-limit-exceeded?]
|
||||
(if (or lower-limit-exceeded? upper-limit-exceeded?)
|
||||
:error
|
||||
:default))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [suggested-values (rf/sub [:wallet/tx-settings-max-gas-amount])
|
||||
hint-text (partial gas-amount-hint-text suggested-values)]
|
||||
(let [spectrum {:low 21000
|
||||
:high 7920027}
|
||||
current (rf/sub [:wallet/tx-settings-gas-amount])
|
||||
hint-text (partial gas-amount-hint-text current spectrum)]
|
||||
[transaction-settings/custom-setting-screen
|
||||
{:screen-title (i18n/label :t/max-gas-amount)
|
||||
:token-symbol :units
|
||||
:hint-text-fn hint-text
|
||||
:suggested-values suggested-values
|
||||
:info-title (i18n/label :t/gas-amount)
|
||||
:info-content (i18n/label :t/about-gas-amount)
|
||||
:on-save (fn [new-val]
|
||||
(rf/dispatch [:wallet/set-max-gas-amount new-val])
|
||||
(rf/dispatch [:navigate-back])
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content transaction-settings/custom-settings-sheet}]))
|
||||
:with-decimals? false}]))
|
||||
{:screen-title (i18n/label :t/max-gas-amount)
|
||||
:token-symbol :units
|
||||
:hint-text-fn hint-text
|
||||
:status-fn gas-amount-hint-status
|
||||
:current current
|
||||
:spectrum spectrum
|
||||
:info-title (i18n/label :t/gas-amount)
|
||||
:info-content (i18n/label :t/about-gas-amount)
|
||||
:on-save (fn [new-val]
|
||||
(rf/dispatch [:wallet/set-max-gas-amount new-val])
|
||||
(rf/dispatch [:navigate-back])
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content transaction-settings/custom-settings-sheet}]))
|
||||
:with-decimals? false}]))
|
||||
|
||||
@@ -6,25 +6,36 @@
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn max-base-fee-hint-text
|
||||
[current lower-limit-exceeded? upper-limit-exceeded?]
|
||||
[max-base-fee priority-fee _entered-value lower-limit-exceeded? upper-limit-exceeded?]
|
||||
(cond
|
||||
upper-limit-exceeded? (i18n/label :t/max-base-fee-higher {:current current})
|
||||
lower-limit-exceeded? (i18n/label :t/max-base-fee-lower {:current current})
|
||||
:else (i18n/label :t/fee-current-gwei {:current current})))
|
||||
upper-limit-exceeded? (i18n/label :t/max-base-fee-higher {:current max-base-fee})
|
||||
lower-limit-exceeded? (i18n/label :t/max-base-fee-lower {:priority-fee priority-fee})
|
||||
:else (i18n/label :t/max-base-fee-current {:current max-base-fee})))
|
||||
|
||||
(defn input-status
|
||||
[_entered-value lower-limit-exceeded? upper-limit-exceeded?]
|
||||
(cond
|
||||
upper-limit-exceeded? :warning
|
||||
lower-limit-exceeded? :error
|
||||
:else :default))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [suggested-values (rf/sub [:wallet/tx-settings-max-base-fee])
|
||||
hint-text (partial max-base-fee-hint-text (:current suggested-values))]
|
||||
(let [max-base-fee (rf/sub [:wallet/tx-settings-max-base-fee])
|
||||
priority-fee (rf/sub [:wallet/tx-settings-priority-fee])
|
||||
hint-text (partial max-base-fee-hint-text max-base-fee priority-fee)]
|
||||
[transaction-settings/custom-setting-screen
|
||||
{:screen-title (i18n/label :t/max-base-fee)
|
||||
:token-sybmol :gwei
|
||||
:hint-text-fn hint-text
|
||||
:suggested-values suggested-values
|
||||
:info-title (i18n/label :t/max-base-fee)
|
||||
:info-content (i18n/label :t/about-max-base-fee)
|
||||
:on-save (fn [new-val]
|
||||
(rf/dispatch [:wallet/set-max-base-fee new-val])
|
||||
(rf/dispatch [:navigate-back])
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content transaction-settings/custom-settings-sheet}]))}]))
|
||||
{:screen-title (i18n/label :t/max-base-fee)
|
||||
:token-sybmol :gwei
|
||||
:hint-text-fn hint-text
|
||||
:status-fn input-status
|
||||
:current max-base-fee
|
||||
:spectrum {:high max-base-fee
|
||||
:low priority-fee}
|
||||
:info-title (i18n/label :t/max-base-fee)
|
||||
:info-content (i18n/label :t/about-max-base-fee)
|
||||
:on-save (fn [new-val]
|
||||
(rf/dispatch [:wallet/set-max-base-fee new-val])
|
||||
(rf/dispatch [:navigate-back])
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content transaction-settings/custom-settings-sheet}]))}]))
|
||||
|
||||
@@ -11,14 +11,15 @@
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [{:keys [last-transaction current]} (rf/sub [:wallet/tx-settings-nonce])
|
||||
suggested-nonce (inc last-transaction)
|
||||
[input-state set-input-state] (rn/use-state (controlled-input/set-value-numeric
|
||||
controlled-input/init-state
|
||||
current))
|
||||
input-value (controlled-input/input-value input-state)
|
||||
warning? (> (controlled-input/value-numeric input-state)
|
||||
suggested-nonce)]
|
||||
(let [current (rf/sub [:wallet/tx-settings-nonce])
|
||||
suggested-nonce (rf/sub [:wallet/tx-settings-suggested-nonce])
|
||||
last-tx-nonce (dec suggested-nonce)
|
||||
[input-state set-input-state] (rn/use-state (controlled-input/set-value-numeric
|
||||
controlled-input/init-state
|
||||
current))
|
||||
input-value (controlled-input/input-value input-state)
|
||||
warning? (> (controlled-input/value-numeric input-state)
|
||||
current)]
|
||||
[rn/view
|
||||
{:style {:flex 1}}
|
||||
[quo/page-nav
|
||||
@@ -41,7 +42,10 @@
|
||||
[quo/input
|
||||
{:type :text
|
||||
:label (i18n/label :t/type-nonce)
|
||||
:label-right (i18n/label :t/last-transaction-is {:number last-transaction})
|
||||
:label-right (i18n/label :t/last-transaction-is
|
||||
{:number (if (< last-tx-nonce 0)
|
||||
"-"
|
||||
last-tx-nonce)})
|
||||
:editable false
|
||||
:default-value input-value
|
||||
:clearable? true
|
||||
|
||||
@@ -6,25 +6,62 @@
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn priority-fee-hint-text
|
||||
[{:keys [current low high]} lower-limit-exceeded? upper-limit-exceeded?]
|
||||
[priority-fee spectrum max-base-fee entered-value lower-limit-exceeded? upper-limit-exceeded?]
|
||||
(cond
|
||||
upper-limit-exceeded? (i18n/label :t/priority-fee-higher {:low low :high high})
|
||||
lower-limit-exceeded? (i18n/label :t/priority-fee-lower {:low low :high high})
|
||||
:else (i18n/label :t/fee-current-gwei {:current current})))
|
||||
(and upper-limit-exceeded? (> entered-value max-base-fee))
|
||||
(i18n/label :t/priority-fee-higher-max-base {:max-base-fee max-base-fee})
|
||||
|
||||
upper-limit-exceeded?
|
||||
(i18n/label :t/priority-fee-higher spectrum)
|
||||
|
||||
lower-limit-exceeded?
|
||||
(i18n/label :t/priority-fee-lower spectrum)
|
||||
|
||||
:else
|
||||
(i18n/label :t/priority-fee-current {:current priority-fee})))
|
||||
|
||||
(defn priority-fee-hint-status
|
||||
[max-base-fee entered-value lower-limit-exceeded? upper-limit-exceeded?]
|
||||
(cond
|
||||
(and upper-limit-exceeded? (> entered-value max-base-fee))
|
||||
:error
|
||||
|
||||
upper-limit-exceeded?
|
||||
:warning
|
||||
|
||||
lower-limit-exceeded?
|
||||
:warning
|
||||
|
||||
:else
|
||||
:default))
|
||||
|
||||
(comment
|
||||
(rf/sub [:wallet/tx-settings-gas-fees])
|
||||
(rf/sub [:wallet/tx-settings-priority-fee])
|
||||
(rf/sub [:wallet/send-route])
|
||||
(:gas-fees (first (rf/sub [:wallet/send-route])))
|
||||
(rf/dispatch [:navigate-back])
|
||||
)
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [suggested-values (rf/sub [:wallet/tx-settings-priority-fee])
|
||||
hint-text (partial priority-fee-hint-text suggested-values)]
|
||||
(let [priority-fee (rf/sub [:wallet/tx-settings-priority-fee])
|
||||
max-base-fee (rf/sub [:wallet/tx-settings-max-base-fee])
|
||||
spectrum {:low (rf/sub [:wallet/tx-settings-suggested-min-priority-fee])
|
||||
:high (rf/sub [:wallet/tx-settings-suggested-max-priority-fee])}
|
||||
hint-text (partial priority-fee-hint-text priority-fee spectrum max-base-fee)
|
||||
hint-status (partial priority-fee-hint-status max-base-fee)]
|
||||
[transaction-settings/custom-setting-screen
|
||||
{:screen-title (i18n/label :t/priority-fee)
|
||||
:token-sybmol :gwei
|
||||
:hint-text-fn hint-text
|
||||
:suggested-values suggested-values
|
||||
:info-title (i18n/label :t/priority-fee)
|
||||
:info-content (i18n/label :t/about-priority-fee)
|
||||
:on-save (fn [new-val]
|
||||
(rf/dispatch [:wallet/set-priority-fee new-val])
|
||||
(rf/dispatch [:navigate-back])
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content transaction-settings/custom-settings-sheet}]))}]))
|
||||
{:screen-title (i18n/label :t/priority-fee)
|
||||
:token-sybmol :gwei
|
||||
:hint-text-fn hint-text
|
||||
:status-fn hint-status
|
||||
:current priority-fee
|
||||
:spectrum spectrum
|
||||
:info-title (i18n/label :t/priority-fee)
|
||||
:info-content (i18n/label :t/about-priority-fee)
|
||||
:on-save (fn [new-val]
|
||||
(rf/dispatch [:wallet/set-priority-fee new-val])
|
||||
(rf/dispatch [:navigate-back])
|
||||
(rf/dispatch [:show-bottom-sheet
|
||||
{:content transaction-settings/custom-settings-sheet}]))}]))
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
(defn custom-settings-sheet
|
||||
[_]
|
||||
(let [max-base-fee (:current (rf/sub [:wallet/tx-settings-max-base-fee]))
|
||||
priority-fee (:current (rf/sub [:wallet/tx-settings-priority-fee]))
|
||||
max-gas-amount (:current (rf/sub [:wallet/tx-settings-max-gas-amount]))
|
||||
nonce (:current (rf/sub [:wallet/tx-settings-nonce]))]
|
||||
(let [max-base-fee (rf/sub [:wallet/tx-settings-max-base-fee])
|
||||
priority-fee (rf/sub [:wallet/tx-settings-priority-fee])
|
||||
max-gas-amount (rf/sub [:wallet/tx-settings-gas-amount])
|
||||
nonce (rf/sub [:wallet/tx-settings-nonce])]
|
||||
[rn/view
|
||||
[quo/drawer-top
|
||||
{:title (i18n/label :t/custom)}]
|
||||
@@ -62,71 +62,80 @@
|
||||
:preview-size :size-32}]}]
|
||||
[quo/bottom-actions
|
||||
{:actions :one-action
|
||||
:button-one-props {:on-press #(rf/dispatch [:hide-bottom-sheet])}
|
||||
:button-one-props {:on-press (fn []
|
||||
(rf/dispatch [:wallet/custom-transaction-settings-confirmed])
|
||||
(rf/dispatch [:hide-bottom-sheet]))}
|
||||
:button-one-label (i18n/label :t/confirm)}]]))
|
||||
|
||||
(defn settings-sheet
|
||||
[_]
|
||||
(let [[selected-id set-selected-id] (rn/use-state :normal)]
|
||||
[]
|
||||
(let [current-transaction-setting (rf/sub [:wallet/confirmed-quick-tx-setting])
|
||||
[transaction-setting set-transaction-setting] (rn/use-state current-transaction-setting)]
|
||||
[rn/view
|
||||
[quo/drawer-top
|
||||
{:title (i18n/label :t/transaction-settings)}]
|
||||
[quo/category
|
||||
{:list-type :settings
|
||||
:data [{:title (str (i18n/label :t/normal) "~60s")
|
||||
:image-props "🍿"
|
||||
:description-props {:text "€1.45"}
|
||||
:image :emoji
|
||||
:description :text
|
||||
:action :selector
|
||||
:action-props {:type :radio
|
||||
:checked? (= :normal selected-id)}
|
||||
:on-press #(set-selected-id :normal)
|
||||
:label :text
|
||||
:preview-size :size-32}
|
||||
{:title (str (i18n/label :t/fast) "~40s")
|
||||
:image-props "🚗"
|
||||
:description-props {:text "€1.65"}
|
||||
:image :emoji
|
||||
:description :text
|
||||
:action :selector
|
||||
:action-props {:type :radio
|
||||
:checked? (= :fast selected-id)}
|
||||
:on-press #(set-selected-id :fast)
|
||||
:label :text
|
||||
:preview-size :size-32}
|
||||
{:title (str (i18n/label :t/urgent) "~15s")
|
||||
:image-props "🚀"
|
||||
:description-props {:text "€1.85"}
|
||||
:image :emoji
|
||||
:description :text
|
||||
:action :selector
|
||||
:action-props {:type :radio
|
||||
:checked? (= :urgent selected-id)}
|
||||
:on-press #(set-selected-id :urgent)
|
||||
:label :text
|
||||
:preview-size :size-32}
|
||||
{:title (i18n/label :t/custom)
|
||||
:image-props :i/edit
|
||||
:description-props {:text "Set your own fees and nonce"}
|
||||
:image :icon
|
||||
:description :text
|
||||
:action :arrow
|
||||
:on-press #(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content custom-settings-sheet}])
|
||||
:label :text
|
||||
:preview-size :size-32}]}]
|
||||
:data [{:title (str (i18n/label :t/normal) "~60s")
|
||||
:image-props "🍿"
|
||||
:description-props {:text (rf/sub [:wallet/wallet-send-transaction-setting-fiat-formatted
|
||||
:transaction-setting/normal])}
|
||||
:image :emoji
|
||||
:description :text
|
||||
:action :selector
|
||||
:action-props {:type :radio
|
||||
:checked? (= :transaction-setting/normal transaction-setting)}
|
||||
:on-press #(set-transaction-setting :transaction-setting/normal)
|
||||
:label :text
|
||||
:preview-size :size-32}
|
||||
{:title (str (i18n/label :t/fast) "~40s")
|
||||
:image-props "🚗"
|
||||
:description-props {:text (rf/sub [:wallet/wallet-send-transaction-setting-fiat-formatted
|
||||
:transaction-setting/fast])}
|
||||
:image :emoji
|
||||
:description :text
|
||||
:action :selector
|
||||
:action-props {:type :radio
|
||||
:checked? (= :transaction-setting/fast transaction-setting)}
|
||||
:on-press #(set-transaction-setting :transaction-setting/fast)
|
||||
:label :text
|
||||
:preview-size :size-32}
|
||||
{:title (str (i18n/label :t/urgent) "~15s")
|
||||
:image-props "🚀"
|
||||
:description-props {:text (rf/sub [:wallet/wallet-send-transaction-setting-fiat-formatted
|
||||
:transaction-setting/urgent])}
|
||||
:image :emoji
|
||||
:description :text
|
||||
:action :selector
|
||||
:action-props {:type :radio
|
||||
:checked? (= :transaction-setting/urgent transaction-setting)}
|
||||
:on-press #(set-transaction-setting :transaction-setting/urgent)
|
||||
:label :text
|
||||
:preview-size :size-32}
|
||||
{:title (i18n/label :t/custom)
|
||||
:image-props :i/edit
|
||||
:description-props {:text "Set your own fees and nonce"}
|
||||
:image :icon
|
||||
:description :text
|
||||
:action :arrow
|
||||
:on-press #(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content custom-settings-sheet}])
|
||||
:label :text
|
||||
:preview-size :size-32}]}]
|
||||
[quo/bottom-actions
|
||||
{:actions :one-action
|
||||
:button-one-props {:on-press #(rf/dispatch [:hide-bottom-sheet])}
|
||||
:button-one-props {:on-press (fn []
|
||||
(rf/dispatch [:wallet/quick-transaction-settings-confirmed
|
||||
transaction-setting])
|
||||
(rf/dispatch [:hide-bottom-sheet]))}
|
||||
:button-one-label (i18n/label :t/confirm)}]]))
|
||||
|
||||
(defn- hint
|
||||
[{:keys [error? text]}]
|
||||
[{:keys [status text]}]
|
||||
[quo/network-tags
|
||||
{:title text
|
||||
:status (when error? :error)}])
|
||||
:status status}])
|
||||
|
||||
(defn info-sheet
|
||||
[info-title info-content]
|
||||
@@ -147,23 +156,33 @@
|
||||
(i18n/label :t/read-more)]]])
|
||||
|
||||
(defn custom-setting-screen
|
||||
[{:keys [screen-title token-symbol hint-text-fn suggested-values info-title info-content on-save
|
||||
[{:keys [screen-title token-symbol hint-text-fn status-fn current spectrum info-title info-content
|
||||
on-save
|
||||
with-decimals?]
|
||||
:or {with-decimals? true}}]
|
||||
(let [[input-state set-input-state] (rn/use-state (controlled-input/set-value-numeric
|
||||
controlled-input/init-state
|
||||
(:current suggested-values)))
|
||||
current))
|
||||
input-value (controlled-input/input-value input-state)
|
||||
out-of-limits? (controlled-input/input-error input-state)
|
||||
valid-input? (not (or (controlled-input/empty-value? input-state)
|
||||
out-of-limits?))]
|
||||
(rn/use-mount
|
||||
status (when status-fn
|
||||
(status-fn
|
||||
input-value
|
||||
(controlled-input/lower-limit-exceeded? input-state)
|
||||
(controlled-input/upper-limit-exceeded? input-state)))
|
||||
hint-text (when hint-text-fn
|
||||
(hint-text-fn
|
||||
input-value
|
||||
(controlled-input/lower-limit-exceeded? input-state)
|
||||
(controlled-input/upper-limit-exceeded? input-state)))]
|
||||
(tap> {:in :custom-setting-screen
|
||||
:spectrum spectrum})
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
|
||||
(set-input-state (fn [state]
|
||||
(-> state
|
||||
(controlled-input/set-upper-limit (:high suggested-values))
|
||||
(controlled-input/set-lower-limit (:low suggested-values)))))))
|
||||
(controlled-input/set-upper-limit (:high spectrum))
|
||||
(controlled-input/set-lower-limit (:low spectrum))))))
|
||||
[spectrum])
|
||||
[rn/view
|
||||
{:style {:flex 1}}
|
||||
[quo/page-nav
|
||||
@@ -184,18 +203,16 @@
|
||||
:swappable? false
|
||||
:show-token-icon? false
|
||||
:value input-value
|
||||
:error? out-of-limits?
|
||||
:error? (= status :error)
|
||||
:currency-symbol token-symbol
|
||||
:hint-component [hint
|
||||
{:error? out-of-limits?
|
||||
:text (hint-text-fn
|
||||
(controlled-input/lower-limit-exceeded? input-state)
|
||||
(controlled-input/upper-limit-exceeded? input-state))}]}]
|
||||
{:status status
|
||||
:text hint-text}]}]
|
||||
[rn/view {:style {:flex 1}}]
|
||||
[quo/bottom-actions
|
||||
{:actions :one-action
|
||||
:button-one-label (i18n/label :t/save-changes)
|
||||
:button-one-props {:disabled? (not valid-input?)
|
||||
:button-one-props {:disabled? (= status :error)
|
||||
:on-press #(on-save (controlled-input/value-numeric input-state))}}]
|
||||
[quo/numbered-keyboard
|
||||
{:container-style {:padding-bottom (safe-area/get-bottom)}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns status-im.contexts.wallet.send.utils
|
||||
(:require
|
||||
[native-module.core :as native-module]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||
[utils.money :as money]))
|
||||
@@ -25,21 +26,42 @@
|
||||
transaction-hashes))
|
||||
|
||||
(defn calculate-gas-fee
|
||||
[data]
|
||||
(let [gas-amount (money/bignumber (get data :gas-amount))
|
||||
gas-fees (get data :gas-fees)
|
||||
eip1559-enabled? (get gas-fees :eip-1559-enabled)
|
||||
optimal-price-gwei (money/bignumber (if eip1559-enabled?
|
||||
(get gas-fees :max-fee-per-gas-medium)
|
||||
(get gas-fees :gas-price)))
|
||||
total-gas-fee-wei (money/mul (money/->wei :gwei optimal-price-gwei) gas-amount)
|
||||
l1-fee-wei (money/->wei :gwei (get gas-fees :l-1-gas-fee))]
|
||||
[{:keys [gas-amount gas-price l1-gas-fee]}]
|
||||
(let [total-gas-fee-wei (money/mul (money/->wei :gwei gas-price) gas-amount)
|
||||
l1-fee-wei (money/->wei :gwei l1-gas-fee)]
|
||||
(money/add total-gas-fee-wei l1-fee-wei)))
|
||||
|
||||
(defn calculate-full-route-gas-fee
|
||||
(defn path-gas-fee
|
||||
[path]
|
||||
(let [gas-amount (money/bignumber (get path :gas-amount))
|
||||
gas-fees (get path :gas-fees)
|
||||
eip1559-enabled? (get gas-fees :eip-1559-enabled)
|
||||
gas-price (money/bignumber (if eip1559-enabled?
|
||||
(get gas-fees :tx-max-fees-per-gas)
|
||||
(get gas-fees :gas-price)))
|
||||
l1-gas-fee (get gas-fees :l-1-gas-fee)]
|
||||
(calculate-gas-fee {:gas-amount gas-amount
|
||||
:gas-price gas-price
|
||||
:l1-gas-fee l1-gas-fee})))
|
||||
|
||||
(defn path-gas-fee-for-custom-gas-price
|
||||
[route gas-price]
|
||||
(let [gas-amount (money/bignumber (get route :gas-amount))
|
||||
gas-fees (get route :gas-fees)
|
||||
l1-gas-fee (get gas-fees :l-1-gas-fee)]
|
||||
(calculate-gas-fee {:gas-amount gas-amount
|
||||
:gas-price (money/bignumber gas-price)
|
||||
:l1-gas-fee l1-gas-fee})))
|
||||
|
||||
(defn full-route-gas-fee
|
||||
"Sums all the routes fees in wei and then convert the total value to ether"
|
||||
[route]
|
||||
(money/wei->ether (reduce money/add (map calculate-gas-fee route))))
|
||||
(money/wei->ether (reduce money/add (map path-gas-fee route))))
|
||||
|
||||
(defn full-route-gas-fee-for-custom-gas-price
|
||||
"Sums all the routes fees in wei and then convert the total value to ether"
|
||||
[route gas-price]
|
||||
(money/wei->ether (reduce money/add (map #(path-gas-fee-for-custom-gas-price % gas-price) route))))
|
||||
|
||||
(defn- path-amount-in
|
||||
[path]
|
||||
@@ -224,3 +246,23 @@
|
||||
{:r (subs signature 0 64)
|
||||
:s (subs signature 64 128)
|
||||
:v (subs signature 128 130)})
|
||||
|
||||
(defn path-identity
|
||||
[path]
|
||||
{:routerInputParamsUuid (:router-input-params-uuid path)
|
||||
:pathName (:bridge-name path)
|
||||
:chainID (get-in path [:to :chain-id])
|
||||
:isApprovalTx (:approval-required path)})
|
||||
|
||||
(defn path-tx-custom-params
|
||||
[user-tx-settings route]
|
||||
(let [nonce (or (:nonce user-tx-settings) (:nonce route))
|
||||
gas-amount (or (:gas-amount user-tx-settings) (:gas-amount route))
|
||||
priority-fee (or (:priority-fee user-tx-settings) (get-in route [:gas-fees :tx-priority-fee]))
|
||||
max-base-fee (or (:max-base-fee user-tx-settings) (get-in route [:gas-fees :current-base-fee]))]
|
||||
{:gasFeeMode constants/gas-rate-custom
|
||||
:nonce nonce
|
||||
:gasAmount gas-amount
|
||||
:maxFeesPerGas (money/to-hex (money/->wei :gwei (money/add max-base-fee priority-fee)))
|
||||
:priorityFee (money/to-hex (money/->wei :gwei priority-fee))}))
|
||||
|
||||
|
||||
@@ -178,21 +178,21 @@
|
||||
(deftest calculate-gas-fee-test
|
||||
(testing "EIP-1559 transaction without L1 fee"
|
||||
(let [data {:gas-amount "23487"
|
||||
:gas-fees {:max-fee-per-gas-medium "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}
|
||||
:gas-fees {:tx-max-fees-per-gas "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}
|
||||
expected-result (money/bignumber "53063589834657")] ; This is in Wei
|
||||
(is (money/equal-to (utils/calculate-gas-fee data)
|
||||
(is (money/equal-to (utils/path-gas-fee data)
|
||||
expected-result))))
|
||||
|
||||
(testing "EIP-1559 transaction with L1 fee of 60,000 Gwei"
|
||||
(let [data {:gas-amount "23487"
|
||||
:gas-fees {:max-fee-per-gas-medium "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "60000"}}
|
||||
:gas-fees {:tx-max-fees-per-gas "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "60000"}}
|
||||
expected-result (money/bignumber "113063589834657")] ; Added 60,000 Gwei in Wei to the
|
||||
; previous result
|
||||
(is (money/equal-to (utils/calculate-gas-fee data)
|
||||
(is (money/equal-to (utils/path-gas-fee data)
|
||||
expected-result))))
|
||||
|
||||
(testing "Non-EIP-1559 transaction with specified gas price"
|
||||
@@ -202,48 +202,48 @@
|
||||
:l-1-gas-fee "0"}}
|
||||
expected-result (money/bignumber "67471600217343")] ; This is in Wei, for the specified
|
||||
; gas amount and price
|
||||
(is (money/equal-to (utils/calculate-gas-fee data)
|
||||
(is (money/equal-to (utils/path-gas-fee data)
|
||||
expected-result)))))
|
||||
|
||||
(deftest calculate-full-route-gas-fee-test
|
||||
(testing "Route with a single EIP-1559 transaction, no L1 fees"
|
||||
(let [route [{:gas-amount "23487"
|
||||
:gas-fees {:max-fee-per-gas-medium "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}]
|
||||
:gas-fees {:tx-max-fees-per-gas "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}]
|
||||
expected-result (money/bignumber "0.000053063589834657")] ; The Wei amount for the
|
||||
; transaction, converted to
|
||||
; Ether
|
||||
(is (money/equal-to (utils/calculate-full-route-gas-fee route)
|
||||
(is (money/equal-to (utils/full-route-gas-fee route)
|
||||
expected-result))))
|
||||
|
||||
(testing "Route with two EIP-1559 transactions, no L1 fees"
|
||||
(let [route [{:gas-amount "23487"
|
||||
:gas-fees {:max-fee-per-gas-medium "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}
|
||||
:gas-fees {:tx-max-fees-per-gas "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}
|
||||
{:gas-amount "23487"
|
||||
:gas-fees {:max-fee-per-gas-medium "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}]
|
||||
:gas-fees {:tx-max-fees-per-gas "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}]
|
||||
expected-result (money/bignumber "0.000106127179669314")] ; Sum of both transactions' Wei
|
||||
; amounts, converted to Ether
|
||||
(is (money/equal-to (utils/calculate-full-route-gas-fee route)
|
||||
(is (money/equal-to (utils/full-route-gas-fee route)
|
||||
expected-result))))
|
||||
|
||||
(testing "Route with two EIP-1559 transactions, one with L1 fee of 60,000 Gwei"
|
||||
(let [route [{:gas-amount "23487"
|
||||
:gas-fees {:max-fee-per-gas-medium "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}
|
||||
:gas-fees {:tx-max-fees-per-gas "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}
|
||||
{:gas-amount "23487"
|
||||
:gas-fees {:max-fee-per-gas-medium "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "60000"}}]
|
||||
:gas-fees {:tx-max-fees-per-gas "2.259274911"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "60000"}}]
|
||||
expected-result (money/bignumber "0.000166127179669314")] ; Added 60,000 Gwei in Wei to
|
||||
; the previous total and
|
||||
; converted to Ether
|
||||
(is (money/equal-to (utils/calculate-full-route-gas-fee route)
|
||||
(is (money/equal-to (utils/full-route-gas-fee route)
|
||||
expected-result)))))
|
||||
|
||||
(deftest token-available-networks-for-suggested-routes-test
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
[quo.foundations.resources :as resources]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[status-im.common.biometric.utils :as biometric]
|
||||
[status-im.common.events-helper :as events-helper]
|
||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||
[status-im.common.standard-authentication.core :as standard-auth]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.common.utils.external-links :as external-links]
|
||||
[status-im.contexts.wallet.swap.set-spending-cap.style :as style]
|
||||
@@ -216,25 +217,21 @@
|
||||
|
||||
(defn- slide-button
|
||||
[]
|
||||
(let [loading-swap-proposal? (rf/sub [:wallet/swap-loading-swap-proposal?])
|
||||
swap-proposal (rf/sub [:wallet/swap-proposal-without-fees])
|
||||
account (rf/sub [:wallet/current-viewing-account])
|
||||
transaction-for-signing (rf/sub [:wallet/swap-transaction-for-signing])
|
||||
sign-on-keycard? (get-in transaction-for-signing
|
||||
[:signingDetails :signOnKeycard])
|
||||
on-auth-success (rn/use-callback
|
||||
#(rf/dispatch [:wallet/prepare-signatures-for-transactions :swap %]))
|
||||
on-complete (rn/use-callback
|
||||
#(rf/dispatch [:wallet/prepare-signatures-for-transactions :swap ""]))]
|
||||
[standard-auth/slide-button
|
||||
(let [loading-swap-proposal? (rf/sub [:wallet/swap-loading-swap-proposal?])
|
||||
swap-proposal (rf/sub [:wallet/swap-proposal-without-fees])
|
||||
account (rf/sub [:wallet/current-viewing-account])
|
||||
biometric-auth? (= (rf/sub [:auth-method]) constants/auth-method-biometric)
|
||||
biometric-type (rf/sub [:biometrics/supported-type])]
|
||||
[quo/slide-button
|
||||
{:size :size-48
|
||||
:track-text (i18n/label :t/slide-to-sign)
|
||||
:container-style {:z-index 2}
|
||||
:customization-color (:color account)
|
||||
:track-icon (if biometric-auth?
|
||||
(biometric/get-icon-by-type biometric-type)
|
||||
:password)
|
||||
:disabled? (or loading-swap-proposal? (not swap-proposal))
|
||||
:on-complete (when sign-on-keycard? on-complete)
|
||||
:on-auth-success on-auth-success
|
||||
:auth-button-label (i18n/label :t/confirm)}]))
|
||||
:on-complete #(rf/dispatch [:wallet/prepare-signatures-for-transactions :swap])}]))
|
||||
|
||||
(defn- footer
|
||||
[]
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.common.biometric.utils :as biometric]
|
||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||
[status-im.common.standard-authentication.core :as standard-auth]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.send.utils :as send-utils]
|
||||
@@ -167,26 +167,21 @@
|
||||
transaction-for-signing (rf/sub [:wallet/swap-transaction-for-signing])
|
||||
swap-proposal (rf/sub [:wallet/swap-proposal-without-fees])
|
||||
account (rf/sub [:wallet/current-viewing-account])
|
||||
account-color (:color account)
|
||||
sign-on-keycard? (get-in transaction-for-signing
|
||||
[:signingDetails :signOnKeycard])]
|
||||
[standard-auth/slide-button
|
||||
biometric-auth? (= (rf/sub [:auth-method]) constants/auth-method-biometric)
|
||||
biometric-type (rf/sub [:biometrics/supported-type])
|
||||
account-color (:color account)]
|
||||
[quo/slide-button
|
||||
{:size :size-48
|
||||
:track-text (i18n/label :t/slide-to-swap)
|
||||
:container-style {:z-index 2}
|
||||
:customization-color account-color
|
||||
:track-icon (if biometric-auth?
|
||||
(biometric/get-icon-by-type biometric-type)
|
||||
:password)
|
||||
:disabled? (or loading-swap-proposal?
|
||||
(not swap-proposal)
|
||||
(not transaction-for-signing))
|
||||
:auth-button-label (i18n/label :t/confirm)
|
||||
:on-complete (when sign-on-keycard?
|
||||
#(rf/dispatch
|
||||
[:wallet/prepare-signatures-for-transactions
|
||||
:swap
|
||||
""]))
|
||||
:on-auth-success (fn [data]
|
||||
(rf/dispatch [:wallet/stop-get-swap-proposal])
|
||||
(rf/dispatch [:wallet/prepare-signatures-for-transactions :swap data]))}]))
|
||||
:on-complete #(rf/dispatch [:wallet/prepare-signatures-for-transactions :swap])}]))
|
||||
|
||||
(defn footer
|
||||
[]
|
||||
|
||||
@@ -167,6 +167,7 @@
|
||||
(when
|
||||
(= (:chain-id network) bridge-to-chain-id)
|
||||
network))
|
||||
|
||||
networks))))
|
||||
|
||||
(rf/reg-sub
|
||||
@@ -205,27 +206,89 @@
|
||||
{:crypto (str crypto-formatted " " (:symbol token))
|
||||
:fiat fiat-formatted})))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :tx-settings)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-max-base-fee
|
||||
:<- [:wallet/tx-settings]
|
||||
:wallet/confirmed-quick-tx-setting
|
||||
:<- [:wallet/wallet-send]
|
||||
(fn [send-data]
|
||||
(or (:confirmed-quick-tx-setting send-data) :transaction-setting/fast)))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/user-tx-settings
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :user-tx-settings)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-max-base-fee-user
|
||||
:<- [:wallet/user-tx-settings]
|
||||
:-> :max-base-fee)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-priority-fee
|
||||
:<- [:wallet/tx-settings]
|
||||
:wallet/tx-settings-priority-fee-user
|
||||
:<- [:wallet/user-tx-settings]
|
||||
:-> :priority-fee)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-max-gas-amount
|
||||
:<- [:wallet/tx-settings]
|
||||
:-> :max-gas-amount)
|
||||
:wallet/tx-settings-nonce-user
|
||||
:<- [:wallet/user-tx-settings]
|
||||
:-> :nonce)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-gas-amount-user
|
||||
:<- [:wallet/user-tx-settings]
|
||||
:-> :gas-amount)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-gas-amount
|
||||
:<- [:wallet/send-route]
|
||||
:<- [:wallet/tx-settings-gas-amount-user]
|
||||
(fn [[route value-set-by-user]]
|
||||
(or value-set-by-user (:gas-amount (first route)))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-nonce
|
||||
:<- [:wallet/tx-settings]
|
||||
:-> :nonce)
|
||||
:<- [:wallet/send-route]
|
||||
:<- [:wallet/tx-settings-nonce-user]
|
||||
(fn [[route value-set-by-user]]
|
||||
(or value-set-by-user (:nonce (first route)))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-gas-fees
|
||||
:<- [:wallet/send-route]
|
||||
(fn [route]
|
||||
(:gas-fees (first route))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-suggested-nonce
|
||||
:<- [:wallet/send-route]
|
||||
(fn [route]
|
||||
(:suggested-tx-nonce (first route))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-priority-fee
|
||||
:<- [:wallet/tx-settings-gas-fees]
|
||||
:<- [:wallet/tx-settings-priority-fee-user]
|
||||
(fn [[gas-fees value-set-by-user]]
|
||||
(or value-set-by-user (:tx-priority-fee gas-fees))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-max-base-fee
|
||||
:<- [:wallet/tx-settings-gas-fees]
|
||||
:<- [:wallet/tx-settings-max-base-fee-user]
|
||||
(fn [[gas-fees value-set-by-user]]
|
||||
(or value-set-by-user (:current-base-fee gas-fees))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-suggested-max-priority-fee
|
||||
:<- [:wallet/tx-settings-gas-fees]
|
||||
:<- [:wallet/tx-settings-max-base-fee-user]
|
||||
(fn [[gas-fees value-set-by-user]]
|
||||
(or value-set-by-user (:suggested-max-priority-fee gas-fees))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-suggested-min-priority-fee
|
||||
:<- [:wallet/tx-settings-gas-fees]
|
||||
:<- [:wallet/tx-settings-max-base-fee-user]
|
||||
(fn [[gas-fees value-set-by-user]]
|
||||
(or value-set-by-user (:suggested-min-priority-fee gas-fees))))
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@
|
||||
token-for-fees (first (filter #(= (string/lower-case (:symbol %))
|
||||
(string/lower-case token-symbol-for-fees))
|
||||
tokens))
|
||||
fee-in-native-token (send-utils/calculate-full-route-gas-fee [swap-proposal])
|
||||
fee-in-native-token (send-utils/full-route-gas-fee [swap-proposal])
|
||||
fee-in-fiat (utils/calculate-token-fiat-value
|
||||
{:currency currency
|
||||
:balance fee-in-native-token
|
||||
|
||||
@@ -120,9 +120,9 @@
|
||||
:approval-required true
|
||||
:approval-amount-required "0x10000"
|
||||
:gas-amount "25000"
|
||||
:gas-fees {:max-fee-per-gas-medium "4"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}
|
||||
:gas-fees {:tx-max-fees-per-gas "4"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}
|
||||
:error-response "Error"
|
||||
:loading-swap-proposal? false
|
||||
:max-slippage 0.5})
|
||||
|
||||
@@ -162,6 +162,17 @@
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :route)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/gas-fees
|
||||
:<- [:wallet/wallet-send-route]
|
||||
(fn [route]
|
||||
(:gas-fees (first route))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/suggested-gas-fees-for-setting
|
||||
:<- [:wallet/gas-fees]
|
||||
:-> :suggested-gas-fees-for-setting)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/wallet-send-enough-assets?
|
||||
:<- [:wallet/wallet-send]
|
||||
@@ -844,22 +855,51 @@
|
||||
:<- [:profile/currency]
|
||||
:<- [:profile/currency-symbol]
|
||||
:<- [:wallet/prices-per-token]
|
||||
(fn [[account route currency currency-symbol prices-per-token] [_ token-symbol-for-fees]]
|
||||
(when token-symbol-for-fees
|
||||
(let [tokens (:tokens account)
|
||||
token-for-fees (first (filter #(= (string/lower-case (:symbol %))
|
||||
(string/lower-case token-symbol-for-fees))
|
||||
tokens))
|
||||
fee-in-native-token (send-utils/calculate-full-route-gas-fee route)
|
||||
fee-in-fiat (utils/calculate-token-fiat-value
|
||||
{:currency currency
|
||||
:balance fee-in-native-token
|
||||
:token token-for-fees
|
||||
:prices-per-token prices-per-token})
|
||||
fee-formatted (utils/fiat-formatted-for-ui
|
||||
currency-symbol
|
||||
fee-in-fiat)]
|
||||
fee-formatted))))
|
||||
(fn [[account route currency currency-symbol prices-per-token]]
|
||||
(let [token-symbol-for-fees (get-in (first route) [:from :native-currency-symbol])]
|
||||
(when token-symbol-for-fees
|
||||
(let [tokens (:tokens account)
|
||||
token-for-fees (first (filter #(= (string/lower-case (:symbol %))
|
||||
(string/lower-case token-symbol-for-fees))
|
||||
tokens))
|
||||
fee-in-native-token (send-utils/full-route-gas-fee route)
|
||||
fee-in-fiat (utils/calculate-token-fiat-value
|
||||
{:currency currency
|
||||
:balance fee-in-native-token
|
||||
:token token-for-fees
|
||||
:prices-per-token prices-per-token})
|
||||
fee-formatted (utils/fiat-formatted-for-ui
|
||||
currency-symbol
|
||||
fee-in-fiat)]
|
||||
fee-formatted)))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/wallet-send-transaction-setting-fiat-formatted
|
||||
:<- [:wallet/current-viewing-account]
|
||||
:<- [:wallet/wallet-send-route]
|
||||
:<- [:profile/currency]
|
||||
:<- [:profile/currency-symbol]
|
||||
:<- [:wallet/prices-per-token]
|
||||
:<- [:wallet/suggested-gas-fees-for-setting]
|
||||
(fn [[account route currency currency-symbol prices-per-token fees-for-settings]
|
||||
[_ transaction-setting]]
|
||||
(let [token-symbol-for-fees (get-in (first route) [:from :native-currency-symbol])]
|
||||
(when token-symbol-for-fees
|
||||
(let [tokens (:tokens account)
|
||||
token-for-fees (first (filter #(= (string/lower-case (:symbol %))
|
||||
(string/lower-case token-symbol-for-fees))
|
||||
tokens))
|
||||
gas-price (transaction-setting fees-for-settings)
|
||||
fee-in-native-token (send-utils/full-route-gas-fee-for-custom-gas-price route gas-price)
|
||||
fee-in-fiat (utils/calculate-token-fiat-value
|
||||
{:currency currency
|
||||
:balance fee-in-native-token
|
||||
:token token-for-fees
|
||||
:prices-per-token prices-per-token})
|
||||
fee-formatted (utils/fiat-formatted-for-ui
|
||||
currency-symbol
|
||||
fee-in-fiat)]
|
||||
fee-formatted)))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/has-partially-operable-accounts?
|
||||
|
||||
@@ -205,9 +205,10 @@
|
||||
|
||||
(def route-data
|
||||
[{:gas-amount "25000"
|
||||
:gas-fees {:max-fee-per-gas-medium "4"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}}])
|
||||
:gas-fees {:tx-max-fees-per-gas "4"
|
||||
:eip-1559-enabled true
|
||||
:l-1-gas-fee "0"}
|
||||
:from {:native-currency-symbol "ETH"}}])
|
||||
|
||||
(h/deftest-sub :wallet/balances-in-selected-networks
|
||||
[sub-name]
|
||||
@@ -938,9 +939,7 @@
|
||||
(assoc-in [:profile/profile :currency] :usd)
|
||||
(assoc-in [:profile/profile :currency-symbol] "$")))
|
||||
|
||||
(let [token-symbol-for-fees "ETH"
|
||||
result (rf/sub [sub-name token-symbol-for-fees])]
|
||||
(is (match? result "$0.20")))))
|
||||
(is (match? (rf/sub [sub-name]) "$0.20"))))
|
||||
|
||||
(h/deftest-sub :wallet/has-partially-operable-accounts?
|
||||
[sub-name]
|
||||
|
||||
@@ -143,7 +143,8 @@
|
||||
|
||||
(defn to-hex
|
||||
[^js bn]
|
||||
(str "0x" (to-string bn 16)))
|
||||
(when bn
|
||||
(str "0x" (to-string bn 16))))
|
||||
|
||||
(defn from-hex
|
||||
[hex-str]
|
||||
@@ -195,8 +196,9 @@
|
||||
(greater-than-or-equals balance amount)))
|
||||
|
||||
(defn- add*
|
||||
[bn1 n2]
|
||||
(.add ^js bn1 n2))
|
||||
[n1 n2]
|
||||
(when-let [[^js bn1 ^js bn2] (->bignumbers n1 n2)]
|
||||
(.add ^js bn1 bn2)))
|
||||
|
||||
(def add
|
||||
"Add with defaults, this version is able to receive `nil` and takes them as 0."
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v10.0.0",
|
||||
"commit-sha1": "dcce8e9b8aec04876b854eacb56d9de95fd96a59",
|
||||
"src-sha256": "008z0wrf6slf32iy3navq4zznfy6lam72lpqhxqwl8705hk4a4mj"
|
||||
"version": "feat/tx-path-new-props",
|
||||
"commit-sha1": "d2c220fe60bb7817753167184ba70e9b47cfa5be",
|
||||
"src-sha256": "10n4kf7lb0rm57b3llyalpgv70dp3k560nxxfpb7f0gcc5kpl97q"
|
||||
}
|
||||
|
||||
+13
-8
@@ -4,11 +4,11 @@
|
||||
"about-gas-amount": "AKA gas limit. Refers to the maximum number of computational steps (or units of gas) that a transaction can consume. It represents the complexity or amount of work required to execute a transaction or smart contract.\n\nThe gas limit is a cap on how much work the transaction can do on the blockchain. If the gas limit is set too low, the transaction may fail due to insufficient gas.",
|
||||
"about-key-storage-content": "Status will never access your private key. Be sure to backup your seed phrase. If you lose your phone it is the only way to access your keys.",
|
||||
"about-key-storage-title": "About key storage",
|
||||
"about-max-base-fee": "When your transaction gets included in the block, any difference between your max base fee and the actual base fee will be refunded.",
|
||||
"about-max-base-fee": "When your transaction gets included in the block, any difference between your max base fee and the actual base fee will be refunded.\n\nNote: the ETH amount shown for this value is calculated: max base fee (in GWEI) * max gas amount.",
|
||||
"about-names-content": "No one can pretend to be you! You’re anonymous by default and never have to reveal your real name. You can register a custom name for a small fee.",
|
||||
"about-names-title": "Names can’t be changed",
|
||||
"about-nonce": "Transaction counter ensuring transactions from your account are processed in the correct order and can’t be replayed. Each new transaction increments the nonce by 1, ensuring uniqueness and preventing double-spending.\n\nIf a transaction with a lower nonce is pending, higher nonce transactions will remain in the queue until the earlier one is confirmed.",
|
||||
"about-priority-fee": "AKA miner tip. A voluntary fee you can add to incentivise miners or validators to prioritise your transaction.\n\nThe higher the tip, the faster your transaction is likely to be processed, especially curing periods of higher network congestion.",
|
||||
"about-priority-fee": "AKA miner tip. A voluntary fee you can add to incentivise miners or validators to prioritise your transaction.\n\nThe higher the tip, the faster your transaction is likely to be processed, especially during periods of higher network congestion.\n\nNote: the ETH amount shown for this value is calculated: Priority fee (in GWEI) * Max gas amount",
|
||||
"about-sharing-data": "About sharing data",
|
||||
"accent-colour": "Accent colour",
|
||||
"accent-colour-updated": "Accent colour updated",
|
||||
@@ -1111,7 +1111,9 @@
|
||||
"from-label": "From",
|
||||
"gas-amount": "Gas amount",
|
||||
"gas-amount-limit": "Gas amount limit",
|
||||
"gas-amount-lower": "Too low. Recommended: {{current}} UNITS",
|
||||
"gas-amount-lower": "Too low. Minimum: {{low}}",
|
||||
"gas-amount-higher": "Too high. Maximum: {{high}}",
|
||||
"gas-amount-current": "Current: {{current}}",
|
||||
"gas-limit": "Gas limit",
|
||||
"gas-price": "Gas price",
|
||||
"gas-used": "Gas used",
|
||||
@@ -1591,9 +1593,10 @@
|
||||
"master-account": "Master account",
|
||||
"max": "Max: {{number}}",
|
||||
"max-2-decimals": "Max. 2 decimals",
|
||||
"max-base-fee": "Max base fee",
|
||||
"max-base-fee-higher": "Higher than necessary. Current: {{current}} GWEI",
|
||||
"max-base-fee-lower": "Too low. Current: {{current}} GWEI ",
|
||||
"max-base-fee": "Max base fee",
|
||||
"max-base-fee-current": "Current: {{current}}",
|
||||
"max-base-fee-higher": "Higher than necessary (current: {{current}})",
|
||||
"max-base-fee-lower": "Lower than priority fee: {{priority-fee}}",
|
||||
"max-fee": "Max fee",
|
||||
"max-fees": "Max fees",
|
||||
"max-gas-amount": "Max gas amount",
|
||||
@@ -2068,8 +2071,10 @@
|
||||
"principles": "Principles",
|
||||
"priority": "Priority",
|
||||
"priority-fee": "Priority fee",
|
||||
"priority-fee-higher": "More than necessary. Current: {{low}} - {{high}} GWEI",
|
||||
"priority-fee-lower": "Too low. Current: {{low}} - {{high}} GWEI",
|
||||
"priority-fee-higher": "Higher than necessary: {{low}} - {{high}}",
|
||||
"priority-fee-higher-max-base": "Higher than max base fee: {{max-base-fee}}",
|
||||
"priority-fee-lower": "Lower than suggested: {{low}} - {{high}}",
|
||||
"priority-fee-current": "Current: {{current}}",
|
||||
"privacy": "Privacy",
|
||||
"privacy-and-security": "Privacy and security",
|
||||
"privacy-photos": "Profile Photo Privacy",
|
||||
|
||||
Reference in New Issue
Block a user