From 32ba65ee265d6acc3fe8ff87a5a36df36cd9a3d5 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 8 Jun 2017 11:16:06 +0200 Subject: Address feedback --- src/contract_wrappers/exchange_wrapper.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 0e0fb2f6f..d144d8aad 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -263,21 +263,24 @@ export class ExchangeWrapper extends ContractWrapper { * All orders must be from the same maker. */ public async batchCancelOrderAsync(orderCancellationRequests: OrderCancellationRequest[]): Promise { - const makers = _.map(orderCancellationRequests, cancellationRequest => cancellationRequest.order.maker); if (_.isEmpty(orderCancellationRequests)) { - return; + return; // no-op } + const makers = _.map(orderCancellationRequests, cancellationRequest => cancellationRequest.order.maker); assert.assert(_.uniq(makers).length === 1, ExchangeContractErrs.MULTIPLE_MAKERS_IN_SINGLE_CANCEL_BATCH); const maker = makers[0]; await assert.isSenderAddressAvailableAsync(this.web3Wrapper, 'maker', maker); _.forEach(orderCancellationRequests, async (cancellationRequest: OrderCancellationRequest, i: number) => { assert.doesConformToSchema(`orderCancellationRequests[${i}].order`, - SchemaValidator.convertToJSONSchemaCompatibleObject(cancellationRequest.order as object), orderSchema); + SchemaValidator.convertToJSONSchemaCompatibleObject(cancellationRequest.order as object), orderSchema, + ); assert.isBigNumber(`orderCancellationRequests[${i}].takerTokenCancelAmount`, - cancellationRequest.takerTokenCancelAmount); + cancellationRequest.takerTokenCancelAmount, + ); await this.validateCancelOrderAndThrowIfInvalidAsync( - cancellationRequest.order, cancellationRequest.takerTokenCancelAmount); + cancellationRequest.order, cancellationRequest.takerTokenCancelAmount, + ); }); const exchangeInstance = await this.getExchangeContractAsync(); const orderAddressesValuesAndTakerTokenCancelAmounts = _.map(orderCancellationRequests, cancellationRequest => { @@ -286,7 +289,7 @@ export class ExchangeWrapper extends ContractWrapper { cancellationRequest.takerTokenCancelAmount, ]; }); - // _.unzip doesn't type check if values have different types :'( + // We use _.unzip because _.unzip doesn't type check if values have different types :'( const [orderAddresses, orderValues, takerTokenCancelAmounts] = _.unzip(orderAddressesValuesAndTakerTokenCancelAmounts); const gas = await exchangeInstance.batchCancel.estimateGas( -- cgit v1.2.3