1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

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
This commit is contained in:
Dan J Miller 2021-07-20 15:07:07 -02:30 committed by GitHub
parent 0f90c4239a
commit b7ee6f47f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -183,8 +183,19 @@ async function estimateGasLimitForSend({
let isSimpleSendOnNonStandardNetwork = false; let isSimpleSendOnNonStandardNetwork = false;
// blockGasLimit may be a falsy, but defined, value when we receive it from // 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. // state, so we use logical or to fall back to MIN_GAS_LIMIT_HEX. Some
const blockGasLimit = options.blockGasLimit || MIN_GAS_LIMIT_HEX; // 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 // 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 // how much gas will be used for a transaction. That background process is
// located in tx-gas-utils.js in the transaction controller folder. // located in tx-gas-utils.js in the transaction controller folder.