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.ts | |
parent | fa346d94613a43034e1cdaf6b7a3d2de270c58fc (diff) | |
download | dexon-sol-tools-1e9ea09f087c7b3120e758d931a88812b655da08.tar dexon-sol-tools-1e9ea09f087c7b3120e758d931a88812b655da08.tar.gz dexon-sol-tools-1e9ea09f087c7b3120e758d931a88812b655da08.tar.bz2 dexon-sol-tools-1e9ea09f087c7b3120e758d931a88812b655da08.tar.lz dexon-sol-tools-1e9ea09f087c7b3120e758d931a88812b655da08.tar.xz dexon-sol-tools-1e9ea09f087c7b3120e758d931a88812b655da08.tar.zst dexon-sol-tools-1e9ea09f087c7b3120e758d931a88812b655da08.zip |
Introduce new contract-addresses package and use it everywhere
Diffstat (limited to 'packages/contract-wrappers/src/contract_wrappers.ts')
-rw-r--r-- | packages/contract-wrappers/src/contract_wrappers.ts | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers.ts b/packages/contract-wrappers/src/contract_wrappers.ts index 359307da4..25acf823d 100644 --- a/packages/contract-wrappers/src/contract_wrappers.ts +++ b/packages/contract-wrappers/src/contract_wrappers.ts @@ -1,3 +1,4 @@ +import { getContractAddressesForNetwork } from '@0xproject/contract-addresses'; import { ERC20Proxy, ERC20Token, @@ -100,29 +101,50 @@ export class ContractWrappers { const blockPollingIntervalMs = _.isUndefined(config.blockPollingIntervalMs) ? constants.DEFAULT_BLOCK_POLLING_INTERVAL : config.blockPollingIntervalMs; - if (_.isUndefined(config.contractAddresses.erc20Proxy)) { - throw new Error('config.contractAddresses.erc20Proxy is required for testing'); - } - this.erc20Proxy = new ERC20ProxyWrapper(this._web3Wrapper, config.contractAddresses.erc20Proxy); - this.erc721Proxy = new ERC721ProxyWrapper(this._web3Wrapper, config.contractAddresses.erc721Proxy); - this.erc20Token = new ERC20TokenWrapper(this._web3Wrapper, this.erc20Proxy, blockPollingIntervalMs); - this.erc721Token = new ERC721TokenWrapper(this._web3Wrapper, this.erc721Proxy, blockPollingIntervalMs); - this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.erc20Token, blockPollingIntervalMs); + const contractAddresses = _.isUndefined(config.contractAddresses) + ? getContractAddressesForNetwork(config.networkId) + : config.contractAddresses; + this.erc20Proxy = new ERC20ProxyWrapper(this._web3Wrapper, config.networkId, contractAddresses.erc20Proxy); + this.erc721Proxy = new ERC721ProxyWrapper(this._web3Wrapper, config.networkId, contractAddresses.erc721Proxy); + this.erc20Token = new ERC20TokenWrapper( + this._web3Wrapper, + config.networkId, + this.erc20Proxy, + blockPollingIntervalMs, + ); + this.erc721Token = new ERC721TokenWrapper( + this._web3Wrapper, + config.networkId, + this.erc721Proxy, + blockPollingIntervalMs, + ); + this.etherToken = new EtherTokenWrapper( + this._web3Wrapper, + config.networkId, + this.erc20Token, + blockPollingIntervalMs, + ); this.exchange = new ExchangeWrapper( this._web3Wrapper, + config.networkId, this.erc20Token, this.erc721Token, - config.contractAddresses.exchange, - config.contractAddresses.zrxToken, + contractAddresses.exchange, + contractAddresses.zrxToken, blockPollingIntervalMs, ); this.forwarder = new ForwarderWrapper( this._web3Wrapper, - config.contractAddresses.forwarder, - config.contractAddresses.zrxToken, - config.contractAddresses.etherToken, + config.networkId, + contractAddresses.forwarder, + contractAddresses.zrxToken, + contractAddresses.etherToken, + ); + this.orderValidator = new OrderValidatorWrapper( + this._web3Wrapper, + config.networkId, + contractAddresses.orderValidator, ); - this.orderValidator = new OrderValidatorWrapper(this._web3Wrapper, config.contractAddresses.orderValidator); } /** * Sets a new web3 provider for 0x.js. Updating the provider will stop all |