Skip to content

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Aug 19, 2025

Explanation

Migrate the controller guidelines and the sample-controllers package to the next export of the @metamask/base-controller package and the new Messenger class from @metamask/messenger.

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

Migrates controller guidelines and sample controllers to the new @metamask/messenger Messenger and @metamask/base-controller/next, updating APIs, tests, and docs, and adding the messenger dependency.

  • Documentation
    • Update docs/controller-guidelines.md and docs/data-services.md to use Messenger (namespace/parent, delegate, subscribe/publish) instead of RestrictedMessenger and "messaging system".
    • Revise type guidance to pass internal *Actions and *Events directly to Messenger; clarify external unions and non-export rules.
    • Adjust examples to root messenger patterns and replace messagingSystem with messenger API; add includeInDebugSnapshot metadata key.
  • Sample Controllers
    • Migrate SampleGasPricesController and SamplePetnamesController to @metamask/base-controller/next and Messenger; replace RestrictedMessenger types and messagingSystem.* calls with messenger.*.
    • Update services (SampleGasPricesService) and tests to new Messenger (MockAnyNamespace, MessengerActions/MessengerEvents) and root/child messenger delegation.
    • Add @metamask/messenger dependency and TS project references; update yarn.lock.
    • Changelog: note breaking migration to Messenger.

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

@Gudahtt Gudahtt force-pushed the messenger-migrate-controller-docs branch 2 times, most recently from 815bf50 to 39756ca Compare August 19, 2025 18:05
@Gudahtt Gudahtt force-pushed the messenger-migrate-base-controller branch 2 times, most recently from ae71891 to 67c7853 Compare August 20, 2025 14:04
Base automatically changed from messenger-migrate-base-controller to main August 20, 2025 14:10
@Gudahtt Gudahtt force-pushed the messenger-migrate-controller-docs branch 4 times, most recently from 0a1a16b to 0bdc3d1 Compare August 20, 2025 15:58
@Gudahtt Gudahtt marked this pull request as ready for review August 20, 2025 15:58
@Gudahtt Gudahtt requested a review from a team as a code owner August 20, 2025 15:58
@Gudahtt Gudahtt force-pushed the messenger-migrate-controller-docs branch from 0bdc3d1 to 7bbe29c Compare August 20, 2025 17:25
cursor[bot]

This comment was marked as outdated.

Gudahtt added a commit that referenced this pull request Aug 20, 2025
Tests that used the `@metamask/base-controller/next` export were not
working correctly until after a build was completed. They were using
the built code rather than the source code. On CI the tests run without
any build, so they would always fail.

This was resolved up updating the TSConfig and Jest config to map the
`next` export to the correct source code.

This unblocks #6335 as well as other controller migrations to the
upcoming BaseController version.
Gudahtt added a commit that referenced this pull request Aug 20, 2025
Tests that used the `@metamask/base-controller/next` export were not
working correctly until after a build was completed. They were using
the built code rather than the source code. On CI the tests run without
any build, so they would always fail.

This was resolved up updating the TSConfig and Jest config to map the
`next` export to the correct source code.

This unblocks #6335 as well as other controller migrations to the
upcoming BaseController version.
@Gudahtt

This comment was marked as resolved.

Gudahtt added a commit that referenced this pull request Aug 20, 2025
Tests that used the `@metamask/base-controller/next` export were not
working correctly until after a build was completed. They were using
the built code rather than the source code. On CI the tests run without
any build, so they would always fail.

This was resolved up updating the TSConfig and Jest config to map the
`next` export to the correct source code.

This unblocks #6335 as well as other controller migrations to the
upcoming BaseController version.
Gudahtt added a commit that referenced this pull request Aug 21, 2025
Tests that used the `@metamask/base-controller/next` export were not
working correctly until after a build was completed. They were using
the built code rather than the source code. On CI the tests run without
any build, so they would always fail.

This was resolved up updating the TSConfig and Jest config to map the
`next` export to the correct source code.

This unblocks #6335 as well as other controller migrations to the
upcoming BaseController version.
Gudahtt added a commit that referenced this pull request Aug 21, 2025
…6349)

## Explanation

Tests that used the `@metamask/base-controller/next` export were not
working correctly until after a build was completed. They were using the
built code rather than the source code. On CI the tests run without any
build, so they would always fail.

This was resolved up updating the TSConfig and Jest config to map the
`next` export to the correct source code.

This unblocks #6335 as well as other controller migrations to the
upcoming BaseController version.

## References

Relates to #5626

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
@Gudahtt Gudahtt force-pushed the messenger-migrate-controller-docs branch 2 times, most recently from c4836ce to d669a35 Compare August 21, 2025 16:43
@Gudahtt
Copy link
Member Author

Gudahtt commented Aug 21, 2025

Rebased to resolve conflict (the messenger package publish)

@Gudahtt Gudahtt mentioned this pull request Jul 17, 2025
43 tasks
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.

Had some minor comments, but overall these changes make sense.

@Gudahtt Gudahtt force-pushed the messenger-migrate-controller-docs branch 2 times, most recently from 0f4215d to 5d451a9 Compare August 28, 2025 16:50
@Gudahtt Gudahtt force-pushed the messenger-migrate-controller-docs branch from e8652f9 to e59a0bb Compare August 28, 2025 17:00
mcmire
mcmire previously approved these changes Aug 28, 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!

type RootMessenger = Messenger<
ExtractAvailableAction<SampleGasPricesControllerMessenger>,
ExtractAvailableEvent<SampleGasPricesControllerMessenger>
// Use `string` rather than 'Root' here to allow registering actions and publishing events from
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh that's a good idea, I hadn't thought of that.

Copy link
Member Author

Choose a reason for hiding this comment

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

It would have been a good idea if it worked 😅 I forgot there are runtime checks for this, tests are failing. Looking into it now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, it works now.

Gudahtt added a commit that referenced this pull request Sep 2, 2025
## Explanation

Fix mistakes and improve consistency and formatting in comment examples
in the `@metamask/sample-controllers` package.

## References

Extracted from #6335

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
@Gudahtt Gudahtt force-pushed the messenger-migrate-controller-docs branch 2 times, most recently from ed42ac9 to f2bb7e9 Compare September 2, 2025 15:59
@Gudahtt Gudahtt force-pushed the messenger-migrate-controller-docs branch from f2bb7e9 to 0f31c4e Compare October 3, 2025 18:30
@Gudahtt Gudahtt force-pushed the messenger-migrate-controller-docs branch from 0f31c4e to 013b836 Compare October 17, 2025 17:58
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.

2 participants