diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-06-09 21:59:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-09 21:59:19 +0800 |
commit | ba9a0b0bb9e87e69c818a5fe73183d8d22476948 (patch) | |
tree | 87a2416fa3c0506ce0fffe2021de05069db4fbc2 /src/contract_wrappers/exchange_wrapper.ts | |
parent | 6d4cb28b9d08df574e7f335196dfdd82f02a74c3 (diff) | |
parent | 389894088d2372e1eb9bf4d39bde2efe8ab38713 (diff) | |
download | dexon-0x-contracts-ba9a0b0bb9e87e69c818a5fe73183d8d22476948.tar dexon-0x-contracts-ba9a0b0bb9e87e69c818a5fe73183d8d22476948.tar.gz dexon-0x-contracts-ba9a0b0bb9e87e69c818a5fe73183d8d22476948.tar.bz2 dexon-0x-contracts-ba9a0b0bb9e87e69c818a5fe73183d8d22476948.tar.lz dexon-0x-contracts-ba9a0b0bb9e87e69c818a5fe73183d8d22476948.tar.xz dexon-0x-contracts-ba9a0b0bb9e87e69c818a5fe73183d8d22476948.tar.zst dexon-0x-contracts-ba9a0b0bb9e87e69c818a5fe73183d8d22476948.zip |
Merge branch 'master' into fillOrderUpToAsync
Diffstat (limited to 'src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 8ea402624..5473e2565 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -29,6 +29,8 @@ import {ContractWrapper} from './contract_wrapper'; import * as ExchangeArtifacts from '../artifacts/Exchange.json'; import {ecSignatureSchema} from '../schemas/ec_signature_schema'; import {signedOrdersSchema} from '../schemas/signed_orders_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'; @@ -237,12 +239,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); }); @@ -400,8 +400,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); @@ -437,14 +437,10 @@ export class ExchangeWrapper extends ContractWrapper { assert.hasAtMostOneUniqueValue(makers, ExchangeContractErrs.MULTIPLE_MAKERS_IN_SINGLE_CANCEL_BATCH_DISALLOWED); 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, ); |