Skip to content

Commit

Permalink
fix(wallet)_: token max value not updated when switching accounts or …
Browse files Browse the repository at this point in the history
…disabling networks

Signed-off-by: Mohamed Javid <[email protected]>
  • Loading branch information
smohamedjavid committed Sep 20, 2024
1 parent 87d8234 commit 62384ce
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/status_im/contexts/wallet/send/input_amount/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@
:as
token} (rf/sub [:wallet/wallet-send-token])
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
{token-balance :total-balance
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
{:keys [total-balance]
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
(str token-symbol)
enabled-from-chain-ids])
token-balance (or default-limit-crypto total-balance)
usd-conversion-rate (utils/token-usd-price token)
currency (rf/sub [:profile/currency])
conversion-rate (-> token
:market-values-per-currency
Expand All @@ -186,6 +188,14 @@
route (rf/sub [:wallet/wallet-send-route])
on-confirm (or default-on-confirm handle-on-confirm)
crypto-decimals (or token-decimals default-crypto-decimals)
max-limit (if crypto-currency?
(utils/cut-crypto-decimals-to-fit-usd-cents
token-balance
usd-conversion-rate)
(-> (money/crypto->fiat
token-balance
conversion-rate)
utils/cut-fiat-balance-to-two-decimals))
input-value (controlled-input/input-value input-state)
valid-input? (not (or (controlled-input/empty-value? input-state)
(controlled-input/input-error input-state)))
Expand Down Expand Up @@ -288,13 +298,8 @@
(hot-reload/use-safe-unmount on-navigate-back)
(rn/use-effect
(fn []
(set-input-state
#(-> %
(controlled-input/set-upper-limit
(utils/cut-crypto-decimals-to-fit-usd-cents
(or default-limit-crypto token-balance)
conversion-rate)))))
[token-symbol])
(set-input-state #(controlled-input/set-upper-limit % max-limit)))
[max-limit])
(rn/use-effect
(fn []
(when input-error (debounce/clear-all))
Expand Down

0 comments on commit 62384ce

Please sign in to comment.