Skip to content

Commit c767a57

Browse files
authored
fix: Add userFeeLevel as dappSuggested initially when txParams contains gas values for legacy transactions (#5821)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> This PR aims to add `userFeeLevel` as `dappSuggested` initially when `txParams` contains gas values also for `legacy` transactions. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> * Issue found while implementing gas modal: MetaMask/metamask-mobile#15234 ## Changelog <!-- THIS SECTION IS NO LONGER NEEDED. The process for updating changelogs has changed. Please consult the "Updating changelogs" section of the Contributing doc for more. --> ## Checklist - [X] I've updated the test suite for new or updated code as appropriate - [X] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [X] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [X] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent 5e355fd commit c767a57

File tree

4 files changed

+3
-15
lines changed

4 files changed

+3
-15
lines changed

packages/transaction-controller/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12+
- Fix `userFeeLevel` as `dappSuggested` initially when dApp suggested gas values for legacy transactions ([#5821](https://github.com/MetaMask/core/pull/5821))
1213
- Fix `addTransaction` function to correctly identify a transaction as a `simpleSend` type when the recipient is a smart account ([#5822](https://github.com/MetaMask/core/pull/5822))
1314

1415
## [56.1.0]

packages/transaction-controller/src/TransactionController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ import type {
118118
GasFeeEstimateLevel as GasFeeEstimateLevelType,
119119
} from './types';
120120
import {
121+
GasFeeEstimateLevel,
121122
TransactionEnvelopeType,
122123
TransactionType,
123124
TransactionStatus,
124125
SimulationErrorCode,
125-
GasFeeEstimateLevel,
126126
} from './types';
127127
import {
128128
addTransactionBatch,

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,6 @@ describe('gas-fees', () => {
487487
});
488488

489489
describe('sets userFeeLevel', () => {
490-
it('to undefined if not eip1559', async () => {
491-
updateGasFeeRequest.eip1559 = false;
492-
493-
await updateGasFees(updateGasFeeRequest);
494-
495-
expect(updateGasFeeRequest.txMeta.userFeeLevel).toBeUndefined();
496-
});
497-
498490
it('to saved userFeeLevel if saved gas fees defined', async () => {
499491
updateGasFeeRequest.txMeta.type = TransactionType.simpleSend;
500492
updateGasFeeRequest.getSavedGasFees.mockReturnValueOnce({

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,7 @@ function getGasPrice(request: GetGasFeeRequest): string | undefined {
283283
* @returns The user fee level.
284284
*/
285285
function getUserFeeLevel(request: GetGasFeeRequest): UserFeeLevel | undefined {
286-
const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } =
287-
request;
288-
289-
if (!eip1559) {
290-
return undefined;
291-
}
286+
const { initialParams, savedGasFees, suggestedGasFees, txMeta } = request;
292287

293288
if (savedGasFees) {
294289
return UserFeeLevel.CUSTOM;

0 commit comments

Comments
 (0)