diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts | 29 |
1 files changed, 27 insertions, 2 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 1e06d191c..dac243434 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 } from '../types'; +import { OrderAndTraderInfo, OrdersAndTradersInfo, TraderInfo } from '../types'; import { assert } from '../utils/assert'; import { ContractWrapper } from './contract_wrapper'; @@ -26,7 +26,7 @@ export class OrderValidatorWrapper extends ContractWrapper { super(web3Wrapper, networkId); } /** - * Get and object conforming to OrderAndTraderInfo containing on-chain information of the provided order and address + * Get an object conforming to OrderAndTraderInfo containing on-chain information of the provided order and address * @return OrderAndTraderInfo */ public async getOrderAndTraderInfoAsync(order: SignedOrder, takerAddress: string): Promise<OrderAndTraderInfo> { @@ -67,6 +67,31 @@ export class OrderValidatorWrapper extends ContractWrapper { }; return result; } + /** + * Get an object conforming to TraderInfo containing on-chain balance and allowances for maker and taker of order + * @return TraderInfo + */ + public async getTraderInfoAsync(order: SignedOrder, takerAddress: string): Promise<TraderInfo> { + assert.doesConformToSchema('order', order, schemas.signedOrderSchema); + assert.isETHAddressHex('takerAddress', takerAddress); + const OrderValidatorContractInstance = await this._getOrderValidatorContractAsync(); + const result = await OrderValidatorContractInstance.getTraderInfo.callAsync(order, takerAddress); + return result; + } + /** + * Get an array of objects conforming to TraderInfo containing on-chain balance and allowances for maker and taker of order + * @return array of TraderInfo + */ + public async getTradersInfoAsync(orders: SignedOrder[], takerAddresses: string[]): Promise<TraderInfo[]> { + assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema); + _.forEach(takerAddresses, (takerAddress, index) => + assert.isETHAddressHex(`takerAddresses[${index}]`, takerAddress), + ); + assert.assert(orders.length === takerAddresses.length, 'Expected orders.length to equal takerAddresses.length'); + const OrderValidatorContractInstance = await this._getOrderValidatorContractAsync(); + const result = await OrderValidatorContractInstance.getTradersInfo.callAsync(orders, takerAddresses); + 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 |