Skip to content

Commit 5c40062

Browse files
fix: Override lower bound gas when gasLimit is defined
1 parent 0c655ee commit 5c40062

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

packages/transaction-controller/src/gas-flows/OracleLayer1GasFeeFlow.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ describe('OracleLayer1GasFeeFlow', () => {
105105
expect(transactionFactoryMock).toHaveBeenCalledWith(
106106
{
107107
from: TRANSACTION_PARAMS_MOCK.from,
108+
gas: TRANSACTION_PARAMS_MOCK.gas,
108109
gasLimit: TRANSACTION_PARAMS_MOCK.gas,
109110
},
110111
expect.anything(),

packages/transaction-controller/src/gas-flows/OracleLayer1GasFeeFlow.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Contract } from '@ethersproject/contracts';
22
import { Web3Provider, type ExternalProvider } from '@ethersproject/providers';
33
import type { Hex } from '@metamask/utils';
44
import { createModuleLogger } from '@metamask/utils';
5-
import { omit } from 'lodash';
65

76
import { projectLogger } from '../logger';
87
import type {
@@ -103,7 +102,7 @@ export abstract class OracleLayer1GasFeeFlow implements Layer1GasFeeFlow {
103102
transactionMeta: TransactionMeta,
104103
): TransactionMeta['txParams'] {
105104
return {
106-
...omit(transactionMeta.txParams, 'gas'),
105+
...transactionMeta.txParams,
107106
gasLimit: transactionMeta.txParams.gas,
108107
};
109108
}

packages/transaction-controller/src/types.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,14 @@ export type TransactionParams = {
752752
from: string;
753753

754754
/**
755-
* same as gasLimit?
755+
* Maximum number of units of gas to use for this transaction.
756756
*/
757757
gas?: string;
758758

759759
/**
760-
* Maxmimum number of units of gas to use for this transaction.
760+
* Maximum number of units of gas to use for this transaction.
761+
*
762+
* @deprecated Use `gas` instead.
761763
*/
762764
gasLimit?: string;
763765

packages/transaction-controller/src/utils/gas.ts

-5
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ async function getGas(
141141
return [txMeta.txParams.gas, undefined, txMeta.txParams.gas];
142142
}
143143

144-
if (txMeta.txParams.gasLimit) {
145-
log('Using value from request', txMeta.txParams.gasLimit);
146-
return [txMeta.txParams.gasLimit, undefined, txMeta.txParams.gasLimit];
147-
}
148-
149144
if (await requiresFixedGas(request)) {
150145
log('Using fixed value', FIXED_GAS);
151146
return [FIXED_GAS, undefined, FIXED_GAS];

packages/transaction-controller/src/utils/utils.ts

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ export function normalizeTransactionParams(txParams: TransactionParams) {
5858
normalizedTxParams.value = '0x0';
5959
}
6060

61+
if (normalizedTxParams.gasLimit) {
62+
normalizedTxParams.gas =
63+
normalizedTxParams.gas || normalizedTxParams.gasLimit;
64+
}
65+
6166
return normalizedTxParams;
6267
}
6368

0 commit comments

Comments
 (0)