diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-09-08 18:25:05 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-09-08 18:25:05 +0800 |
commit | 762d02b2e0875a8fc70adacdf01f0ed67c4dccb6 (patch) | |
tree | d7662edc5f19bceb9b6fe8137c58f00f59775df1 /src | |
parent | 1dcfd4102bf6582aafd590d70a8a98bbd7bce1dc (diff) | |
download | dexon-sol-tools-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar dexon-sol-tools-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar.gz dexon-sol-tools-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar.bz2 dexon-sol-tools-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar.lz dexon-sol-tools-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar.xz dexon-sol-tools-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar.zst dexon-sol-tools-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.zip |
Allow user to specify defaultBlock when calling const exchange methods
Diffstat (limited to 'src')
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 21 | ||||
-rw-r--r-- | src/types.ts | 6 |
2 files changed, 18 insertions, 9 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 47a066a8f..9d73a4ede 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -27,6 +27,7 @@ import { LogFillContractEventArgs, LogCancelContractEventArgs, LogWithDecodedArgs, + CallOpts, } from '../types'; import {assert} from '../utils/assert'; import {utils} from '../utils/utils'; @@ -85,13 +86,17 @@ export class ExchangeWrapper extends ContractWrapper { * subtracting the unavailable amount from the total order takerAmount. * @param orderHash The hex encoded orderHash for which you would like to retrieve the * unavailable takerAmount. + * @param callOpts ${FABIOS_COMMENT} * @return The amount of the order (in taker tokens) that has either been filled or canceled. */ - public async getUnavailableTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> { + public async getUnavailableTakerAmountAsync(orderHash: string, callOpts?: CallOpts): Promise<BigNumber.BigNumber> { assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema); const exchangeContract = await this._getExchangeContractAsync(); - let unavailableTakerTokenAmount = await exchangeContract.getUnavailableTakerTokenAmount.callAsync(orderHash); + const defaultBlock = _.isUndefined(callOpts) ? undefined : callOpts.defaultBlock; + let unavailableTakerTokenAmount = await exchangeContract.getUnavailableTakerTokenAmount.callAsync( + orderHash, defaultBlock, + ); // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber unavailableTakerTokenAmount = new BigNumber(unavailableTakerTokenAmount); return unavailableTakerTokenAmount; @@ -99,13 +104,15 @@ export class ExchangeWrapper extends ContractWrapper { /** * Retrieve the takerAmount of an order that has already been filled. * @param orderHash The hex encoded orderHash for which you would like to retrieve the filled takerAmount. + * @param callOpts ${FABIOS_COMMENT} * @return The amount of the order (in taker tokens) that has already been filled. */ - public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> { + public async getFilledTakerAmountAsync(orderHash: string, callOpts?: CallOpts): Promise<BigNumber.BigNumber> { assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema); const exchangeContract = await this._getExchangeContractAsync(); - let fillAmountInBaseUnits = await exchangeContract.filled.callAsync(orderHash); + const defaultBlock = _.isUndefined(callOpts) ? undefined : callOpts.defaultBlock; + let fillAmountInBaseUnits = await exchangeContract.filled.callAsync(orderHash, defaultBlock); // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber fillAmountInBaseUnits = new BigNumber(fillAmountInBaseUnits); return fillAmountInBaseUnits; @@ -114,13 +121,15 @@ export class ExchangeWrapper extends ContractWrapper { * Retrieve the takerAmount of an order that has been cancelled. * @param orderHash The hex encoded orderHash for which you would like to retrieve the * cancelled takerAmount. + * @param callOpts ${FABIOS_COMMENT} * @return The amount of the order (in taker tokens) that has been cancelled. */ - public async getCanceledTakerAmountAsync(orderHash: string): Promise<BigNumber.BigNumber> { + public async getCanceledTakerAmountAsync(orderHash: string, callOpts?: CallOpts): Promise<BigNumber.BigNumber> { assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema); const exchangeContract = await this._getExchangeContractAsync(); - let cancelledAmountInBaseUnits = await exchangeContract.cancelled.callAsync(orderHash); + const defaultBlock = _.isUndefined(callOpts) ? undefined : callOpts.defaultBlock; + let cancelledAmountInBaseUnits = await exchangeContract.cancelled.callAsync(orderHash, defaultBlock); // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber cancelledAmountInBaseUnits = new BigNumber(cancelledAmountInBaseUnits); return cancelledAmountInBaseUnits; diff --git a/src/types.ts b/src/types.ts index 4adaa4ccb..a8d4f078e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -52,7 +52,7 @@ export interface ExchangeContract extends Web3.ContractInstance { callAsync: () => Promise<string>; }; getUnavailableTakerTokenAmount: { - callAsync: (orderHash: string) => Promise<BigNumber.BigNumber>; + callAsync: (orderHash: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber.BigNumber>; }; isRoundingError: { callAsync: (fillTakerAmount: BigNumber.BigNumber, takerTokenAmount: BigNumber.BigNumber, @@ -119,10 +119,10 @@ export interface ExchangeContract extends Web3.ContractInstance { v: number[], r: string[], s: string[], txOpts?: TxOpts) => Promise<number>; }; filled: { - callAsync: (orderHash: string) => Promise<BigNumber.BigNumber>; + callAsync: (orderHash: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber.BigNumber>; }; cancelled: { - callAsync: (orderHash: string) => Promise<BigNumber.BigNumber>; + callAsync: (orderHash: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber.BigNumber>; }; getOrderHash: { callAsync: (orderAddresses: OrderAddresses, orderValues: OrderValues) => Promise<string>; |