[#12818] Support tx history (in a way) when on BSC chains
This commit is contained in:
parent
89d42b9ef4
commit
c7e66fb1aa
|
@ -17,16 +17,21 @@
|
||||||
(.hexToUtf8 utils s)
|
(.hexToUtf8 utils s)
|
||||||
(catch :default _ nil)))
|
(catch :default _ nil)))
|
||||||
|
|
||||||
;; IDs standardized in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md#list-of-chain-ids
|
(def BSC-mainnet-chain-id 56)
|
||||||
|
(def BSC-testnet-chain-id 97)
|
||||||
|
|
||||||
|
;; IDs standardized in https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md#list-of-chain-ids
|
||||||
(def chains
|
(def chains
|
||||||
{:mainnet {:id 1 :name "Mainnet"}
|
{:mainnet {:id 1 :name "Mainnet"}
|
||||||
:testnet {:id 3 :name "Ropsten"}
|
:testnet {:id 3 :name "Ropsten"}
|
||||||
:rinkeby {:id 4 :name "Rinkeby"}
|
:rinkeby {:id 4 :name "Rinkeby"}
|
||||||
:xdai {:id 100 :name "xDai"}
|
:xdai {:id 100 :name "xDai"}
|
||||||
:poa {:id 99 :name "POA"}
|
:poa {:id 99 :name "POA"}
|
||||||
:goerli {:id 5 :name "Goerli"}
|
:goerli {:id 5 :name "Goerli"}
|
||||||
:bsc {:id 56 :name "BSC"}})
|
:bsc {:id BSC-mainnet-chain-id
|
||||||
|
:name "BSC"}
|
||||||
|
:bsc-testnet {:id BSC-testnet-chain-id
|
||||||
|
:name "BSC tetnet"}})
|
||||||
|
|
||||||
(defn chain-id->chain-keyword [i]
|
(defn chain-id->chain-keyword [i]
|
||||||
(or (some #(when (= i (:id (val %))) (key %)) chains)
|
(or (some #(when (= i (:id (val %))) (key %)) chains)
|
||||||
|
@ -47,7 +52,8 @@
|
||||||
(defn testnet? [id]
|
(defn testnet? [id]
|
||||||
(contains? #{(chain-keyword->chain-id :testnet)
|
(contains? #{(chain-keyword->chain-id :testnet)
|
||||||
(chain-keyword->chain-id :rinkeby)
|
(chain-keyword->chain-id :rinkeby)
|
||||||
(chain-keyword->chain-id :goerli)} id))
|
(chain-keyword->chain-id :goerli)
|
||||||
|
(chain-keyword->chain-id :bsc-testnet)} id))
|
||||||
|
|
||||||
(defn sidechain? [id]
|
(defn sidechain? [id]
|
||||||
(contains? #{(chain-keyword->chain-id :xdai)
|
(contains? #{(chain-keyword->chain-id :xdai)
|
||||||
|
@ -109,6 +115,16 @@
|
||||||
network-id (get db :networks/current-network)]
|
network-id (get db :networks/current-network)]
|
||||||
(get networks network-id)))
|
(get networks network-id)))
|
||||||
|
|
||||||
|
(defn binance-chain-id? [chain-id]
|
||||||
|
(or (= BSC-mainnet-chain-id chain-id)
|
||||||
|
(= BSC-testnet-chain-id chain-id)))
|
||||||
|
|
||||||
|
(defn binance-chain? [db]
|
||||||
|
(-> db
|
||||||
|
current-network
|
||||||
|
network->chain-id
|
||||||
|
binance-chain-id?))
|
||||||
|
|
||||||
(def custom-rpc-node-id-len 45)
|
(def custom-rpc-node-id-len 45)
|
||||||
|
|
||||||
(defn custom-rpc-node? [{:keys [id]}]
|
(defn custom-rpc-node? [{:keys [id]}]
|
||||||
|
|
|
@ -194,6 +194,7 @@
|
||||||
"wallet_getCryptoOnRamps" {}
|
"wallet_getCryptoOnRamps" {}
|
||||||
"wallet_getOpenseaCollectionsByOwner" {}
|
"wallet_getOpenseaCollectionsByOwner" {}
|
||||||
"wallet_getOpenseaAssetsByOwnerAndCollection" {}
|
"wallet_getOpenseaAssetsByOwnerAndCollection" {}
|
||||||
|
"wallet_loadTransferByHash" {}
|
||||||
"browsers_getBrowsers" {}
|
"browsers_getBrowsers" {}
|
||||||
"browsers_addBrowser" {}
|
"browsers_addBrowser" {}
|
||||||
"browsers_deleteBrowser" {}
|
"browsers_deleteBrowser" {}
|
||||||
|
|
|
@ -17,30 +17,34 @@
|
||||||
|
|
||||||
(def all-native-currencies
|
(def all-native-currencies
|
||||||
(ethereum.macros/resolve-native-currency-icons
|
(ethereum.macros/resolve-native-currency-icons
|
||||||
{:mainnet {:name "Ether"
|
{:mainnet {:name "Ether"
|
||||||
:symbol :ETH
|
:symbol :ETH
|
||||||
:decimals 18}
|
:decimals 18}
|
||||||
:testnet {:name "Ropsten Ether"
|
:testnet {:name "Ropsten Ether"
|
||||||
:symbol :ETH
|
:symbol :ETH
|
||||||
:symbol-display :ETHro
|
:symbol-display :ETHro
|
||||||
:decimals 18}
|
:decimals 18}
|
||||||
:rinkeby {:name "Rinkeby Ether"
|
:rinkeby {:name "Rinkeby Ether"
|
||||||
:symbol :ETH
|
:symbol :ETH
|
||||||
:symbol-display :ETHri
|
:symbol-display :ETHri
|
||||||
:decimals 18}
|
:decimals 18}
|
||||||
:poa {:name "POA"
|
:poa {:name "POA"
|
||||||
:symbol :ETH
|
:symbol :ETH
|
||||||
:symbol-display :POA
|
:symbol-display :POA
|
||||||
:decimals 18}
|
:decimals 18}
|
||||||
:xdai {:name "xDAI"
|
:xdai {:name "xDAI"
|
||||||
:symbol :ETH
|
:symbol :ETH
|
||||||
:symbol-display :xDAI
|
:symbol-display :xDAI
|
||||||
:symbol-exchange :DAI
|
:symbol-exchange :DAI
|
||||||
:decimals 18}
|
:decimals 18}
|
||||||
:bsc {:name "BSC"
|
:bsc {:name "BSC"
|
||||||
:symbol :ETH
|
:symbol :ETH
|
||||||
:symbol-display :BNB
|
:symbol-display :BNB
|
||||||
:decimals 18}}))
|
:decimals 18}
|
||||||
|
:bsc-testnet {:name "BSC test"
|
||||||
|
:symbol :ETH
|
||||||
|
:symbol-display :BNBtest
|
||||||
|
:decimals 18}}))
|
||||||
|
|
||||||
(def native-currency-symbols
|
(def native-currency-symbols
|
||||||
(set (map #(-> % val :symbol) all-native-currencies)))
|
(set (map #(-> % val :symbol) all-native-currencies)))
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
(:require [cljs.spec.alpha :as spec]
|
(:require [cljs.spec.alpha :as spec]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.ens.core :as ens]
|
[status-im.ens.core :as ens]
|
||||||
|
[status-im.ethereum.core :as ethereum]
|
||||||
[status-im.ethereum.decode :as decode]
|
[status-im.ethereum.decode :as decode]
|
||||||
[status-im.ethereum.eip55 :as eip55]
|
[status-im.ethereum.eip55 :as eip55]
|
||||||
[status-im.ethereum.encode :as encode]
|
[status-im.ethereum.encode :as encode]
|
||||||
|
@ -13,16 +14,31 @@
|
||||||
|
|
||||||
(def confirmations-count-threshold 12)
|
(def confirmations-count-threshold 12)
|
||||||
|
|
||||||
(def etherscan-supported? #{:testnet :mainnet :rinkeby})
|
(def etherscan-supported?
|
||||||
|
#{(ethereum/chain-keyword->chain-id :mainnet)
|
||||||
|
(ethereum/chain-keyword->chain-id :testnet)
|
||||||
|
(ethereum/chain-keyword->chain-id :rinkeby)})
|
||||||
|
|
||||||
(let [network->subdomain {:testnet "ropsten" :rinkeby "rinkeby"}]
|
(def binance-mainnet-chain-id (ethereum/chain-keyword->chain-id :bsc))
|
||||||
(defn get-transaction-details-url [chain hash]
|
(def binance-testnet-chain-id (ethereum/chain-keyword->chain-id :bsc-testnet))
|
||||||
{:pre [(keyword? chain) (string? hash)]
|
|
||||||
:post [(or (nil? %) (string? %))]}
|
(def network->subdomain {3 "ropsten"
|
||||||
(when (etherscan-supported? chain)
|
4 "rinkeby"})
|
||||||
(let [network-subdomain (when-let [subdomain (network->subdomain chain)]
|
|
||||||
(str subdomain "."))]
|
(defn get-transaction-details-url [chain-id hash]
|
||||||
(str "https://" network-subdomain "etherscan.io/tx/" hash)))))
|
{:pre [(number? chain-id) (string? hash)]
|
||||||
|
:post [(or (nil? %) (string? %))]}
|
||||||
|
(cond
|
||||||
|
(etherscan-supported? chain-id)
|
||||||
|
(let [network-subdomain (when-let [subdomain (network->subdomain chain-id)]
|
||||||
|
(str subdomain "."))]
|
||||||
|
(str "https://" network-subdomain "etherscan.io/tx/" hash))
|
||||||
|
|
||||||
|
(= chain-id binance-mainnet-chain-id)
|
||||||
|
(str "https://bscscan.com/tx/" hash)
|
||||||
|
|
||||||
|
(= chain-id binance-testnet-chain-id)
|
||||||
|
(str "https://testnet.bscscan.com/tx/" hash)))
|
||||||
|
|
||||||
(def default-erc20-token
|
(def default-erc20-token
|
||||||
{:symbol :ERC20
|
{:symbol :ERC20
|
||||||
|
@ -358,6 +374,7 @@
|
||||||
(tx-fetching-in-progress [address]))))
|
(tx-fetching-in-progress [address]))))
|
||||||
|
|
||||||
(fx/defn get-fetched-transfers
|
(fx/defn get-fetched-transfers
|
||||||
|
{:events [:transaction/get-fetched-transfers]}
|
||||||
[{:keys [db]}]
|
[{:keys [db]}]
|
||||||
{:transactions/get-transfers
|
{:transactions/get-transfers
|
||||||
{:chain-tokens (:wallet/all-tokens db)
|
{:chain-tokens (:wallet/all-tokens db)
|
||||||
|
|
|
@ -122,8 +122,11 @@
|
||||||
(wallet/get-cached-balances scan-all-tokens?))
|
(wallet/get-cached-balances scan-all-tokens?))
|
||||||
(when-not (get db :wallet/new-account)
|
(when-not (get db :wallet/new-account)
|
||||||
(wallet/restart-wallet-service nil))
|
(wallet/restart-wallet-service nil))
|
||||||
(when-not (utils.mobile-sync/syncing-allowed? cofx)
|
(when (or (not (utils.mobile-sync/syncing-allowed? cofx))
|
||||||
|
(ethereum/binance-chain? db))
|
||||||
(transactions/get-fetched-transfers))
|
(transactions/get-fetched-transfers))
|
||||||
|
(when (ethereum/binance-chain? db)
|
||||||
|
(wallet/request-current-block-update))
|
||||||
(prices/update-prices)))
|
(prices/update-prices)))
|
||||||
|
|
||||||
(fx/defn login
|
(fx/defn login
|
||||||
|
|
|
@ -304,13 +304,13 @@
|
||||||
|
|
||||||
(fx/defn transaction-result
|
(fx/defn transaction-result
|
||||||
[{:keys [db] :as cofx} result tx-obj]
|
[{:keys [db] :as cofx} result tx-obj]
|
||||||
(let [{:keys [on-result symbol amount]} (get db :signing/tx)]
|
(let [{:keys [on-result symbol amount from]} (get db :signing/tx)]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (dissoc db :signing/tx :signing/sign)
|
{:db (dissoc db :signing/tx :signing/sign)
|
||||||
:signing/show-transaction-result nil}
|
:signing/show-transaction-result nil}
|
||||||
(prepare-unconfirmed-transaction result tx-obj symbol amount)
|
(prepare-unconfirmed-transaction result tx-obj symbol amount)
|
||||||
(check-queue)
|
(check-queue)
|
||||||
(wallet/watch-tx result)
|
(wallet/watch-tx (get from :address) result)
|
||||||
#(when on-result
|
#(when on-result
|
||||||
{:dispatch (conj on-result result)}))))
|
{:dispatch (conj on-result result)}))))
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@
|
||||||
(fx/merge
|
(fx/merge
|
||||||
cofx
|
cofx
|
||||||
{:db (dissoc db :signing/tx :signing/sign)}
|
{:db (dissoc db :signing/tx :signing/sign)}
|
||||||
(wallet/watch-tx transaction-hash)
|
(wallet/watch-tx (get from :address) transaction-hash)
|
||||||
(if (keycard.common/keycard-multiaccount? db)
|
(if (keycard.common/keycard-multiaccount? db)
|
||||||
(signing.keycard/hash-message
|
(signing.keycard/hash-message
|
||||||
{:data data
|
{:data data
|
||||||
|
|
|
@ -1776,11 +1776,11 @@
|
||||||
(get-in wallet [:fetching address :all-fetched?])))
|
(get-in wallet [:fetching address :all-fetched?])))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:wallet/etherscan-link
|
:wallet/chain-explorer-link
|
||||||
(fn [db [_ address]]
|
(fn [db [_ address]]
|
||||||
(let [network (:networks/current-network db)
|
(let [network (:networks/current-network db)
|
||||||
link (get-in config/default-networks-by-id
|
link (get-in config/default-networks-by-id
|
||||||
[network :etherscan-link])]
|
[network :chain-explorer-link])]
|
||||||
(when link
|
(when link
|
||||||
(str link address)))))
|
(str link address)))))
|
||||||
|
|
||||||
|
@ -2108,8 +2108,8 @@
|
||||||
(fn [[_ _ address] _]
|
(fn [[_ _ address] _]
|
||||||
[(re-frame/subscribe [:wallet.transactions/transactions address])
|
[(re-frame/subscribe [:wallet.transactions/transactions address])
|
||||||
(re-frame/subscribe [:ethereum/native-currency])
|
(re-frame/subscribe [:ethereum/native-currency])
|
||||||
(re-frame/subscribe [:ethereum/chain-keyword])])
|
(re-frame/subscribe [:chain-id])])
|
||||||
(fn [[transactions native-currency chain-keyword] [_ hash _]]
|
(fn [[transactions native-currency chain-id] [_ hash _]]
|
||||||
(let [{:keys [gas-used gas-price fee-cap tip-cap hash timestamp type]
|
(let [{:keys [gas-used gas-price fee-cap tip-cap hash timestamp type]
|
||||||
:as transaction}
|
:as transaction}
|
||||||
(get transactions hash)
|
(get transactions hash)
|
||||||
|
@ -2147,7 +2147,7 @@
|
||||||
(money/fee-value gas-used gas-price)
|
(money/fee-value gas-used gas-price)
|
||||||
native-currency-text))
|
native-currency-text))
|
||||||
:url (transactions/get-transaction-details-url
|
:url (transactions/get-transaction-details-url
|
||||||
chain-keyword
|
chain-id
|
||||||
hash)}))))))
|
hash)}))))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
|
@ -2196,6 +2196,12 @@
|
||||||
:<- [:wallet]
|
:<- [:wallet]
|
||||||
:request-transaction)
|
:request-transaction)
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:wallet/binance-chain?
|
||||||
|
:<- [:current-network]
|
||||||
|
(fn [network]
|
||||||
|
(ethereum/binance-chain-id? (get-in network [:config :NetworkId]))))
|
||||||
|
|
||||||
;;UI ==============================================================================================================
|
;;UI ==============================================================================================================
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
|
|
|
@ -216,7 +216,7 @@
|
||||||
[{:ms 100 :dispatch [:process-statuses statuses]}])
|
[{:ms 100 :dispatch [:process-statuses statuses]}])
|
||||||
(when (seq transactions)
|
(when (seq transactions)
|
||||||
(for [transaction-hash transactions]
|
(for [transaction-hash transactions]
|
||||||
{:ms 100 :dispatch [:watch-tx transaction-hash]})))}
|
{:ms 100 :dispatch [:watch-tx nil transaction-hash]})))}
|
||||||
(process-response response-js process-async)))))
|
(process-response response-js process-async)))))
|
||||||
|
|
||||||
(fx/defn remove-hash
|
(fx/defn remove-hash
|
||||||
|
|
|
@ -110,8 +110,7 @@
|
||||||
[tabs/tab-title state :assets (i18n/label :t/wallet-assets) (= tab :assets)]
|
[tabs/tab-title state :assets (i18n/label :t/wallet-assets) (= tab :assets)]
|
||||||
(when ethereum-network?
|
(when ethereum-network?
|
||||||
[tabs/tab-title state :nft (i18n/label :t/wallet-collectibles) (= tab :nft)])
|
[tabs/tab-title state :nft (i18n/label :t/wallet-collectibles) (= tab :nft)])
|
||||||
(when ethereum-network?
|
[tabs/tab-title state :history (i18n/label :t/history) (= tab :history)]]
|
||||||
[tabs/tab-title state :history (i18n/label :t/history) (= tab :history)])]
|
|
||||||
(cond
|
(cond
|
||||||
(= tab :assets)
|
(= tab :assets)
|
||||||
[:<>
|
[:<>
|
||||||
|
|
|
@ -73,8 +73,8 @@
|
||||||
{:on-press #(re-frame/dispatch [:signing.ui/cancel-transaction-pressed hash])}
|
{:on-press #(re-frame/dispatch [:signing.ui/cancel-transaction-pressed hash])}
|
||||||
(i18n/label :t/cancel)]])])
|
(i18n/label :t/cancel)]])])
|
||||||
|
|
||||||
(defn etherscan-link [address]
|
(defn chain-explorer-link [address]
|
||||||
(let [link @(re-frame/subscribe [:wallet/etherscan-link address])]
|
(let [link @(re-frame/subscribe [:wallet/chain-explorer-link address])]
|
||||||
[react/touchable-highlight
|
[react/touchable-highlight
|
||||||
{:on-press #(when link
|
{:on-press #(when link
|
||||||
(.openURL ^js react/linking link))}
|
(.openURL ^js react/linking link))}
|
||||||
|
@ -124,11 +124,12 @@
|
||||||
keycard-account? @(re-frame/subscribe [:multiaccounts/keycard-account?])
|
keycard-account? @(re-frame/subscribe [:multiaccounts/keycard-account?])
|
||||||
custom-rpc-node? @(re-frame/subscribe [:custom-rpc-node])
|
custom-rpc-node? @(re-frame/subscribe [:custom-rpc-node])
|
||||||
non-archival-rpc-node? @(re-frame/subscribe [:wallet/non-archival-node])
|
non-archival-rpc-node? @(re-frame/subscribe [:wallet/non-archival-node])
|
||||||
|
binance-chain? @(re-frame/subscribe [:wallet/binance-chain?])
|
||||||
all-fetched? @(re-frame/subscribe [:wallet/tx-history-fetched? address])
|
all-fetched? @(re-frame/subscribe [:wallet/tx-history-fetched? address])
|
||||||
syncing-allowed? @(re-frame/subscribe [:mobile-network/syncing-allowed?])]
|
syncing-allowed? @(re-frame/subscribe [:mobile-network/syncing-allowed?])]
|
||||||
[react/view {:flex 1}
|
[react/view {:flex 1}
|
||||||
[etherscan-link address]
|
[chain-explorer-link address]
|
||||||
(cond non-archival-rpc-node?
|
(cond (or non-archival-rpc-node? binance-chain?)
|
||||||
[non-archival-node]
|
[non-archival-node]
|
||||||
custom-rpc-node?
|
custom-rpc-node?
|
||||||
[custom-node])
|
[custom-node])
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
(ns status-im.utils.config
|
(ns status-im.utils.config
|
||||||
(:require [clojure.string :as string]
|
(:require ["react-native-config" :default react-native-config]
|
||||||
|
[clojure.string :as string]
|
||||||
[status-im.ethereum.core :as ethereum]
|
[status-im.ethereum.core :as ethereum]
|
||||||
[status-im.ethereum.ens :as ens]
|
[status-im.ethereum.ens :as ens]))
|
||||||
["react-native-config" :default react-native-config]))
|
|
||||||
|
|
||||||
(def config
|
(def config
|
||||||
(memoize
|
(memoize
|
||||||
|
@ -94,56 +94,65 @@
|
||||||
(get-in default-multiaccount [:wallet/visible-tokens chain]))
|
(get-in default-multiaccount [:wallet/visible-tokens chain]))
|
||||||
|
|
||||||
(def mainnet-networks
|
(def mainnet-networks
|
||||||
[{:id "mainnet_rpc",
|
[{:id "mainnet_rpc",
|
||||||
:etherscan-link "https://etherscan.io/address/",
|
:chain-explorer-link "https://etherscan.io/address/",
|
||||||
:name "Mainnet with upstream RPC",
|
:name "Mainnet with upstream RPC",
|
||||||
:config {:NetworkId (ethereum/chain-keyword->chain-id :mainnet)
|
:config {:NetworkId (ethereum/chain-keyword->chain-id :mainnet)
|
||||||
:DataDir "/ethereum/mainnet_rpc"
|
:DataDir "/ethereum/mainnet_rpc"
|
||||||
:UpstreamConfig {:Enabled true
|
:UpstreamConfig {:Enabled true
|
||||||
:URL mainnet-rpc-url}}}])
|
:URL mainnet-rpc-url}}}])
|
||||||
|
|
||||||
(def sidechain-networks
|
(def sidechain-networks
|
||||||
[{:id "xdai_rpc",
|
[{:id "xdai_rpc",
|
||||||
:name "xDai Chain",
|
:name "xDai Chain",
|
||||||
:config {:NetworkId (ethereum/chain-keyword->chain-id :xdai)
|
:chain-explorer-link "https://blockscout.com/xdai/mainnet/address/",
|
||||||
:DataDir "/ethereum/xdai_rpc"
|
:config {:NetworkId (ethereum/chain-keyword->chain-id :xdai)
|
||||||
:UpstreamConfig {:Enabled true
|
:DataDir "/ethereum/xdai_rpc"
|
||||||
:URL "https://dai.poa.network"}}}
|
:UpstreamConfig {:Enabled true
|
||||||
|
:URL "https://dai.poa.network"}}}
|
||||||
{:id "poa_rpc",
|
{:id "poa_rpc",
|
||||||
:name "POA Network",
|
:name "POA Network",
|
||||||
:config {:NetworkId (ethereum/chain-keyword->chain-id :poa)
|
:config {:NetworkId (ethereum/chain-keyword->chain-id :poa)
|
||||||
:DataDir "/ethereum/poa_rpc"
|
:DataDir "/ethereum/poa_rpc"
|
||||||
:UpstreamConfig {:Enabled true
|
:UpstreamConfig {:Enabled true
|
||||||
:URL "https://core.poa.network"}}}
|
:URL "https://core.poa.network"}}}
|
||||||
{:id "bsc_rpc",
|
{:id "bsc_rpc",
|
||||||
:name "BSC Network",
|
:chain-explorer-link "https://bscscan.com/address/",
|
||||||
:config {:NetworkId (ethereum/chain-keyword->chain-id :bsc)
|
:name "BSC Network",
|
||||||
:DataDir "/ethereum/bsc_rpc"
|
:config {:NetworkId (ethereum/chain-keyword->chain-id :bsc)
|
||||||
:UpstreamConfig {:Enabled true
|
:DataDir "/ethereum/bsc_rpc"
|
||||||
:URL "https://bsc-dataseed.binance.org"}}}])
|
:UpstreamConfig {:Enabled true
|
||||||
|
:URL "https://bsc-dataseed.binance.org"}}}])
|
||||||
|
|
||||||
(def testnet-networks
|
(def testnet-networks
|
||||||
[{:id "testnet_rpc",
|
[{:id "testnet_rpc",
|
||||||
:etherscan-link "https://ropsten.etherscan.io/address/",
|
:chain-explorer-link "https://ropsten.etherscan.io/address/",
|
||||||
:name "Ropsten with upstream RPC",
|
:name "Ropsten with upstream RPC",
|
||||||
:config {:NetworkId (ethereum/chain-keyword->chain-id :testnet)
|
:config {:NetworkId (ethereum/chain-keyword->chain-id :testnet)
|
||||||
:DataDir "/ethereum/testnet_rpc"
|
:DataDir "/ethereum/testnet_rpc"
|
||||||
:UpstreamConfig {:Enabled true
|
:UpstreamConfig {:Enabled true
|
||||||
:URL testnet-rpc-url}}}
|
:URL testnet-rpc-url}}}
|
||||||
{:id "rinkeby_rpc",
|
{:id "rinkeby_rpc",
|
||||||
:etherscan-link "https://rinkeby.etherscan.io/address/",
|
:chain-explorer-link "https://rinkeby.etherscan.io/address/",
|
||||||
:name "Rinkeby with upstream RPC",
|
:name "Rinkeby with upstream RPC",
|
||||||
:config {:NetworkId (ethereum/chain-keyword->chain-id :rinkeby)
|
:config {:NetworkId (ethereum/chain-keyword->chain-id :rinkeby)
|
||||||
:DataDir "/ethereum/rinkeby_rpc"
|
:DataDir "/ethereum/rinkeby_rpc"
|
||||||
:UpstreamConfig {:Enabled true
|
:UpstreamConfig {:Enabled true
|
||||||
:URL (str "https://rinkeby.infura.io/v3/" INFURA_TOKEN)}}}
|
:URL (str "https://rinkeby.infura.io/v3/" INFURA_TOKEN)}}}
|
||||||
{:id "goerli_rpc",
|
{:id "goerli_rpc",
|
||||||
:etherscan-link "https://goerli.etherscan.io/address/",
|
:chain-explorer-link "https://goerli.etherscan.io/address/",
|
||||||
:name "Goerli with upstream RPC",
|
:name "Goerli with upstream RPC",
|
||||||
:config {:NetworkId (ethereum/chain-keyword->chain-id :goerli)
|
:config {:NetworkId (ethereum/chain-keyword->chain-id :goerli)
|
||||||
:DataDir "/ethereum/goerli_rpc"
|
:DataDir "/ethereum/goerli_rpc"
|
||||||
:UpstreamConfig {:Enabled true
|
:UpstreamConfig {:Enabled true
|
||||||
:URL (str "https://goerli.infura.io/v3/" INFURA_TOKEN)}}}])
|
:URL (str "https://goerli.infura.io/v3/" INFURA_TOKEN)}}}
|
||||||
|
{:id "bsc_testnet_rpc",
|
||||||
|
:chain-explorer-link "https://testnet.bscscan.com/address/",
|
||||||
|
:name "BSC testnet",
|
||||||
|
:config {:NetworkId (ethereum/chain-keyword->chain-id :bsc-testnet)
|
||||||
|
:DataDir "/ethereum/bsc_testnet_rpc"
|
||||||
|
:UpstreamConfig {:Enabled true
|
||||||
|
:URL "https://data-seed-prebsc-1-s1.binance.org:8545/"}}}])
|
||||||
|
|
||||||
(def default-networks
|
(def default-networks
|
||||||
(concat testnet-networks mainnet-networks sidechain-networks))
|
(concat testnet-networks mainnet-networks sidechain-networks))
|
||||||
|
|
|
@ -767,12 +767,15 @@
|
||||||
{:keys [force-restart? on-recent-history-fetching]
|
{:keys [force-restart? on-recent-history-fetching]
|
||||||
:as params}]
|
:as params}]
|
||||||
(when (:multiaccount db)
|
(when (:multiaccount db)
|
||||||
(let [syncing-allowed? (mobile-network-utils/syncing-allowed? cofx)]
|
(let [syncing-allowed? (mobile-network-utils/syncing-allowed? cofx)
|
||||||
|
binance-chain? (ethereum/binance-chain? db)]
|
||||||
(log/info "restart-wallet-service"
|
(log/info "restart-wallet-service"
|
||||||
"force-restart?" force-restart?
|
"force-restart?" force-restart?
|
||||||
"syncing-allowed?" syncing-allowed?)
|
"syncing-allowed?" syncing-allowed?
|
||||||
(if (or syncing-allowed?
|
"binance-chain?" binance-chain?)
|
||||||
force-restart?)
|
(if (and (or syncing-allowed?
|
||||||
|
force-restart?)
|
||||||
|
(not binance-chain?))
|
||||||
(check-recent-history cofx params)
|
(check-recent-history cofx params)
|
||||||
(after-checking-history cofx)))))
|
(after-checking-history cofx)))))
|
||||||
|
|
||||||
|
@ -792,6 +795,27 @@
|
||||||
cofx
|
cofx
|
||||||
{:force-restart? force-restart?}))
|
{:force-restart? force-restart?}))
|
||||||
|
|
||||||
|
(re-frame/reg-fx
|
||||||
|
:load-transaction-by-hash
|
||||||
|
(fn [[address hash]]
|
||||||
|
(log/info "calling wallet_loadTransferByHash" address hash)
|
||||||
|
(json-rpc/call
|
||||||
|
{:method "wallet_loadTransferByHash"
|
||||||
|
:params [address hash]
|
||||||
|
:on-success #(re-frame/dispatch [:transaction/get-fetched-transfers])
|
||||||
|
:on-error #(log/warn "Transfer loading failed" %)})))
|
||||||
|
|
||||||
|
(fx/defn load-transaction-by-hash
|
||||||
|
[_ address hash]
|
||||||
|
{:load-transaction-by-hash [address hash]})
|
||||||
|
|
||||||
|
(fx/defn transaction-included
|
||||||
|
{:events [::transaction-included]}
|
||||||
|
[{:keys [db] :as cofx} address hash]
|
||||||
|
(if (ethereum/binance-chain? db)
|
||||||
|
(load-transaction-by-hash cofx address hash)
|
||||||
|
(restart cofx true)))
|
||||||
|
|
||||||
(def pull-to-refresh-cooldown-period (* 1 60 1000))
|
(def pull-to-refresh-cooldown-period (* 1 60 1000))
|
||||||
|
|
||||||
(fx/defn restart-on-pull
|
(fx/defn restart-on-pull
|
||||||
|
@ -813,17 +837,17 @@
|
||||||
::start-watching
|
::start-watching
|
||||||
(fn [hashes]
|
(fn [hashes]
|
||||||
(log/info "[wallet] watch transactions" hashes)
|
(log/info "[wallet] watch transactions" hashes)
|
||||||
(doseq [hash hashes]
|
(doseq [[address hash] hashes]
|
||||||
(json-rpc/call
|
(json-rpc/call
|
||||||
{:method "wallet_watchTransaction"
|
{:method "wallet_watchTransaction"
|
||||||
:params [hash]
|
:params [hash]
|
||||||
:on-success #(re-frame.core/dispatch [::restart true])
|
:on-success #(re-frame.core/dispatch [::transaction-included address hash])
|
||||||
:on-error #(log/info "[wallet] watch transaction error" % "hash" hash)}))))
|
:on-error #(log/info "[wallet] watch transaction error" % "hash" hash)}))))
|
||||||
|
|
||||||
(fx/defn watch-tx
|
(fx/defn watch-tx
|
||||||
{:events [:watch-tx]}
|
{:events [:watch-tx]}
|
||||||
[{:keys [db] :as cofx} tx-id]
|
[{:keys [db] :as cofx} address tx-id]
|
||||||
{::start-watching [tx-id]})
|
{::start-watching [[address tx-id]]})
|
||||||
|
|
||||||
(fx/defn watch-transsactions
|
(fx/defn watch-transsactions
|
||||||
[_ hashes]
|
[_ hashes]
|
||||||
|
@ -1020,7 +1044,7 @@
|
||||||
db)))
|
db)))
|
||||||
db
|
db
|
||||||
(map (partial normalize-transaction db) raw-transactions))
|
(map (partial normalize-transaction db) raw-transactions))
|
||||||
::start-watching (map :hash raw-transactions)})
|
::start-watching (map (juxt :from :hash) raw-transactions)})
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:wallet/delete-pending-transactions
|
:wallet/delete-pending-transactions
|
||||||
|
@ -1037,3 +1061,20 @@
|
||||||
[{:keys [db]} enabled?]
|
[{:keys [db]} enabled?]
|
||||||
{::async-storage/set! {:transactions-management-enabled? enabled?}
|
{::async-storage/set! {:transactions-management-enabled? enabled?}
|
||||||
:db (assoc db :wallet/transactions-management-enabled? enabled?)})
|
:db (assoc db :wallet/transactions-management-enabled? enabled?)})
|
||||||
|
|
||||||
|
(fx/defn update-curent-block
|
||||||
|
{:events [::update-current-block]}
|
||||||
|
[{:keys [db]} block]
|
||||||
|
{:db (assoc db :ethereum/current-block block)})
|
||||||
|
|
||||||
|
(re-frame/reg-fx
|
||||||
|
::request-current-block-update
|
||||||
|
(fn []
|
||||||
|
(json-rpc/call
|
||||||
|
{:method "eth_getBlockByNumber"
|
||||||
|
:params ["latest" false]
|
||||||
|
:on-success #(re-frame/dispatch [::update-current-block (get % :number)])})))
|
||||||
|
|
||||||
|
(fx/defn request-current-block-update
|
||||||
|
[_]
|
||||||
|
{::request-current-block-update nil})
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
(deftest get-transaction-details-url
|
(deftest get-transaction-details-url
|
||||||
(is (= "https://etherscan.io/tx/asdfasdf"
|
(is (= "https://etherscan.io/tx/asdfasdf"
|
||||||
(transactions/get-transaction-details-url :mainnet "asdfasdf")))
|
(transactions/get-transaction-details-url 1 "asdfasdf")))
|
||||||
(is (= "https://rinkeby.etherscan.io/tx/asdfasdfg"
|
(is (= "https://rinkeby.etherscan.io/tx/asdfasdfg"
|
||||||
(transactions/get-transaction-details-url :rinkeby "asdfasdfg")))
|
(transactions/get-transaction-details-url 4 "asdfasdfg")))
|
||||||
(is (= "https://ropsten.etherscan.io/tx/asdfasdfgg"
|
(is (= "https://ropsten.etherscan.io/tx/asdfasdfgg"
|
||||||
(transactions/get-transaction-details-url :testnet "asdfasdfgg")))
|
(transactions/get-transaction-details-url 3 "asdfasdfgg")))
|
||||||
(is (nil? (transactions/get-transaction-details-url :not-a-net "asdfasdfg")))
|
(is (nil? (transactions/get-transaction-details-url 7787878 "asdfasdfg")))
|
||||||
(is (thrown? js/Error (transactions/get-transaction-details-url nil "asdfasdfg")))
|
(is (thrown? js/Error (transactions/get-transaction-details-url nil "asdfasdfg")))
|
||||||
(is (thrown? js/Error (transactions/get-transaction-details-url :asdf 1))))
|
(is (thrown? js/Error (transactions/get-transaction-details-url 676868 1))))
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.91.8",
|
"version": "v0.91.10",
|
||||||
"commit-sha1": "a65c873b8f2633c05a0f108a84ccbc3b8456378a",
|
"commit-sha1": "7ef2efaabd643a476699d545d22faf36ba066b08",
|
||||||
"src-sha256": "16c8nphz7jkfsgcp2gcv91lhky2ykkz0mrazg03pqdrcnjb2y774"
|
"src-sha256": "0rwpbkqwzk772advqs6g98bqrbcvhs25xwwnfci04pqycklh11zb"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue