show warning in profile for all testnet networks

This commit is contained in:
Roman Volosovskyi 2017-10-10 15:07:27 +02:00
parent e732f5559c
commit d7fcb333da
4 changed files with 33 additions and 15 deletions

View File

@ -38,35 +38,39 @@
:raw-config config)])) :raw-config config)]))
(into {}))) (into {})))
(def mainnet-id 1)
(def ropsten-id 3)
(def rinkeby-id 4)
(def default-networks (def default-networks
(transform-config (transform-config
{"testnet" {:id "testnet", {"testnet" {:id "testnet",
:name "Ropsten", :name "Ropsten",
:config {:NetworkId 3 :config {:NetworkId ropsten-id
:DataDir "/ethereum/testnet"}} :DataDir "/ethereum/testnet"}}
"testnet_rpc" {:id "testnet_rpc", "testnet_rpc" {:id "testnet_rpc",
:name "Ropsten with upstream RPC", :name "Ropsten with upstream RPC",
:config {:NetworkId 3 :config {:NetworkId ropsten-id
:DataDir "/ethereum/testnet_rpc" :DataDir "/ethereum/testnet_rpc"
:UpstreamConfig {:Enabled true :UpstreamConfig {:Enabled true
:URL "https://ropsten.infura.io/z6GCTmjdP3FETEJmMBI4"}}} :URL "https://ropsten.infura.io/z6GCTmjdP3FETEJmMBI4"}}}
"rinkeby" {:id "rinkeby", "rinkeby" {:id "rinkeby",
:name "Rinkeby", :name "Rinkeby",
:config {:NetworkId 4 :config {:NetworkId rinkeby-id
:DataDir "/ethereum/rinkeby"}} :DataDir "/ethereum/rinkeby"}}
"rinkeby_rpc" {:id "rinkeby_rpc", "rinkeby_rpc" {:id "rinkeby_rpc",
:name "Rinkeby with upstream RPC", :name "Rinkeby with upstream RPC",
:config {:NetworkId 4 :config {:NetworkId rinkeby-id
:DataDir "/ethereum/rinkeby_rpc" :DataDir "/ethereum/rinkeby_rpc"
:UpstreamConfig {:Enabled true :UpstreamConfig {:Enabled true
:URL "https://rinkeby.infura.io/z6GCTmjdP3FETEJmMBI4"}}} :URL "https://rinkeby.infura.io/z6GCTmjdP3FETEJmMBI4"}}}
"mainnet" {:id "mainnet", "mainnet" {:id "mainnet",
:name "Mainnet", :name "Mainnet",
:config {:NetworkId 1 :config {:NetworkId mainnet-id
:DataDir "/ethereum/mainnet"}} :DataDir "/ethereum/mainnet"}}
"mainnet_rpc" {:id "mainnet_rpc", "mainnet_rpc" {:id "mainnet_rpc",
:name "Mainnet with upstream RPC", :name "Mainnet with upstream RPC",
:config {:NetworkId 1 :config {:NetworkId mainnet-id
:DataDir "/ethereum/mainnet_rpc" :DataDir "/ethereum/mainnet_rpc"
:UpstreamConfig {:Enabled true :UpstreamConfig {:Enabled true
:URL "https://mainnet.infura.io/z6GCTmjdP3FETEJmMBI4 "}}}})) :URL "https://mainnet.infura.io/z6GCTmjdP3FETEJmMBI4 "}}}}))

View File

@ -103,7 +103,7 @@
:error-incorrect-name "Please select another name" :error-incorrect-name "Please select another name"
:error-incorrect-email "Incorrect e-mail" :error-incorrect-email "Incorrect e-mail"
:profile-testnet-icon "Testnet" :profile-testnet-icon "Testnet"
:profile-testnet-text "Ropsten Testnet Only. Please do not send real ETH or SNT to your address" :profile-testnet-text "Testnet Only. Please do not send real ETH or SNT to your address"
;;make_photo ;;make_photo
:image-source-title "Profile image" :image-source-title "Profile image"

View File

@ -1,9 +1,23 @@
(ns status-im.ui.screens.network-settings.subs (ns status-im.ui.screens.network-settings.subs
(:require [re-frame.core :refer [reg-sub subscribe]])) (:require [re-frame.core :refer [reg-sub subscribe]]
[status-im.constants :as constants]))
(reg-sub (reg-sub
:get-current-account-network :get-current-account-network
:<- [:get-current-account] :<- [:get-current-account]
:<- [:get :networks/networks] :<- [:get :networks/networks]
(fn [[current-account networks]] (fn [[current-account networks]]
(get networks (:network current-account)))) (get networks (:network current-account))))
(reg-sub
:get-network-id
:<- [:get :networks/networks]
:<- [:get :network]
(fn [[networks network]]
(get-in networks [network :raw-config :NetworkId])))
(reg-sub
:testnet?
:<- [:get-network-id]
(fn [network-id]
(contains? #{constants/rinkeby-id constants/ropsten-id} network-id)))

View File

@ -205,11 +205,11 @@
(defview my-profile [] (defview my-profile []
(letsubs [{:keys [status] :as current-account} [:get-current-account] (letsubs [{:keys [status] :as current-account} [:get-current-account]
network [:get :network]] testnet? [:testnet?]]
[react/view styles/profile [react/view styles/profile
[status-bar] [status-bar]
[my-profile-toolbar] [my-profile-toolbar]
(when (= network "testnet") (when testnet?
[testnet-only]) [testnet-only])
[react/scroll-view [react/scroll-view
[react/view styles/profile-form [react/view styles/profile-form
@ -230,13 +230,13 @@
(letsubs [{:keys [pending? (letsubs [{:keys [pending?
status status
whisper-identity] whisper-identity]
:as contact} [:contact] :as contact} [:contact]
chat-id [:get :current-chat-id] chat-id [:get :current-chat-id]
network [:get :network]] testnet? [:testnet?]]
[react/view styles/profile [react/view styles/profile
[status-bar] [status-bar]
[profile-toolbar contact] [profile-toolbar contact]
(when (= network "testnet") (when testnet?
[testnet-only]) [testnet-only])
[react/scroll-view [react/scroll-view
[react/view styles/profile-form [react/view styles/profile-form