[wallet] Avoid requesting of token balances on account creation

This commit is contained in:
Roman Volosovskyi 2021-03-02 13:16:42 +02:00
parent 843c015d56
commit 9c7c796e02
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 12 additions and 9 deletions

View File

@ -231,16 +231,16 @@
(wallet/stop-watching-tx hash)) (wallet/stop-watching-tx hash))
transfers)) transfers))
true (and max-known-block
(some #(> (:block %) max-known-block) transfers))
(conj (wallet/update-balances (conj (wallet/update-balances
(into [] (reduce (fn [acc {:keys [address block]}] [address]
(if (and max-known-block (> block max-known-block))
(conj acc address)
acc))
#{}
transfers))
(zero? max-known-block))) (zero? max-known-block)))
(and (zero? max-known-block)
(empty? transfers))
(conj (wallet/set-zero-balances {:address address}))
(< (count transfers) limit) (< (count transfers) limit)
(conj (tx-history-end-reached checksum)))] (conj (tx-history-end-reached checksum)))]
(apply fx/merge cofx (tx-fetching-ended [checksum]) effects))) (apply fx/merge cofx (tx-fetching-ended [checksum]) effects)))

View File

@ -23,7 +23,8 @@
[status-im.utils.hex :as hex] [status-im.utils.hex :as hex]
[status-im.ethereum.ens :as ens] [status-im.ethereum.ens :as ens]
[status-im.ens.core :as ens.core] [status-im.ens.core :as ens.core]
[status-im.ethereum.resolver :as resolver])) [status-im.ethereum.resolver :as resolver]
[status-im.utils.mobile-sync :as utils.mobile-sync]))
(fx/defn start-adding-new-account (fx/defn start-adding-new-account
{:events [:wallet.accounts/start-adding-new-account]} {:events [:wallet.accounts/start-adding-new-account]}
@ -205,7 +206,9 @@
(fx/merge cofx (fx/merge cofx
{:db (update-in db [:add-account :account] merge account)} {:db (update-in db [:add-account :account] merge account)}
(save-new-account) (save-new-account)
(wallet/update-balances nil true) (if (utils.mobile-sync/syncing-allowed? cofx)
(wallet/set-max-block address 0)
(wallet/update-balances nil true))
(prices/update-prices) (prices/update-prices)
(navigation/navigate-back))))) (navigation/navigate-back)))))