diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-10-30 07:43:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-30 07:43:25 +0800 |
commit | 18e530221b0f960907d45995c4703b04ed562dc8 (patch) | |
tree | 9cded0c40efff79e4653abd76f56c5e458205fdc /app/scripts | |
parent | 2baa57bc4af1cf308b01d06d2e8e6ca41700073a (diff) | |
parent | bc7f8d0a5bf42b73ee1d1102362fc0a94dc80c0d (diff) | |
download | tangerine-wallet-browser-18e530221b0f960907d45995c4703b04ed562dc8.tar tangerine-wallet-browser-18e530221b0f960907d45995c4703b04ed562dc8.tar.gz tangerine-wallet-browser-18e530221b0f960907d45995c4703b04ed562dc8.tar.bz2 tangerine-wallet-browser-18e530221b0f960907d45995c4703b04ed562dc8.tar.lz tangerine-wallet-browser-18e530221b0f960907d45995c4703b04ed562dc8.tar.xz tangerine-wallet-browser-18e530221b0f960907d45995c4703b04ed562dc8.tar.zst tangerine-wallet-browser-18e530221b0f960907d45995c4703b04ed562dc8.zip |
Merge pull request #5552 from EthersocialNetwork/eth_chainid
network - check eth_chainId and fallback to net_version
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/controllers/network/network.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index b459b8013..c21e9c764 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -107,10 +107,20 @@ module.exports = class NetworkController extends EventEmitter { } var { type } = this.providerStore.getState() 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, type) + // first attempt to perform lookup via eth_chainId + ethQuery.sendAsync({ method: 'eth_chainId' }, (err, chainIdHex) => { + if (err) { + // if eth_chainId is not supported, fallback to net_verion + ethQuery.sendAsync({ method: 'net_version' }, (err, network) => { + if (err) return this.setNetworkState('loading') + log.info(`net_version returned ${network}`) + this.setNetworkState(network, type) + }) + return + } + const chainId = Number.parseInt(chainIdHex, 16) + log.info(`net_version returned ${chainId}`) + this.setNetworkState(chainId, type) }) } |