diff options
Diffstat (limited to 'packages/0x.js/src')
-rw-r--r-- | packages/0x.js/src/0x.ts | 23 | ||||
-rw-r--r-- | packages/0x.js/src/types.ts | 4 |
2 files changed, 10 insertions, 17 deletions
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts index 85c2b7724..1f4af9fea 100644 --- a/packages/0x.js/src/0x.ts +++ b/packages/0x.js/src/0x.ts @@ -169,17 +169,14 @@ export class ZeroEx { * @param config The configuration object. Look up the type for the description. * @return An instance of the 0x.js ZeroEx class. */ - constructor(provider: Web3Provider, config?: ZeroExConfig) { + constructor(provider: Web3Provider, config: ZeroExConfig) { assert.isWeb3Provider('provider', provider); - if (!_.isUndefined(config)) { - assert.doesConformToSchema('config', config, zeroExConfigSchema); - } + assert.doesConformToSchema('config', config, zeroExConfigSchema); const artifactJSONs = _.values(artifacts); const abiArrays = _.map(artifactJSONs, artifact => artifact.abi); this._abiDecoder = new AbiDecoder(abiArrays); - const gasPrice = _.isUndefined(config) ? undefined : config.gasPrice; const defaults = { - gasPrice, + gasPrice: config.gasPrice, }; this._web3Wrapper = new Web3Wrapper(provider, defaults); this.token = new TokenWrapper( @@ -187,26 +184,20 @@ export class ZeroEx { this._abiDecoder, this._getTokenTransferProxyAddressAsync.bind(this), ); - const exchageContractAddressIfExists = _.isUndefined(config) ? undefined : config.exchangeContractAddress; this.exchange = new ExchangeWrapper( this._web3Wrapper, this._abiDecoder, this.token, - exchageContractAddressIfExists, + config.exchangeContractAddress, ); this.proxy = new TokenTransferProxyWrapper( this._web3Wrapper, this._getTokenTransferProxyAddressAsync.bind(this), ); - const tokenRegistryContractAddressIfExists = _.isUndefined(config) ? - undefined : - config.tokenRegistryContractAddress; - this.tokenRegistry = new TokenRegistryWrapper(this._web3Wrapper, tokenRegistryContractAddressIfExists); - const etherTokenContractAddressIfExists = _.isUndefined(config) ? undefined : config.etherTokenContractAddress; - this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token, etherTokenContractAddressIfExists); - const orderWatcherConfig = _.isUndefined(config) ? undefined : config.orderWatcherConfig; + this.tokenRegistry = new TokenRegistryWrapper(this._web3Wrapper, config.tokenRegistryContractAddress); + this.etherToken = new EtherTokenWrapper(this._web3Wrapper, this.token, config.etherTokenContractAddress); this.orderStateWatcher = new OrderStateWatcher( - this._web3Wrapper, this._abiDecoder, this.token, this.exchange, orderWatcherConfig, + this._web3Wrapper, this._abiDecoder, this.token, this.exchange, config.orderWatcherConfig, ); } /** diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts index ac4106d0b..d34bb02b6 100644 --- a/packages/0x.js/src/types.ts +++ b/packages/0x.js/src/types.ts @@ -407,6 +407,7 @@ export interface OrderStateWatcherConfig { } /* + * networkId: The id of the underlying ethereum network the provider is connected to. (1-mainnet, 42-kovan, 50-testrpc) * gasPrice: Gas price to use with every transaction * exchangeContractAddress: The address of an exchange contract to use * tokenRegistryContractAddress: The address of a token registry contract to use @@ -414,7 +415,8 @@ export interface OrderStateWatcherConfig { * orderWatcherConfig: All the configs related to the orderWatcher */ export interface ZeroExConfig { - gasPrice?: BigNumber; // Gas price to use with every transaction + networkId: number; + gasPrice?: BigNumber; exchangeContractAddress?: string; tokenRegistryContractAddress?: string; etherTokenContractAddress?: string; |