aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher
diff options
context:
space:
mode:
Diffstat (limited to 'packages/order-watcher')
-rw-r--r--packages/order-watcher/CHANGELOG.json9
-rw-r--r--packages/order-watcher/CHANGELOG.md4
-rw-r--r--packages/order-watcher/package.json32
-rw-r--r--packages/order-watcher/src/order_watcher/event_watcher.ts19
4 files changed, 44 insertions, 20 deletions
diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json
index d6be772e2..1b19a4cdd 100644
--- a/packages/order-watcher/CHANGELOG.json
+++ b/packages/order-watcher/CHANGELOG.json
@@ -9,6 +9,15 @@
]
},
{
+ "version": "1.0.4",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ],
+ "timestamp": 1537541580
+ },
+ {
"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 bc86a651f..f764b6518 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": "6.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(