Skip to content

Conversation

cryptodev-2s
Copy link
Contributor

@cryptodev-2s cryptodev-2s commented Sep 9, 2025

Explanation

This PR migrates NotificationServicesController and NotificationServicesPushController to the new @metamask/messenger message bus, as opposed to the one exported from @metamask/base-controller.

References

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

@cryptodev-2s cryptodev-2s requested review from a team as code owners September 9, 2025 17:02
@cryptodev-2s cryptodev-2s self-assigned this Sep 9, 2025
@cryptodev-2s cryptodev-2s force-pushed the cryptodev-2s/messenger/notification-services-controller branch from 9449e6e to 851b86f Compare September 9, 2025 17:05
@cryptodev-2s cryptodev-2s force-pushed the cryptodev-2s/messenger/notification-services-controller branch from 851b86f to e948005 Compare September 9, 2025 17:06
@cryptodev-2s cryptodev-2s mentioned this pull request Sep 9, 2025
42 tasks
isFeatureAnnouncementsEnabled: true,
isNotificationServicesEnabled: true,
},
describe('NotificationServicesController', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we reformat the tests in another PR? Otherwise this diff is somewhat difficult to read.

Comment on lines +38 to +50
const globalMessenger = getRootMessenger();

return globalMessenger.getRestricted<
'NotificationServicesPushController',
AllowedActions['type']
const messenger = new Messenger<
typeof controllerName,
AllNotificationServicesPushControllerActions,
AllNotificationServicesPushControllerEvents,
RootMessenger
>({
name: 'NotificationServicesPushController',
allowedActions: ['AuthenticationController:getBearerToken'],
allowedEvents: [],
namespace: controllerName,
parent: globalMessenger,
});

globalMessenger.delegate({
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Should we rename this variable to rootMessenger?

Suggested change
const globalMessenger = getRootMessenger();
return globalMessenger.getRestricted<
'NotificationServicesPushController',
AllowedActions['type']
const messenger = new Messenger<
typeof controllerName,
AllNotificationServicesPushControllerActions,
AllNotificationServicesPushControllerEvents,
RootMessenger
>({
name: 'NotificationServicesPushController',
allowedActions: ['AuthenticationController:getBearerToken'],
allowedEvents: [],
namespace: controllerName,
parent: globalMessenger,
});
globalMessenger.delegate({
const rootMessenger = getRootMessenger();
const messenger = new Messenger<
typeof controllerName,
AllNotificationServicesPushControllerActions,
AllNotificationServicesPushControllerEvents,
RootMessenger
>({
namespace: controllerName,
parent: rootMessenger,
});
rootMessenger.delegate({

@@ -195,7 +195,7 @@ export type Actions =
| NotificationServicesControllerDeleteNotificationsById;

// Allowed Actions
export type AllowedActions =
type AllowedActions =
Copy link
Contributor

Choose a reason for hiding this comment

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

Because @metamask/notification-services-controller is using barrel exports in index.ts, I believe that if we don't export this type it will remove the export from the whole package, can you confirm? If so should we add this to the changelog?

@@ -231,7 +231,7 @@ export type Events =
| MarkNotificationsAsReadEvent;

// Allowed Events
export type AllowedEvents =
type AllowedEvents =
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar as for AllowedActions.

@@ -55,7 +55,7 @@ export type Actions =
| NotificationServicesPushControllerUpdateTriggerPushNotificationsAction
| NotificationServicesPushControllerSubscribeToNotificationsAction;

export type AllowedActions =
type AllowedActions =
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar comment as for NotificationServicesController.ts.

@@ -79,14 +79,10 @@ export type Events =
| NotificationServicesPushControllerOnNewNotificationEvent
| NotificationServicesPushControllerPushNotificationClickedEvent;

export type AllowedEvents = never;
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar comment as for NotificationServicesController.ts.

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