Skip to content

Commit 261febc

Browse files
authored
fix: Fix userLevelFee to be medium instead of dappSuggested when gasPrice is suggested (#5773)
## 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 fix `userLevelFee` to be settled to `medium` instead of `dappSuggested` fallback when `gasPrice` is suggested. ## 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 --> ## 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 c488d71 commit 261febc

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

packages/transaction-controller/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Fixed
1515

1616
- Validate correct origin in EIP-7702 transaction ([#5771](https://github.com/MetaMask/core/pull/5771))
17+
- Set `userLevelFee` to `medium` instead of `dappSuggested` when gasPrice is suggested ([#5773](https://github.com/MetaMask/core/5773))
1718

1819
## [55.0.0]
1920

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

+13
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,19 @@ describe('gas-fees', () => {
254254
);
255255
});
256256

257+
it('to medium if no request maxFeePerGas or maxPriorityFeePerGas but suggested gasPrice available', async () => {
258+
delete updateGasFeeRequest.txMeta.txParams.maxFeePerGas;
259+
delete updateGasFeeRequest.txMeta.txParams.maxPriorityFeePerGas;
260+
261+
mockGasFeeFlowMockResponse(FLOW_RESPONSE_GAS_PRICE_MOCK);
262+
263+
await updateGasFees(updateGasFeeRequest);
264+
265+
expect(updateGasFeeRequest.txMeta.userFeeLevel).toBe(
266+
UserFeeLevel.MEDIUM,
267+
);
268+
});
269+
257270
it('to suggested medium maxFeePerGas if request gas price and request maxPriorityFeePerGas', async () => {
258271
updateGasFeeRequest.txMeta.txParams.gasPrice = '0x456';
259272
updateGasFeeRequest.txMeta.txParams.maxPriorityFeePerGas = '0x789';

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

+8
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,14 @@ function getUserFeeLevel(request: GetGasFeeRequest): UserFeeLevel | undefined {
313313
return UserFeeLevel.MEDIUM;
314314
}
315315

316+
if (
317+
!initialParams.maxFeePerGas &&
318+
!initialParams.maxPriorityFeePerGas &&
319+
suggestedGasFees.gasPrice
320+
) {
321+
return UserFeeLevel.MEDIUM;
322+
}
323+
316324
if (txMeta.origin === ORIGIN_METAMASK) {
317325
return UserFeeLevel.MEDIUM;
318326
}

0 commit comments

Comments
 (0)