aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-09-08 18:03:04 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-09-08 18:03:04 +0800
commit1dcfd4102bf6582aafd590d70a8a98bbd7bce1dc (patch)
tree55d80ed11c810ff5b1180f798524b94fbd8af10f
parentaaae22642eb280e1fbbc9d90dc13ae3fb82b9fd5 (diff)
downloaddexon-0x-contracts-1dcfd4102bf6582aafd590d70a8a98bbd7bce1dc.tar.gz
dexon-0x-contracts-1dcfd4102bf6582aafd590d70a8a98bbd7bce1dc.tar.zst
dexon-0x-contracts-1dcfd4102bf6582aafd590d70a8a98bbd7bce1dc.zip
Allow user to specify defaultBlock when calling const token methods
-rw-r--r--src/contract_wrappers/token_wrapper.ts19
-rw-r--r--src/types.ts5
2 files changed, 16 insertions, 8 deletions
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts
index 6b2a824de..96dc10b88 100644
--- a/src/contract_wrappers/token_wrapper.ts
+++ b/src/contract_wrappers/token_wrapper.ts
@@ -40,14 +40,17 @@ export class TokenWrapper extends ContractWrapper {
* Retrieves an owner's ERC20 token balance.
* @param tokenAddress The hex encoded contract Ethereum address where the ERC20 token is deployed.
* @param ownerAddress The hex encoded user Ethereum address whose balance you would like to check.
+ * @param callOpts ${FABIOS_COMMENT}
* @return The owner's ERC20 token balance in base units.
*/
- public async getBalanceAsync(tokenAddress: string, ownerAddress: string): Promise<BigNumber.BigNumber> {
+ public async getBalanceAsync(tokenAddress: string, ownerAddress: string,
+ callOpts?: CallOpts): Promise<BigNumber.BigNumber> {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
const tokenContract = await this._getTokenContractAsync(tokenAddress);
- let balance = await tokenContract.balanceOf.callAsync(ownerAddress);
+ const defaultBlock = _.isUndefined(callOpts) ? undefined : callOpts.defaultBlock;
+ let balance = await tokenContract.balanceOf.callAsync(ownerAddress, defaultBlock);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
balance = new BigNumber(balance);
return balance;
@@ -105,14 +108,16 @@ export class TokenWrapper extends ContractWrapper {
* @param ownerAddress The hex encoded user Ethereum address whose allowance to spenderAddress
* you would like to retrieve.
* @param spenderAddress The hex encoded user Ethereum address who can spend the allowance you are fetching.
+ * @param callOpts ${FABIOS_COMMENT}
*/
public async getAllowanceAsync(tokenAddress: string, ownerAddress: string,
- spenderAddress: string): Promise<BigNumber.BigNumber> {
+ spenderAddress: string, callOpts?: CallOpts): Promise<BigNumber.BigNumber> {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
const tokenContract = await this._getTokenContractAsync(tokenAddress);
- let allowanceInBaseUnits = await tokenContract.allowance.callAsync(ownerAddress, spenderAddress);
+ const defaultBlock = _.isUndefined(callOpts) ? undefined : callOpts.defaultBlock;
+ let allowanceInBaseUnits = await tokenContract.allowance.callAsync(ownerAddress, spenderAddress, defaultBlock);
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
allowanceInBaseUnits = new BigNumber(allowanceInBaseUnits);
return allowanceInBaseUnits;
@@ -121,13 +126,15 @@ export class TokenWrapper extends ContractWrapper {
* Retrieves the owner's allowance in baseUnits set to the 0x proxy contract.
* @param tokenAddress The hex encoded contract Ethereum address where the ERC20 token is deployed.
* @param ownerAddress The hex encoded user Ethereum address whose proxy contract allowance we are retrieving.
+ * @param callOpts ${FABIOS_COMMENT}
*/
- public async getProxyAllowanceAsync(tokenAddress: string, ownerAddress: string): Promise<BigNumber.BigNumber> {
+ public async getProxyAllowanceAsync(tokenAddress: string, ownerAddress: string,
+ callOpts?: CallOpts): Promise<BigNumber.BigNumber> {
assert.isETHAddressHex('ownerAddress', ownerAddress);
assert.isETHAddressHex('tokenAddress', tokenAddress);
const proxyAddress = await this._getProxyAddressAsync();
- const allowanceInBaseUnits = await this.getAllowanceAsync(tokenAddress, ownerAddress, proxyAddress);
+ const allowanceInBaseUnits = await this.getAllowanceAsync(tokenAddress, ownerAddress, proxyAddress, callOpts);
return allowanceInBaseUnits;
}
/**
diff --git a/src/types.ts b/src/types.ts
index a15b9f4e1..4adaa4ccb 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -133,10 +133,11 @@ export interface TokenContract extends Web3.ContractInstance {
Transfer: CreateContractEvent;
Approval: CreateContractEvent;
balanceOf: {
- callAsync: (address: string) => Promise<BigNumber.BigNumber>;
+ callAsync: (address: string, defaultBlock?: Web3.BlockParam) => Promise<BigNumber.BigNumber>;
};
allowance: {
- callAsync: (ownerAddress: string, allowedAddress: string) => Promise<BigNumber.BigNumber>;
+ callAsync: (ownerAddress: string, allowedAddress: string,
+ defaultBlock?: Web3.BlockParam) => Promise<BigNumber.BigNumber>;
};
transfer: {
sendTransactionAsync: (toAddress: string, amountInBaseUnits: BigNumber.BigNumber,