diff --git a/.env.e2e b/.env.e2e index 7658cf856a..b82c217477 100644 --- a/.env.e2e +++ b/.env.e2e @@ -25,3 +25,4 @@ ENABLE_ROOT_ALERT=0 ENABLE_REFERRAL_INVITE=1 MAX_IMAGES_BATCH=5 APN_TOPIC=im.status.ethereum.pr +VERIFY_TRANSACTION_CHAIN_ID=3 diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index 9b255fdcaf..9d790e5cbb 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -1,8 +1,6 @@ (ns status-im.constants - (:require [status-im.ethereum.core :as ethereum] - [status-im.react-native.resources :as resources] - [status-im.i18n :as i18n] - [status-im.utils.config :as config])) + (:require [status-im.react-native.resources :as resources] + [status-im.i18n :as i18n])) (def ethereum-rpc-url "http://localhost:8545") @@ -57,80 +55,8 @@ (def mailserver-password "status-offline-inbox") -(def default-network config/default-network) - (def system "system") -(def mainnet-rpc-url (str "https://mainnet.infura.io/v3/" config/INFURA_TOKEN)) - -(def mainnet-networks - [{:id "mainnet_rpc", - :etherscan-link "https://etherscan.io/address/", - :name "Mainnet with upstream RPC", - :config {:NetworkId (ethereum/chain-keyword->chain-id :mainnet) - :DataDir "/ethereum/mainnet_rpc" - :UpstreamConfig {:Enabled true - :URL mainnet-rpc-url}}}]) - -(def sidechain-networks - [{:id "xdai_rpc", - :name "xDai Chain", - :config {:NetworkId (ethereum/chain-keyword->chain-id :xdai) - :DataDir "/ethereum/xdai_rpc" - :UpstreamConfig {:Enabled true - :URL "https://dai.poa.network"}}} - {:id "poa_rpc", - :name "POA Network", - :config {:NetworkId (ethereum/chain-keyword->chain-id :poa) - :DataDir "/ethereum/poa_rpc" - :UpstreamConfig {:Enabled true - :URL "https://core.poa.network"}}}]) - -(def testnet-networks - [{:id "testnet_rpc", - :etherscan-link "https://ropsten.etherscan.io/address/", - :name "Ropsten with upstream RPC", - :config {:NetworkId (ethereum/chain-keyword->chain-id :testnet) - :DataDir "/ethereum/testnet_rpc" - :UpstreamConfig {:Enabled true - :URL (str "https://ropsten.infura.io/v3/" config/INFURA_TOKEN)}}} - {:id "rinkeby_rpc", - :etherscan-link "https://rinkeby.etherscan.io/address/", - :name "Rinkeby with upstream RPC", - :config {:NetworkId (ethereum/chain-keyword->chain-id :rinkeby) - :DataDir "/ethereum/rinkeby_rpc" - :UpstreamConfig {:Enabled true - :URL (str "https://rinkeby.infura.io/v3/" config/INFURA_TOKEN)}}} - {:id "goerli_rpc", - :etherscan-link "https://goerli.etherscan.io/address/", - :name "Goerli with upstream RPC", - :config {:NetworkId (ethereum/chain-keyword->chain-id :goerli) - :DataDir "/ethereum/goerli_rpc" - :UpstreamConfig {:Enabled true - :URL "https://goerli.blockscout.com/"}}}]) - -(def default-networks - (concat testnet-networks mainnet-networks sidechain-networks)) - -(def default-networks-by-id - (into {} - (map (fn [{:keys [id] :as network}] - [id network]) - default-networks))) - -(def default-multiaccount - {:preview-privacy? config/blank-preview? - :wallet/visible-tokens {:mainnet #{:SNT}} - :currency :usd - :appearance 0 - :log-level config/log-level - :webview-allow-permission-requests? false - :link-previews-enabled-sites #{} - :link-preview-request-enabled true}) - -(defn default-visible-tokens [chain] - (get-in default-multiaccount [:wallet/visible-tokens chain])) - (def currencies {:aed {:id :aed :code "AED" :display-name (i18n/label :t/currency-display-name-aed) :symbol "د.إ"} :afn {:id :afn :code "AFN" :display-name (i18n/label :t/currency-display-name-afn) :symbol "؋"} diff --git a/src/status_im/multiaccounts/create/core.cljs b/src/status_im/multiaccounts/create/core.cljs index 66801b7ea7..194ed5194a 100644 --- a/src/status_im/multiaccounts/create/core.cljs +++ b/src/status_im/multiaccounts/create/core.cljs @@ -255,7 +255,7 @@ ;; default mailserver (history node) setting :use-mailservers? true :recovered (or recovered (get-in db [:intro-wizard :recovering?]))} - constants/default-multiaccount) + config/default-multiaccount) ;; The address from which we derive any chat ;; account/encryption keys eip1581-address @@ -275,11 +275,11 @@ :processing true} :multiaccount new-multiaccount :multiaccount/accounts [wallet-account] - :networks/current-network constants/default-network - :networks/networks (data-store.settings/rpc->networks constants/default-networks)) + :networks/current-network config/default-network + :networks/networks (data-store.settings/rpc->networks config/default-networks)) settings (assoc new-multiaccount - :networks/current-network constants/default-network - :networks/networks constants/default-networks)] + :networks/current-network config/default-network + :networks/networks config/default-networks)] (fx/merge cofx {:db db} (if keycard-multiaccount? diff --git a/src/status_im/node/core.cljs b/src/status_im/node/core.cljs index bb25df0e45..3aca4a1308 100644 --- a/src/status_im/node/core.cljs +++ b/src/status_im/node/core.cljs @@ -1,7 +1,5 @@ (ns status-im.node.core (:require [re-frame.core :as re-frame] - [status-im.constants :as constants] - [status-im.ethereum.ens :as ens] [status-im.ethereum.json-rpc :as json-rpc] [status-im.native-module.core :as status] [status-im.utils.config :as config] @@ -130,10 +128,10 @@ :InstallationID installation-id :MaxMessageDeliveryAttempts config/max-message-delivery-attempts :MailServerConfirmations config/mailserver-confirmations-enabled? - :VerifyTransactionURL constants/mainnet-rpc-url - :VerifyENSURL constants/mainnet-rpc-url - :VerifyENSContractAddress (:mainnet ens/ens-registries) - :VerifyTransactionChainID 1 + :VerifyTransactionURL config/verify-transaction-url + :VerifyENSURL config/verify-ens-url + :VerifyENSContractAddress config/verify-ens-contract-address + :VerifyTransactionChainID config/verify-transaction-chain-id :DataSyncEnabled true :PFSEnabled true} :RequireTopics (get-topics current-network) diff --git a/src/status_im/subs.cljs b/src/status_im/subs.cljs index e1aedb8151..408d36e31c 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -1269,7 +1269,7 @@ :wallet/etherscan-link (fn [db [_ address]] (let [network (:networks/current-network db) - link (get-in constants/default-networks-by-id + link (get-in config/default-networks-by-id [network :etherscan-link])] (when link (str link address))))) @@ -2367,7 +2367,7 @@ :get-networks :<- [:networks/networks] (fn [networks] - (let [networks (map (label-networks (into #{} (map :id constants/default-networks))) (sort-by :name (vals networks))) + (let [networks (map (label-networks (into #{} (map :id config/default-networks))) (sort-by :name (vals networks))) types [:mainnet :testnet :custom]] (zipmap types diff --git a/src/status_im/ui/screens/chat/message/command.cljs b/src/status_im/ui/screens/chat/message/command.cljs index bb9a5bba12..3aef60217f 100644 --- a/src/status_im/ui/screens/chat/message/command.cljs +++ b/src/status_im/ui/screens/chat/message/command.cljs @@ -224,7 +224,9 @@ :incoming (str "↓ " (i18n/label :t/incoming-transaction)))] [command-transaction-info contract value] [command-status-and-timestamp - command-state direction address timestamp-str (:type transaction)] + ;; If :type is nil it most likely means the transaction is pending, as those + ;; are not stored and will be gone after logout + command-state direction address timestamp-str (or (:type transaction) :pending)] (when (not outgoing) (cond (= command-state constants/command-state-request-transaction) diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index 33d20a1b12..4b7e345b2c 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -1,5 +1,7 @@ (ns status-im.utils.config (:require [clojure.string :as string] + [status-im.ethereum.core :as ethereum] + [status-im.ethereum.ens :as ens] ["react-native-config" :default react-native-config])) (def config @@ -19,6 +21,8 @@ (goog-define INFURA_TOKEN "d3633f237cbd4649a639067d1807584c") +(def mainnet-rpc-url (str "https://mainnet.infura.io/v3/" INFURA_TOKEN)) +(def testnet-rpc-url (str "https://ropsten.infura.io/v3/" INFURA_TOKEN)) (def bootnodes-settings-enabled? (enabled? (get-config :BOOTNODES_SETTINGS_ENABLED "1"))) (def rpc-networks-only? (enabled? (get-config :RPC_NETWORKS_ONLY "1"))) (def mailserver-confirmations-enabled? (enabled? (get-config :MAILSERVER_CONFIRMATIONS_ENABLED))) @@ -51,3 +55,83 @@ (def pow-target (js/parseFloat (get-config :POW_TARGET "0.0001"))) (def pow-time (js/parseInt (get-config :POW_TIME "1"))) (def max-installations 2) + +(def verify-transaction-chain-id (js/parseInt (get-config :VERIFY_TRANSACTION_CHAIN_ID "1"))) +(def verify-transaction-url (if (= :mainnet (ethereum/chain-id->chain-keyword verify-transaction-chain-id)) + mainnet-rpc-url + testnet-rpc-url)) + +(def verify-ens-chain-id (js/parseInt (get-config :VERIFY_ENS_CHAIN_ID "1"))) +(def verify-ens-url (if (= :mainnet (ethereum/chain-id->chain-keyword verify-ens-chain-id)) + mainnet-rpc-url + testnet-rpc-url)) +(def verify-ens-contract-address (get-config :VERIFY_ENS_CONTRACT_ADDRESS ((ethereum/chain-id->chain-keyword verify-ens-chain-id) ens/ens-registries))) + +(def default-multiaccount + {:preview-privacy? blank-preview? + :wallet/visible-tokens {:mainnet #{:SNT}} + :currency :usd + :appearance 0 + :log-level log-level + :webview-allow-permission-requests? false + :link-previews-enabled-sites #{} + :link-preview-request-enabled true}) + +(defn default-visible-tokens [chain] + (get-in default-multiaccount [:wallet/visible-tokens chain])) + +(def mainnet-networks + [{:id "mainnet_rpc", + :etherscan-link "https://etherscan.io/address/", + :name "Mainnet with upstream RPC", + :config {:NetworkId (ethereum/chain-keyword->chain-id :mainnet) + :DataDir "/ethereum/mainnet_rpc" + :UpstreamConfig {:Enabled true + :URL mainnet-rpc-url}}}]) + +(def sidechain-networks + [{:id "xdai_rpc", + :name "xDai Chain", + :config {:NetworkId (ethereum/chain-keyword->chain-id :xdai) + :DataDir "/ethereum/xdai_rpc" + :UpstreamConfig {:Enabled true + :URL "https://dai.poa.network"}}} + {:id "poa_rpc", + :name "POA Network", + :config {:NetworkId (ethereum/chain-keyword->chain-id :poa) + :DataDir "/ethereum/poa_rpc" + :UpstreamConfig {:Enabled true + :URL "https://core.poa.network"}}}]) + +(def testnet-networks + [{:id "testnet_rpc", + :etherscan-link "https://ropsten.etherscan.io/address/", + :name "Ropsten with upstream RPC", + :config {:NetworkId (ethereum/chain-keyword->chain-id :testnet) + :DataDir "/ethereum/testnet_rpc" + :UpstreamConfig {:Enabled true + :URL testnet-rpc-url}}} + {:id "rinkeby_rpc", + :etherscan-link "https://rinkeby.etherscan.io/address/", + :name "Rinkeby with upstream RPC", + :config {:NetworkId (ethereum/chain-keyword->chain-id :rinkeby) + :DataDir "/ethereum/rinkeby_rpc" + :UpstreamConfig {:Enabled true + :URL (str "https://rinkeby.infura.io/v3/" INFURA_TOKEN)}}} + {:id "goerli_rpc", + :etherscan-link "https://goerli.etherscan.io/address/", + :name "Goerli with upstream RPC", + :config {:NetworkId (ethereum/chain-keyword->chain-id :goerli) + :DataDir "/ethereum/goerli_rpc" + :UpstreamConfig {:Enabled true + :URL "https://goerli.blockscout.com/"}}}]) + +(def default-networks + (concat testnet-networks mainnet-networks sidechain-networks)) + +(def default-networks-by-id + (into {} + (map (fn [{:keys [id] :as network}] + [id network]) + default-networks))) + diff --git a/src/status_im/wallet/core.cljs b/src/status_im/wallet/core.cljs index 963db52642..f63811ed5a 100644 --- a/src/status_im/wallet/core.cljs +++ b/src/status_im/wallet/core.cljs @@ -1,7 +1,7 @@ (ns status-im.wallet.core (:require [re-frame.core :as re-frame] [status-im.multiaccounts.update.core :as multiaccounts.update] - [status-im.constants :as constants] + [status-im.utils.config :as config] [status-im.qr-scanner.core :as qr-scaner] [status-im.ethereum.core :as ethereum] [status-im.ethereum.eip55 :as eip55] @@ -9,7 +9,6 @@ [status-im.ethereum.tokens :as tokens] [status-im.i18n :as i18n] [status-im.navigation :as navigation] - [status-im.utils.config :as config] [status-im.utils.core :as utils.core] [status-im.utils.fx :as fx] [status-im.utils.money :as money] @@ -243,7 +242,7 @@ :db (prices/clear-error-message db :balance-update)} (when-not assets (multiaccounts.update/multiaccount-update - :wallet/visible-tokens (assoc visible-tokens chain (or (constants/default-visible-tokens chain) + :wallet/visible-tokens (assoc visible-tokens chain (or (config/default-visible-tokens chain) #{})) {})))))) @@ -300,7 +299,7 @@ [{:keys [db] :as cofx} balances] (let [chain (ethereum/chain-keyword db) visible-tokens (get-in db [:multiaccount :wallet/visible-tokens]) - chain-visible-tokens (into (or (constants/default-visible-tokens chain) + chain-visible-tokens (into (or (config/default-visible-tokens chain) #{}) (flatten (map keys (vals balances))))] (fx/merge cofx