diff options
Diffstat (limited to 'packages/0x.js/src/0x.ts')
-rw-r--r-- | packages/0x.js/src/0x.ts | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts index 0dd728ff1..7627f1d6e 100644 --- a/packages/0x.js/src/0x.ts +++ b/packages/0x.js/src/0x.ts @@ -15,7 +15,7 @@ import { OrderStateWatcher } from './order_watcher/order_state_watcher'; import { zeroExConfigSchema } from './schemas/zero_ex_config_schema'; import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema'; import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema'; -import { Web3Provider, ZeroExConfig, ZeroExError } from './types'; +import { OrderStateWatcherConfig, ZeroExConfig, ZeroExError } from './types'; import { assert } from './utils/assert'; import { constants } from './utils/constants'; import { decorators } from './utils/decorators'; @@ -57,11 +57,6 @@ export class ZeroEx { * tokenTransferProxy smart contract. */ public proxy: TokenTransferProxyWrapper; - /** - * An instance of the OrderStateWatcher class containing methods for watching a set of orders for relevant - * blockchain state changes. - */ - public orderStateWatcher: OrderStateWatcher; private _web3Wrapper: Web3Wrapper; private _abiDecoder: AbiDecoder; /** @@ -197,13 +192,6 @@ export class ZeroEx { config.tokenRegistryContractAddress, ); this.etherToken = new EtherTokenWrapper(this._web3Wrapper, config.networkId, this._abiDecoder, this.token); - this.orderStateWatcher = new OrderStateWatcher( - this._web3Wrapper, - this._abiDecoder, - this.token, - this.exchange, - config.orderWatcherConfig, - ); } /** * Sets a new web3 provider for 0x.js. Updating the provider will stop all @@ -336,6 +324,21 @@ export class ZeroEx { const txReceipt = await txReceiptPromise; return txReceipt; } + /** + * Instantiates and returns a new OrderStateWatcher instance. + * Defaults to watching the pending state. + * @param config The configuration object. Look up the type for the description. + * @return An instance of the 0x.js OrderStateWatcher class. + */ + public createOrderStateWatcher(config?: OrderStateWatcherConfig) { + return new OrderStateWatcher( + this._web3Wrapper, + this._abiDecoder, + this.token, + this.exchange, + config, + ); + } /* * HACK: `TokenWrapper` needs a token transfer proxy address. `TokenTransferProxy` address is fetched from * an `ExchangeWrapper`. `ExchangeWrapper` needs `TokenWrapper` to validate orders, creating a dependency cycle. |