Skip to content

refactor(delegation): remove duplicate messenger types#32005

Draft
Mrtenz wants to merge 1 commit into
mainfrom
mrtenz/refactor-delegation-messenger-types
Draft

refactor(delegation): remove duplicate messenger types#32005
Mrtenz wants to merge 1 commit into
mainfrom
mrtenz/refactor-delegation-messenger-types

Conversation

@Mrtenz

@Mrtenz Mrtenz commented Jun 18, 2026

Copy link
Copy Markdown
Member

Description

Applies the same messenger type refactoring from #31467 to the two delegation-owned messenger files (delegation-controller-messenger, gator-permissions-controller-messenger).

Narrows rootMessenger parameters to RootMessenger<AllowedActions, AllowedEvents>, simplifies new Messenger<Namespace, Actions, Events, Root>({…}) to typed variable declarations, converts DelegationControllerInitMessenger from ReturnType<typeof …> to an explicit Messenger<'DelegationControllerInit', never, Events> type, and adds an explicit return type to getDelegationControllerInitMessenger.

Also removes the export type { GatorPermissionsControllerMessenger } re-export from the gator-permissions messenger file (replacing RootExtendedMessenger with the narrowed RootMessenger<…>), and updates the init test to import the type directly from @metamask/gator-permissions-controller.

No runtime behaviour changes.

Changelog

CHANGELOG entry: null

Related issues

Fixes: N/A

Manual testing steps

N/A — pure TypeScript refactoring, no runtime behaviour changes.

Screenshots/Recordings

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
  • I've tested with a power user scenario
  • I've instrumented key operations with Sentry traces for production performance metrics

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.

Applies the same messenger type refactoring from #31467 to the two
delegation-owned messenger files.

`delegation-controller-messenger`: narrows `rootMessenger` parameters,
simplifies `new Messenger<...>` constructors, converts
`DelegationControllerInitMessenger` from `ReturnType<typeof ...>` to an
explicit `Messenger<'DelegationControllerInit', never, Events>` type,
and adds an explicit return type to `getDelegationControllerInitMessenger`.

`gator-permissions-controller-messenger`: narrows `rootMessenger`
parameter (replacing `RootExtendedMessenger`), simplifies constructor,
removes the `export type { GatorPermissionsControllerMessenger }` re-export,
and updates the init test to import the type directly from
`@metamask/gator-permissions-controller`.
@Mrtenz Mrtenz requested a review from Copilot June 18, 2026 13:45
@mm-token-exchange-service mm-token-exchange-service Bot added the team-core-platform Core Platform team label Jun 18, 2026
@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 18, 2026
@mm-token-exchange-service

Copy link
Copy Markdown

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Screenshots/Recordings section is empty. Add an image/video for user-facing changes, logs/console output for non-user-facing changes, or write N/A if no evidence is applicable.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Ready to approve

The changes are type-only refactors consistent with existing messenger patterns, with only minor follow-up best-practice nits noted.

Note: this review does not count toward required approvals for merging.

Pull request overview

This PR applies the RootMessenger<AllowedActions, AllowedEvents> narrowing and related messenger typing cleanups (previously done in #31467) to the delegation-owned messenger modules, aiming to remove duplicate messenger type declarations and make init messenger types explicit/self-contained without changing runtime behavior.

Changes:

  • Narrowed messenger factory parameters to RootMessenger<AllowedActions, AllowedEvents> and simplified new Messenger<...>({ ... }) usages to typed variable declarations.
  • Converted DelegationControllerInitMessenger from a ReturnType<typeof ...> alias to an explicit Messenger<'DelegationControllerInit', never, ...> type and added an explicit return type to getDelegationControllerInitMessenger.
  • Removed the GatorPermissionsControllerMessenger type re-export from the local messenger file and updated the init test to import the type directly from @metamask/gator-permissions-controller.
File summaries
File Description
app/core/Engine/messengers/gator-permissions-controller-messenger/gator-permissions-controller-messenger.ts Narrows the root messenger parameter typing and removes the local type re-export.
app/core/Engine/messengers/delegation/delegation-controller-messenger.ts Applies the narrowed RootMessenger<...> pattern and makes the init messenger type and factory return type explicit.
app/core/Engine/controllers/gator-permissions-controller/gator-permissions-controller-init.test.ts Updates imports to use the upstream GatorPermissionsControllerMessenger type rather than a local re-export.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1 to 3
import type { GatorPermissionsControllerMessenger } from '@metamask/gator-permissions-controller';
import { RootExtendedMessenger, RootMessenger } from '../../types';
import { RootMessenger } from '../../types';
import {
Comment on lines +12 to 16
export type DelegationControllerInitMessenger = Messenger<
'DelegationControllerInit',
never,
TransactionControllerTransactionStatusUpdatedEvent
>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. size-S team-core-platform Core Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants