diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-10-30 17:34:26 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-10-31 00:49:16 +0800 |
commit | 7bf6e6188aad6f5ae3de4fe04074abed33c73c53 (patch) | |
tree | b46532a85b2d0d7deb94467e71c9e5ca8864adfe /src/mempool | |
parent | 26394813f4824590bac00da05ab1026aa360c77f (diff) | |
download | dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar.gz dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar.bz2 dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar.lz dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar.xz dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.tar.zst dexon-sol-tools-7bf6e6188aad6f5ae3de4fe04074abed33c73c53.zip |
Move provider altering logic to Web3Wrapper
Diffstat (limited to 'src/mempool')
-rw-r--r-- | src/mempool/order_watcher.ts | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mempool/order_watcher.ts b/src/mempool/order_watcher.ts index 90c15cd34..b2c8598e7 100644 --- a/src/mempool/order_watcher.ts +++ b/src/mempool/order_watcher.ts @@ -1,22 +1,23 @@ -import * as Web3 from 'web3'; import * as _ from 'lodash'; -import {Web3Provider, SignedOrder} from '../types'; +import {ZeroEx} from '../'; +import {assert} from '../utils/assert'; +import {Web3Provider, SignedOrder, OnOrderFillabilityStateChangeCallback} from '../types'; import {Web3Wrapper} from '../web3_wrapper'; export class OrderWatcher { + private _orders = new Map<string, SignedOrder>(); + private _web3Wrapper: Web3Wrapper; constructor(provider: Web3Provider) { - if (_.isUndefined((provider as any).sendAsync)) { - // Web3@1.0 provider doesn't support synchronous http requests, - // so it only has an async `send` method, instead of a `send` and `sendAsync` in web3@0.x.x` - // We re-assign the send method so that Web3@1.0 providers work with 0x.js - (provider as any).sendAsync = (provider as any).send; - } + assert.isWeb3Provider('provider', provider); + this._web3Wrapper = new Web3Wrapper(provider); } public addOrder(signedOrder: SignedOrder): void { - // + const orderHash = ZeroEx.getOrderHashHex(signedOrder); + this._orders.set(orderHash, signedOrder); } public removeOrder(signedOrder: SignedOrder): void { - // + const orderHash = ZeroEx.getOrderHashHex(signedOrder); + this._orders.delete(orderHash); } public subscribe(callback: OnOrderFillabilityStateChangeCallback): void { // |