aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contract-wrappers/src')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts20
-rw-r--r--packages/contract-wrappers/src/types.ts6
2 files changed, 25 insertions, 1 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 dac243434..3b83fc53b 100644
--- a/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts
@@ -5,7 +5,7 @@ import { ContractAbi } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from '../artifacts';
-import { OrderAndTraderInfo, OrdersAndTradersInfo, TraderInfo } from '../types';
+import { BalanceAndAllowance, OrderAndTraderInfo, OrdersAndTradersInfo, TraderInfo } from '../types';
import { assert } from '../utils/assert';
import { ContractWrapper } from './contract_wrapper';
@@ -92,6 +92,24 @@ export class OrderValidatorWrapper extends ContractWrapper {
const result = await OrderValidatorContractInstance.getTradersInfo.callAsync(orders, takerAddresses);
return result;
}
+ /**
+ * Get an object conforming to BalanceAndAllowance containing on-chain balance and allowance for some address and assetData
+ * @return BalanceAndAllowance
+ */
+ public async getBalanceAndAllowanceAsync(address: string, assetData: string): Promise<BalanceAndAllowance> {
+ assert.isETHAddressHex('address', address);
+ assert.isHexString('assetData', assetData);
+ const OrderValidatorContractInstance = await this._getOrderValidatorContractAsync();
+ const balanceAndAllowance = await OrderValidatorContractInstance.getBalanceAndAllowance.callAsync(
+ address,
+ assetData,
+ );
+ const result = {
+ balance: balanceAndAllowance[0],
+ allowance: balanceAndAllowance[1],
+ };
+ return result;
+ }
// HACK: We don't want this method to be visible to the other units within that package but not to the end user.
// TS doesn't give that possibility and therefore we make it private and access it over an any cast. Because of that tslint sees it as unused.
// tslint:disable-next-line:no-unused-variable
diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts
index e73a09fe3..c51e0ae48 100644
--- a/packages/contract-wrappers/src/types.ts
+++ b/packages/contract-wrappers/src/types.ts
@@ -204,7 +204,13 @@ export interface OrdersAndTradersInfo {
ordersInfo: OrderInfo[];
tradersInfo: TraderInfo[];
}
+
export interface OrderAndTraderInfo {
orderInfo: OrderInfo;
traderInfo: TraderInfo;
}
+
+export interface BalanceAndAllowance {
+ balance: BigNumber;
+ allowance: BigNumber;
+}