MetaMask / MetaMask/metamask-extension

[P1] selectors: extract accounts / keyrings / contacts selectors (hub)

Open
#44,576 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

~50 identity/balance/keyring/contact selectors (`getMetaMaskAccounts*`, `getSelectedAccount*`, `getInternalAccountsSortedByKeyring`, `getMetaMaskKeyrings`/`getMetaMaskHdKeyrings`, `getSelectedKeyringByIdOrDefault`, address-book `getAddressBook*`/`getAccountName`/`getEnsResolutionByAddress`, …). This is the internal hub most domains import from.

## Solution

Extend the existing `ui/selectors/accounts.ts`. **Must precede `permissions`/`snaps`.** Exclude the connected-account-list selectors (they go to `permissions.ts` to break the accounts↔permissions cycle) — keep `accounts.ts` free of permission imports. Address-book may sit in an `accounts/address-book.ts` sub-file.

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

- [ ] Selectors in `accounts.ts` (no permission imports); connected-account lists explicitly excluded; 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 the existing ui/selectors/accounts.ts. Identify the account, keyring, and address-book selectors to move while excluding connected-account-list selectors, then locate imports that need direct module paths. Done means accounts.ts has no permission imports, selectors.js no longer defines the moved selectors, no barrel is added, and tests are green.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.