From b7ee6f47f83767f4c1e2ddeebea1db7458b3a4bd Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Tue, 20 Jul 2021 15:07:07 -0230 Subject: [PATCH] Ensure gas limit estimation for token sends has correct default/base gas (#11565) * Ensure gas limit estimation for token sends has correct default/base gas * Fix comment change --- ui/ducks/send/send.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/ducks/send/send.js b/ui/ducks/send/send.js index 718d78d93..b10f5fa29 100644 --- a/ui/ducks/send/send.js +++ b/ui/ducks/send/send.js @@ -183,8 +183,19 @@ async function estimateGasLimitForSend({ let isSimpleSendOnNonStandardNetwork = false; // blockGasLimit may be a falsy, but defined, value when we receive it from - // state, so we use logical or to fall back to MIN_GAS_LIMIT_HEX. - const blockGasLimit = options.blockGasLimit || MIN_GAS_LIMIT_HEX; + // state, so we use logical or to fall back to MIN_GAS_LIMIT_HEX. Some + // network implementations check the gas parameter supplied to + // eth_estimateGas for validity. For this reason, we set token sends + // blockGasLimit default to a higher number. Note that the current gasLimit + // on a BLOCK is 15,000,000 and will be 30,000,000 on mainnet after London. + // Meanwhile, MIN_GAS_LIMIT_HEX is 0x5208. + let blockGasLimit = MIN_GAS_LIMIT_HEX; + if (options.blockGasLimit) { + blockGasLimit = options.blockGasLimit; + } else if (sendToken) { + blockGasLimit = GAS_LIMITS.BASE_TOKEN_ESTIMATE; + } + // The parameters below will be sent to our background process to estimate // how much gas will be used for a transaction. That background process is // located in tx-gas-utils.js in the transaction controller folder.