Skip to content

refactor(musd): replace decodeMerklClaimAmount with getClaimPayoutFromReceipt cp-7.66.0#26342

Merged
Matt561 merged 2 commits into
mainfrom
claim-tx-fix
Feb 20, 2026
Merged

refactor(musd): replace decodeMerklClaimAmount with getClaimPayoutFromReceipt cp-7.66.0#26342
Matt561 merged 2 commits into
mainfrom
claim-tx-fix

Conversation

@PatrykLucka

@PatrykLucka PatrykLucka commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Description

The mUSD claim transaction amount was displaying the cumulative total reward (from Merkl distributor calldata amounts[0]) instead of the actual per-transaction payout. This caused incorrect amounts in the Activity list and transaction detail views — e.g., if a user made multiple claims, each one would show the running total rather than what was actually claimed in that specific transaction.

The fix introduces getClaimPayoutFromReceipt() which extracts the real payout from the ERC-20 Transfer event in the transaction receipt logs (emitted when the Merkl distributor transfers mUSD to the user). This is used as the primary source for confirmed transactions across:

  • Activity list (decodeMusdClaimTx)
  • Transaction detail hero (useClaimAmount)
  • Confirmation flow (useMerklClaimAmount)

Changelog

CHANGELOG entry: Fixed mUSD claim transactions showing incorrect cumulative total instead of per-transaction payout amount

Related issues

Fixes:

Manual testing steps

Feature: mUSD claim transaction amount display

  Scenario: user views a confirmed mUSD claim transaction in Activity
    Given user has made one or more mUSD claim transactions from this device
    And at least one claim transaction is confirmed

    When user navigates to the Activity tab
    Then the claim transaction shows the correct per-transaction payout amount (not cumulative total)

  Scenario: user views claim transaction details
    Given user has a confirmed mUSD claim transaction visible in Activity

    When user taps on the claim transaction
    Then the detail view shows the correct claimed amount matching the actual payout

  Scenario: user views a pending mUSD claim in the Activity list
    Given user has a pending mUSD claim transaction

    When user views the transaction in Activity
    Then the amount shows "Not available" until the transaction confirms
    And once confirmed, the correct payout amount appears

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Touches transaction amount display logic across multiple surfaces and relies on receipt log shape/topic matching; incorrect parsing could cause missing/incorrect amounts but does not affect signing or on-chain behavior.

Overview
mUSD claim amount rendering is updated to use the actual per-transaction payout by extracting the mUSD Transfer event from the confirmed transaction receipt, replacing the prior calldata-based decode that returned cumulative totals.

This introduces getClaimPayoutFromReceipt() in Earn/utils/musd (matches Transfer topic + mUSD token address + from=MERKL_DISTRIBUTOR_ADDRESS + to=user) and wires it into the Activity list (decodeMusdClaimTx), the transaction details hero (useClaimAmount), and the confirmations flow (useMerklClaimAmount, with receipt-first for confirmed txs and contract-computed fallback for pending). Tests are updated accordingly to validate log parsing and UI behavior.

Written by Cursor Bugbot for commit 9674cf7. This will update automatically on new commits. Configure here.

@PatrykLucka PatrykLucka self-assigned this Feb 20, 2026
@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.

@metamaskbot metamaskbot added the team-mobile-ux Mobile UX team label Feb 20, 2026
@PatrykLucka PatrykLucka marked this pull request as ready for review February 20, 2026 13:28
@PatrykLucka PatrykLucka requested review from a team as code owners February 20, 2026 13:28
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The PR changes how mUSD claim amounts are extracted from transactions - switching from decoding transaction calldata (decodeMerklClaimAmount) to extracting from transaction receipt logs (getClaimPayoutFromReceipt). This affects:

  1. TransactionElement/utils.js - Used for displaying transaction details in activity lists, now extracts claim amount from txReceipt.logs instead of data
  2. transaction-details-hero.tsx - Confirmation component showing transaction details for mUSD claims
  3. useMerklClaimAmount.ts - Hook for computing claim amounts, now prioritizes receipt logs for confirmed transactions

The changes are well-contained to the Earn/mUSD claim functionality with comprehensive unit tests. Selected tags:

  • SmokeWalletPlatform: mUSD conversion tests are tagged with this, and transaction history display is affected
  • SmokeTrade: Gasless swap tests involve mUSD, stake tests use Earn button, and the Earn feature is related to trading functionality
  • SmokeConfirmations: The transaction-details-hero component is part of the confirmations flow, and the useMerklClaimAmount hook is used in confirmations

The risk is medium because while the logic change is significant (from calldata to receipt logs), it's a targeted improvement with good test coverage and doesn't affect core wallet functionality.

Performance Test Selection:
No performance impact expected. The changes are to utility functions that extract data from transaction receipts - this is a data parsing change, not a UI rendering or data loading change. The functions are called synchronously and the logic change (from calldata decoding to receipt log parsing) should have negligible performance difference.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@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.

if (isTransferEvent && isFromDistributor && isToUser && isMuSDToken) {
const amount = log.data;
if (!amount) continue;
return BigInt(amount).toString();

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.

Missing error handling in receipt parsing

Medium Severity

BigInt(amount) on line 288 can throw if log.data is malformed (e.g., "0x" or invalid hex), crashing the UI instead of gracefully returning null. The removed decodeMerklClaimAmount function had try-catch protection via decodeMerklClaimParams, making this a regression in error handling.

Fix in Cursor Fix in Web

@Matt561 Matt561 changed the title refactor(musd): replace decodeMerklClaimAmount with getClaimPayoutFromReceipt refactor(musd): replace decodeMerklClaimAmount with getClaimPayoutFromReceipt cp-7.66.0 Feb 20, 2026
@Matt561 Matt561 added this pull request to the merge queue Feb 20, 2026
Merged via the queue into main with commit 0ef570f Feb 20, 2026
108 checks passed
@Matt561 Matt561 deleted the claim-tx-fix branch February 20, 2026 16:40
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 20, 2026
@metamaskbot metamaskbot added the release-7.68.0 Issue or pull request that will be included in release 7.68.0 label Feb 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.68.0 Issue or pull request that will be included in release 7.68.0 size-M team-mobile-ux Mobile UX team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants