aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher
diff options
context:
space:
mode:
Diffstat (limited to 'packages/order-watcher')
-rw-r--r--packages/order-watcher/CHANGELOG.json8
-rw-r--r--packages/order-watcher/src/order_watcher/event_watcher.ts12
-rw-r--r--packages/order-watcher/src/order_watcher/order_watcher.ts8
-rw-r--r--packages/order-watcher/src/types.ts2
4 files changed, 16 insertions, 14 deletions
diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json
index a66db6eec..e747a2129 100644
--- a/packages/order-watcher/CHANGELOG.json
+++ b/packages/order-watcher/CHANGELOG.json
@@ -9,6 +9,14 @@
{
"note": "Do not stop subscription if error is encountered",
"pr": 825
+ },
+ {
+ "note": "Fixed a bug that caused the incorrect block to be fetched via JSON-RPC within Blockstream",
+ "pr": 875
+ },
+ {
+ "note": "Remove stateLayer config from OrderWatcher. It now always operates on the latest block",
+ "pr": 875
}
],
"timestamp": 1531149657
diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts
index 68c043dfe..415a7d99a 100644
--- a/packages/order-watcher/src/order_watcher/event_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/event_watcher.ts
@@ -30,7 +30,7 @@ export class EventWatcher {
constructor(
provider: Provider,
pollingIntervalIfExistsMs: undefined | number,
- stateLayer: BlockParamLiteral = BlockParamLiteral.Latest,
+ stateLayer: BlockParamLiteral,
isVerbose: boolean,
) {
this._isVerbose = isVerbose;
@@ -61,13 +61,9 @@ export class EventWatcher {
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
throw new Error(OrderWatcherError.SubscriptionAlreadyPresent);
}
- const eventFilter = {
- fromBlock: this._stateLayer,
- toBlock: this._stateLayer,
- };
this._blockAndLogStreamerIfExists = new BlockAndLogStreamer(
- this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper, this._stateLayer),
- this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper, eventFilter),
+ this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper),
+ this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper),
this._onBlockAndLogStreamerError.bind(this),
);
const catchAllLogFilter = {};
@@ -104,7 +100,7 @@ export class EventWatcher {
await this._emitDifferencesAsync(log, isRemoved ? LogEventState.Removed : LogEventState.Added, callback);
}
private async _reconcileBlockAsync(): Promise<void> {
- const latestBlock = await this._web3Wrapper.getBlockAsync(BlockParamLiteral.Latest);
+ const latestBlock = await this._web3Wrapper.getBlockAsync(this._stateLayer);
// 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
diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts
index c43887b77..ebfac4b25 100644
--- a/packages/order-watcher/src/order_watcher/order_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/order_watcher.ts
@@ -58,7 +58,6 @@ interface OrderStateByOrderHash {
}
const DEFAULT_ORDER_WATCHER_CONFIG: OrderWatcherConfig = {
- stateLayer: BlockParamLiteral.Latest,
orderExpirationCheckingIntervalMs: 50,
eventPollingIntervalMs: 200,
expirationMarginMs: 0,
@@ -66,6 +65,7 @@ const DEFAULT_ORDER_WATCHER_CONFIG: OrderWatcherConfig = {
cleanupJobIntervalMs: 1000 * 60 * 60, // 1h
isVerbose: true,
};
+const STATE_LAYER = BlockParamLiteral.Latest;
/**
* This class includes all the functionality related to watching a set of orders
@@ -110,20 +110,20 @@ export class OrderWatcher {
this._eventWatcher = new EventWatcher(
provider,
config.eventPollingIntervalMs,
- config.stateLayer,
+ STATE_LAYER,
config.isVerbose,
);
const balanceAndProxyAllowanceFetcher = new AssetBalanceAndProxyAllowanceFetcher(
contractWrappers.erc20Token,
contractWrappers.erc721Token,
- config.stateLayer,
+ STATE_LAYER,
);
this._balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore(
balanceAndProxyAllowanceFetcher,
);
const orderFilledCancelledFetcher = new OrderFilledCancelledFetcher(
contractWrappers.exchange,
- config.stateLayer,
+ STATE_LAYER,
);
this._orderFilledCancelledLazyStore = new OrderFilledCancelledLazyStore(orderFilledCancelledFetcher);
this._orderStateUtils = new OrderStateUtils(balanceAndProxyAllowanceFetcher, orderFilledCancelledFetcher);
diff --git a/packages/order-watcher/src/types.ts b/packages/order-watcher/src/types.ts
index 7991df58c..b5637bd91 100644
--- a/packages/order-watcher/src/types.ts
+++ b/packages/order-watcher/src/types.ts
@@ -9,7 +9,6 @@ export enum OrderWatcherError {
export type EventWatcherCallback = (err: null | Error, log?: LogEntryEvent) => void;
/**
- * stateLayer: Optional blockchain state layer OrderWatcher will monitor for new events. Default=latest.
* orderExpirationCheckingIntervalMs: How often to check for expired orders. Default=50.
* eventPollingIntervalMs: How often to poll the Ethereum node for new events. Default=200.
* expirationMarginMs: Amount of time before order expiry that you'd like to be notified
@@ -18,7 +17,6 @@ export type EventWatcherCallback = (err: null | Error, log?: LogEntryEvent) => v
* isVerbose: Weather the order watcher should be verbose. Default=true.
*/
export interface OrderWatcherConfig {
- stateLayer: BlockParamLiteral;
orderExpirationCheckingIntervalMs: number;
eventPollingIntervalMs: number;
expirationMarginMs: number;