aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/exchange_wrapper.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2017-09-28 23:44:29 +0800
committerBrandon Millman <brandon.millman@gmail.com>2017-09-28 23:44:29 +0800
commitd21fbbc4c83cd7dd434f7e8389d48ed35fe0a5b0 (patch)
treebee5d0b011d5d8686711fe8da0bf7553305db3ab /src/contract_wrappers/exchange_wrapper.ts
parent333665370fda26753e137f5b11464493b7d5880c (diff)
downloaddexon-sol-tools-d21fbbc4c83cd7dd434f7e8389d48ed35fe0a5b0.tar
dexon-sol-tools-d21fbbc4c83cd7dd434f7e8389d48ed35fe0a5b0.tar.gz
dexon-sol-tools-d21fbbc4c83cd7dd434f7e8389d48ed35fe0a5b0.tar.bz2
dexon-sol-tools-d21fbbc4c83cd7dd434f7e8389d48ed35fe0a5b0.tar.lz
dexon-sol-tools-d21fbbc4c83cd7dd434f7e8389d48ed35fe0a5b0.tar.xz
dexon-sol-tools-d21fbbc4c83cd7dd434f7e8389d48ed35fe0a5b0.tar.zst
dexon-sol-tools-d21fbbc4c83cd7dd434f7e8389d48ed35fe0a5b0.zip
Fixed nits
Diffstat (limited to 'src/contract_wrappers/exchange_wrapper.ts')
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 2ab1635c1..d02a6e642 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -41,6 +41,8 @@ import {TokenWrapper} from './token_wrapper';
import {decorators} from '../utils/decorators';
import {artifacts} from '../artifacts';
+const SHOULD_VALIDATE_BY_DEFAULT = true;
+
/**
* This class includes all the functionality related to calling methods and subscribing to
* events of the 0x Exchange smart contract.
@@ -169,7 +171,9 @@ export class ExchangeWrapper extends ContractWrapper {
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const exchangeInstance = await this._getExchangeContractAsync();
- const shouldValidate = _.isUndefined(orderTransactionOpts) ? true : orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts) ?
+ SHOULD_VALIDATE_BY_DEFAULT :
+ orderTransactionOpts.shouldValidate;
if (shouldValidate) {
await this.validateFillOrderThrowIfInvalidAsync(signedOrder, fillTakerTokenAmount, takerAddress);
}
@@ -236,7 +240,9 @@ export class ExchangeWrapper extends ContractWrapper {
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
- const shouldValidate = _.isUndefined(orderTransactionOpts) ? true : orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts) ?
+ SHOULD_VALIDATE_BY_DEFAULT :
+ orderTransactionOpts.shouldValidate;
if (shouldValidate) {
await Promise.all(signedOrders.map(signedOrder => this.validateFillOrderThrowIfInvalidAsync(
signedOrder, fillTakerTokenAmount, takerAddress)));
@@ -320,10 +326,13 @@ export class ExchangeWrapper extends ContractWrapper {
ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress);
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
- const shouldValidate = _.isUndefined(orderTransactionOpts) ? true : orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts) ?
+ SHOULD_VALIDATE_BY_DEFAULT :
+ orderTransactionOpts.shouldValidate;
if (shouldValidate) {
await Promise.all(orderFillRequests.map(orderFillRequest => this.validateFillOrderThrowIfInvalidAsync(
- orderFillRequest.signedOrder, orderFillRequest.takerTokenFillAmount, takerAddress)));
+ orderFillRequest.signedOrder, orderFillRequest.takerTokenFillAmount, takerAddress)),
+ );
}
if (_.isEmpty(orderFillRequests)) {
throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem);
@@ -392,7 +401,9 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeInstance = await this._getExchangeContractAsync();
- const shouldValidate = _.isUndefined(orderTransactionOpts) ? true : orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts) ?
+ SHOULD_VALIDATE_BY_DEFAULT :
+ orderTransactionOpts.shouldValidate;
if (shouldValidate) {
await this.validateFillOrKillOrderThrowIfInvalidAsync(signedOrder, fillTakerTokenAmount, takerAddress);
}
@@ -451,10 +462,13 @@ export class ExchangeWrapper extends ContractWrapper {
}
const exchangeInstance = await this._getExchangeContractAsync();
- const shouldValidate = _.isUndefined(orderTransactionOpts) ? true : orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts) ?
+ SHOULD_VALIDATE_BY_DEFAULT :
+ orderTransactionOpts.shouldValidate;
if (shouldValidate) {
await Promise.all(orderFillOrKillRequests.map(request => this.validateFillOrKillOrderThrowIfInvalidAsync(
- request.signedOrder, request.fillTakerAmount, takerAddress)));
+ request.signedOrder, request.fillTakerAmount, takerAddress)),
+ );
}
const orderAddressesValuesAndTakerTokenFillAmounts = _.map(orderFillOrKillRequests, request => {
@@ -514,7 +528,9 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeInstance = await this._getExchangeContractAsync();
- const shouldValidate = _.isUndefined(orderTransactionOpts) ? true : orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts) ?
+ SHOULD_VALIDATE_BY_DEFAULT :
+ orderTransactionOpts.shouldValidate;
if (shouldValidate) {
await this.validateCancelOrderThrowIfInvalidAsync(order, cancelTakerTokenAmount);
}
@@ -562,7 +578,9 @@ export class ExchangeWrapper extends ContractWrapper {
assert.hasAtMostOneUniqueValue(makers, ExchangeContractErrs.MultipleMakersInSingleCancelBatchDisallowed);
const maker = makers[0];
await assert.isSenderAddressAsync('maker', maker, this._web3Wrapper);
- const shouldValidate = _.isUndefined(orderTransactionOpts) ? true : orderTransactionOpts.shouldValidate;
+ const shouldValidate = _.isUndefined(orderTransactionOpts) ?
+ SHOULD_VALIDATE_BY_DEFAULT :
+ orderTransactionOpts.shouldValidate;
if (shouldValidate) {
await Promise.all(orderCancellationRequests.map(cancellationRequest =>
this.validateCancelOrderThrowIfInvalidAsync(