aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorhackyminer <hackyminer@gmail.com>2018-10-19 23:45:59 +0800
committerhackyminer <hackyminer@gmail.com>2018-10-20 00:08:46 +0800
commit2f6530a4948743fe156dc3519f04bd44f7c6e2ae (patch)
treed78533d20c37b07e196ee09d68bdd8c5e86e02bf /app
parentea214945cf88cef457147bd33a3017c8ea97956a (diff)
downloadtangerine-wallet-browser-2f6530a4948743fe156dc3519f04bd44f7c6e2ae.tar
tangerine-wallet-browser-2f6530a4948743fe156dc3519f04bd44f7c6e2ae.tar.gz
tangerine-wallet-browser-2f6530a4948743fe156dc3519f04bd44f7c6e2ae.tar.bz2
tangerine-wallet-browser-2f6530a4948743fe156dc3519f04bd44f7c6e2ae.tar.lz
tangerine-wallet-browser-2f6530a4948743fe156dc3519f04bd44f7c6e2ae.tar.xz
tangerine-wallet-browser-2f6530a4948743fe156dc3519f04bd44f7c6e2ae.tar.zst
tangerine-wallet-browser-2f6530a4948743fe156dc3519f04bd44f7c6e2ae.zip
support both eth_chainId and net_version
get the real chainId using eth_chainId and use net_version as a fallback
Diffstat (limited to 'app')
-rw-r--r--app/scripts/controllers/network/network.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js
index c1667d9a6..b386161da 100644
--- a/app/scripts/controllers/network/network.js
+++ b/app/scripts/controllers/network/network.js
@@ -86,10 +86,17 @@ module.exports = class NetworkController extends EventEmitter {
return log.warn('NetworkController - lookupNetwork aborted due to missing provider')
}
const ethQuery = new EthQuery(this._provider)
- ethQuery.sendAsync({ method: 'net_version' }, (err, network) => {
- if (err) return this.setNetworkState('loading')
- log.info('web3.getNetwork returned ' + network)
- this.setNetworkState(network)
+ ethQuery.sendAsync({ method: 'eth_chainId' }, (err, chainId) => {
+ if (err) {
+ ethQuery.sendAsync({ method: 'net_version' }, (err, network) => {
+ if (err) return this.setNetworkState('loading')
+ log.info('web3.getNetwork returned net_version = ' + network)
+ this.setNetworkState(network)
+ })
+ return
+ }
+ log.info('web3.getNetwork returned chainId = ' + parseInt(chainId))
+ this.setNetworkState(parseInt(chainId))
})
}