Skip to content

Conversation

@mikesposito
Copy link
Member

@mikesposito mikesposito commented Sep 29, 2025

This PR migrates SwapsController to new @metamask/messenger instead of @metamask/base-controller. This is part of a larger effort to migrate all controllers to use @metamask/messenger.


Note

Migrate SwapsController to the new @metamask/messenger, rename metadata flag, and bump network/gas-fee controller peers to v25.

  • Controller:
    • Replace RestrictedMessenger usage with new @metamask/messenger in SwapsController, using this.messenger for action handlers, calls, and subscriptions.
    • Rename state metadata flag from anonymous to includeInDebugSnapshot across metadata and tests.
    • Refactor stopPollingAndResetState to partially reset state using defaults.
    • Use messenger.call('NetworkController:getNetworkClientById', ...) for network lookups.
  • Types/Tests:
    • Update SwapsControllerMessenger to Messenger<...> and related type wiring.
    • Rewrite tests to construct root and delegated messengers with @metamask/messenger and adjust snapshots.
  • Dependencies:
    • Peer bumps: @metamask/gas-fee-controller ^25.0.0, @metamask/network-controller ^25.0.0.
    • Runtime: add @metamask/messenger ^0.3.0, bump @metamask/base-controller to ^9.0.0.
  • Changelog:
    • Document breaking changes for messenger migration, metadata rename, and peer bumps.

Written by Cursor Bugbot for commit d49af03. This will update automatically on new commits. Configure here.

@mikesposito mikesposito requested a review from a team as a code owner September 29, 2025 09:46
@socket-security
Copy link

socket-security bot commented Sep 29, 2025

mcmire
mcmire previously approved these changes Oct 8, 2025
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mcmire mcmire dismissed their stale review October 8, 2025 19:51

Hmm, looks like CI is failing.

@Gudahtt Gudahtt force-pushed the mikesposito/messenger/swaps-controller branch from 45c5fb5 to 4c94bcb Compare October 23, 2025 17:05
_state.error.key = error.key;
_state.error.description = error.description;

// Partially reset state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous strategy of resetting the state one-property-at-a-time was causing a type error. The types for all properties were being combined into a single union, so then it wasn't able to ensure we were assigning a compatible type to each property.

It seemed simplest to reverse the process, and explicitly clear the properties we want, rather than clearing everything then restoring state to the properties we didn't want to clear.

@Gudahtt
Copy link
Member

Gudahtt commented Oct 23, 2025

@metamaskbot publish-previews

@github-actions
Copy link
Contributor

A preview build for this branch has been published.

You can configure your project to use the preview build with this identifier:

npm:@metamask-previews/swaps-controller@14.0.0-preview-4c94bcb

See these instructions for more information about preview builds.

cryptodev-2s
cryptodev-2s previously approved these changes Oct 26, 2025
Copy link
Contributor

@cryptodev-2s cryptodev-2s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Gudahtt Gudahtt merged commit 273553b into main Oct 27, 2025
12 checks passed
@Gudahtt Gudahtt deleted the mikesposito/messenger/swaps-controller branch October 27, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace RestrictedMessenger with delegated Messenger

5 participants