aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/protocol/test/utils/simple_order_filled_cancelled_fetcher.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2019-01-09 19:02:25 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2019-01-09 19:02:25 +0800
commitea14913b412e78ff458bdfba47182f7363e776e5 (patch)
tree3ee220bfbbd9923b5e1adc36ee51f9b5d39ad640 /contracts/protocol/test/utils/simple_order_filled_cancelled_fetcher.ts
parent5868c91cfb54cfa9177572b201d88d1168bf5b06 (diff)
parent5dd55491b86bf8577405e37d0f2d668aa1273b10 (diff)
downloaddexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar.gz
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar.bz2
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar.lz
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar.xz
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar.zst
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.zip
Merge development
Diffstat (limited to 'contracts/protocol/test/utils/simple_order_filled_cancelled_fetcher.ts')
-rw-r--r--contracts/protocol/test/utils/simple_order_filled_cancelled_fetcher.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/contracts/protocol/test/utils/simple_order_filled_cancelled_fetcher.ts b/contracts/protocol/test/utils/simple_order_filled_cancelled_fetcher.ts
new file mode 100644
index 000000000..af959e00e
--- /dev/null
+++ b/contracts/protocol/test/utils/simple_order_filled_cancelled_fetcher.ts
@@ -0,0 +1,31 @@
+import { AbstractOrderFilledCancelledFetcher, orderHashUtils } from '@0x/order-utils';
+import { SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
+
+import { ExchangeWrapper } from './exchange_wrapper';
+
+export class SimpleOrderFilledCancelledFetcher implements AbstractOrderFilledCancelledFetcher {
+ private readonly _exchangeWrapper: ExchangeWrapper;
+ private readonly _zrxAssetData: string;
+ constructor(exchange: ExchangeWrapper, zrxAssetData: string) {
+ this._exchangeWrapper = exchange;
+ this._zrxAssetData = zrxAssetData;
+ }
+ public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
+ const filledTakerAmount = new BigNumber(await this._exchangeWrapper.getTakerAssetFilledAmountAsync(orderHash));
+ return filledTakerAmount;
+ }
+ public async isOrderCancelledAsync(signedOrder: SignedOrder): Promise<boolean> {
+ const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
+ const isCancelled = await this._exchangeWrapper.isCancelledAsync(orderHash);
+ const orderEpoch = await this._exchangeWrapper.getOrderEpochAsync(
+ signedOrder.makerAddress,
+ signedOrder.senderAddress,
+ );
+ const isCancelledByOrderEpoch = orderEpoch > signedOrder.salt;
+ return isCancelled || isCancelledByOrderEpoch;
+ }
+ public getZRXAssetData(): string {
+ return this._zrxAssetData;
+ }
+}