diff options
author | F. Eugene Aumson <feuGeneA@users.noreply.github.com> | 2018-09-25 01:30:37 +0800 |
---|---|---|
committer | F. Eugene Aumson <feuGeneA@users.noreply.github.com> | 2018-09-25 01:30:37 +0800 |
commit | 2116548eed666c3c61277f17e996fee720301f31 (patch) | |
tree | 6f4b601b59659ac9134ffe4efed79c8a8a2750e0 /packages/order-watcher | |
parent | 57fca16d7b1dc61c060c90fa440b1dc947aefb93 (diff) | |
parent | b830c28d83a33c0170d4f150ee287ea97ccf7865 (diff) | |
download | dexon-sol-tools-2116548eed666c3c61277f17e996fee720301f31.tar dexon-sol-tools-2116548eed666c3c61277f17e996fee720301f31.tar.gz dexon-sol-tools-2116548eed666c3c61277f17e996fee720301f31.tar.bz2 dexon-sol-tools-2116548eed666c3c61277f17e996fee720301f31.tar.lz dexon-sol-tools-2116548eed666c3c61277f17e996fee720301f31.tar.xz dexon-sol-tools-2116548eed666c3c61277f17e996fee720301f31.tar.zst dexon-sol-tools-2116548eed666c3c61277f17e996fee720301f31.zip |
Merge remote-tracking branch 'upstream/development' into sol-doc
Diffstat (limited to 'packages/order-watcher')
-rw-r--r-- | packages/order-watcher/CHANGELOG.json | 9 | ||||
-rw-r--r-- | packages/order-watcher/CHANGELOG.md | 4 | ||||
-rw-r--r-- | packages/order-watcher/package.json | 32 | ||||
-rw-r--r-- | packages/order-watcher/src/order_watcher/event_watcher.ts | 19 |
4 files changed, 44 insertions, 20 deletions
diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index 8d8aaf702..dec154f0f 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "timestamp": 1537541580, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.0.3", "changes": [ { diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md index e79bf638e..a4e1cc79f 100644 --- a/packages/order-watcher/CHANGELOG.md +++ b/packages/order-watcher/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 19, 2018_ * Drastically reduce the bundle size by removing unused parts of included contract artifacts. diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index a07e0f795..8ce57364f 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/order-watcher", - "version": "1.0.3", + "version": "1.0.4", "description": "An order watcher daemon that watches for order validity", "keywords": [ "0x", @@ -42,14 +42,14 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/abi-gen": "^1.0.8", - "@0xproject/dev-utils": "^1.0.7", - "@0xproject/migrations": "^1.0.9", + "@0xproject/abi-gen": "^1.0.9", + "@0xproject/dev-utils": "^1.0.8", + "@0xproject/migrations": "^1.0.10", "@0xproject/tslint-config": "^1.0.7", "@types/bintrees": "^1.0.2", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/sinon": "^2.2.2", "awesome-typescript-loader": "^3.1.3", "chai": "^4.0.1", @@ -70,18 +70,18 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/base-contract": "^2.0.2", - "@0xproject/contract-wrappers": "^1.0.3", - "@0xproject/fill-scenarios": "^1.0.2", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", + "@0xproject/assert": "^1.0.9", + "@0xproject/base-contract": "^2.0.3", + "@0xproject/contract-wrappers": "^1.0.4", + "@0xproject/fill-scenarios": "^1.0.3", + "@0xproject/json-schemas": "^1.0.2", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", "bintrees": "^1.0.2", - "ethereum-types": "^1.0.6", + "ethereum-types": "^1.0.7", "ethereumjs-blockstream": "5.0.0", "ethers": "3.0.22", "lodash": "^4.17.5" diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts index 9509c75de..eca235e26 100644 --- a/packages/order-watcher/src/order_watcher/event_watcher.ts +++ b/packages/order-watcher/src/order_watcher/event_watcher.ts @@ -1,6 +1,6 @@ import { intervalUtils, logUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import { BlockParamLiteral, LogEntry, Provider } from 'ethereum-types'; +import { BlockParamLiteral, BlockWithoutTransactionData, LogEntry, Provider } from 'ethereum-types'; import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream'; import * as _ from 'lodash'; @@ -62,7 +62,7 @@ export class EventWatcher { throw new Error(OrderWatcherError.SubscriptionAlreadyPresent); } this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( - this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper), + this._getBlockOrNullAsync.bind(this), this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), this._onBlockAndLogStreamerError.bind(this), ); @@ -82,6 +82,14 @@ export class EventWatcher { this._onLogStateChangedAsync.bind(this, callback, isRemoved), ); } + // This method only exists in order to comply with the expected interface of Blockstream's constructor + private async _getBlockOrNullAsync(): Promise<BlockWithoutTransactionData | null> { + const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); + if (_.isUndefined(blockIfExists)) { + return null; + } + return blockIfExists; + } private _stopBlockAndLogStream(): void { if (_.isUndefined(this._blockAndLogStreamerIfExists)) { throw new Error(OrderWatcherError.SubscriptionNotFound); @@ -100,11 +108,14 @@ export class EventWatcher { await this._emitDifferencesAsync(log, isRemoved ? LogEventState.Removed : LogEventState.Added, callback); } private async _reconcileBlockAsync(): Promise<void> { - const latestBlock = await this._web3Wrapper.getBlockAsync(this._stateLayer); + const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(this._stateLayer); + if (_.isUndefined(latestBlockIfExists)) { + return; // noop + } // We need to coerce to Block type cause Web3.Block includes types for mempool blocks if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined - await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlock as any) as Block); + await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block); } } private async _emitDifferencesAsync( |