diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-10-10 14:10:33 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-10-16 04:38:33 +0800 |
commit | 1e9ea09f087c7b3120e758d931a88812b655da08 (patch) | |
tree | b0da3efc0733d566356ed2a938d18eb08192f674 /packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts | |
parent | fa346d94613a43034e1cdaf6b7a3d2de270c58fc (diff) | |
download | dexon-0x-contracts-1e9ea09f087c7b3120e758d931a88812b655da08.tar dexon-0x-contracts-1e9ea09f087c7b3120e758d931a88812b655da08.tar.gz dexon-0x-contracts-1e9ea09f087c7b3120e758d931a88812b655da08.tar.bz2 dexon-0x-contracts-1e9ea09f087c7b3120e758d931a88812b655da08.tar.lz dexon-0x-contracts-1e9ea09f087c7b3120e758d931a88812b655da08.tar.xz dexon-0x-contracts-1e9ea09f087c7b3120e758d931a88812b655da08.tar.zst dexon-0x-contracts-1e9ea09f087c7b3120e758d931a88812b655da08.zip |
Introduce new contract-addresses package and use it everywhere
Diffstat (limited to 'packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts')
-rw-r--r-- | packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts index 22fc916e2..b72a77e8b 100644 --- a/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/forwarder_wrapper.ts @@ -27,12 +27,36 @@ export class ForwarderWrapper extends ContractWrapper { public zrxTokenAddress: string; public etherTokenAddress: string; private _forwarderContractIfExists?: ForwarderContract; - // TODO(albrow): Make addresses optional? - constructor(web3Wrapper: Web3Wrapper, address: string, zrxTokenAddress: string, etherTokenAddress: string) { - super(web3Wrapper); - this.address = address; - this.zrxTokenAddress = zrxTokenAddress; - this.etherTokenAddress = etherTokenAddress; + + /** + * Instantiate ForwarderWrapper + * @param web3Wrapper Web3Wrapper instance to use. + * @param networkId Desired networkId. + * @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 etherTokenAddress (Optional) The address of a WETH (Ether token) + * contract. If undefined, will default to the known address corresponding + * to the networkId. + */ + constructor( + web3Wrapper: Web3Wrapper, + networkId: number, + address?: string, + zrxTokenAddress?: string, + etherTokenAddress?: string, + ) { + super(web3Wrapper, networkId); + this.address = _.isUndefined(address) ? this._getDefaultContractAddresses().exchange : address; + this.zrxTokenAddress = _.isUndefined(zrxTokenAddress) + ? this._getDefaultContractAddresses().zrxToken + : zrxTokenAddress; + this.etherTokenAddress = _.isUndefined(etherTokenAddress) + ? this._getDefaultContractAddresses().etherToken + : etherTokenAddress; } /** * Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value. |