aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-11-09 07:45:48 +0800
committerFabio Berger <me@fabioberger.com>2018-11-09 07:45:48 +0800
commit857a35d4f71c1c954033c3b0505250e18be21cfb (patch)
tree47dc81508fe8d71b0c0acfcd24b36fa8455c6ae6 /packages/contracts
parent8b06b3627426c3f9eda3262d0b6479d55cc4c9ad (diff)
downloaddexon-sol-tools-857a35d4f71c1c954033c3b0505250e18be21cfb.tar
dexon-sol-tools-857a35d4f71c1c954033c3b0505250e18be21cfb.tar.gz
dexon-sol-tools-857a35d4f71c1c954033c3b0505250e18be21cfb.tar.bz2
dexon-sol-tools-857a35d4f71c1c954033c3b0505250e18be21cfb.tar.lz
dexon-sol-tools-857a35d4f71c1c954033c3b0505250e18be21cfb.tar.xz
dexon-sol-tools-857a35d4f71c1c954033c3b0505250e18be21cfb.tar.zst
dexon-sol-tools-857a35d4f71c1c954033c3b0505250e18be21cfb.zip
Fix validateOrderFillableOrThrowAsync method so it also checks order signature, cancelled, cancelledUpTo, and throws helpful error messages
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/test/utils/exchange_wrapper.ts4
-rw-r--r--packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts13
2 files changed, 14 insertions, 3 deletions
diff --git a/packages/contracts/test/utils/exchange_wrapper.ts b/packages/contracts/test/utils/exchange_wrapper.ts
index 29dba690a..cfff682e1 100644
--- a/packages/contracts/test/utils/exchange_wrapper.ts
+++ b/packages/contracts/test/utils/exchange_wrapper.ts
@@ -219,6 +219,10 @@ export class ExchangeWrapper {
const isCancelled = await this._exchange.cancelled.callAsync(orderHashHex);
return isCancelled;
}
+ public async getOrderEpochAsync(makerAddress: string, takerAddress: string): Promise<BigNumber> {
+ const orderEpoch = new BigNumber(await this._exchange.orderEpoch.callAsync(makerAddress, takerAddress));
+ return orderEpoch;
+ }
public async getOrderInfoAsync(signedOrder: SignedOrder): Promise<OrderInfo> {
const orderInfo = (await this._exchange.getOrderInfo.callAsync(signedOrder)) as OrderInfo;
return orderInfo;
diff --git a/packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts b/packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts
index 5f5575c7b..af959e00e 100644
--- a/packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts
+++ b/packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts
@@ -1,4 +1,5 @@
-import { AbstractOrderFilledCancelledFetcher } from '@0x/order-utils';
+import { AbstractOrderFilledCancelledFetcher, orderHashUtils } from '@0x/order-utils';
+import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { ExchangeWrapper } from './exchange_wrapper';
@@ -14,9 +15,15 @@ export class SimpleOrderFilledCancelledFetcher implements AbstractOrderFilledCan
const filledTakerAmount = new BigNumber(await this._exchangeWrapper.getTakerAssetFilledAmountAsync(orderHash));
return filledTakerAmount;
}
- public async isOrderCancelledAsync(orderHash: string): Promise<boolean> {
+ public async isOrderCancelledAsync(signedOrder: SignedOrder): Promise<boolean> {
+ const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const isCancelled = await this._exchangeWrapper.isCancelledAsync(orderHash);
- return isCancelled;
+ const orderEpoch = await this._exchangeWrapper.getOrderEpochAsync(
+ signedOrder.makerAddress,
+ signedOrder.senderAddress,
+ );
+ const isCancelledByOrderEpoch = orderEpoch > signedOrder.salt;
+ return isCancelled || isCancelledByOrderEpoch;
}
public getZRXAssetData(): string {
return this._zrxAssetData;