Refactor getContractAddress to contractWrapper

This commit is contained in:
Leonid Logvinov
2017-11-23 09:41:05 -06:00
parent 7bc6a7b23f
commit 34beee1edc
5 changed files with 17 additions and 41 deletions

View File

@@ -104,16 +104,10 @@ export class TokenRegistryWrapper extends ContractWrapper {
* @returns The Ethereum address of the TokenRegistry contract being used.
*/
public getContractAddress(): string {
const networkId = this._web3Wrapper.getNetworkId();
if (_.isUndefined(this._contractAddressIfExists)) {
const contractAddress = artifacts.TokenRegistryArtifact.networks[networkId].address;
if (_.isUndefined(contractAddress)) {
throw new Error(ZeroExError.ExchangeContractDoesNotExist);
}
return contractAddress;
} else {
return this._contractAddressIfExists;
}
const contractAddress = this._getContractAddress(
artifacts.TokenRegistryArtifact, this._contractAddressIfExists,
);
return contractAddress;
}
private _invalidateContractInstance(): void {
delete this._tokenRegistryContractIfExists;