Skip to content

Commit 9a52339

Browse files
authored
wallet(account): disable send and bridge options for assets with a 0 balance (#21033)
1 parent d53bef3 commit 9a52339

File tree

1 file changed

+31
-25
lines changed
  • src/status_im/contexts/wallet/common/token_value

1 file changed

+31
-25
lines changed

src/status_im/contexts/wallet/common/token_value/view.cljs

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
66
[status-im.feature-flags :as ff]
77
[utils.i18n :as i18n]
8+
[utils.money :as money]
89
[utils.re-frame :as rf]))
910

1011
(defn- action-buy
@@ -21,6 +22,7 @@
2122
{:icon :i/send
2223
:accessibility-label :send
2324
:label (i18n/label :t/send)
25+
:disabled? (:disabled? send-params)
2426
:on-press (fn []
2527
(rf/dispatch [:hide-bottom-sheet])
2628
(rf/dispatch [:wallet/clean-send-data])
@@ -69,31 +71,35 @@
6971

7072
(defn token-value-drawer
7173
[token watch-only? entry-point]
72-
(let [token-symbol (:token token)
73-
token-data (first (rf/sub [:wallet/current-viewing-account-tokens-filtered
74-
token-symbol]))
75-
selected-account? (rf/sub [:wallet/current-viewing-account-address])
76-
token-owners (rf/sub [:wallet/operable-addresses-with-token-symbol token-symbol])
77-
send-params (if selected-account?
78-
{:token token-data
79-
:stack-id :screen/wallet.accounts
80-
:start-flow? true
81-
:owners token-owners}
82-
{:token-symbol token-symbol
83-
:stack-id :wallet-stack
84-
:start-flow? true
85-
:owners token-owners})
86-
bridge-params (if selected-account?
87-
{:token token-data
88-
:bridge-disabled? (send-utils/bridge-disabled? token-symbol)
89-
:stack-id :screen/wallet.accounts
90-
:start-flow? true
91-
:owners token-owners}
92-
{:token-symbol token-symbol
93-
:bridge-disabled? (send-utils/bridge-disabled? token-symbol)
94-
:stack-id :wallet-stack
95-
:start-flow? true
96-
:owners token-owners})]
74+
(let [token-symbol (:token token)
75+
token-data (first (rf/sub [:wallet/current-viewing-account-tokens-filtered
76+
token-symbol]))
77+
fiat-unformatted-value (get-in token [:values :fiat-unformatted-value])
78+
has-balance? (money/greater-than fiat-unformatted-value (money/bignumber "0"))
79+
selected-account? (rf/sub [:wallet/current-viewing-account-address])
80+
token-owners (rf/sub [:wallet/operable-addresses-with-token-symbol token-symbol])
81+
send-params (if selected-account?
82+
{:token token-data
83+
:stack-id :screen/wallet.accounts
84+
:disabled? (not has-balance?)
85+
:start-flow? true
86+
:owners token-owners}
87+
{:token-symbol token-symbol
88+
:stack-id :wallet-stack
89+
:start-flow? true
90+
:owners token-owners})
91+
bridge-params (if selected-account?
92+
{:token token-data
93+
:bridge-disabled? (or (not has-balance?)
94+
(send-utils/bridge-disabled? token-symbol))
95+
:stack-id :screen/wallet.accounts
96+
:start-flow? true
97+
:owners token-owners}
98+
{:token-symbol token-symbol
99+
:bridge-disabled? (send-utils/bridge-disabled? token-symbol)
100+
:stack-id :wallet-stack
101+
:start-flow? true
102+
:owners token-owners})]
97103
[quo/action-drawer
98104
[(cond->> [(when (ff/enabled? ::ff/wallet.assets-modal-manage-tokens)
99105
(action-manage-tokens watch-only?))

0 commit comments

Comments
 (0)