aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/exchange_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-07 23:46:55 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-07 23:46:55 +0800
commitbadbaa39fc000e6febced9d8d0118565af7648dc (patch)
tree184dc1db322fc349792fcc7d9394589534f50a42 /src/contract_wrappers/exchange_wrapper.ts
parent3126279de715d74a73af270a730cf5b0c069634f (diff)
downloaddexon-sol-tools-badbaa39fc000e6febced9d8d0118565af7648dc.tar
dexon-sol-tools-badbaa39fc000e6febced9d8d0118565af7648dc.tar.gz
dexon-sol-tools-badbaa39fc000e6febced9d8d0118565af7648dc.tar.bz2
dexon-sol-tools-badbaa39fc000e6febced9d8d0118565af7648dc.tar.lz
dexon-sol-tools-badbaa39fc000e6febced9d8d0118565af7648dc.tar.xz
dexon-sol-tools-badbaa39fc000e6febced9d8d0118565af7648dc.tar.zst
dexon-sol-tools-badbaa39fc000e6febced9d8d0118565af7648dc.zip
Address feedback
Diffstat (limited to 'src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index e4d360690..af8b8db24 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -18,7 +18,8 @@ import {
CreateContractEvent,
ContractEventObj,
EventCallback,
- ContractResponse, OrderCancellationRequest,
+ ContractResponse,
+ OrderCancellationRequest,
} from '../types';
import {assert} from '../utils/assert';
import {utils} from '../utils/utils';
@@ -187,16 +188,18 @@ export class ExchangeWrapper extends ContractWrapper {
*/
public async batchCancelOrderAsync(cancellationRequestsBatch: OrderCancellationRequest[]): Promise<void> {
const makers = _.map(cancellationRequestsBatch, cancellationRequest => cancellationRequest.order.maker);
- assert.assert(!_.isEmpty(cancellationRequestsBatch), 'Can not cancel an empty batch');
- assert.assert(_.uniq(makers).length === 1, 'Can not cancel orders from multiple makers in a single batch');
+ if (_.isEmpty(cancellationRequestsBatch)) {
+ return;
+ }
+ 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(cancellationRequestsBatch,
- async (cancellationRequest: OrderCancellationRequest) => {
- assert.doesConformToSchema('order',
+ async (cancellationRequest: OrderCancellationRequest, i: number) => {
+ assert.doesConformToSchema(`orderCancellationRequests[${i}].order`,
SchemaValidator.convertToJSONSchemaCompatibleObject(cancellationRequest.order as object), orderSchema);
- assert.isBigNumber('takerTokenCancelAmount', cancellationRequest.takerTokenCancelAmount);
- await assert.isSenderAddressAvailableAsync(this.web3Wrapper, 'order.maker',
- cancellationRequest.order.maker);
+ assert.isBigNumber(`orderCancellationRequests[${i}].takerTokenCancelAmount`,
+ cancellationRequest.takerTokenCancelAmount);
await this.validateCancelOrderAndThrowIfInvalidAsync(
cancellationRequest.order, cancellationRequest.takerTokenCancelAmount);
});