[Fix] Chain down toast shown for chains unrelated to current network (#19155)
This commit fixes chain down toast shown for chains unrelated to the current network. Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
parent
d0d7310e82
commit
10c6bf7156
|
@ -429,6 +429,12 @@
|
||||||
(def ^:const mainnet-chain-ids
|
(def ^:const mainnet-chain-ids
|
||||||
#{ethereum-mainnet-chain-id arbitrum-mainnet-chain-id optimism-mainnet-chain-id})
|
#{ethereum-mainnet-chain-id arbitrum-mainnet-chain-id optimism-mainnet-chain-id})
|
||||||
|
|
||||||
|
(def ^:const goerli-chain-ids
|
||||||
|
#{ethereum-goerli-chain-id arbitrum-goerli-chain-id optimism-goerli-chain-id})
|
||||||
|
|
||||||
|
(def ^:const sepolia-chain-ids
|
||||||
|
#{ethereum-sepolia-chain-id arbitrum-sepolia-chain-id optimism-sepolia-chain-id})
|
||||||
|
|
||||||
(def ^:const mainnet-short-name "eth")
|
(def ^:const mainnet-short-name "eth")
|
||||||
(def ^:const optimism-short-name "opt")
|
(def ^:const optimism-short-name "opt")
|
||||||
(def ^:const arbitrum-short-name "arb1")
|
(def ^:const arbitrum-short-name "arb1")
|
||||||
|
|
|
@ -303,3 +303,15 @@
|
||||||
label-props
|
label-props
|
||||||
(assoc :label :text
|
(assoc :label :text
|
||||||
:label-props label-props)))
|
:label-props label-props)))
|
||||||
|
|
||||||
|
(defn get-default-chain-ids-by-mode
|
||||||
|
[{:keys [test-networks-enabled? is-goerli-enabled?]}]
|
||||||
|
(cond
|
||||||
|
(and test-networks-enabled? is-goerli-enabled?)
|
||||||
|
constants/goerli-chain-ids
|
||||||
|
|
||||||
|
test-networks-enabled?
|
||||||
|
constants/sepolia-chain-ids
|
||||||
|
|
||||||
|
:else
|
||||||
|
constants/mainnet-chain-ids))
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[react-native.background-timer :as background-timer]
|
[react-native.background-timer :as background-timer]
|
||||||
[react-native.platform :as platform]
|
[react-native.platform :as platform]
|
||||||
[status-im.constants :as constants]
|
|
||||||
[status-im.contexts.wallet.accounts.add-account.address-to-watch.events]
|
[status-im.contexts.wallet.accounts.add-account.address-to-watch.events]
|
||||||
[status-im.contexts.wallet.common.utils :as utils]
|
[status-im.contexts.wallet.common.utils :as utils]
|
||||||
[status-im.contexts.wallet.data-store :as data-store]
|
[status-im.contexts.wallet.data-store :as data-store]
|
||||||
|
@ -447,16 +446,15 @@
|
||||||
(fn [{:keys [db]} [{:keys [message]}]]
|
(fn [{:keys [db]} [{:keys [message]}]]
|
||||||
(let [chains (-> (transforms/json->clj message)
|
(let [chains (-> (transforms/json->clj message)
|
||||||
(update-keys (comp utils.number/parse-int name)))
|
(update-keys (comp utils.number/parse-int name)))
|
||||||
down-chains (-> (select-keys chains
|
down-chain-ids (-> (select-keys chains
|
||||||
(for [[k v] chains :when (= v "down")] k))
|
(for [[k v] chains :when (= v "down")] k))
|
||||||
keys)
|
keys)
|
||||||
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
|
||||||
disabled-chain-id? (fn [chain-id]
|
is-goerli-enabled? (get-in db [:profile/profile :is-goerli-enabled?])
|
||||||
(let [mainnet-chain? (contains? constants/mainnet-chain-ids chain-id)]
|
chain-ids-by-mode (utils/get-default-chain-ids-by-mode
|
||||||
(if test-networks-enabled?
|
{:test-networks-enabled? test-networks-enabled?
|
||||||
mainnet-chain?
|
:is-goerli-enabled? is-goerli-enabled?})
|
||||||
(not mainnet-chain?))))
|
chains-filtered-by-mode (remove #(not (contains? chain-ids-by-mode %)) down-chain-ids)
|
||||||
chains-filtered-by-mode (remove disabled-chain-id? down-chains)
|
|
||||||
chains-down? (seq chains-filtered-by-mode)
|
chains-down? (seq chains-filtered-by-mode)
|
||||||
chain-names (when chains-down?
|
chain-names (when chains-down?
|
||||||
(->> (map #(-> (utils/id->network %)
|
(->> (map #(-> (utils/id->network %)
|
||||||
|
@ -465,9 +463,10 @@
|
||||||
chains-filtered-by-mode)
|
chains-filtered-by-mode)
|
||||||
distinct
|
distinct
|
||||||
(string/join ", ")))]
|
(string/join ", ")))]
|
||||||
(when (seq down-chains)
|
(when (seq down-chain-ids)
|
||||||
(log/info "[wallet] Chain(s) down: " down-chains)
|
(log/info "[wallet] Chain(s) down: " down-chain-ids)
|
||||||
(log/info "[wallet] Test network enabled: " (boolean test-networks-enabled?)))
|
(log/info "[wallet] Test network enabled: " (boolean test-networks-enabled?))
|
||||||
|
(log/info "[wallet] Goerli network enabled: " (boolean is-goerli-enabled?)))
|
||||||
{:db (assoc-in db [:wallet :statuses :blockchains] chains)
|
{:db (assoc-in db [:wallet :statuses :blockchains] chains)
|
||||||
:fx (when chains-down?
|
:fx (when chains-down?
|
||||||
[[:dispatch
|
[[:dispatch
|
||||||
|
|
Loading…
Reference in New Issue