add token-with-balances utils functions

Signed-off-by: Brian Sztamfater <brian@status.im>
This commit is contained in:
Brian Sztamfater 2024-12-19 00:00:51 -03:00
parent 3ff460fdc7
commit 80bab0f976
No known key found for this signature in database
GPG Key ID: 59EB921E0706B48F
3 changed files with 13 additions and 22 deletions

View File

@ -546,14 +546,20 @@
(let [priority #(get constants/token-sort-priority (:symbol %) ##Inf)]
(sort-by (juxt :symbol priority) tokens)))
(defn token-with-balance
([token networks]
(token-with-balance token networks nil))
([token networks chain-ids]
(assoc token
:networks (network-utils/network-list-with-positive-balance token networks)
:supported-networks (network-utils/network-list token networks)
:available-balance (calculate-total-token-balance token)
:total-balance (calculate-total-token-balance token chain-ids))))
(defn tokens-with-balance
[tokens networks chain-ids]
(map (fn [token]
(assoc token
:networks (network-utils/network-list-with-positive-balance token networks)
:supported-networks (network-utils/network-list token networks)
:available-balance (calculate-total-token-balance token)
:total-balance (calculate-total-token-balance token chain-ids)))
(token-with-balance token networks chain-ids))
tokens))
(defn estimated-time-format

View File

@ -366,14 +366,7 @@
(let [token (utils/get-token-from-account db
token-symbol
unique-owner)]
(assoc token
:networks (network-utils/network-list-with-positive-balance
token
network-details)
:supported-networks (network-utils/network-list
token
network-details)
:total-balance (utils/calculate-total-token-balance token)))
(utils/token-with-balance token network-details))
token)
missing-recipient? (-> db :wallet :ui :send :to-address nil?)
to-address (or unique-owner

View File

@ -5,7 +5,6 @@
[status-im.contexts.wallet.collectible.utils :as collectible.utils]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.common.utils.networks :as network-utils]
[status-im.contexts.wallet.common.wizard.utils :as wizard-utils]
[status-im.contexts.wallet.data-store :as data-store]
[status-im.contexts.wallet.send.utils :as send-utils]
[status-im.contexts.wallet.sheets.network-selection.view :as network-selection]
@ -667,14 +666,7 @@
;; token or collectible to send, but we don't know from which
;; account, so we extract the token data from the picked account.
(let [token (utils/get-token-from-account db token-symbol address)]
(assoc token
:networks (network-utils/network-list-with-positive-balance
token
network-details)
:supported-networks (network-utils/network-list
token
network-details)
:total-balance (utils/calculate-total-token-balance token))))
(utils/token-with-balance token network-details)))
bridge-tx? (= tx-type :tx/bridge)
flow-id (if bridge-tx?
:wallet-bridge-flow