aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-08-28 04:49:44 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-08-28 04:49:44 +0800
commit7271fc0bab45c3d85acee102f2e5cf7ec1249268 (patch)
tree507545b0c7a3acc38de0f40f3a4cf95263bffc40 /packages
parent6c039bbeb1fb0a3120a215b2f52e0259bde2553d (diff)
downloaddexon-sol-tools-7271fc0bab45c3d85acee102f2e5cf7ec1249268.tar
dexon-sol-tools-7271fc0bab45c3d85acee102f2e5cf7ec1249268.tar.gz
dexon-sol-tools-7271fc0bab45c3d85acee102f2e5cf7ec1249268.tar.bz2
dexon-sol-tools-7271fc0bab45c3d85acee102f2e5cf7ec1249268.tar.lz
dexon-sol-tools-7271fc0bab45c3d85acee102f2e5cf7ec1249268.tar.xz
dexon-sol-tools-7271fc0bab45c3d85acee102f2e5cf7ec1249268.tar.zst
dexon-sol-tools-7271fc0bab45c3d85acee102f2e5cf7ec1249268.zip
Add getBalancesAndAllowances to wrapper
Diffstat (limited to 'packages')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts
index b33428306..1da88f624 100644
--- a/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts
@@ -127,6 +127,31 @@ export class OrderValidatorWrapper extends ContractWrapper {
return result;
}
/**
+ * Get an array of objects conforming to BalanceAndAllowance containing on-chain balance and allowance for some address and array of assetDatas
+ * @param address An ethereum address
+ * @param assetDatas An array of encoded strings that can be decoded by a specified proxy contract
+ * @return BalanceAndAllowance
+ */
+ public async getBalancesAndAllowancesAsync(address: string, assetDatas: string[]): Promise<BalanceAndAllowance[]> {
+ assert.isETHAddressHex('address', address);
+ _.forEach(assetDatas, (assetData, index) => assert.isHexString(`assetDatas[${index}]`, assetData));
+ const OrderValidatorContractInstance = await this._getOrderValidatorContractAsync();
+ const balancesAndAllowances = await OrderValidatorContractInstance.getBalancesAndAllowances.callAsync(
+ address,
+ assetDatas,
+ );
+ const balances = balancesAndAllowances[0];
+ const allowances = balancesAndAllowances[1];
+ const result = _.map(balances, (balance, index) => {
+ const allowance = allowances[index];
+ return {
+ balance,
+ allowance,
+ };
+ });
+ return result;
+ }
+ /**
* Get owner address of tokenId by calling `token.ownerOf(tokenId)`, but returns a null owner instead of reverting on an unowned token.
* @param tokenAddress An ethereum address
* @param tokenId An ERC721 tokenId