From bed2057d97e4d39ee1f407c19628c3375eae9dc1 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Fri, 16 Aug 2024 11:44:11 +0100 Subject: [PATCH] Add caching of token amounts https://github.com/status-im/status-go/compare/1f7816dd...022b6fd4 --- src/status_im/config.cljs | 2 +- src/status_im/contexts/wallet/common/utils_test.cljs | 5 +++++ src/status_im/contexts/wallet/events.cljs | 4 +--- src/status_im/subs/wallet/wallet.cljs | 8 ++------ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/status_im/config.cljs b/src/status_im/config.cljs index 18d5eed8ce..0ed0bb8f1a 100644 --- a/src/status_im/config.cljs +++ b/src/status_im/config.cljs @@ -48,7 +48,7 @@ (def opensea-api-key OPENSEA_API_KEY) (def status-proxy-enabled? true) -(def status-proxy-stage-name (get-config :STATUS_PROXY_STAGE_NAME "prod")) +(def status-proxy-stage-name (get-config :STATUS_PROXY_STAGE_NAME "test")) (def bootnodes-settings-enabled? (enabled? (get-config :BOOTNODES_SETTINGS_ENABLED "1"))) (def mailserver-confirmations-enabled? (enabled? (get-config :MAILSERVER_CONFIRMATIONS_ENABLED))) (def pairing-popup-disabled? (enabled? (get-config :PAIRING_POPUP_DISABLED "0"))) diff --git a/src/status_im/contexts/wallet/common/utils_test.cljs b/src/status_im/contexts/wallet/common/utils_test.cljs index f72f9bbb37..d4e9674f89 100644 --- a/src/status_im/contexts/wallet/common/utils_test.cljs +++ b/src/status_im/contexts/wallet/common/utils_test.cljs @@ -64,6 +64,11 @@ (is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency} token-units) "0.005"))) + (let [market-values-per-currency {:usd {:price nil}} + token-units (money/bignumber 0.0123456)] + (is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency} + token-units) + "0.012346"))) (let [market-values-per-currency {:usd {:price 0.005}} token-units (money/bignumber 0.01)] (is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency} diff --git a/src/status_im/contexts/wallet/events.cljs b/src/status_im/contexts/wallet/events.cljs index 8ef89ff2bf..66a1283a3f 100644 --- a/src/status_im/contexts/wallet/events.cljs +++ b/src/status_im/contexts/wallet/events.cljs @@ -190,9 +190,7 @@ :fx [[:json-rpc/call [{:method "wallet_getWalletToken" :params [[address]] - :on-success #(do - (println "RESPONSE HERE" %) - (rf/dispatch [:wallet/store-wallet-token address %])) + :on-success [:wallet/store-wallet-token address] :on-error [:wallet/get-wallet-token-for-account-failed address]}]]]})) (rf/reg-event-fx diff --git a/src/status_im/subs/wallet/wallet.cljs b/src/status_im/subs/wallet/wallet.cljs index 71ace84c54..83e68bed49 100644 --- a/src/status_im/subs/wallet/wallet.cljs +++ b/src/status_im/subs/wallet/wallet.cljs @@ -340,14 +340,10 @@ :<- [:profile/currency] :<- [:wallet/selected-networks->chain-ids] (fn [[accounts currency chain-ids]] - (println "CHAINS" currency chain-ids) (zipmap (map :address accounts) - (map #(do - (println "HERE" chain-ids (:tokens %)) - (println "HERE2" %) - (utils/calculate-balance-from-tokens {:currency currency + (map #(utils/calculate-balance-from-tokens {:currency currency :tokens (:tokens %) - :chain-ids chain-ids})) + :chain-ids chain-ids}) accounts)))) (rf/reg-sub