[Fix #2683] Do not run sync state loop on upstream RPC networks
This commit is contained in:
parent
5206f297cf
commit
3e8ce2d6d7
|
@ -15,7 +15,8 @@
|
|||
[taoensso.timbre :as log :refer-macros [debug]]
|
||||
[status-im.native-module.core :as status]
|
||||
[clojure.string :as string]
|
||||
[status-im.utils.web3-provider :as web3-provider]))
|
||||
[status-im.utils.web3-provider :as web3-provider]
|
||||
[status-im.utils.ethereum.core :as utils]))
|
||||
|
||||
;;;; COFX
|
||||
|
||||
|
@ -302,8 +303,9 @@
|
|||
|
||||
(handlers/register-handler-fx
|
||||
:initialize-sync-listener
|
||||
(fn [{{:keys [sync-listening-started] :as db} :db} _]
|
||||
(when-not sync-listening-started
|
||||
(fn [{{:keys [sync-listening-started network networks/networks] :as db} :db} _]
|
||||
(when (and (not sync-listening-started)
|
||||
(not (utils/network-with-upstream-rpc? networks network)))
|
||||
{:db (assoc db :sync-listening-started true)
|
||||
:dispatch [:check-sync]})))
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
[status-im.data-store.networks :as networks]
|
||||
[status-im.ui.screens.network-settings.navigation]
|
||||
[status-im.ui.screens.accounts.events :as accounts-events]
|
||||
[status-im.i18n :as i18n]))
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.utils.ethereum.core :as utils]))
|
||||
|
||||
;;;; FX
|
||||
|
||||
|
@ -28,9 +29,6 @@
|
|||
(assoc :new-networks (vals new-networks')))
|
||||
:save-networks new-networks'})))
|
||||
|
||||
(defn network-with-upstream-rpc? [networks network]
|
||||
(get-in networks [network :raw-config :UpstreamConfig :Enabled]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::save-network
|
||||
(fn [{:keys [db now]} [_ network]]
|
||||
|
@ -44,7 +42,7 @@
|
|||
(fn [{:keys [db now]} [_ network]]
|
||||
(let [current-network (:network db)
|
||||
networks (:networks/networks db)]
|
||||
(if (network-with-upstream-rpc? networks current-network)
|
||||
(if (utils/network-with-upstream-rpc? networks current-network)
|
||||
(merge (accounts-events/account-update {:db db} {:network network
|
||||
:last-updated now})
|
||||
{:dispatch [:navigate-to-clean :accounts]
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
(defn testnet? [id]
|
||||
(contains? #{(chain-id :ropsten) (chain-id :rinkeby)} id))
|
||||
|
||||
(defn network-with-upstream-rpc? [networks network]
|
||||
(get-in networks [network :raw-config :UpstreamConfig :Enabled]))
|
||||
|
||||
(def hex-prefix "0x")
|
||||
|
||||
(defn normalized-address [address]
|
||||
|
@ -66,4 +69,4 @@
|
|||
|
||||
(defn call-params [contract method-sig & params]
|
||||
(let [data (apply format-call-params (sig->method-id method-sig) params)]
|
||||
{:to contract :data data}))
|
||||
{:to contract :data data}))
|
||||
|
|
Loading…
Reference in New Issue