Skip to content

Commit 95e7280

Browse files
fix(activity): restore Perps after popular networks without forcing Ethereum (#29676)
## **Description** 1. **Reason:** On Activity, the Perps tab is gated by `selectIsEvmNetworkSelected`. After choosing Solana and then **All popular networks**, `isEvmSelected` stayed false, so Perps did not return ([TMCU-672](https://consensyssoftware.atlassian.net/browse/TMCU-672)). An earlier approach called `selectPopularNetwork('eip155:1')` after `enableAllPopularNetworks()`, which fixed Perps but incorrectly forced the global EVM chain to Ethereum mainnet, so the network picker showed Ethereum instead of aggregate popular networks. 2. **Solution:** Keep `selectAllPopularNetworks` limited to `NetworkEnablementController.enableAllPopularNetworks()` (no implicit chain switch). Drive Activity Perps visibility with **`useNetworksByCustomNamespace`** (`eip155`, popular): show Perps when the Perps feature flag is on **and** either the user is on EVM (`isEvmSelected`) **or** all popular EVM networks are enabled—without changing the active multichain selection. ## **Changelog** CHANGELOG entry: Fixed the Activity Perps tab not reappearing after switching the transaction network filter back to popular networks from Solana, without forcing Ethereum as the selected chain. ## **Related issues** Fixes #29053 Refs: https://consensyssoftware.atlassian.net/browse/TMCU-672 ## **Manual testing steps** ```gherkin Feature: Activity Perps tab and popular network filter (TMCU-602) Scenario: Perps returns after Solana then all popular networks without picking Ethereum Given the Perps feature flag is enabled And the user is on Activity with the transaction network filter showing popular networks When the user opens the network picker and selects Solana Then the Perps tab is hidden When the user opens the network picker and selects all popular networks Then the Perps tab is visible again And the picker does not show Ethereum as the sole selected chain while aggregate popular mode is intended Scenario: Perps still shows when directly on an EVM chain Given the Perps feature flag is enabled When the user selects an EVM network (e.g. Ethereum) from the picker Then the Perps tab is visible ``` ## **Screenshots/Recordings** ### **Before** See #28035 ### **After** https://github.com/user-attachments/assets/f5192178-b7ae-4501-9daa-992afe0680cd ## **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 - [ ] 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. #### Performance checks (if applicable) Not applicable for this change (network filter / tab visibility only). Left unchecked until you validate on device if required by your release process. - [ ] 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](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [ ] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example ## **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. [TMCU-602]: https://consensyssoftware.atlassian.net/browse/TMCU-602?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [TMCU-672]: https://consensyssoftware.atlassian.net/browse/TMCU-672?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk UI gating change that only affects whether the Perps tab is shown; main risk is incorrect tab visibility for certain multichain network-filter states. > > **Overview** > Restores Perps visibility on the Activity screen when the user switches to *All popular networks* after selecting a non‑EVM network, without forcing an EVM chain selection. > > `ActivityView` now enables the Perps tab when the feature flag is on and either an EVM network is selected **or** all popular `eip155` networks are enabled (via `useNetworksByCustomNamespace`). Tests update mocks accordingly and add coverage for the non‑EVM + all popular EVM networks case. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f0566bd. 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: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Pedro Pablo Aste Kompen <wachunei@users.noreply.github.com>
1 parent dbfe481 commit 95e7280

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

app/components/Views/ActivityView/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import TextComponent, {
1919
TextVariant,
2020
} from '../../../component-library/components/Texts/Text';
2121
import { useTailwind } from '@metamask/design-system-twrnc-preset';
22+
import { KnownCaipNamespace } from '@metamask/utils';
2223
import { selectIsEvmNetworkSelected } from '../../../selectors/multichainNetworkController';
2324
import { selectChainId } from '../../../selectors/networkController';
2425
import { selectNetworkName } from '../../../selectors/networkInfos';
@@ -37,6 +38,7 @@ import RampOrdersList from '../../UI/Ramp/Aggregator/Views/OrdersList';
3738
import { useCurrentNetworkInfo } from '../../hooks/useCurrentNetworkInfo';
3839
import {
3940
NetworkType,
41+
useNetworksByCustomNamespace,
4042
useNetworksByNamespace,
4143
} from '../../hooks/useNetworksByNamespace/useNetworksByNamespace';
4244
import { useStyles } from '../../hooks/useStyles';
@@ -96,13 +98,20 @@ const ActivityView = () => {
9698
networkType: NetworkType.Popular,
9799
});
98100

