diff options
author | Fabio Berger <me@fabioberger.com> | 2017-11-10 12:24:46 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-11-10 12:24:46 +0800 |
commit | 0cd5bf796766f653999591607a2ee87706f80383 (patch) | |
tree | 733b2bb5e8c8b32bc7c3a4553ae57e1c48cf8682 | |
parent | 0205f9ede337e5574245b45e1ee940b8ace89456 (diff) | |
download | dexon-sol-tools-0cd5bf796766f653999591607a2ee87706f80383.tar dexon-sol-tools-0cd5bf796766f653999591607a2ee87706f80383.tar.gz dexon-sol-tools-0cd5bf796766f653999591607a2ee87706f80383.tar.bz2 dexon-sol-tools-0cd5bf796766f653999591607a2ee87706f80383.tar.lz dexon-sol-tools-0cd5bf796766f653999591607a2ee87706f80383.tar.xz dexon-sol-tools-0cd5bf796766f653999591607a2ee87706f80383.tar.zst dexon-sol-tools-0cd5bf796766f653999591607a2ee87706f80383.zip |
Make sure to set the defaultBlock to the blockNumber rather then the number of confirmations
-rw-r--r-- | src/order_watcher/order_state_watcher.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/order_watcher/order_state_watcher.ts b/src/order_watcher/order_state_watcher.ts index fa91d1f44..303ec8bd3 100644 --- a/src/order_watcher/order_state_watcher.ts +++ b/src/order_watcher/order_state_watcher.ts @@ -1,5 +1,6 @@ import * as _ from 'lodash'; import {schemas} from '0x-json-schemas'; +import * as ethUtil from 'ethereumjs-util'; import {ZeroEx} from '../0x'; import {EventWatcher} from './event_watcher'; import {assert} from '../utils/assert'; @@ -115,6 +116,9 @@ export class OrderStateWatcher { if (!isDecodedLog) { return; // noop } + const blockNumberBuff = ethUtil.toBuffer(maybeDecodedLog.blockNumber); + const blockNumber = ethUtil.bufferToInt(blockNumberBuff); + const decodedLog = maybeDecodedLog as LogWithDecodedArgs<any>; let makerToken: string; let makerAddress: string; @@ -126,7 +130,7 @@ export class OrderStateWatcher { orderHashesSet = _.get(this._dependentOrderHashes, [makerAddress, makerToken]); if (!_.isUndefined(orderHashesSet)) { const orderHashes = Array.from(orderHashesSet); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, blockNumber); } break; @@ -136,7 +140,7 @@ export class OrderStateWatcher { orderHashesSet = _.get(this._dependentOrderHashes, [makerAddress, makerToken]); if (!_.isUndefined(orderHashesSet)) { const orderHashes = Array.from(orderHashesSet); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, blockNumber); } break; @@ -145,7 +149,7 @@ export class OrderStateWatcher { const orderHash = decodedLog.args.orderHash; const isOrderWatched = !_.isUndefined(this._orders[orderHash]); if (isOrderWatched) { - await this._emitRevalidateOrdersAsync([orderHash]); + await this._emitRevalidateOrdersAsync([orderHash], blockNumber); } break; @@ -156,10 +160,10 @@ export class OrderStateWatcher { throw utils.spawnSwitchErr('decodedLog.event', decodedLog.event); } } - private async _emitRevalidateOrdersAsync(orderHashes: string[]): Promise<void> { + private async _emitRevalidateOrdersAsync(orderHashes: string[], blockNumber: number): Promise<void> { const defaultBlock = this._numConfirmations === 0 ? BlockParamLiteral.Pending : - this._numConfirmations; + blockNumber; const methodOpts = { defaultBlock, }; |