aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/web3_wrapper.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index a0923bef9..7b9a28a7d 100644
--- a/src/web3_wrapper.ts
+++ b/src/web3_wrapper.ts
@@ -51,6 +51,7 @@ export class Web3Wrapper {
}
public async getContractInstanceFromArtifactAsync<A extends Web3.ContractInstance>(artifact: Artifact,
address?: string): Promise<A> {
+ let contractAddress: string;
if (_.isUndefined(address)) {
const networkIdIfExists = await this.getNetworkIdIfExistsAsync();
if (_.isUndefined(networkIdIfExists)) {
@@ -59,14 +60,16 @@ export class Web3Wrapper {
if (_.isUndefined(artifact.networks[networkIdIfExists])) {
throw new Error(ZeroExError.ContractNotDeployedOnNetwork);
}
- address = artifact.networks[networkIdIfExists].address.toLowerCase();
+ contractAddress = artifact.networks[networkIdIfExists].address.toLowerCase();
+ } else {
+ contractAddress = address;
}
- const doesContractExist = await this.doesContractExistAtAddressAsync(address);
+ const doesContractExist = await this.doesContractExistAtAddressAsync(contractAddress);
if (!doesContractExist) {
throw new Error(ZeroExError.ContractDoesNotExist);
}
const contractInstance = this.getContractInstance<A>(
- artifact.abi, address,
+ artifact.abi, contractAddress,
);
return contractInstance;
}