diff --git a/src/constants.ts b/src/constants.ts index dcce8d7ba9..a8ff9a31f7 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -17,6 +17,7 @@ export const DEFAULT_LOGGER_INCLUDE_TIMESTAMP = true; export const ONE_SECOND_MS = 1000; export const ONE_MINUTE_MS = ONE_SECOND_MS * 60; export const TEN_MINUTES_MS = ONE_MINUTE_MS * 10; +export const DEFAULT_VALIDATION_GAS_LIMIT = 10e6; // The number of orders to post to Mesh at one time export const MESH_ORDERS_BATCH_SIZE = 200; diff --git a/src/services/meta_transaction_service.ts b/src/services/meta_transaction_service.ts index 5cf68e5460..1d4372edb7 100644 --- a/src/services/meta_transaction_service.ts +++ b/src/services/meta_transaction_service.ts @@ -21,6 +21,7 @@ import { RFQT_SKIP_BUY_REQUESTS, } from '../config'; import { + DEFAULT_VALIDATION_GAS_LIMIT, ONE_GWEI, ONE_MINUTE_MS, ONE_SECOND_MS, @@ -265,6 +266,7 @@ export class MetaTransactionService { from: PUBLIC_ADDRESS_FOR_ETH_CALLS, gasPrice, value: protocolFee, + gas: DEFAULT_VALIDATION_GAS_LIMIT, }); } catch (err) { // we reach into the underlying revert and throw it instead of @@ -296,7 +298,6 @@ export class MetaTransactionService { protocolFee: BigNumber, ): Promise { const gasPrice = zeroExTransaction.gasPrice; - // TODO(dekz): our pattern is to eth_call and estimateGas in parallel and return the result of eth_call validations const gas = await this._contractWrappers.exchange .executeTransaction(zeroExTransaction, signature) .estimateGasAsync({ diff --git a/src/services/swap_service.ts b/src/services/swap_service.ts index 79f7a5b719..a0dd4c1ef2 100644 --- a/src/services/swap_service.ts +++ b/src/services/swap_service.ts @@ -282,12 +282,8 @@ export class SwapService { } private async _estimateGasOrThrowRevertErrorAsync(txData: Partial): Promise { - // Perform this concurrently - // if the call fails the gas estimation will also fail, we can throw a more helpful - // error message than gas estimation failure - const estimateGasPromise = this._web3Wrapper.estimateGasAsync(txData).catch(_e => 0); - await this._throwIfCallIsRevertErrorAsync(txData); - const gas = await estimateGasPromise; + const gas = await this._web3Wrapper.estimateGasAsync(txData); + await this._throwIfCallIsRevertErrorAsync({ ...txData, gas }); return new BigNumber(gas); }