diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-11-06 03:13:37 +0800 |
---|---|---|
committer | Paul Bouchon <mail@bitpshr.net> | 2018-11-06 03:13:37 +0800 |
commit | 86f09e6bb53bb90e524366c1f225cc9005e01a2a (patch) | |
tree | 849bc2eb03e62f0b01df6a4fc4cce9280286cd39 /app | |
parent | 4489a57f2fd32ae4b9b5aa12aede289fa0b03fb1 (diff) | |
download | tangerine-wallet-browser-86f09e6bb53bb90e524366c1f225cc9005e01a2a.tar tangerine-wallet-browser-86f09e6bb53bb90e524366c1f225cc9005e01a2a.tar.gz tangerine-wallet-browser-86f09e6bb53bb90e524366c1f225cc9005e01a2a.tar.bz2 tangerine-wallet-browser-86f09e6bb53bb90e524366c1f225cc9005e01a2a.tar.lz tangerine-wallet-browser-86f09e6bb53bb90e524366c1f225cc9005e01a2a.tar.xz tangerine-wallet-browser-86f09e6bb53bb90e524366c1f225cc9005e01a2a.tar.zst tangerine-wallet-browser-86f09e6bb53bb90e524366c1f225cc9005e01a2a.zip |
network - infura - hardcode net_version and eth_chainId (#5670)
* network - infura - hardcode net_version and eth_chainId
* network - infura - add rinkeby handling
* lint fix
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/controllers/network/createInfuraClient.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/scripts/controllers/network/createInfuraClient.js b/app/scripts/controllers/network/createInfuraClient.js index 326bcb355..c70fa9e38 100644 --- a/app/scripts/controllers/network/createInfuraClient.js +++ b/app/scripts/controllers/network/createInfuraClient.js @@ -1,4 +1,5 @@ const mergeMiddleware = require('json-rpc-engine/src/mergeMiddleware') +const createScaffoldMiddleware = require('json-rpc-engine/src/createScaffoldMiddleware') const createBlockReRefMiddleware = require('eth-json-rpc-middleware/block-ref') const createRetryOnEmptyMiddleware = require('eth-json-rpc-middleware/retryOnEmpty') const createBlockCacheMiddleware = require('eth-json-rpc-middleware/block-cache') @@ -16,6 +17,7 @@ function createInfuraClient ({ network }) { const blockTracker = new BlockTracker({ provider: infuraProvider }) const networkMiddleware = mergeMiddleware([ + createNetworkAndChainIdMiddleware({ network }), createBlockCacheMiddleware({ blockTracker }), createInflightMiddleware(), createBlockReRefMiddleware({ blockTracker, provider: infuraProvider }), @@ -25,3 +27,34 @@ function createInfuraClient ({ network }) { ]) return { networkMiddleware, blockTracker } } + +function createNetworkAndChainIdMiddleware({ network }) { + let chainId + let netId + + switch (network) { + case 'mainnet': + netId = '1' + chainId = '0x01' + break + case 'ropsten': + netId = '3' + chainId = '0x03' + break + case 'rinkeby': + netId = '4' + chainId = '0x04' + break + case 'kovan': + netId = '42' + chainId = '0x2a' + break + default: + throw new Error(`createInfuraClient - unknown network "${network}"`) + } + + return createScaffoldMiddleware({ + eth_chainId: chainId, + net_version: netId, + }) +} |