Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Override lower bound gas when gasLimit is defined #5396

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('OracleLayer1GasFeeFlow', () => {
expect(transactionFactoryMock).toHaveBeenCalledWith(
{
from: TRANSACTION_PARAMS_MOCK.from,
gas: TRANSACTION_PARAMS_MOCK.gas,
gasLimit: TRANSACTION_PARAMS_MOCK.gas,
},
expect.anything(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Contract } from '@ethersproject/contracts';
import { Web3Provider, type ExternalProvider } from '@ethersproject/providers';
import type { Hex } from '@metamask/utils';
import { createModuleLogger } from '@metamask/utils';
import { omit } from 'lodash';

import { projectLogger } from '../logger';
import type {
Expand Down Expand Up @@ -103,7 +102,7 @@ export abstract class OracleLayer1GasFeeFlow implements Layer1GasFeeFlow {
transactionMeta: TransactionMeta,
): TransactionMeta['txParams'] {
return {
...omit(transactionMeta.txParams, 'gas'),
...transactionMeta.txParams,
gasLimit: transactionMeta.txParams.gas,
};
}
Expand Down
6 changes: 4 additions & 2 deletions packages/transaction-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,14 @@ export type TransactionParams = {
from: string;

/**
* same as gasLimit?
* Maximum number of units of gas to use for this transaction.
*/
gas?: string;

/**
* Maxmimum number of units of gas to use for this transaction.
* Maximum number of units of gas to use for this transaction.
*
* @deprecated Use `gas` instead.
*/
gasLimit?: string;

Expand Down
5 changes: 5 additions & 0 deletions packages/transaction-controller/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export function normalizeTransactionParams(txParams: TransactionParams) {
normalizedTxParams.value = '0x0';
}

if (normalizedTxParams.gasLimit) {
normalizedTxParams.gas =
normalizedTxParams.gas || normalizedTxParams.gasLimit;
}

return normalizedTxParams;
}

Expand Down
Loading