diff options
author | Fabio Berger <me@fabioberger.com> | 2018-11-09 07:45:48 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-11-09 07:45:48 +0800 |
commit | 857a35d4f71c1c954033c3b0505250e18be21cfb (patch) | |
tree | 47dc81508fe8d71b0c0acfcd24b36fa8455c6ae6 /packages/contract-wrappers/src/fetchers | |
parent | 8b06b3627426c3f9eda3262d0b6479d55cc4c9ad (diff) | |
download | dexon-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/contract-wrappers/src/fetchers')
-rw-r--r-- | packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts b/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts index acf7038fa..5d350916c 100644 --- a/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts +++ b/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts @@ -1,5 +1,6 @@ // tslint:disable:no-unnecessary-type-assertion -import { AbstractOrderFilledCancelledFetcher } from '@0x/order-utils'; +import { AbstractOrderFilledCancelledFetcher, orderHashUtils } from '@0x/order-utils'; +import { SignedOrder } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { BlockParamLiteral } from 'ethereum-types'; @@ -18,9 +19,18 @@ export class OrderFilledCancelledFetcher implements AbstractOrderFilledCancelled }); 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._exchange.isCancelledAsync(orderHash); - return isCancelled; + const orderEpoch = await this._exchange.getOrderEpochAsync( + signedOrder.makerAddress, + signedOrder.senderAddress, + { + defaultBlock: this._stateLayer, + }, + ); + const isCancelledByOrderEpoch = orderEpoch > signedOrder.salt; + return isCancelled || isCancelledByOrderEpoch; } public getZRXAssetData(): string { const zrxAssetData = this._exchange.getZRXAssetData(); |