refactor(musd): replace decodeMerklClaimAmount with getClaimPayoutFromReceipt cp-7.66.0#26342
Conversation
|
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
The changes are well-contained to the Earn/mUSD claim functionality with comprehensive unit tests. Selected tags:
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: |
|
| if (isTransferEvent && isFromDistributor && isToUser && isMuSDToken) { | ||
| const amount = log.data; | ||
| if (!amount) continue; | ||
| return BigInt(amount).toString(); |
There was a problem hiding this comment.
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.





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-20Transferevent 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:decodeMusdClaimTx)useClaimAmount)useMerklClaimAmount)Changelog
CHANGELOG entry: Fixed mUSD claim transactions showing incorrect cumulative total instead of per-transaction payout amount
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
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
Transferevent from the confirmed transaction receipt, replacing the prior calldata-based decode that returned cumulative totals.This introduces
getClaimPayoutFromReceipt()inEarn/utils/musd(matchesTransfertopic + 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.