aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/utils/simple_filled_cancelled_fetcher.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src/utils/simple_filled_cancelled_fetcher.ts')
-rw-r--r--packages/contracts/src/utils/simple_filled_cancelled_fetcher.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/contracts/src/utils/simple_filled_cancelled_fetcher.ts b/packages/contracts/src/utils/simple_filled_cancelled_fetcher.ts
new file mode 100644
index 000000000..0a80637cc
--- /dev/null
+++ b/packages/contracts/src/utils/simple_filled_cancelled_fetcher.ts
@@ -0,0 +1,32 @@
+import { AbstractOrderFilledCancelledFetcher } from '@0xproject/order-utils';
+import { BigNumber } from '@0xproject/utils';
+import { BlockParamLiteral } from 'ethereum-types';
+
+import {
+ CancelContractEventArgs,
+ ExchangeContract,
+ FillContractEventArgs,
+} from '../contract_wrappers/generated/exchange';
+
+export class SimpleOrderFilledCancelledFetcher implements AbstractOrderFilledCancelledFetcher {
+ private _exchangeContract: ExchangeContract;
+ private _zrxAddress: string;
+ constructor(exchange: ExchangeContract, zrxAddress: string) {
+ this._exchangeContract = exchange;
+ this._zrxAddress = zrxAddress;
+ }
+ public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
+ const filledTakerAmount = new BigNumber(await this._exchangeContract.filled.callAsync(orderHash));
+ return filledTakerAmount;
+ }
+ public async isOrderCancelledAsync(orderHash: string): Promise<boolean> {
+ const methodOpts = {
+ defaultBlock: BlockParamLiteral.Latest,
+ };
+ const isCancelled = await this._exchangeContract.cancelled.callAsync(orderHash);
+ return isCancelled;
+ }
+ public getZRXTokenAddress(): string {
+ return this._zrxAddress;
+ }
+}