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/contract_wrappers/exchange_wrapper.ts | |
parent | 1dcfd4102bf6582aafd590d70a8a98bbd7bce1dc (diff) | |
download | dexon-0x-contracts-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar dexon-0x-contracts-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar.gz dexon-0x-contracts-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar.bz2 dexon-0x-contracts-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar.lz dexon-0x-contracts-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar.xz dexon-0x-contracts-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.tar.zst dexon-0x-contracts-762d02b2e0875a8fc70adacdf01f0ed67c4dccb6.zip |
Allow user to specify defaultBlock when calling const exchange methods
Diffstat (limited to 'src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 21 |
1 files changed, 15 insertions, 6 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; |