From ec22097efb61d27aa73c979758bc0231cea7d61d Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 5 Sep 2017 13:49:47 +0200 Subject: Don't override function arguments --- src/web3_wrapper.ts | 9 ++++++--- 1 file 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(artifact: Artifact, address?: string): Promise { + 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( - artifact.abi, address, + artifact.abi, contractAddress, ); return contractInstance; } -- cgit v1.2.3