MetaMask / MetaMask/metamask-extension

[P1] selectors: extract network identity / config / chains selectors

Open
#44,574 1 comment 0 reactions 0 assignees View on GitHub
exalate-duplicate INVALID-ISSUE-TEMPLATE mig-epic-71-child team-extension-platform
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

**Parent Epic:** [#44566 — `selectors.js` decomposition](https://github.com/MetaMask/metamask-extension/issues/44566)
**Source:** `ui/selectors/selectors.js`
**Size:** L

---

## Problem

~30 network selectors (`getCurrentNetwork`, `getSelectedNetwork`, `getIsMainnet`/`getIsTestnet`, `checkNetworkAndAccountSupports1559`, `getAllEnabledNetworks`, `getChainIdsToPoll`, `getNetworkClientIdsToPoll`, `getIsCustomNetwork`, `getNetworkConnectionBanner`, network-UI appState reads, …). Network base is external. Two entanglements: the `getTokenNetworkFilter` pair (keep in `tokens.ts`, import it) and `getNetworkToAutomaticallySwitchTo` (imports confirmations/active-tab/domains — needs cross-imports).

## Solution

Create `ui/selectors/network.ts`; isolate the entangled `getNetworkToAutomaticallySwitchTo` via explicit cross-imports; keep the token-network-filter pair in `tokens.ts`.

Migration seam (no barrel): repoint every site importing the moved selectors to `ui/selectors/` directly (a `ts-morph` codemod that splits any `../selectors` barrel imports into per-module imports) and delete them from `selectors.js` in the same PR — no re-export facade, per the no-barrel-files convention.

## Acceptance Criteria

- [ ] `network.ts`; entangled selector handled via cross-imports (no cycle); imports repointed directly to the module (no barrel). Tests green.

Contributor guide

Open the contributing guide

Research direction

Start with ui/selectors/selectors.js and map the listed network selectors, keeping the getTokenNetworkFilter pair in tokens.ts. Create ui/selectors/network.ts, inspect the entangled getNetworkToAutomaticallySwitchTo imports, then repoint importing sites directly to domain modules; run the selector and broader test suite to confirm all tests pass without a barrel.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.