aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-08-28 01:54:50 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-08-28 04:04:54 +0800
commit68f2dc11b4361af125f9f2ab367d758f673928ea (patch)
tree586025f24ef5324f0195f2b07f86be6622ab39ac /packages/contract-wrappers
parentd6c670dfcb1bd74f675a9a1cf3b86cfcf6cd85df (diff)
downloaddexon-sol-tools-68f2dc11b4361af125f9f2ab367d758f673928ea.tar
dexon-sol-tools-68f2dc11b4361af125f9f2ab367d758f673928ea.tar.gz
dexon-sol-tools-68f2dc11b4361af125f9f2ab367d758f673928ea.tar.bz2
dexon-sol-tools-68f2dc11b4361af125f9f2ab367d758f673928ea.tar.lz
dexon-sol-tools-68f2dc11b4361af125f9f2ab367d758f673928ea.tar.xz
dexon-sol-tools-68f2dc11b4361af125f9f2ab367d758f673928ea.tar.zst
dexon-sol-tools-68f2dc11b4361af125f9f2ab367d758f673928ea.zip
Add getTraderInfo and getTradersInfo to wrapper
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/order_validator_wrapper.ts29
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