Skip to content

Commit

Permalink
Add gasLimitNoBuffer support for legacy transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
OGPoyraz committed Jan 8, 2025
1 parent d96d86b commit 44608df
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions shared/modules/gas.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ export function getMaximumGasTotalInHexWei({
*/
export function getMinimumGasTotalInHexWei({
gasLimit = '0x0',
gasLimitNoBuffer,
gasPrice,
maxPriorityFeePerGas,
maxFeePerGas,
baseFeePerGas,
} = {}) {
const minimumGasLimit = gasLimitNoBuffer ?? gasLimit;
const isEIP1559Estimate = Boolean(
maxFeePerGas || maxPriorityFeePerGas || baseFeePerGas,
);
Expand Down Expand Up @@ -91,16 +93,22 @@ export function getMinimumGasTotalInHexWei({
);
}
if (isEIP1559Estimate === false) {
return getMaximumGasTotalInHexWei({ gasLimit, gasPrice });
return getMaximumGasTotalInHexWei({
gasLimit: minimumGasLimit,
gasPrice,
});
}
const minimumFeePerGas = new Numeric(baseFeePerGas, 16)
.add(new Numeric(maxPriorityFeePerGas, 16))
.toString();

if (new Numeric(minimumFeePerGas, 16).greaterThan(maxFeePerGas, 16)) {
return getMaximumGasTotalInHexWei({ gasLimit, maxFeePerGas });
return getMaximumGasTotalInHexWei({
gasLimit: minimumGasLimit,
maxFeePerGas,
});
}
return new Numeric(gasLimit, 16)
return new Numeric(minimumGasLimit, 16)
.times(new Numeric(minimumFeePerGas, 16))
.toPrefixedHexString();
}
1 change: 1 addition & 0 deletions ui/pages/confirmations/hooks/useGasEstimates.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export function useGasEstimates({
// gas fees.
let gasSettings = {
gasLimit: decimalToHex(gasLimit),
gasLimitNoBuffer: transaction.gasLimitNoBuffer,
};
if (supportsEIP1559) {
gasSettings = {
Expand Down
1 change: 1 addition & 0 deletions ui/selectors/confirm-transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export const transactionFeeSelector = function (state, txData) {

const gasEstimationObject = {
gasLimit: txData.txParams?.gas ?? '0x0',
gasLimitNoBuffer: txData?.gasLimitNoBuffer

Check failure on line 219 in ui/selectors/confirm-transaction.js

View workflow job for this annotation

GitHub Actions / Test lint / Test lint

Insert `,`
};

if (networkAndAccountSupportsEIP1559) {
Expand Down

0 comments on commit 44608df

Please sign in to comment.