Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// If networkName is undefined, it means the network doesn't exist
if (typeof this.networkName === 'undefined') {
throw Error(`The network id ${web3Connection.networkId} doesn't exist`);
}
this.hashStorageAddress = SmartContracts.requestHashStorageArtifact.getAddress(
this.networkName,
);
this.hashSubmitterAddress = SmartContracts.requestHashSubmitterArtifact.getAddress(
this.networkName,
);
// Initialize smart contract instance
this.requestHashStorage = new this.eth.Contract(
SmartContracts.requestHashStorageArtifact.getContractAbi(),
this.hashStorageAddress,
);
this.requestHashSubmitter = new this.eth.Contract(
SmartContracts.requestHashSubmitterArtifact.getContractAbi(),
this.hashSubmitterAddress,
);
this.timeout = web3Connection.timeout || config.getDefaultEthereumProviderTimeout();
this.creationBlockNumberHashStorage =
SmartContracts.requestHashStorageArtifact.getCreationBlockNumber(this.networkName) || 0;
this.ethereumBlocks = new EthereumBlocks(
this.eth,
this.creationBlockNumberHashStorage,
this.retryDelay || config.getEthereumRetryDelay(),
throw Error(`Can't initialize web3-eth ${error}`);
}
// Checks if networkId is defined
// If not defined we use default value from config
this.networkName =
typeof web3Connection.networkId === 'undefined'
? config.getDefaultEthereumNetwork()
: EthereumUtils.getEthereumNetworkNameFromId(web3Connection.networkId);
// If networkName is undefined, it means the network doesn't exist
if (typeof this.networkName === 'undefined') {
throw Error(`The network id ${web3Connection.networkId} doesn't exist`);
}
this.hashStorageAddress = SmartContracts.requestHashStorageArtifact.getAddress(
this.networkName,
);
this.hashSubmitterAddress = SmartContracts.requestHashSubmitterArtifact.getAddress(
this.networkName,
);
// Initialize smart contract instance
this.requestHashStorage = new this.eth.Contract(
SmartContracts.requestHashStorageArtifact.getContractAbi(),
this.hashStorageAddress,
);
this.requestHashSubmitter = new this.eth.Contract(
SmartContracts.requestHashSubmitterArtifact.getContractAbi(),
this.hashSubmitterAddress,
);
// If not defined we use default value from config
this.networkName =
typeof web3Connection.networkId === 'undefined'
? config.getDefaultEthereumNetwork()
: EthereumUtils.getEthereumNetworkNameFromId(web3Connection.networkId);
// If networkName is undefined, it means the network doesn't exist
if (typeof this.networkName === 'undefined') {
throw Error(`The network id ${web3Connection.networkId} doesn't exist`);
}
this.hashStorageAddress = SmartContracts.requestHashStorageArtifact.getAddress(
this.networkName,
);
this.hashSubmitterAddress = SmartContracts.requestHashSubmitterArtifact.getAddress(
this.networkName,
);
// Initialize smart contract instance
this.requestHashStorage = new this.eth.Contract(
SmartContracts.requestHashStorageArtifact.getContractAbi(),
this.hashStorageAddress,
);
this.requestHashSubmitter = new this.eth.Contract(
SmartContracts.requestHashSubmitterArtifact.getContractAbi(),
this.hashSubmitterAddress,
);
this.timeout = web3Connection.timeout || config.getDefaultEthereumProviderTimeout();
this.creationBlockNumberHashStorage =
this.hashStorageAddress = SmartContracts.requestHashStorageArtifact.getAddress(
this.networkName,
);
this.hashSubmitterAddress = SmartContracts.requestHashSubmitterArtifact.getAddress(
this.networkName,
);
// Initialize smart contract instance
this.requestHashStorage = new this.eth.Contract(
SmartContracts.requestHashStorageArtifact.getContractAbi(),
this.hashStorageAddress,
);
this.requestHashSubmitter = new this.eth.Contract(
SmartContracts.requestHashSubmitterArtifact.getContractAbi(),
this.hashSubmitterAddress,
);
this.timeout = web3Connection.timeout || config.getDefaultEthereumProviderTimeout();
this.creationBlockNumberHashStorage =
SmartContracts.requestHashStorageArtifact.getCreationBlockNumber(this.networkName) || 0;
this.ethereumBlocks = new EthereumBlocks(
this.eth,
this.creationBlockNumberHashStorage,
this.retryDelay || config.getEthereumRetryDelay(),
this.maxRetries || config.getEthereumMaxRetries(),
getLastBlockNumberDelay,
this.logger,
);