Compare commits

..
12 changed files with 42 additions and 89 deletions
+2 -2
View File
@@ -31,8 +31,8 @@
(let [^js data (.parse js/JSON event-str)
^js event-js (.-event data)
type (.-type data)]
(log/info "Signal received" {:type type})
(log/info "Signal received" {:payload event-str})
(log/debug "Signal received" {:type type})
(log/trace "Signal received" {:payload event-str})
(case type
"wallet"
{:fx [[:dispatch [:wallet/signal-received event-js]]]}
+1 -1
View File
@@ -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")))
@@ -1,5 +0,0 @@
(ns status-im.contexts.network.data-store)
(defn online?
[{:network/keys [status]}]
(= :online status))
+4 -4
View File
@@ -12,10 +12,10 @@
:wakuV2Nameserver "8.8.8.8"
:statusProxyEnabled config/status-proxy-enabled?
:statusProxyStageName config/status-proxy-stage-name
:statusProxyMarketUser config/STATUS_BUILD_PROXY_USER
:statusProxyMarketPassword config/STATUS_BUILD_PROXY_PASSWORD
:statusProxyBlockchainUser config/STATUS_BUILD_PROXY_USER
:statusProxyBlockchainPassword config/STATUS_BUILD_PROXY_PASSWORD
:statusProxyMarketUser "test"
:statusProxyMarketPassword "test"
:statusProxyBlockchainUser "test"
:statusProxyBlockchainPassword "test"
:openseaAPIKey config/opensea-api-key
:poktToken config/POKT_TOKEN
:infuraToken config/INFURA_TOKEN
@@ -2,7 +2,6 @@
(:require [camel-snake-kebab.extras :as cske]
[clojure.string :as string]
[react-native.platform :as platform]
[status-im.contexts.network.data-store :as network.data-store]
[status-im.contexts.wallet.collectible.utils :as collectible-utils]
[taoensso.timbre :as log]
[utils.ethereum.chain :as chain]
@@ -123,15 +122,14 @@
(rf/reg-event-fx
:wallet/request-collectibles-for-current-viewing-account
(fn [{:keys [db]} _]
(when (network.data-store/online? db)
(let [current-viewing-account (-> db :wallet :current-viewing-account-address)
[request-id] (get-unique-collectible-request-id 1)]
{:db (assoc-in db [:wallet :ui :collectibles :pending-requests] 1)
:fx [[:dispatch
[:wallet/request-new-collectibles-for-account
{:request-id request-id
:account current-viewing-account
:amount collectibles-request-batch-size}]]]}))))
(let [current-viewing-account (-> db :wallet :current-viewing-account-address)
[request-id] (get-unique-collectible-request-id 1)]
{:db (assoc-in db [:wallet :ui :collectibles :pending-requests] 1)
:fx [[:dispatch
[:wallet/request-new-collectibles-for-account
{:request-id request-id
:account current-viewing-account
:amount collectibles-request-batch-size}]]]})))
(defn- update-fetched-collectibles-progress
[db owner-address collectibles offset has-more?]
@@ -262,7 +262,3 @@
;; :cost () ;; tbd not used on desktop
:token-fees token-fees
:gas-amount (:tx-gas-amount new-path)}))
(defn tokens-never-loaded?
[db]
(nil? (get-in db [:wallet :ui :tokens-loading])))
+1 -4
View File
@@ -7,7 +7,4 @@
(def defaults
{:ui {:network-filter network-filter-defaults
;; Note: we set it to nil by default to differentiate when the user logs
;; in and the device is offline, versus re-fetching when offline and
;; tokens already exist in the app-db.
:tokens-loading nil}})
:tokens-loading {}}})
+10 -32
View File
@@ -5,7 +5,6 @@
[clojure.string :as string]
[react-native.platform :as platform]
[status-im.constants :as constants]
[status-im.contexts.network.data-store :as network.data-store]
[status-im.contexts.settings.wallet.effects]
[status-im.contexts.settings.wallet.events]
[status-im.contexts.wallet.common.activity-tab.events]
@@ -108,44 +107,23 @@
[:dispatch [:wallet/request-new-collectibles-for-account-from-signal address]]
[:dispatch [:wallet/check-recent-history-for-account address]]]}))
(defn- reconcile-accounts
[db-accounts-by-address new-accounts]
(reduce
(fn [res {:keys [address] :as account}]
;; Because we add extra fields (tokens and collectibles) into the RPC
;; response from accounts_getAccounts, if we are offline we want to keep
;; the old balances in the accounts, thus we merge the up-to-date account
;; from status-go into the cached accounts. We also merge when online
;; because we will re-fetch balances anyway.
;;
;; Refactor improvement: don't augment entities from status-go, store
;; tokens and collectibles in separate keys in the app-db indexed by
;; account address.
(assoc res
address
(-> (get db-accounts-by-address address)
(merge account)
;; These should not be cached, otherwise when going
;; offline->online collectibles won't be fetched.
(dissoc :current-collectible-idx :has-more-collectibles?))))
{}
new-accounts))
(rf/reg-event-fx :wallet/get-accounts-success
(rf/reg-event-fx
:wallet/get-accounts-success
(fn [{:keys [db]} [accounts]]
(let [wallet-accounts (data-store/rpc->accounts accounts)
wallet-db (get db :wallet)
new-account? (:new-account? wallet-db)
navigate-to-account (:navigate-to-account wallet-db)]
{:db (update-in db [:wallet :accounts] reconcile-accounts wallet-accounts)
:fx (concat (when (or (data-store/tokens-never-loaded? db)
(network.data-store/online? db))
refresh-accounts-fx-dispatches)
{:db (assoc-in db
[:wallet :accounts]
(utils.collection/index-by :address wallet-accounts))
:fx (concat refresh-accounts-fx-dispatches
[(when new-account?
[:dispatch [:wallet/navigate-to-new-account navigate-to-account]])])})))
(rf/reg-event-fx :wallet/get-accounts
(fn []
(rf/reg-event-fx
:wallet/get-accounts
(fn [_]
{:fx [[:json-rpc/call
[{:method "accounts_getAccounts"
:on-success [:wallet/get-accounts-success]
@@ -508,7 +486,7 @@
{:test-networks-enabled? test-networks-enabled?
:is-goerli-enabled? is-goerli-enabled?})
chains-filtered-by-mode (remove #(not (contains? chain-ids-by-mode %)) down-chain-ids)
chains-down? (and (network.data-store/online? db) (seq chains-filtered-by-mode))
chains-down? (seq chains-filtered-by-mode)
chain-names (when chains-down?
(->> (map #(-> (network-utils/id->network %)
name
+3 -9
View File
@@ -43,15 +43,9 @@
{:fx [[:dispatch [:wallet/reload]]]}
"wallet-blockchain-status-changed"
{:fx [[:dispatch-later
;; Don't dispatch immediately because the signal may arrive as
;; soon as the device goes offline. We need to give some time for
;; RN to dispatch the network status update, otherwise when going
;; offline the user will immediately see a toast saying "provider
;; X is down".
[{:ms 500
:dispatch [:wallet/blockchain-status-changed
(transforms/js->clj event-js)]}]]]}
{:fx [[:dispatch
[:wallet/blockchain-status-changed
(transforms/js->clj event-js)]]]}
"wallet-activity-filtering-done"
{:fx
+2 -6
View File
@@ -152,12 +152,8 @@
(fn [toasts [_ toast-id & cursor]]
(get-in toasts (into [:toasts toast-id] cursor))))
(re-frame/reg-sub :network/offline?
(re-frame/reg-sub
:network/offline?
:<- [:network/status]
(fn [status]
(= status :offline)))
(re-frame/reg-sub :network/online?
:<- [:network/status]
(fn [status]
(= status :online)))
+8 -9
View File
@@ -48,10 +48,11 @@
:wallet/home-tokens-loading?
:<- [:wallet/tokens-loading]
(fn [tokens-loading]
(->> tokens-loading
vals
(some true?)
boolean)))
(or (empty? tokens-loading)
(->> tokens-loading
vals
(some true?)
boolean))))
(rf/reg-sub
:wallet/current-viewing-account-tokens-loading?
@@ -350,10 +351,9 @@
:<- [:wallet/accounts]
:<- [:wallet/balances-in-selected-networks]
:<- [:wallet/tokens-loading]
:<- [:network/online?]
:<- [:profile/currency-symbol]
:<- [:wallet/keypairs]
(fn [[accounts balances tokens-loading online? currency-symbol keypairs]]
(fn [[accounts balances tokens-loading currency-symbol keypairs]]
(mapv (fn [{:keys [color address watch-only? key-uid operable] :as account}]
(let [account-type (cond
(= operable :no) :missing-keypair
@@ -373,9 +373,8 @@
account
keypair)}]))
#(rf/dispatch [:wallet/navigate-to-account address]))
:loading? (and online?
(or (get tokens-loading address)
(not (contains? tokens-loading address))))
:loading? (or (get tokens-loading address)
(not (contains? tokens-loading address)))
:balance (utils/prettify-balance currency-symbol
(get balances address)))))
accounts)))
+3 -3
View File
@@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "fix/circuit-breaker-errors",
"commit-sha1": "352e67a02af2a011a8c63d9d9431e5ba39e7244e",
"src-sha256": "06j5pal1vb4kai1l1923bdfy7qk62caprmm3y2h1g9kcgc2a1ly6"
"version": "test/set-api-proxy-test-debug",
"commit-sha1": "022b6fd45b99819ec14baabd6d482ae85ed468bf",
"src-sha256": "03p7x3s9005ghi02x334077nxwdhwlkxmvhcnc07lsygfsnzkkzk"
}