Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8727a3a17 |
@@ -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)
|
||||
|
||||
@@ -233,7 +233,8 @@
|
||||
|
||||
(defn new->old-route-path
|
||||
[new-path]
|
||||
(let [to-bignumber (fn [k] (-> new-path k money/bignumber))]
|
||||
(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 +243,34 @@
|
||||
: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)
|
||||
: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}
|
||||
:l-1-gas-fee (send-utils/convert-to-gwei (:tx-l-1-fee
|
||||
new-path)
|
||||
precision)
|
||||
:eip-1559-enabled true
|
||||
:tx-max-fees-per-gas (send-utils/convert-to-gwei
|
||||
(:tx-max-fees-per-gas
|
||||
new-path)
|
||||
precision)
|
||||
:suggested-gas-fees-for-setting
|
||||
{:transaction-setting/normal (send-utils/convert-to-gwei
|
||||
(:low
|
||||
suggested-levels-for-max-fees-per-gas)
|
||||
precision)
|
||||
:transaction-setting/fast (send-utils/convert-to-gwei
|
||||
(:medium
|
||||
suggested-levels-for-max-fees-per-gas)
|
||||
precision)
|
||||
:transaction-setting/urgent (send-utils/convert-to-gwei
|
||||
(:high
|
||||
suggested-levels-for-max-fees-per-gas)
|
||||
precision)}}
|
||||
:bridge-name (:processor-name new-path)
|
||||
:amount-out (:amount-out new-path)
|
||||
:approval-contract-address (:approval-contract-address new-path)
|
||||
@@ -279,7 +279,8 @@
|
||||
: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)}))
|
||||
|
||||
(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]
|
||||
@@ -384,16 +386,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
|
||||
@@ -405,16 +491,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
|
||||
@@ -665,66 +749,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}]]
|
||||
@@ -813,35 +837,58 @@
|
||||
(rf/reg-event-fx
|
||||
:wallet/init-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 (-> db
|
||||
(assoc-in [:wallet :ui :send :custom-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}})
|
||||
(assoc-in [:wallet :ui :send :confirmed-tx-setting] :transaction-setting/fast))}))
|
||||
|
||||
(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 :custom-tx-settings :max-base-fee :current] 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 :custom-tx-settings :priority-fee :current] 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 :custom-tx-settings :max-gas-amount :current] value)}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet/set-nonce
|
||||
(fn [{db :db} [value]]
|
||||
{:db (assoc-in db [:wallet :ui :send :tx-settings :nonce :current] 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-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.send/set-sign-transactions-callback-fx
|
||||
(fn [{:keys [db]} [callback-fx]]
|
||||
{:db (assoc-in db
|
||||
[:wallet :ui :send :sign-transactions-callback-fx]
|
||||
callback-fx)}))
|
||||
|
||||
@@ -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,20 +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)
|
||||
@@ -283,27 +267,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,13 @@
|
||||
(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
|
||||
constants/gas-rate-medium))
|
||||
@@ -66,60 +66,67 @@
|
||||
: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-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
|
||||
|
||||
@@ -25,21 +25,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 +245,10 @@
|
||||
{: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)})
|
||||
|
||||
@@ -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
|
||||
[]
|
||||
|
||||
@@ -205,27 +205,33 @@
|
||||
{:crypto (str crypto-formatted " " (:symbol token))
|
||||
:fiat fiat-formatted})))
|
||||
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings
|
||||
:wallet/confirmed-tx-setting
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :tx-settings)
|
||||
:-> :confirmed-tx-setting)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/custom-tx-settings
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :custom-tx-settings)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-max-base-fee
|
||||
:<- [:wallet/tx-settings]
|
||||
:<- [:wallet/custom-tx-settings]
|
||||
:-> :max-base-fee)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-priority-fee
|
||||
:<- [:wallet/tx-settings]
|
||||
:<- [:wallet/custom-tx-settings]
|
||||
:-> :priority-fee)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-max-gas-amount
|
||||
:<- [:wallet/tx-settings]
|
||||
:<- [:wallet/custom-tx-settings]
|
||||
:-> :max-gas-amount)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/tx-settings-nonce
|
||||
:<- [:wallet/tx-settings]
|
||||
:<- [:wallet/custom-tx-settings]
|
||||
:-> :nonce)
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user