Commit 39190c9
authored
refactor: remove swaps-controller package (#27547)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
The `@metamask/swaps-controller` package is no longer needed — swaps
functionality is now handled by `BridgeController` and
`BridgeStatusController`. This PR removes the package and all associated
wiring:
- **Deleted** the controller initializer (`swaps-controller-init.ts`)
and its messenger (`swaps-controller-messenger.ts`), along with their
tests.
- **Removed** `SwapsController` from the Engine initialization, types,
state-change event constants, and Sentry state mask.
- **Cleaned up** the swaps Redux reducer by removing all selectors that
read from `SwapsController` state (e.g. `swapsTokensObjectSelector`,
`swapsTokensMultiChainObjectSelector`, `swapsTopAssetsSelector`, etc.)
and the helper functions they depended on.
- **Inlined** the `FeatureFlags` interface and `CHAIN_ID_TO_NAME_MAP`
constant locally in `app/reducers/swaps/utils.ts` so the remaining
liveness logic no longer imports from the deleted package.
- **Added** migration 126 to strip `SwapsController` from persisted
`backgroundState` on upgrade.
- **Removed** `SwapsController` entries from test fixtures
(`initial-background-state.json`, `default-fixture.json`), snapshot
files, and mock states (Bridge, EngineService).
- **Removed** the `@metamask/swaps-controller` dependency from
`package.json` and cleaned up `yarn.lock` (also drops transitive
`@metamask/utils@10`, `human-standard-token-abi`).
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: null
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3927
## **Manual testing steps**
N/A — This is an internal refactoring with no UI or behavior changes.
Swaps functionality continues to work through BridgeController. Existing
unit tests and migration tests cover the removal.
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
N/A
### **After**
N/A
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- Generated with the help of the pr-description AI skill -->
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Removes a controller from Engine wiring, persisted state, and selector
surface area; any missed references could cause runtime init or
state-shape regressions despite being a deletion-focused change.
>
> **Overview**
> Removes the legacy `SwapsController` integration end-to-end: Engine
init/messenger/type wiring is deleted, state-change subscriptions and
Sentry masking are updated, and the `@metamask/swaps-controller`
dependency is dropped.
>
> Strips `SwapsController`-backed Redux selectors and test/mocked state
that depended on its persisted background state, and adds migration
`127` to delete `engine.backgroundState.SwapsController` on upgrade.
Fixtures, snapshots, and Bridge/EngineService tests are updated
accordingly, with swaps liveness utilities inlining the needed
feature-flag types and chain-name mapping.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
23265cb. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 13baa70 commit 39190c9
29 files changed
Lines changed: 151 additions & 1297 deletions
File tree
- .agents/skills/e2e-test
- app
- components/UI/Bridge
- Views/BridgeView
- _mocks_
- core
- EngineService
- Engine
- controllers
- messengers
- reducers/swaps
- selectors
- store/migrations
- util
- logs/__snapshots__
- sentry
- test
- tests
- framework/fixtures
- json
- tools/e2e-ai-analyzer/skills
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | 101 | | |
107 | 102 | | |
108 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | 612 | | |
642 | 613 | | |
643 | 614 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
168 | 167 | | |
169 | 168 | | |
170 | 169 | | |
| |||
334 | 333 | | |
335 | 334 | | |
336 | 335 | | |
337 | | - | |
338 | 336 | | |
339 | 337 | | |
340 | 338 | | |
| |||
450 | 448 | | |
451 | 449 | | |
452 | 450 | | |
453 | | - | |
454 | 451 | | |
455 | 452 | | |
456 | 453 | | |
| |||
530 | 527 | | |
531 | 528 | | |
532 | 529 | | |
533 | | - | |
534 | 530 | | |
535 | 531 | | |
536 | 532 | | |
| |||
1351 | 1347 | | |
1352 | 1348 | | |
1353 | 1349 | | |
1354 | | - | |
1355 | 1350 | | |
1356 | 1351 | | |
1357 | 1352 | | |
| |||
1421 | 1416 | | |
1422 | 1417 | | |
1423 | 1418 | | |
1424 | | - | |
1425 | 1419 | | |
1426 | 1420 | | |
1427 | 1421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
| |||
92 | 91 | | |
93 | 92 | | |
94 | 93 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | 94 | | |
112 | 95 | | |
113 | 96 | | |
| |||
Lines changed: 0 additions & 51 deletions
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | 121 | | |
123 | 122 | | |
124 | 123 | | |
| |||
372 | 371 | | |
373 | 372 | | |
374 | 373 | | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | 374 | | |
380 | 375 | | |
381 | 376 | | |
| |||
Lines changed: 0 additions & 28 deletions
This file was deleted.
This file was deleted.
0 commit comments