aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/exchange_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-09 00:50:39 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-09 00:50:39 +0800
commit62b8a2690b20a7fde83144a2205d5927ac0a55d1 (patch)
treef0e45874bd7c5241b319bb01b9d09b8e8d69fdc2 /src/contract_wrappers/exchange_wrapper.ts
parent743ba29918715e21c7891b3c7426dcb5fdc14e17 (diff)
downloaddexon-0x-contracts-62b8a2690b20a7fde83144a2205d5927ac0a55d1.tar.gz
dexon-0x-contracts-62b8a2690b20a7fde83144a2205d5927ac0a55d1.tar.zst
dexon-0x-contracts-62b8a2690b20a7fde83144a2205d5927ac0a55d1.zip
Add orderCancelrequestsSchema and orderFillRequestsSchema
Diffstat (limited to 'src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 73ec0886c..ed0438372 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -28,6 +28,8 @@ import {utils} from '../utils/utils';
import {ContractWrapper} from './contract_wrapper';
import * as ExchangeArtifacts from '../artifacts/Exchange.json';
import {ecSignatureSchema} from '../schemas/ec_signature_schema';
+import {orderFillRequestsSchema} from '../schemas/order_fill_requests_schema';
+import {orderCancellationRequestsSchema} from '../schemas/order_cancel_schema';
import {orderFillOrKillRequestsSchema} from '../schemas/order_fill_or_kill_requests_schema';
import {signedOrderSchema, orderSchema} from '../schemas/order_schemas';
import {SchemaValidator} from '../utils/schema_validator';
@@ -170,12 +172,10 @@ export class ExchangeWrapper extends ContractWrapper {
shouldCheckTransfer: boolean, takerAddress: string): Promise<void> {
assert.isBoolean('shouldCheckTransfer', shouldCheckTransfer);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this.web3Wrapper);
- _.forEach(orderFillRequests,
- async (orderFillRequest: OrderFillRequest, i: number) => {
- assert.doesConformToSchema(`orderFillRequests[${i}].signedOrder`,
- SchemaValidator.convertToJSONSchemaCompatibleObject(orderFillRequest.signedOrder as object),
- signedOrderSchema);
- assert.isBigNumber(`orderFillRequests[${i}].takerTokenFillAmount`, orderFillRequest.takerTokenFillAmount);
+ assert.doesConformToSchema('orderFillRequests',
+ SchemaValidator.convertToJSONSchemaCompatibleObject(orderFillRequests as object),
+ orderFillRequestsSchema);
+ _.forEach(orderFillRequests, async (orderFillRequest: OrderFillRequest) => {
await this.validateFillOrderAndThrowIfInvalidAsync(
orderFillRequest.signedOrder, orderFillRequest.takerTokenFillAmount, takerAddress);
});
@@ -333,8 +333,8 @@ export class ExchangeWrapper extends ContractWrapper {
public async cancelOrderAsync(
order: Order|SignedOrder, takerTokenCancelAmount: BigNumber.BigNumber): Promise<void> {
assert.doesConformToSchema('order',
- SchemaValidator.convertToJSONSchemaCompatibleObject(order as object),
- orderSchema);
+ SchemaValidator.convertToJSONSchemaCompatibleObject(order),
+ orderSchema);
assert.isBigNumber('takerTokenCancelAmount', takerTokenCancelAmount);
await assert.isSenderAddressAsync('order.maker', order.maker, this.web3Wrapper);
@@ -373,14 +373,10 @@ export class ExchangeWrapper extends ContractWrapper {
assert.assert(_.uniq(makers).length === 1, ExchangeContractErrs.MULTIPLE_MAKERS_IN_SINGLE_CANCEL_BATCH);
const maker = makers[0];
await assert.isSenderAddressAsync('maker', maker, this.web3Wrapper);
- _.forEach(orderCancellationRequests,
- async (cancellationRequest: OrderCancellationRequest, i: number) => {
- assert.doesConformToSchema(`orderCancellationRequests[${i}].order`,
- SchemaValidator.convertToJSONSchemaCompatibleObject(cancellationRequest.order as object), orderSchema,
- );
- assert.isBigNumber(`orderCancellationRequests[${i}].takerTokenCancelAmount`,
- cancellationRequest.takerTokenCancelAmount,
- );
+ assert.doesConformToSchema('orderCancellationRequests',
+ SchemaValidator.convertToJSONSchemaCompatibleObject(orderCancellationRequests),
+ orderCancellationRequestsSchema);
+ _.forEach(orderCancellationRequests, async (cancellationRequest: OrderCancellationRequest) => {
await this.validateCancelOrderAndThrowIfInvalidAsync(
cancellationRequest.order, cancellationRequest.takerTokenCancelAmount,
);