Skip to content

Commit 6fa6209

Browse files
committed
fix(wallet): Exception when navigating back from route generation
- Slightly improved code styles
1 parent 131da5f commit 6fa6209

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/status_im/contexts/wallet/send/input_amount/view.cljs

+6-9
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,14 @@
158158
active-screen? (= view-id current-screen-id)
159159
bottom (safe-area/get-bottom)
160160
[crypto-currency? set-crypto-currency] (rn/use-state initial-crypto-currency?)
161-
on-navigate-back on-navigate-back
162161
handle-on-confirm (fn [amount]
163162
(rf/dispatch [:wallet/set-token-amount-to-send
164163
{:amount amount
165164
:stack-id current-screen-id}]))
166165
{fiat-currency :currency} (rf/sub [:profile/profile])
167-
{token-symbol :symbol
166+
{token-symbol :symbol
168167
token-networks :networks
169-
:as
170-
token} (rf/sub [:wallet/wallet-send-token])
168+
:as token} (rf/sub [:wallet/wallet-send-token])
171169
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
172170
{:keys [total-balance]
173171
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
@@ -196,10 +194,8 @@
196194
(utils/cut-crypto-decimals-to-fit-usd-cents
197195
token-balance
198196
usd-conversion-rate)
199-
(-> (money/crypto->fiat
200-
token-balance
201-
conversion-rate)
202-
utils/cut-fiat-balance-to-two-decimals))
197+
(utils/cut-fiat-balance-to-two-decimals
198+
(money/crypto->fiat token-balance conversion-rate)))
203199
input-value (controlled-input/input-value input-state)
204200
valid-input? (not (or (controlled-input/empty-value? input-state)
205201
(controlled-input/input-error input-state)))
@@ -389,7 +385,8 @@
389385
:button-one-label (if should-try-again?
390386
(i18n/label :t/try-again)
391387
button-one-label)
392-
:button-one-props (merge (when-not should-try-again? button-one-props)
388+
:button-one-props (merge (when-not should-try-again?
389+
button-one-props)
393390
{:disabled? (or loading-routes?
394391
(and (not should-try-again?) confirm-disabled?))
395392
:on-press (cond

src/status_im/contexts/wallet/send/send_amount/view.cljs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
[input-amount/view
1111
{:current-screen-id :screen/wallet.send-input-amount
1212
:button-one-label (i18n/label :t/review-send)
13-
:enabled-from-chain-ids (rf/sub
14-
[:wallet/wallet-send-enabled-from-chain-ids])
13+
:enabled-from-chain-ids (rf/sub [:wallet/wallet-send-enabled-from-chain-ids])
1514
:from-enabled-networks (rf/sub [:wallet/wallet-send-enabled-networks])
1615
:on-navigate-back (fn []
1716
(rf/dispatch-sync [:wallet/stop-and-clean-suggested-routes])

src/utils/money.cljs

+6-3
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,12 @@
239239

240240
(defn crypto->fiat
241241
[crypto fiat-price]
242-
(when-let [^js bn (bignumber crypto)]
243-
(-> (.times bn ^js (bignumber fiat-price))
244-
(with-precision 2))))
242+
(let [^js crypto-bn (bignumber crypto)
243+
^js fiat-price-bn (bignumber fiat-price)]
244+
(when (and crypto-bn fiat-price-bn)
245+
(-> crypto-bn
246+
(.times fiat-price-bn)
247+
(with-precision 2)))))
245248

246249
(defn sufficient-funds?
247250
[^js amount ^js balance]

0 commit comments

Comments
 (0)