diff options
-rw-r--r-- | src/mempool/order_state_watcher.ts | 9 | ||||
-rw-r--r-- | test/order_state_watcher_test.ts | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/mempool/order_state_watcher.ts b/src/mempool/order_state_watcher.ts index dc24d5b4a..528b8ceff 100644 --- a/src/mempool/order_state_watcher.ts +++ b/src/mempool/order_state_watcher.ts @@ -56,9 +56,12 @@ export class OrderStateWatcher { this._orders[orderHash] = signedOrder; this.addToDependentOrderHashes(signedOrder, orderHash); } - public removeOrder(signedOrder: SignedOrder): void { - assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema); - const orderHash = ZeroEx.getOrderHashHex(signedOrder); + public removeOrder(orderHash: string): void { + assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema); + const signedOrder = this._orders[orderHash]; + if (_.isUndefined(signedOrder)) { + return; + } delete this._orders[orderHash]; this._dependentOrderHashes[signedOrder.maker][signedOrder.makerTokenAddress].delete(orderHash); // We currently do not remove the maker/makerToken keys from the mapping when all orderHashes removed diff --git a/test/order_state_watcher_test.ts b/test/order_state_watcher_test.ts index f1b027c40..f5fc5d4ea 100644 --- a/test/order_state_watcher_test.ts +++ b/test/order_state_watcher_test.ts @@ -57,7 +57,7 @@ describe('OrderStateWatcher', () => { afterEach(async () => { zeroEx.orderStateWatcher.unsubscribe(); const orderHash = ZeroEx.getOrderHashHex(signedOrder); - zeroEx.orderStateWatcher.removeOrder(signedOrder); + zeroEx.orderStateWatcher.removeOrder(orderHash); }); it('should emit orderStateInvalid when maker allowance set to 0 for watched order', (done: DoneCallback) => { (async () => { |