aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/contract_wrappers
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contract-wrappers/src/contract_wrappers')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts5
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts5
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts204
3 files changed, 177 insertions, 37 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
index 883d7c4d6..821d1a8a2 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts
@@ -1,3 +1,4 @@
+import { AssetProxyId } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi } from 'ethereum-types';
import * as _ from 'lodash';
@@ -23,9 +24,9 @@ export class ERC20ProxyWrapper extends ContractWrapper {
* Get the 4 bytes ID of this asset proxy
* @return Proxy id
*/
- public async getProxyIdAsync(): Promise<string> {
+ public async getProxyIdAsync(): Promise<AssetProxyId> {
const ERC20ProxyContractInstance = await this._getERC20ProxyContractAsync();
- const proxyId = await ERC20ProxyContractInstance.getProxyId.callAsync();
+ const proxyId = (await ERC20ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId;
return proxyId;
}
/**
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts
index 648c150df..38ecd4687 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts
@@ -1,3 +1,4 @@
+import { AssetProxyId } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi } from 'ethereum-types';
import * as _ from 'lodash';
@@ -23,9 +24,9 @@ export class ERC721ProxyWrapper extends ContractWrapper {
* Get the 4 bytes ID of this asset proxy
* @return Proxy id
*/
- public async getProxyIdAsync(): Promise<string> {
+ public async getProxyIdAsync(): Promise<AssetProxyId> {
const ERC721ProxyContractInstance = await this._getERC721ProxyContractAsync();
- const proxyId = await ERC721ProxyContractInstance.getProxyId.callAsync();
+ const proxyId = (await ERC721ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId;
return proxyId;
}
/**
diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts
index 0e8664cc9..8b7148aed 100644
--- a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts
@@ -1,5 +1,5 @@
import { schemas } from '@0xproject/json-schemas';
-import { Order, SignedOrder } from '@0xproject/types';
+import { AssetProxyId, Order, SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
@@ -9,7 +9,15 @@ import { artifacts } from '../artifacts';
import { methodOptsSchema } from '../schemas/method_opts_schema';
import { orderTxOptsSchema } from '../schemas/order_tx_opts_schema';
import { txOptsSchema } from '../schemas/tx_opts_schema';
-import { BlockRange, EventCallback, IndexedFilterValues, MethodOpts, OrderInfo, OrderTransactionOpts } from '../types';
+import {
+ BlockRange,
+ EventCallback,
+ ExchangeWrapperError,
+ IndexedFilterValues,
+ MethodOpts,
+ OrderInfo,
+ OrderTransactionOpts,
+} from '../types';
import { assert } from '../utils/assert';
import { decorators } from '../utils/decorators';
@@ -38,21 +46,17 @@ export class ExchangeWrapper extends ContractWrapper {
}
/**
* Retrieve the address of an asset proxy by signature.
- * @param proxySignature The 4 bytes signature of an asset proxy
+ * @param proxyId The 4 bytes signature of an asset proxy
* @param methodOpts Optional arguments this method accepts.
* @return The address of an asset proxy for a given signature
*/
- public async getAssetProxyBySignatureAsync(proxySignature: string, methodOpts: MethodOpts = {}): Promise<string> {
- assert.isHexString('proxySignature', proxySignature);
+ public async getAssetProxyBySignatureAsync(proxyId: AssetProxyId, methodOpts: MethodOpts = {}): Promise<string> {
+ assert.doesBelongToStringEnum('proxyId', proxyId, AssetProxyId);
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
const exchangeContract = await this._getExchangeContractAsync();
const txData = {};
- const assetProxy = await exchangeContract.getAssetProxy.callAsync(
- proxySignature,
- txData,
- methodOpts.defaultBlock,
- );
+ const assetProxy = await exchangeContract.getAssetProxy.callAsync(proxyId, txData, methodOpts.defaultBlock);
return assetProxy;
}
/**
@@ -143,7 +147,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrder: SignedOrder,
takerAssetFillAmount: BigNumber,
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount);
@@ -152,6 +156,13 @@ export class ExchangeWrapper extends ContractWrapper {
const normalizedTakerAddress = takerAddress.toLowerCase();
const exchangeInstance = await this._getExchangeContractAsync();
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.fillOrder.callAsync(signedOrder, takerAssetFillAmount, signedOrder.signature, {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.fillOrder.sendTransactionAsync(
signedOrder,
@@ -179,7 +190,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrder: SignedOrder,
takerAssetFillAmount: BigNumber,
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount);
@@ -188,7 +199,18 @@ export class ExchangeWrapper extends ContractWrapper {
const normalizedTakerAddress = takerAddress.toLowerCase();
const exchangeInstance = await this._getExchangeContractAsync();
-
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.fillOrderNoThrow.callAsync(
+ signedOrder,
+ takerAssetFillAmount,
+ signedOrder.signature,
+ {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ },
+ );
+ }
const txHash = await exchangeInstance.fillOrderNoThrow.sendTransactionAsync(
signedOrder,
takerAssetFillAmount,
@@ -216,7 +238,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrder: SignedOrder,
takerAssetFillAmount: BigNumber,
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount);
@@ -225,7 +247,13 @@ export class ExchangeWrapper extends ContractWrapper {
const normalizedTakerAddress = takerAddress.toLowerCase();
const exchangeInstance = await this._getExchangeContractAsync();
-
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.fillOrKillOrder.callAsync(signedOrder, takerAssetFillAmount, signedOrder.signature, {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.fillOrKillOrder.sendTransactionAsync(
signedOrder,
takerAssetFillAmount,
@@ -257,7 +285,7 @@ export class ExchangeWrapper extends ContractWrapper {
data: string,
signature: string,
senderAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.isBigNumber('salt', salt);
assert.isETHAddressHex('signerAddress', signerAddress);
@@ -268,7 +296,13 @@ export class ExchangeWrapper extends ContractWrapper {
const normalizedSenderAddress = senderAddress.toLowerCase();
const exchangeInstance = await this._getExchangeContractAsync();
-
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.executeTransaction.callAsync(salt, signerAddress, data, signature, {
+ from: normalizedSenderAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.executeTransaction.sendTransactionAsync(
salt,
signerAddress,
@@ -296,7 +330,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrders: SignedOrder[],
takerAssetFillAmounts: BigNumber[],
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
_.forEach(takerAssetFillAmounts, takerAssetFillAmount =>
@@ -308,6 +342,13 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeInstance = await this._getExchangeContractAsync();
const signatures = _.map(signedOrders, signedOrder => signedOrder.signature);
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.batchFillOrders.callAsync(signedOrders, takerAssetFillAmounts, signatures, {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.batchFillOrders.sendTransactionAsync(
signedOrders,
takerAssetFillAmounts,
@@ -334,7 +375,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrders: SignedOrder[],
makerAssetFillAmount: BigNumber,
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount);
@@ -344,6 +385,13 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeInstance = await this._getExchangeContractAsync();
const signatures = _.map(signedOrders, signedOrder => signedOrder.signature);
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.marketBuyOrders.callAsync(signedOrders, makerAssetFillAmount, signatures, {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.marketBuyOrders.sendTransactionAsync(
signedOrders,
makerAssetFillAmount,
@@ -370,7 +418,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrders: SignedOrder[],
takerAssetFillAmount: BigNumber,
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount);
@@ -380,6 +428,13 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeInstance = await this._getExchangeContractAsync();
const signatures = _.map(signedOrders, signedOrder => signedOrder.signature);
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.marketSellOrders.callAsync(signedOrders, takerAssetFillAmount, signatures, {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.marketSellOrders.sendTransactionAsync(
signedOrders,
takerAssetFillAmount,
@@ -406,7 +461,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrders: SignedOrder[],
makerAssetFillAmount: BigNumber,
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount);
@@ -416,6 +471,13 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeInstance = await this._getExchangeContractAsync();
const signatures = _.map(signedOrders, signedOrder => signedOrder.signature);
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.marketBuyOrdersNoThrow.callAsync(signedOrders, makerAssetFillAmount, signatures, {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.marketBuyOrdersNoThrow.sendTransactionAsync(
signedOrders,
makerAssetFillAmount,
@@ -442,7 +504,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrders: SignedOrder[],
takerAssetFillAmount: BigNumber,
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount);
@@ -452,6 +514,13 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeInstance = await this._getExchangeContractAsync();
const signatures = _.map(signedOrders, signedOrder => signedOrder.signature);
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.marketSellOrdersNoThrow.callAsync(signedOrders, takerAssetFillAmount, signatures, {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.marketSellOrdersNoThrow.sendTransactionAsync(
signedOrders,
takerAssetFillAmount,
@@ -478,7 +547,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrders: SignedOrder[],
takerAssetFillAmounts: BigNumber[],
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
_.forEach(takerAssetFillAmounts, takerAssetFillAmount =>
@@ -490,6 +559,13 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeInstance = await this._getExchangeContractAsync();
const signatures = _.map(signedOrders, signedOrder => signedOrder.signature);
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.batchFillOrdersNoThrow.callAsync(signedOrders, takerAssetFillAmounts, signatures, {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.batchFillOrdersNoThrow.sendTransactionAsync(
signedOrders,
takerAssetFillAmounts,
@@ -516,7 +592,7 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrders: SignedOrder[],
takerAssetFillAmounts: BigNumber[],
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
_.forEach(takerAssetFillAmounts, takerAssetFillAmount =>
@@ -528,6 +604,13 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeInstance = await this._getExchangeContractAsync();
const signatures = _.map(signedOrders, signedOrder => signedOrder.signature);
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.batchFillOrKillOrders.callAsync(signedOrders, takerAssetFillAmounts, signatures, {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.batchFillOrKillOrders.sendTransactionAsync(
signedOrders,
takerAssetFillAmounts,
@@ -549,7 +632,7 @@ export class ExchangeWrapper extends ContractWrapper {
@decorators.asyncZeroExErrorHandler
public async batchCancelOrdersAsync(
orders: Array<Order | SignedOrder>,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('orders', orders, schemas.ordersSchema);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
@@ -559,6 +642,13 @@ export class ExchangeWrapper extends ContractWrapper {
const normalizedMakerAddress = makerAddress.toLowerCase();
const exchangeInstance = await this._getExchangeContractAsync();
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.batchCancelOrders.callAsync(orders, {
+ from: normalizedMakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.batchCancelOrders.sendTransactionAsync(orders, {
from: normalizedMakerAddress,
gas: orderTransactionOpts.gasLimit,
@@ -581,17 +671,37 @@ export class ExchangeWrapper extends ContractWrapper {
leftSignedOrder: SignedOrder,
rightSignedOrder: SignedOrder,
takerAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('leftSignedOrder', leftSignedOrder, schemas.signedOrderSchema);
assert.doesConformToSchema('rightSignedOrder', rightSignedOrder, schemas.signedOrderSchema);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
const normalizedTakerAddress = takerAddress.toLowerCase();
- // TODO(logvinov): Check that:
- // rightOrder.makerAssetData === leftOrder.takerAssetData;
- // rightOrder.takerAssetData === leftOrder.makerAssetData;
+ if (
+ rightSignedOrder.makerAssetData !== leftSignedOrder.takerAssetData ||
+ rightSignedOrder.takerAssetData !== leftSignedOrder.makerAssetData
+ ) {
+ throw new Error(ExchangeWrapperError.AssetDataMismatch);
+ } else {
+ // Smart contracts assigns the asset data from the left order to the right one so we can save gas on reducing the size of call data
+ rightSignedOrder.makerAssetData = '0x';
+ rightSignedOrder.takerAssetData = '0x';
+ }
const exchangeInstance = await this._getExchangeContractAsync();
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.matchOrders.callAsync(
+ leftSignedOrder,
+ rightSignedOrder,
+ leftSignedOrder.signature,
+ rightSignedOrder.signature,
+ {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ },
+ );
+ }
const txHash = await exchangeInstance.matchOrders.sendTransactionAsync(
leftSignedOrder,
rightSignedOrder,
@@ -620,7 +730,7 @@ export class ExchangeWrapper extends ContractWrapper {
signerAddress: string,
signature: string,
senderAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.isHexString('hash', hash);
assert.isETHAddressHex('signerAddress', signerAddress);
@@ -629,6 +739,13 @@ export class ExchangeWrapper extends ContractWrapper {
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
const normalizedTakerAddress = senderAddress.toLowerCase();
const exchangeInstance = await this._getExchangeContractAsync();
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.preSign.callAsync(hash, signerAddress, signature, {
+ from: normalizedTakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.preSign.sendTransactionAsync(hash, signerAddress, signature, {
from: normalizedTakerAddress,
gas: orderTransactionOpts.gasLimit,
@@ -769,7 +886,7 @@ export class ExchangeWrapper extends ContractWrapper {
@decorators.asyncZeroExErrorHandler
public async cancelOrderAsync(
order: Order | SignedOrder,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('order', order, schemas.orderSchema);
await assert.isSenderAddressAsync('order.maker', order.makerAddress, this._web3Wrapper);
@@ -777,6 +894,13 @@ export class ExchangeWrapper extends ContractWrapper {
const normalizedMakerAddress = order.makerAddress.toLowerCase();
const exchangeInstance = await this._getExchangeContractAsync();
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.cancelOrder.callAsync(order, {
+ from: normalizedMakerAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.cancelOrder.sendTransactionAsync(order, {
from: normalizedMakerAddress,
gas: orderTransactionOpts.gasLimit,
@@ -797,7 +921,7 @@ export class ExchangeWrapper extends ContractWrapper {
validatorAddress: string,
isApproved: boolean,
senderAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.isETHAddressHex('validatorAddress', validatorAddress);
assert.isBoolean('isApproved', isApproved);
@@ -806,6 +930,13 @@ export class ExchangeWrapper extends ContractWrapper {
const normalizedSenderAddress = senderAddress.toLowerCase();
const exchangeInstance = await this._getExchangeContractAsync();
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.setSignatureValidatorApproval.callAsync(validatorAddress, isApproved, {
+ from: normalizedSenderAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.setSignatureValidatorApproval.sendTransactionAsync(
validatorAddress,
isApproved,
@@ -829,7 +960,7 @@ export class ExchangeWrapper extends ContractWrapper {
public async cancelOrdersUpToAsync(
targetOrderEpoch: BigNumber,
senderAddress: string,
- orderTransactionOpts: OrderTransactionOpts = {},
+ orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.isBigNumber('targetOrderEpoch', targetOrderEpoch);
await assert.isSenderAddressAsync('senderAddress', senderAddress, this._web3Wrapper);
@@ -837,6 +968,13 @@ export class ExchangeWrapper extends ContractWrapper {
const normalizedSenderAddress = senderAddress.toLowerCase();
const exchangeInstance = await this._getExchangeContractAsync();
+ if (orderTransactionOpts.shouldValidate) {
+ await exchangeInstance.cancelOrdersUpTo.callAsync(targetOrderEpoch, {
+ from: normalizedSenderAddress,
+ gas: orderTransactionOpts.gasLimit,
+ gasPrice: orderTransactionOpts.gasPrice,
+ });
+ }
const txHash = await exchangeInstance.cancelOrdersUpTo.sendTransactionAsync(targetOrderEpoch, {
from: normalizedSenderAddress,
gas: orderTransactionOpts.gasLimit,