From 813824868ea1e091974a672ce8a63093f643c680 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 9 Jul 2018 10:33:37 +0200 Subject: Return AssetProxyId instead of string from proxy.getProxyIdAsync() --- .../contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts | 5 +++-- .../contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'packages/contract-wrappers') 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..68bdc2de7 100644 --- a/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts @@ -3,6 +3,7 @@ import { ContractAbi } from 'ethereum-types'; import * as _ from 'lodash'; import { artifacts } from '../artifacts'; +import { AssetProxyId } from '../types'; import { assert } from '../utils/assert'; import { ContractWrapper } from './contract_wrapper'; @@ -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 { + public async getProxyIdAsync(): Promise { 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..e249f2f74 100644 --- a/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts @@ -3,6 +3,7 @@ import { ContractAbi } from 'ethereum-types'; import * as _ from 'lodash'; import { artifacts } from '../artifacts'; +import { AssetProxyId } from '../types'; import { assert } from '../utils/assert'; import { ContractWrapper } from './contract_wrapper'; @@ -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 { + public async getProxyIdAsync(): Promise { const ERC721ProxyContractInstance = await this._getERC721ProxyContractAsync(); - const proxyId = await ERC721ProxyContractInstance.getProxyId.callAsync(); + const proxyId = (await ERC721ProxyContractInstance.getProxyId.callAsync()) as AssetProxyId; return proxyId; } /** -- cgit From ab1e38701d40692be0f0e3f2939fda90084564af Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 9 Jul 2018 10:46:15 +0200 Subject: Add revert reason parsing to error handling decorator --- packages/contract-wrappers/src/utils/constants.ts | 1 + packages/contract-wrappers/src/utils/decorators.ts | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'packages/contract-wrappers') diff --git a/packages/contract-wrappers/src/utils/constants.ts b/packages/contract-wrappers/src/utils/constants.ts index 76d805cac..039475b7f 100644 --- a/packages/contract-wrappers/src/utils/constants.ts +++ b/packages/contract-wrappers/src/utils/constants.ts @@ -4,6 +4,7 @@ export const constants = { NULL_ADDRESS: '0x0000000000000000000000000000000000000000', TESTRPC_NETWORK_ID: 50, INVALID_JUMP_PATTERN: 'invalid JUMP at', + REVERT: 'revert', OUT_OF_GAS_PATTERN: 'out of gas', INVALID_TAKER_FORMAT: 'instance.taker is not of a type(s) string', // tslint:disable-next-line:custom-no-magic-numbers diff --git a/packages/contract-wrappers/src/utils/decorators.ts b/packages/contract-wrappers/src/utils/decorators.ts index ccb4c6e11..6e77450e8 100644 --- a/packages/contract-wrappers/src/utils/decorators.ts +++ b/packages/contract-wrappers/src/utils/decorators.ts @@ -1,3 +1,4 @@ +import { RevertReason } from '@0xproject/types'; import * as _ from 'lodash'; import { AsyncMethod, ContractWrappersError, SyncMethod } from '../types'; @@ -13,6 +14,10 @@ const contractCallErrorTransformer = (error: Error) => { if (_.includes(error.message, constants.OUT_OF_GAS_PATTERN)) { return new Error(ContractWrappersError.OutOfGas); } + if (_.includes(error.message, constants.REVERT)) { + const revertReason = error.message.split(constants.REVERT)[1].trim(); + return new Error(revertReason); + } return error; }; -- cgit From 0fe0433b9a36f54d394df84495da9b0ba790b451 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 9 Jul 2018 10:46:54 +0200 Subject: Add type for AssetProxyId --- packages/contract-wrappers/src/types.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'packages/contract-wrappers') diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts index 8d19d085f..aa33089cf 100644 --- a/packages/contract-wrappers/src/types.ts +++ b/packages/contract-wrappers/src/types.ts @@ -29,6 +29,11 @@ export enum ContractWrappersError { ERC721NoApproval = 'ERC_721_NO_APPROVAL', } +export declare enum AssetProxyId { + ERC20 = '0xf47261b0', + ERC721 = '0x08e937fa', +} + export enum InternalContractWrappersError { NoAbiDecoder = 'NO_ABI_DECODER', ZrxNotInTokenRegistry = 'ZRX_NOT_IN_TOKEN_REGISTRY', -- cgit From 0f8f5ca5ff20ca79e6fc23ecb92b73021371c0dc Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 9 Jul 2018 10:47:52 +0200 Subject: Add basic validation for exchange contract wrapper --- .../src/contract_wrappers/exchange_wrapper.ts | 171 +++++++++++++++++++-- packages/contract-wrappers/src/types.ts | 6 +- 2 files changed, 159 insertions(+), 18 deletions(-) (limited to 'packages/contract-wrappers') diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts index 0e8664cc9..71da6562f 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 { ExchangeContractErrs, 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,16 @@ 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 { + AssetProxyId, + BlockRange, + EventCallback, + ExchangeWrapperError, + IndexedFilterValues, + MethodOpts, + OrderInfo, + OrderTransactionOpts, +} from '../types'; import { assert } from '../utils/assert'; import { decorators } from '../utils/decorators'; @@ -38,21 +47,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 { - assert.isHexString('proxySignature', proxySignature); + public async getAssetProxyBySignatureAsync(proxyId: AssetProxyId, methodOpts: MethodOpts = {}): Promise { + 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; } /** @@ -152,6 +157,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, @@ -188,7 +200,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, @@ -225,7 +248,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, @@ -268,7 +297,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, @@ -308,6 +343,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, @@ -344,6 +386,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, @@ -380,6 +429,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, @@ -416,6 +472,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, @@ -452,6 +515,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, @@ -490,6 +560,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, @@ -528,6 +605,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, @@ -559,6 +643,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, @@ -588,10 +679,30 @@ export class ExchangeWrapper extends ContractWrapper { 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 redicing 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, @@ -629,6 +740,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, @@ -777,6 +895,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, @@ -806,6 +931,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, @@ -837,6 +969,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, diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts index aa33089cf..e0d83f6ed 100644 --- a/packages/contract-wrappers/src/types.ts +++ b/packages/contract-wrappers/src/types.ts @@ -8,6 +8,10 @@ import { ERC721TokenEventArgs, ERC721TokenEvents } from './contract_wrappers/gen import { ExchangeEventArgs, ExchangeEvents } from './contract_wrappers/generated/exchange'; import { WETH9EventArgs, WETH9Events } from './contract_wrappers/generated/weth9'; +export enum ExchangeWrapperError { + AssetDataMismatch = 'ASSET_DATA_MISMATCH', +} + export enum ContractWrappersError { ExchangeContractDoesNotExist = 'EXCHANGE_CONTRACT_DOES_NOT_EXIST', ZRXContractDoesNotExist = 'ZRX_CONTRACT_DOES_NOT_EXIST', @@ -36,8 +40,6 @@ export declare enum AssetProxyId { export enum InternalContractWrappersError { NoAbiDecoder = 'NO_ABI_DECODER', - ZrxNotInTokenRegistry = 'ZRX_NOT_IN_TOKEN_REGISTRY', - WethNotInTokenRegistry = 'WETH_NOT_IN_TOKEN_REGISTRY', } export type LogEvent = LogEntryEvent; -- cgit From e3bed5cc71bf64aa4bdab6bfc0e6b5c052f8124c Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 9 Jul 2018 11:29:09 +0200 Subject: Default shouldValidate to true --- .../src/contract_wrappers/exchange_wrapper.ts | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'packages/contract-wrappers') diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts index 71da6562f..9319b2238 100644 --- a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts @@ -148,7 +148,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrder: SignedOrder, takerAssetFillAmount: BigNumber, takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema); assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount); @@ -191,7 +191,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrder: SignedOrder, takerAssetFillAmount: BigNumber, takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema); assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount); @@ -239,7 +239,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrder: SignedOrder, takerAssetFillAmount: BigNumber, takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema); assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount); @@ -286,7 +286,7 @@ export class ExchangeWrapper extends ContractWrapper { data: string, signature: string, senderAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.isBigNumber('salt', salt); assert.isETHAddressHex('signerAddress', signerAddress); @@ -331,7 +331,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrders: SignedOrder[], takerAssetFillAmounts: BigNumber[], takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema); _.forEach(takerAssetFillAmounts, takerAssetFillAmount => @@ -376,7 +376,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrders: SignedOrder[], makerAssetFillAmount: BigNumber, takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema); assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); @@ -419,7 +419,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrders: SignedOrder[], takerAssetFillAmount: BigNumber, takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema); assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); @@ -462,7 +462,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrders: SignedOrder[], makerAssetFillAmount: BigNumber, takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema); assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount); @@ -505,7 +505,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrders: SignedOrder[], takerAssetFillAmount: BigNumber, takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema); assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount); @@ -548,7 +548,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrders: SignedOrder[], takerAssetFillAmounts: BigNumber[], takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema); _.forEach(takerAssetFillAmounts, takerAssetFillAmount => @@ -593,7 +593,7 @@ export class ExchangeWrapper extends ContractWrapper { signedOrders: SignedOrder[], takerAssetFillAmounts: BigNumber[], takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema); _.forEach(takerAssetFillAmounts, takerAssetFillAmount => @@ -633,7 +633,7 @@ export class ExchangeWrapper extends ContractWrapper { @decorators.asyncZeroExErrorHandler public async batchCancelOrdersAsync( orders: Array, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('orders', orders, schemas.ordersSchema); assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]); @@ -672,7 +672,7 @@ export class ExchangeWrapper extends ContractWrapper { leftSignedOrder: SignedOrder, rightSignedOrder: SignedOrder, takerAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('leftSignedOrder', leftSignedOrder, schemas.signedOrderSchema); assert.doesConformToSchema('rightSignedOrder', rightSignedOrder, schemas.signedOrderSchema); @@ -731,7 +731,7 @@ export class ExchangeWrapper extends ContractWrapper { signerAddress: string, signature: string, senderAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.isHexString('hash', hash); assert.isETHAddressHex('signerAddress', signerAddress); @@ -887,7 +887,7 @@ export class ExchangeWrapper extends ContractWrapper { @decorators.asyncZeroExErrorHandler public async cancelOrderAsync( order: Order | SignedOrder, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.doesConformToSchema('order', order, schemas.orderSchema); await assert.isSenderAddressAsync('order.maker', order.makerAddress, this._web3Wrapper); @@ -922,7 +922,7 @@ export class ExchangeWrapper extends ContractWrapper { validatorAddress: string, isApproved: boolean, senderAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.isETHAddressHex('validatorAddress', validatorAddress); assert.isBoolean('isApproved', isApproved); @@ -961,7 +961,7 @@ export class ExchangeWrapper extends ContractWrapper { public async cancelOrdersUpToAsync( targetOrderEpoch: BigNumber, senderAddress: string, - orderTransactionOpts: OrderTransactionOpts = {}, + orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true }, ): Promise { assert.isBigNumber('targetOrderEpoch', targetOrderEpoch); await assert.isSenderAddressAsync('senderAddress', senderAddress, this._web3Wrapper); -- cgit From 12f30c78ff342f5a34b709a6c7d4a34a0c134692 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 9 Jul 2018 11:29:42 +0200 Subject: Fix a typo --- packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/contract-wrappers') diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts index 9319b2238..0e6be132b 100644 --- a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts @@ -685,7 +685,7 @@ export class ExchangeWrapper extends ContractWrapper { ) { 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 redicing the size of call data + // 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'; } -- cgit From 9fb7865292e52a62e90facfd57670366c8caf3a8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 9 Jul 2018 11:43:00 +0200 Subject: Dedupe AssetProxyId types --- .../contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts | 2 +- .../contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts | 2 +- packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts | 3 +-- packages/contract-wrappers/src/types.ts | 5 ----- 4 files changed, 3 insertions(+), 9 deletions(-) (limited to 'packages/contract-wrappers') 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 68bdc2de7..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,9 +1,9 @@ +import { AssetProxyId } from '@0xproject/types'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { ContractAbi } from 'ethereum-types'; import * as _ from 'lodash'; import { artifacts } from '../artifacts'; -import { AssetProxyId } from '../types'; import { assert } from '../utils/assert'; import { ContractWrapper } from './contract_wrapper'; 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 e249f2f74..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,9 +1,9 @@ +import { AssetProxyId } from '@0xproject/types'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { ContractAbi } from 'ethereum-types'; import * as _ from 'lodash'; import { artifacts } from '../artifacts'; -import { AssetProxyId } from '../types'; import { assert } from '../utils/assert'; import { ContractWrapper } from './contract_wrapper'; diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts index 0e6be132b..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 { ExchangeContractErrs, 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'; @@ -10,7 +10,6 @@ import { methodOptsSchema } from '../schemas/method_opts_schema'; import { orderTxOptsSchema } from '../schemas/order_tx_opts_schema'; import { txOptsSchema } from '../schemas/tx_opts_schema'; import { - AssetProxyId, BlockRange, EventCallback, ExchangeWrapperError, diff --git a/packages/contract-wrappers/src/types.ts b/packages/contract-wrappers/src/types.ts index e0d83f6ed..f9d7a6b9f 100644 --- a/packages/contract-wrappers/src/types.ts +++ b/packages/contract-wrappers/src/types.ts @@ -33,11 +33,6 @@ export enum ContractWrappersError { ERC721NoApproval = 'ERC_721_NO_APPROVAL', } -export declare enum AssetProxyId { - ERC20 = '0xf47261b0', - ERC721 = '0x08e937fa', -} - export enum InternalContractWrappersError { NoAbiDecoder = 'NO_ABI_DECODER', } -- cgit