MetaMask / MetaMask/metamask-extension
[P2] selectors: extract swaps + bridge selectors
- 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:** S
---
## Problem
6 selectors (`getSwapsDefaultToken`, `getIsSwapsChain`, `selectHasBridgeQuotes`, `getIsBridgeChain`, `getIsBridgeEnabled` + private `getBridgeFeatureFlags`). Depends on accounts (`getSelectedAccount`) + multichain + `getUseExternalServices`.
## Solution
Create `ui/selectors/swaps-bridge.ts` (after accounts).
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
- [ ] `swaps-bridge.ts`; imports repointed directly to the module (no barrel). Tests green.
Contributor guide
Research direction
Start with ui/selectors/selectors.js and trace the six swaps and bridge selectors, including the private getBridgeFeatureFlags and their accounts, multichain, and external-services dependencies. Create ui/selectors/swaps-bridge.ts, repoint importing sites directly to that module without a barrel, remove the selectors from selectors.js, and confirm the tests are green.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100