MetaMask / MetaMask/metamask-extension

[P1] selectors: extract permissions / subjects / connected-sites selectors

Open
#44,578 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

exalate-duplicate INVALID-ISSUE-TEMPLATE mig-epic-71-child ta-triaged 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

~35 permission/subject/connected-site selectors (`getPermissionSubjects`, `getSubjectMetadata`, `getTargetSubjectMetadata`, `getAllPermittedAccounts*`, `getPermittedEVMChainsForSelectedTab`, `getConnectedSitesList*`, `getPermissionsForActiveTab`, `getOriginOfCurrentTab`, …) **plus the connected-account-list selectors** (`getUnconnectedAccounts`, `getOrderedConnectedAccountsForActiveTab`, `getUpdatedAndSortedAccounts*`). Highest coupling: imports accounts + network + approvals; owns the subject/metadata base that snaps reuses. `permissions.test.js` already exists.

## Solution

Create `ui/selectors/permissions.ts` (after accounts + network). **Place the connected-account-list selectors here** (one-way permissions→accounts) to break the accounts↔permissions cycle. This module owns the subject/metadata base — extract before `snaps`.

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

- [ ] `permissions.ts` incl. connected-account lists + subject/metadata base; no require cycle with `accounts.ts`; imports repointed directly to the module (no barrel); pairs with existing test. Tests green.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ui/selectors/selectors.js and the existing permissions.test.js, then identify the listed permission, subject, connected-site, and connected-account selectors and their importing sites. Move them into ui/selectors/permissions.ts, repoint imports directly, and verify there is no require cycle with accounts.ts and that the tests are green.

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.