feat: activity details for perps and predict
Description
Adds redesigned Activity Details support for Perps and Predict activity rows behind the transactions redesign flow.
This PR routes Perps and Predict domain activity to the new ActivityDetails screen, using preloaded domain items when provider-backed data cannot be safely re-read outside its source/provider tree. It adds dedicated Perps and Predict templates, shared timeline/footer/frame building blocks, Polymarket deep links, Perps block explorer links, and domain-specific formatting for trades, orders, funding, deposits, withdrawals, predictions, cash-outs, and winnings claims.
It also expands Perps activity adapter coverage for historical order rows, preserves Polymarket market slugs for details links, and standardizes canceled copy in the redesigned activity surfaces.
Changelog
CHANGELOG entry: Added redesigned activity details for Perps and Predict transactions
Related issues
Fixes:
Manual testing steps
Feature: Redesigned activity details for Perps and Predict
Scenario: user opens a Perps trade from Activity
Given the transactions redesign feature flag is enabled
And the user has Perps trade activity in the Activity list
When the user taps the Perps activity row
Then the Activity Details screen opens
And the Perps trade details, status, date, fees, explorer CTA, and "Trade again" CTA are shown
Scenario: user opens a Perps funds movement from Activity
Given the transactions redesign feature flag is enabled
And the user has Perps deposit or withdrawal activity in the Activity list
When the user taps the Perps funds movement row
Then the Activity Details screen opens
And the funds amount, account metadata, network metadata, step timeline, and fund/withdraw CTA are shown
Scenario: user opens a Predict market activity from Activity
Given the transactions redesign feature flag is enabled
And the user has Predict placed, cashed out, or claim winnings activity in the Activity list
When the user taps the Predict activity row
Then the Activity Details screen opens
And the prediction market context, amount/share rows, Polymarket CTA, and "Place another prediction" CTA are shown where applicable
Scenario: user opens a Predict funds movement from Activity
Given the transactions redesign feature flag is enabled
And the user has Predict add funds or withdraw funds activity in the Activity list
When the user taps the Predict funds row
Then the Activity Details screen opens
And the funds amount, account metadata, network metadata, step timeline, and fund/withdraw CTA are shown
Screenshots/Recordings
Before
After
Pre-merge author checklist
- [x] I've followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards.
- [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 format if applicable
- [x] I've applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
Performance checks (if applicable)
- [ ] I've tested on Android
- Ideally on a mid-range device; emulator is acceptable
- [ ] I've tested with a power user scenario
- Use these power-user SRPs to import wallets with many accounts and tokens
- [ ] I've instrumented key operations with Sentry traces for production performance metrics
- See
trace()for usage andaddTokenfor an example
- See
For performance guidelines and tooling, see the Performance Guide.
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 Large new navigation and detail UI for trading/prediction flows with preloaded-item resolution; adapter changes affect which perps orders appear in activity and how they are classified.
Overview With the transactions redesign enabled, Perps and Predict rows now open the shared Activity Details screen instead of legacy dedicated flows (bridges still use their own screen). Navigation passes an optional
preloadedItemso domain rows whoserawdata cannot be re-fetched outside the provider tree still render correctly; lookup also indexes perps/predict ids and prefers the preloaded row over hash collisions.
TemplateLoaderwires newPerpsDetailsandPredictDetailstemplates (plus shared frame, step timeline, webview footer, and perps hero/metadata). Perps covers trades, orders, funding, and deposit/withdrawal timelines with explorer and repeat CTAs; Predict covers market activity (Polymarket link, P&L when present), claim winnings, and fund movements.The perps activity adapter now maps historical order rows (filled/canceled/rejected) into activity kinds, including new
limitShort/limitCloseShort, with list titles/icons updated accordingly. Polymarket parsing preservesslug,eventSlug, and P&L fields for details and deep links.Copy/UI polish:
transaction.canceled(US spelling) in redesigned surfaces, Predict buy/sell divider fix, and Total Net P&L capitalization.Reviewed by Cursor Bugbot for commit 25e6771b98a4ef07d0cee98ab83278f0a859ca94. Bugbot is set up for automated code reviews on this repo. Configure here.
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.
PR template — items to address before "Ready for review"
Warnings — informational, address before merging:
Pre-merge author checklisthas unchecked items (e.g. "I've tested on Android"). Every box must be consciously checked — seedocs/readme/ready-for-review.md.
See docs/readme/ready-for-review.md for the full Definition of Ready for Review.
Requesting changes, but this is close to ready. I agree that
preloadedItemis the right approach for Perps and Predict rows because the details screen should render the provider backed item it was opened from.The changes I am blocking on are:
- Order rows currently drop the position size subtitle because
sourceToken.amountis missing.- Limit order titles from
transformOrdersToTransactionscan be displayed as market orders.Non-blocking follow-up: I think the new Perps detail formatters should be aligned with the existing Perps formatter contract. I also noticed the legacy Perps order detail screen likely mishandles Triggered-order fees by checking the display text instead of the filled status type; I would not change this new Activity Details behavior to match that legacy zero fee display.
Solid call outs let me look into the issues you raised
Update: Fixed here 07ab66e
Found these:
🔴 High Severity
H1 — preloadedItem is a non-serializable object in React Navigation params
Files: ActivityList.tsx → ActivityDetails.types.ts → ActivityDetails.tsx
The PR passes a full ActivityListItem object as a navigation parameter to avoid re-fetching provider-backed Perps/Predict items outside their source tree:
navigation.navigate(Routes.ACTIVITY_DETAILS, {
chainId: item.chainId,
txIdentifier: item.hash,
...(raw.type === 'perpsTransaction' || raw.type === 'predictActivity'
? { preloadedItem: item }
: {}),
});
Problems:
- React Navigation serializes route params to JSON for state persistence, deep-link rehydration, and
@react-navigation/devtools. Non-serializable values (nested class instances, functions, circular references insideraw.data) trigger a dev warning and silently break state persistence for theActivityDetailsroute. - If state is ever restored from persistence (app killed and re-opened via a background notification), the screen will have the
chainId/txIdentifierparams but nopreloadedItem, and Perps/Predict rows will fall through to "not found." - There is no guard in the current
useActivityDetailsItemto skip lookup and return the preloaded item — the branch must introduce this, but it needs to be verified.
Recommendation: Use a module-scoped ref store (e.g. Map<hash, ActivityListItem>) or React context to hand off the transient item before navigating, and keep route params serializable. If preloadedItem stays in params, the ActivityDetails route must be explicitly excluded from any persisted navigation state and documented as such.
H2 — Claim breakdown ignores totalNetPnlUsd / netPnlUsd (regression vs. legacy)
Files: PredictProviderActivityDetails.tsx, PredictDetailsShared.tsx
The PR adds totalNetPnlUsd and netPnlUsd to PredictActivity and the Polymarket parser, but the new claim template never consumes them. ClaimWinningsBreakdown receives only entry.amount and renders the same gross amount in both the "Total Net P&L" row and the per-market row.
The legacy PredictActivityDetail.tsx correctly used dedicated fields:
// Legacy claim branch
formatCurrencyValue(activity.totalNetPnlUsd ?? entryAmount, { showSign: true }); // total row
formatCurrencyValue(activity.netPnlUsd ?? entryAmount, { showSign: true }); // market row
When the API supplies real P&L figures, users will see the gross claimed amount displayed twice instead of the correct total and per-market P&L values. This is a behavioral regression relative to the legacy screen.
Note: The cashed-out (isSell) P&L path was correctly updated in a follow-up commit to use netPnlUsd with sign-aware coloring. The claim path was missed.
Fix: Mirror the legacy approach — pass activity.totalNetPnlUsd ?? entry.amount for the total row and activity.netPnlUsd ?? entry.amount for the market row inside ClaimWinningsBreakdown.
🟠 Medium Severity
M1 — Order sourceToken.amount derived from subtitle string parsing is fragile
Files: perps-transaction.ts (commit 1af5022)
After reviewer feedback, order row sourceToken.amount is recovered by parsing transaction.subtitle (format: "<size> <symbol>"):
const [sizeStr] = transaction.subtitle?.split(' ') ?? [];
sourceToken: { amount: sizeStr, symbol: transaction.asset, direction }
This is parsing a human-readable display string as structured data. If formatOrderLabel changes its subtitle format (e.g. adds a prefix, uses a non-breaking space, or localizes), sizeStr will silently become undefined or garbage without any test failure. The original approach of computing from size / limitPrice was equally fragile for limit-price-absent cases.
Recommendation: Either surface size as a dedicated structured field in PerpsTransaction.order, or add a guard and fallback with a logged warning so the failure mode is visible rather than silent.
M2 — Predict withdrawal timeline is silently omitted
Files: PredictFundsDetails.tsx
const steps =
isDeposit && item.status !== 'cancelled'
? getPredictFundsSteps(item.status, item.timestamp)
: undefined;
The timeline is only built for deposits. Withdrawal rows never render the step timeline, despite the PR description stating "the funds amount, account metadata, network metadata, step timeline, and fund/withdraw CTA are shown" for all Predict funds movements.
There are no predict.transactions.steps locale keys defined for withdrawal (only bridge_funds / add_funds are present). If withdrawal timelines are genuinely out of scope for this PR, the code needs a comment explaining why, and the PR description should be corrected. If withdrawal timelines are needed, the locale keys and step builder are missing.
M3 — Triggered order fees diverge from legacy screen
Files: PerpsDetails template (activity details), legacy PerpsOrderTransactionView
The new Activity Details template treats triggered orders as fully executed (maps to statusType: Filled, filled: 100% via transformOrdersToTransactions) and shows calculated order fees.
The legacy PerpsOrderTransactionView zeroes fees for triggered orders by checking order.text === 'Filled' as the gate.
Per HyperLiquid docs, triggered and filled are separate statuses: triggered means the trigger condition fired, while fees appear on the actual fill/trade record. This means:
- The new screen may show non-zero fees for triggered orders that have not yet produced a fill.
- The two details surfaces (legacy and new) show different fee values for the same order.
This was raised as a non-blocking follow-up by geositta but is a real UX correctness risk. A Product decision is needed on whether to gate fee display on a shared helper that checks actual fill data.
🔴 High Severity
H1 —
preloadedItemis a non-serializable object in React Navigation paramsFiles:
ActivityList.tsx→ActivityDetails.types.ts→ActivityDetails.tsxThe PR passes a full
ActivityListItemobject as a navigation parameter to avoid re-fetching provider-backed Perps/Predict items outside their source tree:navigation.navigate(Routes.ACTIVITY_DETAILS, { chainId: item.chainId, txIdentifier: item.hash, ...(raw.type === 'perpsTransaction' || raw.type === 'predictActivity' ? { preloadedItem: item } : {}), });Problems:
- React Navigation serializes route params to JSON for state persistence, deep-link rehydration, and
@react-navigation/devtools. Non-serializable values (nested class instances, functions, circular references insideraw.data) trigger a dev warning and silently break state persistence for theActivityDetailsroute.- If state is ever restored from persistence (app killed and re-opened via a background notification), the screen will have the
chainId/txIdentifierparams but nopreloadedItem, and Perps/Predict rows will fall through to "not found."- There is no guard in the current
useActivityDetailsItemto skip lookup and return the preloaded item — the branch must introduce this, but it needs to be verified.Recommendation: Use a module-scoped ref store (e.g.
Map<hash, ActivityListItem>) or React context to hand off the transient item before navigating, and keep route params serializable. IfpreloadedItemstays in params, theActivityDetailsroute must be explicitly excluded from any persisted navigation state and documented as such.
Fixed here using transient store b79a420
H2 — Claim breakdown ignores
totalNetPnlUsd/netPnlUsd(regression vs. legacy)Files:
PredictProviderActivityDetails.tsx,PredictDetailsShared.tsxThe PR adds
totalNetPnlUsdandnetPnlUsdtoPredictActivityand the Polymarket parser, but the new claim template never consumes them.ClaimWinningsBreakdownreceives onlyentry.amountand renders the same gross amount in both the "Total Net P&L" row and the per-market row.The legacy
PredictActivityDetail.tsxcorrectly used dedicated fields:// Legacy claim branch formatCurrencyValue(activity.totalNetPnlUsd ?? entryAmount, { showSign: true }); // total row formatCurrencyValue(activity.netPnlUsd ?? entryAmount, { showSign: true }); // market rowWhen the API supplies real P&L figures, users will see the gross claimed amount displayed twice instead of the correct total and per-market P&L values. This is a behavioral regression relative to the legacy screen.
Note: The cashed-out (
isSell) P&L path was correctly updated in a follow-up commit to usenetPnlUsdwith sign-aware coloring. The claim path was missed.Fix: Mirror the legacy approach — pass
activity.totalNetPnlUsd ?? entry.amountfor the total row andactivity.netPnlUsd ?? entry.amountfor the market row insideClaimWinningsBreakdown.
This is fixed here c229759
🟠 Medium Severity
M1 — Order
sourceToken.amountderived from subtitle string parsing is fragileFiles:
perps-transaction.ts(commit1af5022)After reviewer feedback, order row
sourceToken.amountis recovered by parsingtransaction.subtitle(format:"<size> <symbol>"):const [sizeStr] = transaction.subtitle?.split(' ') ?? []; sourceToken: { amount: sizeStr, symbol: transaction.asset, direction }This is parsing a human-readable display string as structured data. If
formatOrderLabelchanges its subtitle format (e.g. adds a prefix, uses a non-breaking space, or localizes),sizeStrwill silently becomeundefinedor garbage without any test failure. The original approach of computing fromsize / limitPricewas equally fragile for limit-price-absent cases.Recommendation: Either surface
sizeas a dedicated structured field inPerpsTransaction.order, or add a guard and fallback with a logged warning so the failure mode is visible rather than silent.
M2 — Predict withdrawal timeline is silently omitted
Files:
PredictFundsDetails.tsxconst steps = isDeposit && item.status !== 'cancelled' ? getPredictFundsSteps(item.status, item.timestamp) : undefined;The timeline is only built for deposits. Withdrawal rows never render the step timeline, despite the PR description stating "the funds amount, account metadata, network metadata, step timeline, and fund/withdraw CTA are shown" for all Predict funds movements.
There are no
predict.transactions.stepslocale keys defined for withdrawal (onlybridge_funds/add_fundsare present). If withdrawal timelines are genuinely out of scope for this PR, the code needs a comment explaining why, and the PR description should be corrected. If withdrawal timelines are needed, the locale keys and step builder are missing.
-
M1: order size now only uses the subtitle token when it's a valid number else omits it no garbage, with the
transformOrdersToTransactionstest guarding against format drift. -
M2: the Predict step timeline is intentionally deposit-only documented in-code, and I'll fix the PR description. Fix here: c229759
M3 — Triggered order fees diverge from legacy screen
Files:
PerpsDetailstemplate (activity details), legacyPerpsOrderTransactionViewThe new Activity Details template treats
triggeredorders as fully executed (maps tostatusType: Filled,filled: 100%viatransformOrdersToTransactions) and shows calculated order fees.The legacy
PerpsOrderTransactionViewzeroes fees for triggered orders by checkingorder.text === 'Filled'as the gate.Per HyperLiquid docs,
triggeredandfilledare separate statuses:triggeredmeans the trigger condition fired, while fees appear on the actual fill/trade record. This means:
- The new screen may show non-zero fees for triggered orders that have not yet produced a fill.
- The two details surfaces (legacy and new) show different fee values for the same order.
This was raised as a non-blocking follow-up by
geosittabut is a real UX correctness risk. A Product decision is needed on whether to gate fee display on a shared helper that checks actual fill data.
This was flagged earlier by @geositta as well. Leaving it as is for now and waiting on Product's verdict on what to do @MarioAslau
🔍 Smart E2E Test Selection
- Selected E2E tags: SmokePerps, SmokePredictions, SmokeWalletPlatform, SmokeConfirmations
- Selected Performance tags: None (no tests recommended)
- Risk Level: medium
- AI Confidence: 88%
click to see 🤖 AI reasoning details
E2E Test Selection: The PR introduces significant changes to the Activity Details and Activity List flows for Perps and Predictions:
-
SmokePerps: Directly impacted by:
- New
PerpsDetailstemplate for rendering perps activity details (trades, orders, funding, deposits/withdrawals) ActivityList.tsxnow routes perps transactions throughActivityDetailsscreen viapreloadedActivityItemStore- New order transaction support in
perps-transaction.ts(limit/market short orders) - New
ActivityDetailsPerps.utils.tsutility file - New activity kinds:
limitShort,limitCloseShort - Per tag description, SmokePerps also requires SmokeWalletPlatform (Trending section) and SmokeConfirmations
- New
-
SmokePredictions: Directly impacted by:
- New
PredictDetailstemplate for rendering predict activity details ActivityList.tsxnow routes predict activities throughActivityDetailsscreen- Bug fix in
PredictActivityDetail.tsxfor conditional rendering - New predict-specific strings in locales
- Per tag description, SmokePredictions also requires SmokeWalletPlatform and SmokeConfirmations
- New
-
SmokeWalletPlatform: Impacted by:
- Transaction history display changes (ActivityList routing changes)
- "cancelled" → "canceled" string change in
en.jsonanduseActivityListItemRowContent.tsaffects all transaction status displays - Activity list item row content changes
-
SmokeConfirmations: Required as a dependent tag per both SmokePerps and SmokePredictions tag descriptions (deposits/withdrawals and position operations are on-chain transactions).
Performance Test Selection: The changes are focused on UI rendering for activity details (Perps/Predict), routing logic in the activity list, and new templates. These are not performance-sensitive paths - they affect detail screens that are navigated to after tapping an activity item, not core app launch, login, asset loading, or swap flows. No performance test tags are warranted.
Quality Gate passed
Issues
36 New issues
0 Accepted issues
Measures
0 Security Hotspots
90.1% Coverage on New Code
0.0% Duplication on New Code