From 0c74d5ba0157429f7f4651dcfe750bf00360962c Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 23 Nov 2017 13:48:44 -0600 Subject: Move variable declaration inside the if --- packages/0x.js/src/contract_wrappers/contract_wrapper.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'packages') diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts index 522b40d52..395d974b2 100644 --- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts @@ -96,6 +96,18 @@ export class ContractWrapper { await this._web3Wrapper.getContractInstanceFromArtifactAsync(artifact, addressIfExists); return contractInstance; } + protected _getContractAddress(artifact: Artifact, addressIfExists?: string): string { + if (_.isUndefined(addressIfExists)) { + const networkId = this._web3Wrapper.getNetworkId(); + const contractAddress = artifact.networks[networkId].address; + if (_.isUndefined(contractAddress)) { + throw new Error(ZeroExError.ExchangeContractDoesNotExist); + } + return contractAddress; + } else { + return addressIfExists; + } + } private _onLogStateChanged(isRemoved: boolean, log: Web3.LogEntry): void { _.forEach(this._filters, (filter: Web3.FilterObject, filterToken: string) => { if (filterUtils.matchesFilter(log, filter)) { -- cgit v1.2.3