From 732de574441321080259925b000867d32cd30dc7 Mon Sep 17 00:00:00 2001 From: Igor Mandrigin Date: Wed, 23 May 2018 12:04:50 +0200 Subject: [PATCH] Filter out non-RPC networks for new and restored accounts. Those who plainly upgrades, will keep these networks as "Custom" in their DB. Signed-off-by: Julien Eluard --- .env | 1 + .env.prod | 1 + src/status_im/constants.cljs | 9 +++++++-- src/status_im/utils/config.cljs | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 3f69eced05..26e5ef197a 100644 --- a/.env +++ b/.env @@ -3,6 +3,7 @@ STUB_STATUS_GO=0 ETHEREUM_DEV_CLUSTER=1 MAINNET_WARNING_ENABLED=0 OFFLINE_INBOX_ENABLED=1 +RPC_NETWORKS_ONLY 1 LOG_LEVEL=debug LOG_LEVEL_STATUS_GO=info QUEUE_MESSAGE_ENABLED=1 diff --git a/.env.prod b/.env.prod index 7de0658229..e802c15ffe 100644 --- a/.env.prod +++ b/.env.prod @@ -2,6 +2,7 @@ TESTFAIRY_ENABLED=0 STUB_STATUS_GO=0 ETHEREUM_DEV_CLUSTER=0 MAINNET_WARNING_ENABLED=1 +RPC_NETWORKS_ONLY 1 OFFLINE_INBOX_ENABLED=0 LOG_LEVEL=info LOG_LEVEL_STATUS_GO=info diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index f8b9fc676d..b6983df070 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -68,9 +68,14 @@ :UpstreamConfig {:Enabled true :URL "https://rinkeby.infura.io/z6GCTmjdP3FETEJmMBI4"}}}}) +(defn network-enabled? [network] + (if config/rpc-networks-only? + (get-in (val network) [:config :UpstreamConfig :Enabled]) + true)) + (def default-networks - (merge testnet-networks - mainnet-networks)) + (into {} (filter network-enabled? + (merge testnet-networks mainnet-networks)))) (def default-wnodes {:testnet {"mailserver-a" {:id "mailserver-a" diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index 3fd4131319..94dc8f75e0 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -32,6 +32,8 @@ (def compile-views-enabled? (enabled? (get-config :COMPILE_VIEWS_ENABLED 0))) (def mixpanel-token (get-config :MIXPANEL_TOKEN)) (def default-network (get-config :DEFAULT_NETWORK)) +;; the default value should be a string for `enabled?` to work correctly. +(def rpc-networks-only? (enabled? (get-config :RPC_NETWORKS_ONLY "1"))) (def testfairy-token (get-config :TESTFAIRY_TOKEN)) (def instabug-token (get-config :INSTABUG_TOKEN)) (def instabug-surveys-enabled? (get-config :INSTABUG_SURVEYS))