[Fixes: #9851] Allow setting ens & transaction verify url, and fix

pending transaction

This commit fixes an issue where pending transactions would be marked as
confirmed in commands, due to the fact that we would default to pending
if no transaction was in the database.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2020-12-04 10:05:56 +01:00
parent a70b07e83d
commit 2df5eccff0
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
8 changed files with 104 additions and 94 deletions

View File

@ -25,3 +25,4 @@ ENABLE_ROOT_ALERT=0
ENABLE_REFERRAL_INVITE=1 ENABLE_REFERRAL_INVITE=1
MAX_IMAGES_BATCH=5 MAX_IMAGES_BATCH=5
APN_TOPIC=im.status.ethereum.pr APN_TOPIC=im.status.ethereum.pr
VERIFY_TRANSACTION_CHAIN_ID=3

View File

@ -1,8 +1,6 @@
(ns status-im.constants (ns status-im.constants
(:require [status-im.ethereum.core :as ethereum] (:require [status-im.react-native.resources :as resources]
[status-im.react-native.resources :as resources] [status-im.i18n :as i18n]))
[status-im.i18n :as i18n]
[status-im.utils.config :as config]))
(def ethereum-rpc-url "http://localhost:8545") (def ethereum-rpc-url "http://localhost:8545")
@ -57,80 +55,8 @@
(def mailserver-password "status-offline-inbox") (def mailserver-password "status-offline-inbox")
(def default-network config/default-network)
(def system "system") (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 (def currencies
{:aed {:id :aed :code "AED" :display-name (i18n/label :t/currency-display-name-aed) :symbol "د.إ"} {: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 "؋"} :afn {:id :afn :code "AFN" :display-name (i18n/label :t/currency-display-name-afn) :symbol "؋"}

View File

@ -255,7 +255,7 @@
;; default mailserver (history node) setting ;; default mailserver (history node) setting
:use-mailservers? true :use-mailservers? true
:recovered (or recovered (get-in db [:intro-wizard :recovering?]))} :recovered (or recovered (get-in db [:intro-wizard :recovering?]))}
constants/default-multiaccount) config/default-multiaccount)
;; The address from which we derive any chat ;; The address from which we derive any chat
;; account/encryption keys ;; account/encryption keys
eip1581-address eip1581-address
@ -275,11 +275,11 @@
:processing true} :processing true}
:multiaccount new-multiaccount :multiaccount new-multiaccount
:multiaccount/accounts [wallet-account] :multiaccount/accounts [wallet-account]
:networks/current-network constants/default-network :networks/current-network config/default-network
:networks/networks (data-store.settings/rpc->networks constants/default-networks)) :networks/networks (data-store.settings/rpc->networks config/default-networks))
settings (assoc new-multiaccount settings (assoc new-multiaccount
:networks/current-network constants/default-network :networks/current-network config/default-network
:networks/networks constants/default-networks)] :networks/networks config/default-networks)]
(fx/merge cofx (fx/merge cofx
{:db db} {:db db}
(if keycard-multiaccount? (if keycard-multiaccount?

View File

@ -1,7 +1,5 @@
(ns status-im.node.core (ns status-im.node.core
(:require [re-frame.core :as re-frame] (: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.ethereum.json-rpc :as json-rpc]
[status-im.native-module.core :as status] [status-im.native-module.core :as status]
[status-im.utils.config :as config] [status-im.utils.config :as config]
@ -130,10 +128,10 @@
:InstallationID installation-id :InstallationID installation-id
:MaxMessageDeliveryAttempts config/max-message-delivery-attempts :MaxMessageDeliveryAttempts config/max-message-delivery-attempts
:MailServerConfirmations config/mailserver-confirmations-enabled? :MailServerConfirmations config/mailserver-confirmations-enabled?
:VerifyTransactionURL constants/mainnet-rpc-url :VerifyTransactionURL config/verify-transaction-url
:VerifyENSURL constants/mainnet-rpc-url :VerifyENSURL config/verify-ens-url
:VerifyENSContractAddress (:mainnet ens/ens-registries) :VerifyENSContractAddress config/verify-ens-contract-address
:VerifyTransactionChainID 1 :VerifyTransactionChainID config/verify-transaction-chain-id
:DataSyncEnabled true :DataSyncEnabled true
:PFSEnabled true} :PFSEnabled true}
:RequireTopics (get-topics current-network) :RequireTopics (get-topics current-network)

View File

@ -1269,7 +1269,7 @@
:wallet/etherscan-link :wallet/etherscan-link
(fn [db [_ address]] (fn [db [_ address]]
(let [network (:networks/current-network db) (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])] [network :etherscan-link])]
(when link (when link
(str link address))))) (str link address)))))
@ -2367,7 +2367,7 @@
:get-networks :get-networks
:<- [:networks/networks] :<- [:networks/networks]
(fn [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]] types [:mainnet :testnet :custom]]
(zipmap (zipmap
types types

View File

@ -224,7 +224,9 @@
:incoming (str "↓ " (i18n/label :t/incoming-transaction)))] :incoming (str "↓ " (i18n/label :t/incoming-transaction)))]
[command-transaction-info contract value] [command-transaction-info contract value]
[command-status-and-timestamp [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) (when (not outgoing)
(cond (cond
(= command-state constants/command-state-request-transaction) (= command-state constants/command-state-request-transaction)

View File

@ -1,5 +1,7 @@
(ns status-im.utils.config (ns status-im.utils.config
(:require [clojure.string :as string] (:require [clojure.string :as string]
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.ens :as ens]
["react-native-config" :default react-native-config])) ["react-native-config" :default react-native-config]))
(def config (def config
@ -19,6 +21,8 @@
(goog-define INFURA_TOKEN "d3633f237cbd4649a639067d1807584c") (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 bootnodes-settings-enabled? (enabled? (get-config :BOOTNODES_SETTINGS_ENABLED "1")))
(def rpc-networks-only? (enabled? (get-config :RPC_NETWORKS_ONLY "1"))) (def rpc-networks-only? (enabled? (get-config :RPC_NETWORKS_ONLY "1")))
(def mailserver-confirmations-enabled? (enabled? (get-config :MAILSERVER_CONFIRMATIONS_ENABLED))) (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-target (js/parseFloat (get-config :POW_TARGET "0.0001")))
(def pow-time (js/parseInt (get-config :POW_TIME "1"))) (def pow-time (js/parseInt (get-config :POW_TIME "1")))
(def max-installations 2) (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)))

View File

@ -1,7 +1,7 @@
(ns status-im.wallet.core (ns status-im.wallet.core
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[status-im.multiaccounts.update.core :as multiaccounts.update] [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.qr-scanner.core :as qr-scaner]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.ethereum.eip55 :as eip55] [status-im.ethereum.eip55 :as eip55]
@ -9,7 +9,6 @@
[status-im.ethereum.tokens :as tokens] [status-im.ethereum.tokens :as tokens]
[status-im.i18n :as i18n] [status-im.i18n :as i18n]
[status-im.navigation :as navigation] [status-im.navigation :as navigation]
[status-im.utils.config :as config]
[status-im.utils.core :as utils.core] [status-im.utils.core :as utils.core]
[status-im.utils.fx :as fx] [status-im.utils.fx :as fx]
[status-im.utils.money :as money] [status-im.utils.money :as money]
@ -243,7 +242,7 @@
:db (prices/clear-error-message db :balance-update)} :db (prices/clear-error-message db :balance-update)}
(when-not assets (when-not assets
(multiaccounts.update/multiaccount-update (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] [{:keys [db] :as cofx} balances]
(let [chain (ethereum/chain-keyword db) (let [chain (ethereum/chain-keyword db)
visible-tokens (get-in db [:multiaccount :wallet/visible-tokens]) 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))))] (flatten (map keys (vals balances))))]
(fx/merge cofx (fx/merge cofx