diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-29 00:26:13 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-29 00:26:13 +0800 |
commit | 141ac0ca0be15602a1bcf466e873134e084f30c1 (patch) | |
tree | f0e08db40c46e8c671a99231b645365747a8073f /contracts/exchange/test/utils/simple_order_filled_cancelled_fetcher.ts | |
parent | 0c12128f64f7d9a8de6088e98c2e638533d6f5bf (diff) | |
parent | 25e42c0ad47e9ec06e474cd12a488ae837660302 (diff) | |
download | dexon-0x-contracts-141ac0ca0be15602a1bcf466e873134e084f30c1.tar dexon-0x-contracts-141ac0ca0be15602a1bcf466e873134e084f30c1.tar.gz dexon-0x-contracts-141ac0ca0be15602a1bcf466e873134e084f30c1.tar.bz2 dexon-0x-contracts-141ac0ca0be15602a1bcf466e873134e084f30c1.tar.lz dexon-0x-contracts-141ac0ca0be15602a1bcf466e873134e084f30c1.tar.xz dexon-0x-contracts-141ac0ca0be15602a1bcf466e873134e084f30c1.tar.zst dexon-0x-contracts-141ac0ca0be15602a1bcf466e873134e084f30c1.zip |
Merge development
Diffstat (limited to 'contracts/exchange/test/utils/simple_order_filled_cancelled_fetcher.ts')
-rw-r--r-- | contracts/exchange/test/utils/simple_order_filled_cancelled_fetcher.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/contracts/exchange/test/utils/simple_order_filled_cancelled_fetcher.ts b/contracts/exchange/test/utils/simple_order_filled_cancelled_fetcher.ts new file mode 100644 index 000000000..af959e00e --- /dev/null +++ b/contracts/exchange/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; + } +} |