From 1e9ea09f087c7b3120e758d931a88812b655da08 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 9 Oct 2018 23:10:33 -0700 Subject: Introduce new contract-addresses package and use it everywhere --- .../src/contract_wrappers/exchange_wrapper.ts | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts') diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts index 6b3694bc5..b185b7e0c 100644 --- a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts @@ -50,26 +50,33 @@ export class ExchangeWrapper extends ContractWrapper { /** * Instantiate ExchangeWrapper * @param web3Wrapper Web3Wrapper instance to use. + * @param networkId Desired networkId. * @param erc20TokenWrapper ERC20TokenWrapper instance to use. * @param erc721TokenWrapper ERC721TokenWrapper instance to use. - * @param address The address of the Exchange contract. - * @param zrxTokenAddress The address of the ZRX Token contract. + * @param address (Optional) The address of the Exchange contract. If + * undefined, will default to the known address corresponding to the + * networkId. + * @param zrxTokenAddress (Optional) The address of the ZRXToken contract. + * If undefined, will default to the known address corresponding to the + * networkId. * @param blockPollingIntervalMs The block polling interval to use for active subscriptions. */ constructor( web3Wrapper: Web3Wrapper, + networkId: number, erc20TokenWrapper: ERC20TokenWrapper, erc721TokenWrapper: ERC721TokenWrapper, - // TODO(albrow): Make address optional? - address: string, - zrxTokenAddress: string, + address?: string, + zrxTokenAddress?: string, blockPollingIntervalMs?: number, ) { - super(web3Wrapper, blockPollingIntervalMs); + super(web3Wrapper, networkId, blockPollingIntervalMs); this._erc20TokenWrapper = erc20TokenWrapper; this._erc721TokenWrapper = erc721TokenWrapper; - this.address = address; - this.zrxTokenAddress = zrxTokenAddress; + this.address = _.isUndefined(address) ? this._getDefaultContractAddresses().exchange : address; + this.zrxTokenAddress = _.isUndefined(zrxTokenAddress) + ? this._getDefaultContractAddresses().zrxToken + : zrxTokenAddress; } /** * Retrieve the address of an asset proxy by signature. -- cgit v1.2.3