Skip to content

Conversation

@Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Oct 23, 2025

Explanation

The @metamask/base-controller package has been updated to use the new API that had previously been exposed under the next export. Major changes include:

  • Remove Messenger and RestrictedMessenger
    • Replaced by the @metamask/messenger library
  • Update BaseController to require @metamask/messenger instance
  • Rename anonymous metadata property to includeInDebugLogs
  • Make includeInStateLogs and usedInUi metadata properties required
  • Remove getPersistentState and getAnonymizedState
  • Remove isBaseController
  • Rename ListenerV2 to StateChangeListener
  • Rename messagingSystem protected instance variable to messenger
  • Remove next export

References

Relates to #5626

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Migrate all packages to the new @metamask/base-controller API using @metamask/messenger, remove the /next export and legacy messenger, and update metadata types and configs accordingly.

  • base-controller (BREAKING):
    • Replace internal Messenger/RestrictedMessenger with @metamask/messenger; BaseController now requires a Messenger instance.
    • Remove /next export and legacy files (src/next/*, next.js, next.d.ts).
    • Rename metadata anonymous -> includeInDebugSnapshot; require includeInStateLogs and usedInUi.
    • Rename ListenerV2 -> StateChangeListener; rename messagingSystem -> messenger.
    • Remove getPersistentState, getAnonymizedState, and isBaseController.
    • Update types and implementation to new messenger integration and events.
    • Update CHANGELOG.md with breaking changes.
  • Repo-wide refactor:
    • Change imports from @metamask/base-controller/next to @metamask/base-controller across controllers/tests (accounts, assets, network, permissions, transactions, etc.).
    • Update tests to use @metamask/messenger and new metadata keys.
  • Config/build:
    • Remove Jest moduleNameMapper for /next; adjust TypeScript paths and add skipLibCheck in tsconfig.packages.build.json.
    • Update eslint-warning-thresholds.json accordingly.

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

@Gudahtt Gudahtt force-pushed the promote-base-controller-next-export branch from 096b17b to f2a74d5 Compare October 23, 2025 13:06
@Gudahtt Gudahtt marked this pull request as ready for review October 23, 2025 13:09
@Gudahtt Gudahtt requested a review from a team as a code owner October 23, 2025 13:09
@Gudahtt Gudahtt force-pushed the promote-base-controller-next-export branch from f2a74d5 to 0f304e9 Compare October 23, 2025 13:10
@Gudahtt Gudahtt changed the title feat: Messenger delegation feat: Promote next export of base-controller Oct 23, 2025
@Gudahtt Gudahtt changed the title feat: Promote next export of base-controller feat: New base-controller API Oct 23, 2025
mikesposito
mikesposito previously approved these changes Oct 23, 2025
Copy link
Member

@mikesposito mikesposito left a comment

Choose a reason for hiding this comment

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

LGTM!

@cursor
Copy link

cursor bot commented Oct 23, 2025

Bug: Metadata Constraint Mismatch Causes Type Issues

The StatePropertyMetadataConstraint type is out of sync with StatePropertyMetadata. It still uses anonymous instead of includeInDebugSnapshot, and its includeInStateLogs and usedInUi properties are optional when they should be required. This mismatch causes type compatibility issues.

Fix in Cursor Fix in Web

@cursor
Copy link

cursor bot commented Oct 23, 2025

Bug: Inconsistent Messenger Usage in BaseController Methods

The destroy method uses this.messenger.clearEventSubscriptions() while the update and applyPatches methods use this.#messenger.publish(). This is inconsistent. The destroy method should use this.#messenger.clearEventSubscriptions() to be consistent with the other methods that interact with the messenger for BaseController-specific actions/events. Using this.messenger instead of this.#messenger bypasses the type safety that restricts the messenger to only BaseController's own actions and events.

Fix in Cursor Fix in Web

@Gudahtt Gudahtt force-pushed the promote-base-controller-next-export branch from 0f304e9 to 955f43b Compare October 27, 2025 13:23
@Gudahtt
Copy link
Member Author

Gudahtt commented Oct 27, 2025

I have added no-changelog because the removal of the /next imports in most packages doesn't constitute a change since the previous published version.

cursor[bot]

This comment was marked as outdated.

cryptodev-2s
cryptodev-2s previously approved these changes Oct 27, 2025
mikesposito
mikesposito previously approved these changes Oct 27, 2025
Copy link
Member

@mikesposito mikesposito 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 dismissed stale reviews from mikesposito and cryptodev-2s via 7811651 October 27, 2025 13:37
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@Gudahtt Gudahtt force-pushed the promote-base-controller-next-export branch from 2735ccd to 61b5206 Compare October 27, 2025 15:37
@Gudahtt
Copy link
Member Author

Gudahtt commented Oct 27, 2025

Rebased to resolve conflicts

The `@metamask/base-controller` package has been updated to use the new API
that had previously been exposed under the `next` export. Major changes
include:

- Remove `Messenger` and `RestrictedMessenger`
  - Replaced by the `@metamask/messenger` library
- Update `BaseController` to require `@metamask/messenger` instance
- Rename `anonymous` metadata property to `includeInDebugLogs`
- Make `includeInStateLogs` and `usedInUi` metadata properties required
- Remove `getPersistentState` and `getAnonymizedState`
- Remove `isBaseController`
- Rename `ListenerV2` to `StateChangeListener`
- Rename `messagingSystem` protected instance variable to `messenger`
Breaking changes are now labelled as such, and a sub-bullet was added about the
two places where the new metadata proeprties are now required.

Additionally, a bug fix entry was removed because it's now redundant alongside
the entry about renaming the `anonymous` metadata property in the main export.
The TypeScript compiler option `skipLibCheck` has been temporarily enabled for
workspace packages. We don't want to leave this enabled forever because it can
result in dependencies silently degrading to type `any` when they have errors.
But this is necessary until we publish the next major version of the package
`base-controller`, to avoid resolving `base-controller` in dependencies to an
incompatible version.
@Gudahtt Gudahtt force-pushed the promote-base-controller-next-export branch from 61b5206 to be031b5 Compare October 27, 2025 16:02
cryptodev-2s
cryptodev-2s previously approved these changes Oct 27, 2025
Copy link
Member

@mikesposito mikesposito left a comment

Choose a reason for hiding this comment

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

LFG!

@Gudahtt Gudahtt enabled auto-merge October 27, 2025 16:08
@Gudahtt Gudahtt added this pull request to the merge queue Oct 27, 2025
Merged via the queue into main with commit b5aa379 Oct 27, 2025
252 checks passed
@Gudahtt Gudahtt deleted the promote-base-controller-next-export branch October 27, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants