aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher
diff options
context:
space:
mode:
Diffstat (limited to 'packages/order-watcher')
-rw-r--r--packages/order-watcher/src/order_watcher/order_watcher.ts25
-rw-r--r--packages/order-watcher/test/order_watcher_test.ts26
2 files changed, 39 insertions, 12 deletions
diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts
index cab2efa4b..f9a63efe3 100644
--- a/packages/order-watcher/src/order_watcher/order_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/order_watcher.ts
@@ -275,6 +275,7 @@ export class OrderWatcher {
return; // noop
}
const decodedLog = (maybeDecodedLog as any) as LogWithDecodedArgs<ContractEventArgs>;
+ const transactionHash = decodedLog.transactionHash;
switch (decodedLog.event) {
case ERC20TokenEvents.Approval:
case ERC721TokenEvents.Approval: {
@@ -290,7 +291,7 @@ export class OrderWatcher {
args._owner,
tokenAssetData,
);
- await this._emitRevalidateOrdersAsync(orderHashes);
+ await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break;
} else {
// ERC721
@@ -303,7 +304,7 @@ export class OrderWatcher {
args._owner,
tokenAssetData,
);
- await this._emitRevalidateOrdersAsync(orderHashes);
+ await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break;
}
}
@@ -322,7 +323,7 @@ export class OrderWatcher {
args._from,
tokenAssetData,
);
- await this._emitRevalidateOrdersAsync(orderHashes);
+ await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break;
} else {
// ERC721
@@ -336,7 +337,7 @@ export class OrderWatcher {
args._from,
tokenAssetData,
);
- await this._emitRevalidateOrdersAsync(orderHashes);
+ await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break;
}
}
@@ -350,7 +351,7 @@ export class OrderWatcher {
args._owner,
tokenAddress,
);
- await this._emitRevalidateOrdersAsync(orderHashes);
+ await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break;
}
case WETH9Events.Deposit: {
@@ -363,7 +364,7 @@ export class OrderWatcher {
args._owner,
tokenAssetData,
);
- await this._emitRevalidateOrdersAsync(orderHashes);
+ await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break;
}
case WETH9Events.Withdrawal: {
@@ -376,7 +377,7 @@ export class OrderWatcher {
args._owner,
tokenAssetData,
);
- await this._emitRevalidateOrdersAsync(orderHashes);
+ await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break;
}
case ExchangeEvents.Fill: {
@@ -387,7 +388,7 @@ export class OrderWatcher {
const orderHash = args.orderHash;
const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]);
if (isOrderWatched) {
- await this._emitRevalidateOrdersAsync([orderHash]);
+ await this._emitRevalidateOrdersAsync([orderHash], transactionHash);
}
break;
}
@@ -399,7 +400,7 @@ export class OrderWatcher {
const orderHash = args.orderHash;
const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]);
if (isOrderWatched) {
- await this._emitRevalidateOrdersAsync([orderHash]);
+ await this._emitRevalidateOrdersAsync([orderHash], transactionHash);
}
break;
}
@@ -410,7 +411,7 @@ export class OrderWatcher {
this._orderFilledCancelledLazyStore.deleteAllIsCancelled();
// Revalidate orders
const orderHashes = this._dependentOrderHashesTracker.getDependentOrderHashesByMaker(args.makerAddress);
- await this._emitRevalidateOrdersAsync(orderHashes);
+ await this._emitRevalidateOrdersAsync(orderHashes, transactionHash);
break;
}
@@ -418,12 +419,12 @@ export class OrderWatcher {
throw errorUtils.spawnSwitchErr('decodedLog.event', decodedLog.event);
}
}
- private async _emitRevalidateOrdersAsync(orderHashes: string[]): Promise<void> {
+ private async _emitRevalidateOrdersAsync(orderHashes: string[], transactionHash?: string): Promise<void> {
for (const orderHash of orderHashes) {
const signedOrder = this._orderByOrderHash[orderHash];
// Most of these calls will never reach the network because the data is fetched from stores
// and only updated when cache is invalidated
- const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder);
+ const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder, transactionHash);
if (_.isUndefined(this._callbackIfExists)) {
break; // Unsubscribe was called
}
diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts
index 38bfde7ef..60d9069e8 100644
--- a/packages/order-watcher/test/order_watcher_test.ts
+++ b/packages/order-watcher/test/order_watcher_test.ts
@@ -250,6 +250,32 @@ describe('OrderWatcher', () => {
await contractWrappers.exchange.fillOrderAsync(signedOrder, fillableAmount, takerAddress);
})().catch(done);
});
+ it('should include transactionHash in emitted orderStateInvalid when watched order fully filled', (done: DoneCallback) => {
+ (async () => {
+ signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerAssetData,
+ takerAssetData,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ );
+ await orderWatcher.addOrderAsync(signedOrder);
+
+ let transactionHash: string;
+ const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => {
+ expect(orderState.isValid).to.be.false();
+ const invalidOrderState = orderState as OrderStateInvalid;
+ expect(invalidOrderState.transactionHash).to.be.equal(transactionHash);
+ });
+ orderWatcher.subscribe(callback);
+
+ transactionHash = await contractWrappers.exchange.fillOrderAsync(
+ signedOrder,
+ fillableAmount,
+ takerAddress,
+ );
+ })().catch(done);
+ });
it('should emit orderStateValid when watched order partially filled', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(