diff options
author | Ara Kevonian <ara@dextroid.io> | 2018-04-13 18:04:51 +0800 |
---|---|---|
committer | Ara Kevonian <ara@dextroid.io> | 2018-04-13 18:04:51 +0800 |
commit | 38f7c4a0d2d9269b5fd185b303ede7a44ab78c99 (patch) | |
tree | 901387c575cd38968bb5dbe58c34fccd7a7bf9eb /packages/0x.js/src/fetchers | |
parent | bf0ef055fbd4f5f798ea56868ad0beddf1111e7f (diff) | |
download | dexon-sol-tools-38f7c4a0d2d9269b5fd185b303ede7a44ab78c99.tar dexon-sol-tools-38f7c4a0d2d9269b5fd185b303ede7a44ab78c99.tar.gz dexon-sol-tools-38f7c4a0d2d9269b5fd185b303ede7a44ab78c99.tar.bz2 dexon-sol-tools-38f7c4a0d2d9269b5fd185b303ede7a44ab78c99.tar.lz dexon-sol-tools-38f7c4a0d2d9269b5fd185b303ede7a44ab78c99.tar.xz dexon-sol-tools-38f7c4a0d2d9269b5fd185b303ede7a44ab78c99.tar.zst dexon-sol-tools-38f7c4a0d2d9269b5fd185b303ede7a44ab78c99.zip |
Implement Simple Fetchers
Diffstat (limited to 'packages/0x.js/src/fetchers')
4 files changed, 50 insertions, 12 deletions
diff --git a/packages/0x.js/src/fetchers/balance_and_allowance_fetcher.ts b/packages/0x.js/src/fetchers/balance_and_allowance_fetcher.ts deleted file mode 100644 index f7b1183f1..000000000 --- a/packages/0x.js/src/fetchers/balance_and_allowance_fetcher.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BigNumber } from '@0xproject/utils'; - -export abstract class BalanceAndAllowanceFetcher { - public abstract async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber>; - public abstract async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber>; -} diff --git a/packages/0x.js/src/fetchers/order_filled_cancelled_fetcher.ts b/packages/0x.js/src/fetchers/order_filled_cancelled_fetcher.ts deleted file mode 100644 index 81ae04b9c..000000000 --- a/packages/0x.js/src/fetchers/order_filled_cancelled_fetcher.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BigNumber } from '@0xproject/utils'; - -export abstract class OrderFilledCancelledFetcher { - public abstract async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber>; - public abstract async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber>; -} diff --git a/packages/0x.js/src/fetchers/simple_balance_and_allowance_fetcher.ts b/packages/0x.js/src/fetchers/simple_balance_and_allowance_fetcher.ts new file mode 100644 index 000000000..2aa1cc2b7 --- /dev/null +++ b/packages/0x.js/src/fetchers/simple_balance_and_allowance_fetcher.ts @@ -0,0 +1,26 @@ +import { BlockParamLiteral } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; + +import {BalanceAndAllowanceFetcher} from '../abstract/balance_and_allowance_fetcher'; +import {TokenWrapper} from '../contract_wrappers/token_wrapper'; + +export class SimpleBalanceAndAllowanceFetcher implements BalanceAndAllowanceFetcher { + private _token: TokenWrapper; + private _defaultBlock: BlockParamLiteral; + constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) { + this._token = token; + this._defaultBlock = defaultBlock; + } + public async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> { + const methodOpts = { + defaultBlock: this._defaultBlock, + }; + return this._token.getBalanceAsync(tokenAddress, userAddress, methodOpts); + } + public async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> { + const methodOpts = { + defaultBlock: this._defaultBlock, + }; + return this._token.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts); + } +} diff --git a/packages/0x.js/src/fetchers/simple_order_filled_cancelled_fetcher.ts b/packages/0x.js/src/fetchers/simple_order_filled_cancelled_fetcher.ts new file mode 100644 index 000000000..e24f02726 --- /dev/null +++ b/packages/0x.js/src/fetchers/simple_order_filled_cancelled_fetcher.ts @@ -0,0 +1,24 @@ +import { BlockParamLiteral } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; + +import {OrderFilledCancelledFetcher} from '../abstract/order_filled_cancelled_fetcher'; +import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; + +export class SimpleOrderFilledCancelledFetcher implements OrderFilledCancelledFetcher { + private _exchange: ExchangeWrapper; + constructor(exchange: ExchangeWrapper) { + this._exchange = exchange; + } + public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> { + const methodOpts = { + defaultBlock: BlockParamLiteral.Pending, + }; + return this._exchange.getFilledTakerAmountAsync(orderHash, methodOpts); + } + public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> { + const methodOpts = { + defaultBlock: BlockParamLiteral.Pending, + }; + return this._exchange.getCancelledTakerAmountAsync(orderHash, methodOpts); + } +} |