do not show zeros for token balances, and fetch all tokens only when creating new account
This commit is contained in:
parent
85991d2272
commit
e602f0493d
|
@ -228,7 +228,8 @@
|
|||
(conj acc address)
|
||||
acc))
|
||||
#{}
|
||||
transfers))))
|
||||
transfers))
|
||||
nil))
|
||||
|
||||
(< (count transfers) limit)
|
||||
(conj (tx-history-end-reached checksum)))]
|
||||
|
|
|
@ -67,7 +67,8 @@
|
|||
status-im.ui.screens.profile.events
|
||||
status-im.chat.models.images
|
||||
status-im.ui.screens.privacy-and-security-settings.events
|
||||
[status-im.data-store.invitations :as data-store.invitations]))
|
||||
[status-im.data-store.invitations :as data-store.invitations]
|
||||
[status-im.ui.screens.wallet.events :as wallet.events]))
|
||||
|
||||
;; init module
|
||||
(handlers/register-handler-fx
|
||||
|
@ -1256,4 +1257,5 @@
|
|||
;; messages
|
||||
:chat (chat.loading/load-messages %)
|
||||
:multiaccounts (keycard/multiaccounts-screen-did-load %)
|
||||
(:wallet-stack :wallet) (wallet.events/wallet-will-focus %)
|
||||
nil))))
|
||||
|
|
|
@ -148,7 +148,8 @@
|
|||
whisper-private-key
|
||||
encryption-public-key
|
||||
instance-uid
|
||||
key-uid]} multiaccount
|
||||
key-uid
|
||||
recovered]} multiaccount
|
||||
{:keys [pairing paired-on]} secrets
|
||||
{:keys [name photo-path]}
|
||||
(if (nil? name)
|
||||
|
@ -167,7 +168,8 @@
|
|||
(assoc-in [:keycard :setup-step] nil)
|
||||
(dissoc :intro-wizard))}
|
||||
(multiaccounts.create/on-multiaccount-created
|
||||
{:derived {constants/path-wallet-root-keyword
|
||||
{:recovered (or recovered (get-in db [:intro-wizard :recovering?]))
|
||||
:derived {constants/path-wallet-root-keyword
|
||||
{:public-key wallet-root-public-key
|
||||
:address (eip55/address->checksum wallet-root-address)}
|
||||
constants/path-whisper-keyword
|
||||
|
@ -268,6 +270,7 @@
|
|||
{:db (update-in db [:keycard :multiaccount]
|
||||
(fn [multiacc]
|
||||
(assoc multiacc
|
||||
:recovered true
|
||||
:name whisper-name
|
||||
:photo-path photo-path)))}
|
||||
(create-keycard-multiaccount)))
|
||||
|
|
|
@ -218,7 +218,7 @@
|
|||
(fx/defn on-multiaccount-created
|
||||
[{:keys [signing-phrase random-guid-generator db] :as cofx}
|
||||
{:keys [address chat-key keycard-instance-uid key-uid
|
||||
keycard-pairing keycard-paired-on mnemonic public-key]
|
||||
keycard-pairing keycard-paired-on mnemonic recovered]
|
||||
:as multiaccount}
|
||||
password
|
||||
{:keys [save-mnemonic? login?] :or {login? true save-mnemonic? false}}]
|
||||
|
@ -252,7 +252,8 @@
|
|||
:latest-derived-path 0
|
||||
:signing-phrase signing-phrase
|
||||
:send-push-notifications? true
|
||||
:installation-id (random-guid-generator)}
|
||||
:installation-id (random-guid-generator)
|
||||
:recovered (or recovered (get-in db [:intro-wizard :recovering?]))}
|
||||
constants/default-multiaccount)
|
||||
;; The address from which we derive any chat
|
||||
;; account/encryption keys
|
||||
|
|
|
@ -55,14 +55,14 @@
|
|||
|
||||
(fx/defn initialize-wallet
|
||||
{:events [::initialize-wallet]}
|
||||
[{:keys [db] :as cofx} accounts custom-tokens favourites]
|
||||
[{:keys [db] :as cofx} accounts custom-tokens favourites new-account?]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc db :multiaccount/accounts
|
||||
(rpc->accounts accounts))}
|
||||
(wallet/initialize-tokens custom-tokens)
|
||||
(wallet/initialize-favourites favourites)
|
||||
(wallet/update-balances nil)
|
||||
(wallet/update-balances nil new-account?)
|
||||
(prices/update-prices)))
|
||||
|
||||
(fx/defn login
|
||||
|
@ -264,6 +264,7 @@
|
|||
;;so here we set it at 1 already so that it passes the check once it has
|
||||
;;been initialized
|
||||
:filters/initialized 1))
|
||||
:dispatch-later [{:ms 2000 :dispatch [::initialize-wallet accounts nil nil (:recovered multiaccount)]}]
|
||||
:filters/load-filters [[]]}
|
||||
(finish-keycard-setup)
|
||||
(when first-account?
|
||||
|
@ -273,8 +274,7 @@
|
|||
:mailserver-topics {}
|
||||
:default-mailserver true})
|
||||
(multiaccounts/switch-preview-privacy-mode-flag)
|
||||
(logging/set-log-level (:log-level multiaccount))
|
||||
(initialize-wallet accounts nil nil))))
|
||||
(logging/set-log-level (:log-level multiaccount)))))
|
||||
|
||||
(defn- keycard-setup? [cofx]
|
||||
(boolean (get-in cofx [:db :keycard :flow])))
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
{:db (assoc db :network-status (if is-connected? :online :offline))}
|
||||
(when is-connected?
|
||||
(if-not (= (count (get-in db [:wallet :accounts])) (count (get db :multiaccount/accounts)))
|
||||
(wallet/update-balances nil)))))
|
||||
(wallet/update-balances nil nil)))))
|
||||
|
||||
(fx/defn change-network-type
|
||||
[{:keys [db] :as cofx} old-network-type network-type expensive?]
|
||||
|
|
|
@ -1277,9 +1277,9 @@
|
|||
|
||||
(defn get-asset-amount [balances sym]
|
||||
(reduce #(if-let [^js bl (get %2 sym)]
|
||||
(.plus ^js %1 bl)
|
||||
(.plus ^js (or ^js %1 ^js (money/bignumber 0)) bl)
|
||||
%1)
|
||||
^js (money/bignumber 0)
|
||||
nil
|
||||
balances))
|
||||
|
||||
(re-frame/reg-sub
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
[status-im.ui.screens.routing.intro-login-stack :as intro-login-stack]
|
||||
[status-im.ui.screens.routing.chat-stack :as chat-stack]
|
||||
[status-im.ui.screens.routing.wallet-stack :as wallet-stack]
|
||||
[status-im.ui.screens.wallet.events :as wallet.events]
|
||||
[status-im.ui.screens.group.views :as group-chat]
|
||||
[status-im.ui.screens.group.events :as group.events]
|
||||
[status-im.ui.screens.routing.profile-stack :as profile-stack]
|
||||
|
@ -43,7 +42,6 @@
|
|||
:insets {:top false}
|
||||
:component browser-stack/browser-stack}
|
||||
{:name :wallet-stack
|
||||
:on-focus [::wallet.events/wallet-stack]
|
||||
:insets {:top false}
|
||||
:component wallet-stack/wallet-stack}
|
||||
{:name :profile-stack
|
||||
|
|
|
@ -18,6 +18,13 @@
|
|||
:accessibility-label :wallet-manage-assets
|
||||
:on-press #(hide-sheet-and-dispatch
|
||||
[:navigate-to :wallet-settings-assets])}]
|
||||
[quo/list-item
|
||||
{:theme :accent
|
||||
:title (i18n/label :t/scan-tokens)
|
||||
:icon :main-icons/refresh
|
||||
:accessibility-label :wallet-manage-assets
|
||||
:on-press #(hide-sheet-and-dispatch
|
||||
[:wallet/update-balances nil true])}]
|
||||
[quo/list-item
|
||||
{:theme :accent
|
||||
:title (i18n/label :t/set-currency)
|
||||
|
|
|
@ -74,12 +74,14 @@
|
|||
[quo/list-item
|
||||
(merge {:title [quo/text {:weight :medium}
|
||||
[quo/text {:weight :inherit}
|
||||
(str (wallet.utils/format-amount amount decimals)
|
||||
(str (if amount
|
||||
(wallet.utils/format-amount amount decimals)
|
||||
"...")
|
||||
" ")]
|
||||
[quo/text {:color :secondary
|
||||
:weight :inherit}
|
||||
(wallet.utils/display-symbol token)]]
|
||||
:subtitle (str (if value value "0.00") " " currency)
|
||||
:subtitle (str (if value value "...") " " currency)
|
||||
:accessibility-label (str (:symbol token) "-asset-value")
|
||||
:icon (if icon
|
||||
[list/item-image icon]
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
(ns status-im.ui.screens.wallet.events
|
||||
(:require [status-im.ui.screens.wallet.signing-phrase.views :as signing-phrase]
|
||||
[status-im.utils.handlers :as handlers]))
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.fx :as fx]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::wallet-stack
|
||||
(fn [{:keys [db]}]
|
||||
(let [wallet-set-up-passed? (get-in db [:multiaccount :wallet-set-up-passed?])
|
||||
sign-phrase-showed? (get db :wallet/sign-phrase-showed?)]
|
||||
{:dispatch [:wallet.ui/pull-to-refresh] ;TODO temporary simple fix for v1
|
||||
:db (if (or wallet-set-up-passed? sign-phrase-showed?)
|
||||
db
|
||||
(assoc db :popover/popover {:view [signing-phrase/signing-phrase]}
|
||||
:wallet/sign-phrase-showed? true))})))
|
||||
(fx/defn wallet-will-focus
|
||||
{:events [::wallet-stack]}
|
||||
[{:keys [db]}]
|
||||
(let [wallet-set-up-passed? (get-in db [:multiaccount :wallet-set-up-passed?])
|
||||
sign-phrase-showed? (get db :wallet/sign-phrase-showed?)]
|
||||
{:dispatch [:wallet.ui/pull-to-refresh] ;TODO temporary simple fix for v1
|
||||
:db (if (or wallet-set-up-passed? sign-phrase-showed?)
|
||||
db
|
||||
(assoc db :popover/popover {:view [signing-phrase/signing-phrase]}
|
||||
:wallet/sign-phrase-showed? true))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::wallet-add-custom-token
|
||||
|
|
|
@ -201,7 +201,7 @@
|
|||
(fx/merge cofx
|
||||
{:db (update-in db [:add-account :account] merge account)}
|
||||
(save-new-account)
|
||||
(wallet/update-balances nil)
|
||||
(wallet/update-balances nil true)
|
||||
(prices/update-prices)
|
||||
(navigation/navigate-back)))))
|
||||
|
||||
|
|
|
@ -218,15 +218,14 @@
|
|||
favourites))})
|
||||
|
||||
(fx/defn update-balances
|
||||
{:events [:wallet/update-balances]}
|
||||
[{{:keys [network-status :wallet/all-tokens
|
||||
multiaccount :multiaccount/accounts] :as db} :db
|
||||
:as cofx} addresses]
|
||||
:as cofx} addresses init?]
|
||||
(let [addresses (or addresses (map (comp string/lower-case :address) accounts))
|
||||
{:keys [:wallet/visible-tokens]} multiaccount
|
||||
chain (ethereum/chain-keyword db)
|
||||
assets (get visible-tokens chain)
|
||||
init? (or (empty? assets)
|
||||
(= assets (constants/default-visible-tokens chain)))
|
||||
tokens (->> (vals all-tokens)
|
||||
(remove #(or (:hidden? %)
|
||||
;;if not init remove not visible tokens
|
||||
|
@ -267,12 +266,14 @@
|
|||
[{{:keys [multiaccount] :as db} :db :as cofx} symbol checked?]
|
||||
(let [chain (ethereum/chain-keyword db)
|
||||
visible-tokens (get multiaccount :wallet/visible-tokens)]
|
||||
(multiaccounts.update/multiaccount-update
|
||||
cofx
|
||||
:wallet/visible-tokens (update visible-tokens
|
||||
chain
|
||||
#(set-checked % symbol checked?))
|
||||
{})))
|
||||
(fx/merge cofx
|
||||
(multiaccounts.update/multiaccount-update
|
||||
:wallet/visible-tokens (update visible-tokens
|
||||
chain
|
||||
#(set-checked % symbol checked?))
|
||||
{})
|
||||
#(when checked?
|
||||
(update-balances % nil nil)))))
|
||||
|
||||
(fx/defn toggle-visible-token
|
||||
[cofx symbol checked?]
|
||||
|
@ -315,9 +316,7 @@
|
|||
|
||||
(fx/defn add-custom-token
|
||||
[cofx {:keys [symbol]}]
|
||||
(fx/merge cofx
|
||||
(update-toggle-in-settings symbol true)
|
||||
(update-balances nil)))
|
||||
(update-toggle-in-settings cofx symbol true))
|
||||
|
||||
(fx/defn remove-custom-token
|
||||
[cofx {:keys [symbol]}]
|
||||
|
|
|
@ -1275,5 +1275,6 @@
|
|||
"address-or-ens-name": "Address or ENS name",
|
||||
"name-optional": "Name (optional)",
|
||||
"mute": "Mute",
|
||||
"scan-tokens": "Scan tokens",
|
||||
"warning-sending-to-contract-descr": "The address you entered is a smart contract, sending funds to this address may result in loss of funds. To interact with a DApp, open the DApp in the Status DApp Browser."
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue