Make sure we always pass in the correct networkId even if no injectedWeb3 found
This commit is contained in:
parent
598f1dd2d8
commit
1eaefac12b
@ -621,19 +621,24 @@ export class Blockchain {
|
|||||||
// In addition, if the user has an injectedWeb3 instance that is disconnected from a backing
|
// 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
|
// Ethereum node, this call will throw. We need to handle this case gracefully
|
||||||
const injectedWeb3 = (window as any).web3;
|
const injectedWeb3 = (window as any).web3;
|
||||||
let networkId: number;
|
let networkIdIfExists: number;
|
||||||
if (!_.isUndefined(injectedWeb3)) {
|
if (!_.isUndefined(injectedWeb3)) {
|
||||||
try {
|
try {
|
||||||
networkId = _.parseInt(await promisify(injectedWeb3.version.getNetwork)());
|
networkIdIfExists = _.parseInt(await promisify(injectedWeb3.version.getNetwork)());
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Ignore error and proceed with networkId undefined
|
// Ignore error and proceed with networkId undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const provider = await Blockchain.getProviderAsync(injectedWeb3, networkId);
|
const provider = await Blockchain.getProviderAsync(injectedWeb3, networkIdIfExists);
|
||||||
this.zeroEx = new ZeroEx(provider, {
|
const networkId = !_.isUndefined(networkIdIfExists) ? networkIdIfExists :
|
||||||
|
configs.isMainnetEnabled ?
|
||||||
|
constants.MAINNET_NETWORK_ID :
|
||||||
|
constants.TESTNET_NETWORK_ID;
|
||||||
|
const zeroExConfigs = {
|
||||||
networkId,
|
networkId,
|
||||||
});
|
};
|
||||||
|
this.zeroEx = new ZeroEx(provider, zeroExConfigs);
|
||||||
this.updateProviderName(injectedWeb3);
|
this.updateProviderName(injectedWeb3);
|
||||||
const shouldPollUserAddress = true;
|
const shouldPollUserAddress = true;
|
||||||
this.web3Wrapper = new Web3Wrapper(this.dispatcher, provider, networkId, shouldPollUserAddress);
|
this.web3Wrapper = new Web3Wrapper(this.dispatcher, provider, networkId, shouldPollUserAddress);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user