Skip to content

fix: include Mantle operator fee in Activity Details network fee#33643

Open
adaOctopus wants to merge 1 commit into
mainfrom
fix-mantle-opf
Open

fix: include Mantle operator fee in Activity Details network fee#33643
adaOctopus wants to merge 1 commit into
mainfrom
fix-mantle-opf

Conversation

@adaOctopus

@adaOctopus adaOctopus commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
  • After WPN-1001, confirmation estimates include Mantle’s L1 + operator fee via transactionMeta.layer1GasFee, but Activity Details still showed L2 only (gasUsed × effectiveGasPrice), so the fee after confirm looked lower than before confirm.
  • Activity Details now adds layer1GasFee (preferred; includes Mantle operator fee) or receipt l1Fee onto the network fee.
  • Post-receipt confirmation fee math keeps layer1GasFee instead of dropping it when receiptGasPrice is present.
  • Pre-commit sets a higher Node heap so lint-staged eslint doesn’t OOM.

Test plan

  • Unit tests: yarn jest app/util/activity-adapters/adapters/helpers.test.ts app/components/Views/confirmations/utils/gas.test.ts
  • Mantle: confirm a tx — confirmation fee and Activity Details “Network fee” should align (includes operator fee)
  • Optimism/Base (or other OP Stack): Activity network fee still correct; no double-count of L1
  • Non-L2 chain (e.g. Ethereum): network fee unchanged when layer1GasFee / l1Fee absent

Note

Low Risk
Localized fee math and display changes with unit tests; L1 preference avoids double-counting on OP Stack–style chains.

Overview
Aligns network fee display with pre-confirm estimates on L2 chains (especially Mantle) by including L1 data and operator costs, not only L2 gasUsed × effectiveGasPrice.

Activity Details (getLocalTransactionFees) now adds layer1GasFee when present (TransactionController, includes Mantle operator fee), otherwise receipt l1Fee. layer1GasFee wins over l1Fee so L1 is not double-counted when both exist.

Confirmation UI (calculateGasEstimate): when fees are derived from receipt gas price, layer1GasFee is still added to the L2 total (same behavior as the estimate path).

Pre-commit sets NODE_OPTIONS to an 8GB heap so lint-staged eslint matches yarn lint and avoids OOM on the default ~2GB limit.

Reviewed by Cursor Bugbot for commit ce00a4e. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-authored-by: Cursor <cursoragent@cursor.com>
@adaOctopus
adaOctopus requested a review from a team as a code owner July 22, 2026 10:38
@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamask-ci metamask-ci Bot added team-networks Networks team INVALID-PR-TEMPLATE PR's body doesn't match template labels Jul 22, 2026
@metamask-ci

metamask-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeConfirmations, SmokeWalletPlatform
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR contains three types of changes:

  1. .husky/pre-commit: Infrastructure-only change adding NODE_OPTIONS for memory management during lint-staged. No functional app impact.

  2. app/components/Views/confirmations/utils/gas.ts + gas.test.ts: Bug fix in calculateGasEstimate - when receiptGasPrice is present (i.e., for completed/receipt-based transactions), the function now correctly adds layer1GasFee (L1 data fee + operator fee) to the L2 fee before returning. This directly affects gas fee display in transaction confirmation screens, particularly for L2 networks like Optimism, Mantle, etc. → SmokeConfirmations is required.

  3. app/util/activity-adapters/adapters/helpers.ts + helpers.test.ts: Bug fix in getLocalTransactionFees - adds a new addLayer1FeeToNetworkFeeAmount helper that incorporates layer1GasFee (preferred) or receipt l1Fee into the displayed network fee for completed transactions. This affects the transaction history/activity feed display for L2 network transactions. → SmokeWalletPlatform covers transaction history display (incoming/outgoing ETH transactions, token transfer details).

No other tags are warranted: the changes are scoped to gas fee calculation utilities and activity adapters, not touching swap flows, account management, browser, snaps, network management, or other areas.

Performance Test Selection:
The changes are bug fixes to gas fee calculation utilities and activity adapter helpers. These are pure computation/display logic changes that don't affect app launch, rendering performance, asset loading, onboarding, login, swaps, or any other performance-sensitive flows measured by the available performance test tags. No performance tests are warranted.

View GitHub Actions results

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ce00a4e. Configure here.

if (layer1GasFee) {
return getFeesFromHexFn(addHexes(receiptL2Fee, layer1GasFee) as Hex);
}
return getFeesFromHexFn(receiptL2Fee);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Receipt L1 fee omitted on confirm

Medium Severity

After a tx is mined, calculateGasEstimate adds layer1GasFee to the receipt L2 fee but never falls back to txReceipt.l1Fee. Activity Details now uses that fallback via getLocalTransactionFees, so the same confirmed OP Stack–style tx can show a higher network fee in Activity than on the confirmation/summary path when meta has no layer1GasFee but the receipt includes l1Fee.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ce00a4e. Configure here.

@github-actions github-actions Bot added size-M risk:medium AI analysis: medium risk labels Jul 22, 2026
@sonarqubecloud

Copy link
Copy Markdown

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.62%. Comparing base (801a438) to head (ce00a4e).
⚠️ Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
app/util/activity-adapters/adapters/helpers.ts 88.88% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33643   +/-   ##
=======================================
  Coverage   84.61%   84.62%           
=======================================
  Files        6200     6201    +1     
  Lines      166650   166692   +42     
  Branches    40774    40781    +7     
=======================================
+ Hits       141017   141067   +50     
+ Misses      15984    15976    -8     
  Partials     9649     9649           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template risk:medium AI analysis: medium risk size-M team-networks Networks team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants