MetaMask / MetaMask/metamask-extension

[P2] selectors: extract snaps registry / metadata / interface selectors

Open
#44,579 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 snap selectors (`getSnaps`, `getSnap`, `getSnapsMetadata`, `getSnapMetadata`, `getSnapRegistryData`, `getAllSnapAvailableUpdates`, `getInterface(s)`, `getSnapInsights`, `getKeyringSnapAccounts`, `getSnapInstallOrUpdateRequests`, …). Depends on the subject/metadata base now in `permissions.ts` + accounts + locale.

## Solution

Create a top-level `ui/selectors/snaps.ts` (**last** — needs the permissions subject base). Note: the existing `snaps/` dir holds `accounts.ts`/`address-book.ts`, not snap selectors — verify before colliding. Consider moving generic `getLocale` to `app-ui-state.ts` instead.

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

- [ ] `snaps.ts`; depends on `permissions.ts` subject base; 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 listed snap selectors, then read ui/selectors/permissions.ts for the subject and metadata base. Create ui/selectors/snaps.ts, check whether getLocale belongs in app-ui-state.ts, and repoint imports directly to the domain module without a barrel; done means the selectors are removed from selectors.js 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
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.