101+
const { areAllNetworksSelected: areAllEvmPopularNetworksEnabled } =
102+
useNetworksByCustomNamespace({
103+
networkType: NetworkType.Popular,
104+
namespace: KnownCaipNamespace.Eip155,
105+
});
106+
99107
const currentNetworkName = getNetworkInfo(0)?.networkName;
100108

101109
const params = useParams();
102110
const perpsEnabledFlag = useSelector(selectPerpsEnabledFlag);
103111
const isPerpsEnabled = useMemo(
104-
() => perpsEnabledFlag && isEvmSelected,
105-
[perpsEnabledFlag, isEvmSelected],
112+
() =>
113+
perpsEnabledFlag && (isEvmSelected || areAllEvmPopularNetworksEnabled),
114+
[perpsEnabledFlag, isEvmSelected, areAllEvmPopularNetworksEnabled],
106115
);
107116
const predictEnabledFlag = useSelector(selectPredictEnabledFlag);
108117
const isPredictEnabled = useMemo(

app/components/Views/ActivityView/index.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,20 @@ jest.mock('../../../core/Engine', () => ({
131131
},
132132
}));
133133

134+
let mockAreAllEvmPopularNetworksEnabled = false;
135+
134136
jest.mock('../../hooks/useNetworksByNamespace/useNetworksByNamespace', () => ({
135137
useNetworksByNamespace: () => ({
136138
networks: [],
139+
areAllNetworksSelected: false,
137140
selectNetwork: jest.fn(),
138141
selectCustomNetwork: jest.fn(),
139142
selectPopularNetwork: jest.fn(),
140143
}),
144+
useNetworksByCustomNamespace: () => ({
145+
networks: [],
146+
areAllNetworksSelected: mockAreAllEvmPopularNetworksEnabled,
147+
}),
141148
NetworkType: {
142149
Popular: 'popular',
143150
Custom: 'custom',
@@ -263,6 +270,7 @@ describe('ActivityView', () => {
263270
mockIsEvmSelected = true;
264271
mockPerpsEnabled = false;
265272
mockPredictEnabled = false;
273+
mockAreAllEvmPopularNetworksEnabled = false;
266274
clearRenderedTabs();
267275
mockRoute.params = {};
268276
});
@@ -474,6 +482,18 @@ describe('ActivityView', () => {
474482
expect(getRenderedTabs()).toContain('perps');
475483
});
476484

485+
it('includes Perps tab when all popular EVM networks are enabled while on non-EVM', () => {
486+
mockPerpsEnabled = true;
487+
mockIsEvmSelected = false;
488+
mockAreAllEvmPopularNetworksEnabled = true;
489+
490+
const { getByTestId, queryByTestId } = renderComponent(mockInitialState);
491+
492+
expect(getByTestId('tab-perps')).toBeOnTheScreen();
493+
expect(queryByTestId('perps-transactions-view')).toBeNull();
494+
expect(getRenderedTabs()).toContain('perps');
495+
});
496+
477497
it('excludes Perps tab when feature flag is disabled', () => {
478498
mockPerpsEnabled = false;
479499
mockIsEvmSelected = true;
@@ -486,6 +506,7 @@ describe('ActivityView', () => {
486506
it('excludes Perps tab on non-EVM network even with feature flag enabled', () => {
487507
mockPerpsEnabled = true;
488508
mockIsEvmSelected = false;
509+
mockAreAllEvmPopularNetworksEnabled = false;
489510

490511
renderComponent(mockInitialState);
491512

0 commit comments

Comments
 (0)