Skip to content

Commit 5da5788

Browse files
abretonc7sgambinishHowardBraham
authored
fix: Recent activity fields display orders and funding payments (#41446)
## **Description** The perps home tab Recent Activity section was displaying order and funding payment entries alongside trade executions and deposits. Only trades, deposits, and withdrawals should appear there — open orders are already shown in the Positions/Orders section above, and funding payments belong on the full activity page. Root cause: `perps-view.tsx` passed the unfiltered result of `usePerpsTransactionHistory()` directly to `<PerpsRecentActivity>`. The hook returns all transaction types (`trade`, `order`, `funding`, `deposit`, `withdrawal`). Added a `useMemo` filter to keep only `trade`, `deposit`, and `withdrawal` before rendering. ## **Changelog** CHANGELOG entry: Fixed a bug causing order and funding transactions to appear in the perps Recent Activity section ## **Related issues** Fixes: TAT-2793 ## **Manual testing steps** 1. Enable perps (`PERPS_ENABLED=true` in `.metamaskrc` + `perpsEnabledVersion` remote flag) 2. Open the extension and navigate to the Perps tab 3. Scroll down to the Recent Activity section 4. Confirm only trade executions, deposits, and withdrawals appear (no "Order" or "Funding" entries) 5. Navigate to the full activity page and confirm funding/order entries still appear there ## **Screenshots/Recordings** ### **Before** Recording: `before.mp4` (recipe run against unfixed code — wallet has no live data so empty-state path taken) ### **After** Recording: `after.mp4` — recipe validates no `transaction-card-order-*` or `transaction-card-funding-*` elements appear in `[data-testid="perps-recent-activity"]`. All 7 recipe nodes PASS. ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/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-extension/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** > Low risk UI logic change that only filters which transaction types are shown in the Perps home Recent Activity list; minimal surface area and covered by a new unit test. > > **Overview** > Fixes the Perps home **Recent Activity** list to exclude `order` and `funding` entries by filtering the `usePerpsTransactionHistory()` results to only `trade`, `deposit`, and `withdrawal` before rendering. > > Adds a regression test in `perps-view.test.tsx` asserting that trade/deposit cards render while funding/order cards do not appear. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3277fc7. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Nick Gambino <nicholas.gambino@consensys.net> Co-authored-by: Howard Braham <howrad@gmail.com>
1 parent dd15b92 commit 5da5788

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

ui/components/app/perps/perps-view.test.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,31 @@ describe('PerpsView', () => {
203203
).toBeInTheDocument();
204204
});
205205

206+
it('filters out order and funding transactions from Recent Activity', () => {
207+
// mockTransactions contains trades (tx-001, tx-002, tx-002b),
208+
// a funding entry (tx-003), orders (tx-004 to tx-004d), and a deposit (tx-005)
209+
jest.mocked(usePerpsTransactionHistory).mockReturnValueOnce({
210+
transactions: mocks.mockTransactions,
211+
isLoading: false,
212+
error: null,
213+
refetch: jest.fn(),
214+
});
215+
216+
renderWithProvider(<PerpsView />, mockStore);
217+
218+
// Trade and deposit cards should be shown
219+
expect(screen.getByTestId('transaction-card-tx-001')).toBeInTheDocument();
220+
expect(screen.getByTestId('transaction-card-tx-005')).toBeInTheDocument();
221+
222+
// Funding and order cards must not appear in Recent Activity
223+
expect(
224+
screen.queryByTestId('transaction-card-tx-003'),
225+
).not.toBeInTheDocument();
226+
expect(
227+
screen.queryByTestId('transaction-card-tx-004'),
228+
).not.toBeInTheDocument();
229+
});
230+
206231
it('shows watchlist when mock watchlist symbols match market data', () => {
207232
renderWithProvider(<PerpsView />, mockStore);
208233

ui/components/app/perps/perps-view.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,25 @@ export const PerpsView: React.FC = () => {
6868
} = usePerpsLiveMarketData();
6969

7070
const {
71-
transactions: recentActivityTransactions,
71+
transactions: allRecentActivityTransactions,
7272
isLoading: recentActivityLoading,
7373
error: recentActivityError,
7474
} = usePerpsTransactionHistory();
7575

76+
// Recent Activity shows only trade executions, deposits, and withdrawals.
77+
// Open orders are already surfaced in PerpsPositionsOrders above.
78+
// Funding payments belong in the full activity page.
79+
const recentActivityTransactions = useMemo(
80+
() =>
81+
allRecentActivityTransactions.filter(
82+
(tx) =>
83+
tx.type === 'trade' ||
84+
tx.type === 'deposit' ||
85+
tx.type === 'withdrawal',
86+
),
87+
[allRecentActivityTransactions],
88+
);
89+
7690
// Show only user-placed limit orders resting on the orderbook.
7791
// Excludes:
7892
// - isTrigger: TP/SL trigger orders

0 commit comments

Comments
 (0)