diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-31 01:56:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-31 01:56:16 +0800 |
commit | 644da2b0cbe83ae1f2857764c1d092bc4d7ea824 (patch) | |
tree | ef4bbcf452b2665e4503a7521181adcb3b987a5e /packages/0x.js/src/0x.ts | |
parent | 6122840241a47119b046b639e326cfead1ea3e10 (diff) | |
parent | 57446d78f14fa1a2ae4d64e4c470095a01c7396e (diff) | |
download | dexon-sol-tools-644da2b0cbe83ae1f2857764c1d092bc4d7ea824.tar dexon-sol-tools-644da2b0cbe83ae1f2857764c1d092bc4d7ea824.tar.gz dexon-sol-tools-644da2b0cbe83ae1f2857764c1d092bc4d7ea824.tar.bz2 dexon-sol-tools-644da2b0cbe83ae1f2857764c1d092bc4d7ea824.tar.lz dexon-sol-tools-644da2b0cbe83ae1f2857764c1d092bc4d7ea824.tar.xz dexon-sol-tools-644da2b0cbe83ae1f2857764c1d092bc4d7ea824.tar.zst dexon-sol-tools-644da2b0cbe83ae1f2857764c1d092bc4d7ea824.zip |
Merge pull request #488 from avonian/development
Monitor different state layers with OrderWatcher
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. |