diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-12-08 19:46:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-08 19:46:51 +0800 |
commit | 36125c3539fce6f67d62ab3378bbf09653a1c3c1 (patch) | |
tree | 053c7b62f54be4447fb352c84a8452da5f92b697 /packages/website/ts/blockchain.ts | |
parent | b362e2c28e9cafa7335bced17ec61fba93b018e6 (diff) | |
parent | 72ced622d7fddac4d17b7814f45aeea01db23959 (diff) | |
download | dexon-sol-tools-36125c3539fce6f67d62ab3378bbf09653a1c3c1.tar dexon-sol-tools-36125c3539fce6f67d62ab3378bbf09653a1c3c1.tar.gz dexon-sol-tools-36125c3539fce6f67d62ab3378bbf09653a1c3c1.tar.bz2 dexon-sol-tools-36125c3539fce6f67d62ab3378bbf09653a1c3c1.tar.lz dexon-sol-tools-36125c3539fce6f67d62ab3378bbf09653a1c3c1.tar.xz dexon-sol-tools-36125c3539fce6f67d62ab3378bbf09653a1c3c1.tar.zst dexon-sol-tools-36125c3539fce6f67d62ab3378bbf09653a1c3c1.zip |
Merge branch 'development' into feature/web3-wrapper
Diffstat (limited to 'packages/website/ts/blockchain.ts')
-rw-r--r-- | packages/website/ts/blockchain.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index 9136dc916..24205802d 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -621,19 +621,24 @@ export class Blockchain { // In addition, if the user has an injectedWeb3 instance that is disconnected from a backing // Ethereum node, this call will throw. We need to handle this case gracefully const injectedWeb3 = (window as any).web3; - let networkId: number; + let networkIdIfExists: number; if (!_.isUndefined(injectedWeb3)) { try { - networkId = _.parseInt(await promisify<string>(injectedWeb3.version.getNetwork)()); + networkIdIfExists = _.parseInt(await promisify<string>(injectedWeb3.version.getNetwork)()); } catch (err) { // Ignore error and proceed with networkId undefined } } - const provider = await Blockchain.getProviderAsync(injectedWeb3, networkId); - this.zeroEx = new ZeroEx(provider, { + const provider = await Blockchain.getProviderAsync(injectedWeb3, networkIdIfExists); + const networkId = !_.isUndefined(networkIdIfExists) ? networkIdIfExists : + configs.isMainnetEnabled ? + constants.MAINNET_NETWORK_ID : + constants.TESTNET_NETWORK_ID; + const zeroExConfigs = { networkId, - }); + }; + this.zeroEx = new ZeroEx(provider, zeroExConfigs); this.updateProviderName(injectedWeb3); const shouldPollUserAddress = true; this.web3Wrapper = new Web3Wrapper(this.dispatcher, provider, networkId, shouldPollUserAddress); |