Commit 27e3f35
authored
feat(perps): add recent activity section to market details view (#22865)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
This PR adds a "Recent activity" section to the Perps Market Details
view, displaying the 3 most recent trades for the selected market.
## **Changelog**
CHANGELOG entry: Added recent activity section to Perps market details
screen showing the 3 most recent trades
## **Related issues**
Fixes:
https://consensyssoftware.atlassian.net/browse/TAT-1968?atlOrigin=eyJpIjoiODNjZmM2NDUwZGM2NDVmMmE1NmM5MGI5NDJmODBkMGIiLCJwIjoiaiJ9
## **Manual testing steps**
```gherkin
Feature: Recent activity on Perps market details
Scenario: user views recent trades for a market with activity
Given user is on the Perps market details screen for ETH
And user has completed at least one trade for ETH
When user scrolls to the "Recent activity" section
Then user sees up to 3 recent trades for ETH market
And each trade displays the token logo, trade type (e.g., "Opened long"), size, and PnL/fee amount
And user sees a "See all" button in the header
Scenario: user navigates to full activity list
Given user is on the Perps market details screen
And the "Recent activity" section is visible
When user taps the "See all" button
Then user is navigated to the Activity screen with the Trades tab selected
And user sees the back button to return to market details
Scenario: user views trade details
Given user is on the Perps market details screen
And the "Recent activity" section shows trades
When user taps on a trade item
Then user is navigated to the position transaction detail screen
And user sees full details of the selected trade
Scenario: user views market with no recent activity
Given user is on the Perps market details screen for a market
And user has no trades for this market
When user scrolls to the "Recent activity" section
Then user sees "No recent activity" message
Scenario: user views loading state
Given user is on the Perps market details screen
And trades are being fetched
When the "Recent activity" section is loading
Then user sees skeleton loading indicators for 3 rows
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
https://github.com/user-attachments/assets/0c33a281-707e-4d55-b5e2-31ee63f94e1c
## **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]
> Adds a "Recent activity" section to Perps Market Details showing up to
3 latest trades with navigation to Activity and trade detail, plus
supporting constants, i18n, and tests.
>
> - **Perps Market Details UI**:
> - Integrates `PerpsMarketTradesList` into `PerpsMarketDetailsView`,
positioned above the risk disclaimer; moves `PerpsNavigationCard` below
the disclaimer.
> - **New Component**: `components/PerpsMarketTradesList`
> - Fetches order fills via `usePerpsOrderFills`, transforms to
transactions, filters by `symbol`, sorts by `timestamp`, and limits to
`PERPS_CONSTANTS.RECENT_ACTIVITY_LIMIT`.
> - Renders header with title and "See all" (navigates to
`Routes.PERPS.ACTIVITY`), shows skeleton while loading, empty state when
no trades, and navigates to `Routes.PERPS.POSITION_TRANSACTION` on item
press.
> - **Constants**: Adds `PERPS_CONSTANTS.RECENT_ACTIVITY_LIMIT = 3` in
`perpsConfig`.
> - **i18n**: Adds `perps.market.recent_trades` and
`perps.market.no_trades` strings.
> - **Tests**: Comprehensive tests for loading/empty states, rendering,
navigation, hook params, filtering/limiting, edge cases, and FlatList
config in `PerpsMarketTradesList.test.tsx`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2db4a4a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent f29ec33 commit 27e3f35
File tree
7 files changed
+910
-4
lines changed- app/components/UI/Perps
- Views/PerpsMarketDetailsView
- components/PerpsMarketTradesList
- constants
- locales/languages
7 files changed
+910
-4
lines changedLines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
751 | 752 | | |
752 | 753 | | |
753 | 754 | | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
758 | 761 | | |
759 | 762 | | |
760 | 763 | | |
| |||
773 | 776 | | |
774 | 777 | | |
775 | 778 | | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
776 | 784 | | |
777 | 785 | | |
778 | 786 | | |
| |||
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
0 commit comments