Skip to content

Commit 44608df

Browse files
committed
Add gasLimitNoBuffer support for legacy transactions
1 parent d96d86b commit 44608df

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

shared/modules/gas.utils.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ export function getMaximumGasTotalInHexWei({
5959
*/
6060
export function getMinimumGasTotalInHexWei({
6161
gasLimit = '0x0',
62+
gasLimitNoBuffer,
6263
gasPrice,
6364
maxPriorityFeePerGas,
6465
maxFeePerGas,
6566
baseFeePerGas,
6667
} = {}) {
68+
const minimumGasLimit = gasLimitNoBuffer ?? gasLimit;
6769
const isEIP1559Estimate = Boolean(
6870
maxFeePerGas || maxPriorityFeePerGas || baseFeePerGas,
6971
);
@@ -91,16 +93,22 @@ export function getMinimumGasTotalInHexWei({
9193
);
9294
}
9395
if (isEIP1559Estimate === false) {
94-
return getMaximumGasTotalInHexWei({ gasLimit, gasPrice });
96+
return getMaximumGasTotalInHexWei({
97+
gasLimit: minimumGasLimit,
98+
gasPrice,
99+
});
95100
}
96101
const minimumFeePerGas = new Numeric(baseFeePerGas, 16)
97102
.add(new Numeric(maxPriorityFeePerGas, 16))
98103
.toString();
99104

100105
if (new Numeric(minimumFeePerGas, 16).greaterThan(maxFeePerGas, 16)) {
101-
return getMaximumGasTotalInHexWei({ gasLimit, maxFeePerGas });
106+
return getMaximumGasTotalInHexWei({
107+
gasLimit: minimumGasLimit,
108+
maxFeePerGas,
109+
});
102110
}
103-
return new Numeric(gasLimit, 16)
111+
return new Numeric(minimumGasLimit, 16)
104112
.times(new Numeric(minimumFeePerGas, 16))
105113
.toPrefixedHexString();
106114
}

ui/pages/confirmations/hooks/useGasEstimates.js

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export function useGasEstimates({
6969
// gas fees.
7070
let gasSettings = {
7171
gasLimit: decimalToHex(gasLimit),
72+
gasLimitNoBuffer: transaction.gasLimitNoBuffer,
7273
};
7374
if (supportsEIP1559) {
7475
gasSettings = {

ui/selectors/confirm-transaction.js

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export const transactionFeeSelector = function (state, txData) {
216216

217217
const gasEstimationObject = {
218218
gasLimit: txData.txParams?.gas ?? '0x0',
219+
gasLimitNoBuffer: txData?.gasLimitNoBuffer
219220
};
220221

221222
if (networkAndAccountSupportsEIP1559) {

0 commit comments

Comments
 (0)