Commit ffdaba8
authored
fix(activity-redesign): show token amount on indexed contract interaction activity (#32194)
## **Description**
The redesigned Activity list (behind `tmcuActivityRedesignEnabled`)
rendered some contract interactions without a token amount, while the
extension showed it (e.g. `-0.5801 USDC`).
The cause is in the API/indexed-history adapter: its
`contractInteraction` branch never read the transaction's
`valueTransfers`, so `data.token` was `undefined` and no amount was
displayed. Every other branch already extracts the transfer via
`getToken(...)`.
This change extracts the user-involved transfer (sent first, else
received) and attaches it as `data.token` when it has an amount,
mirroring the extension's `api-evm-transactions` adapter. The
local-transaction path already handled native value, so only the indexed
path needed the fix.
## **Changelog**
CHANGELOG entry: Fixed contract interactions in the redesigned Activity
list not showing the token amount
## **Related issues**
Fixes:
[TMCU-935](https://consensyssoftware.atlassian.net/browse/TMCU-935)
## **Manual testing steps**
```gherkin
Feature: Contract interaction activity amount
Scenario: user views a contract interaction that moved an ERC-20
Given the activity redesign feature flag is enabled
And the account has an indexed contract interaction that transferred an ERC-20 token
When the user opens the Activity tab
Then the contract interaction row shows the token amount (e.g. -0.01 aEthUSDC)
And it matches what the extension displays
```
## **Screenshots/Recordings**
### **Before**
<img width="500" alt="Simulator Screenshot - iPhone 17 - 2026-06-22 at
16 29 24"
src="https://github.com/user-attachments/assets/366e9dee-5122-4bf4-80d0-a67fa2646f24"
/>
### **After**
<img width="500" alt="Simulator Screenshot - iPhone 17 - 2026-06-23 at
09 53 55"
src="https://github.com/user-attachments/assets/706d19d0-f60e-46f5-8464-55c6cc534437"
/>
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Narrow adapter change for activity display only; optional `data.token`
on contract interactions with no auth or transaction execution impact.
>
> **Overview**
> Fixes **contract interaction** rows in the redesigned Activity list
showing no token amount when indexed history includes ERC-20 (or other)
**value transfers**.
>
> The `mapApiEvmTransactions` fallback **`contractInteraction`** branch
now picks the user’s **sent** transfer, or **received** if none, runs it
through the existing **`getToken`** helper, and spreads **`data.token`**
only when the result has an **`amount`**—same pattern as
send/receive/swap branches. Interactions without a quantified transfer
stay unchanged (no `token` field).
>
> Adds a unit test for a **GENERIC_CONTRACT_CALL** with an outbound USDC
transfer asserting **`direction: 'out'`** and formatted amount metadata.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
58b6cc6. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[TMCU-935]:
https://consensyssoftware.atlassian.net/browse/TMCU-935?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ1 parent 83d1e85 commit ffdaba8
2 files changed
Lines changed: 64 additions & 0 deletions
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
894 | 894 | | |
895 | 895 | | |
896 | 896 | | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
897 | 949 | | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
465 | 474 | | |
466 | 475 | | |
467 | 476 | | |
| |||
476 | 485 | | |
477 | 486 | | |
478 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
479 | 491 | | |
480 | 492 | | |
481 | 493 | | |
0 commit comments