refactor(delegation): remove duplicate messenger types#32005
Conversation
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`.
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
There was a problem hiding this comment.
✅ 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 simplifiednew Messenger<...>({ ... })usages to typed variable declarations. - Converted
DelegationControllerInitMessengerfrom aReturnType<typeof ...>alias to an explicitMessenger<'DelegationControllerInit', never, ...>type and added an explicit return type togetDelegationControllerInitMessenger. - Removed the
GatorPermissionsControllerMessengertype 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.
| import type { GatorPermissionsControllerMessenger } from '@metamask/gator-permissions-controller'; | ||
| import { RootExtendedMessenger, RootMessenger } from '../../types'; | ||
| import { RootMessenger } from '../../types'; | ||
| import { |
| export type DelegationControllerInitMessenger = Messenger< | ||
| 'DelegationControllerInit', | ||
| never, | ||
| TransactionControllerTransactionStatusUpdatedEvent | ||
| >; |
Description
Applies the same messenger type refactoring from #31467 to the two delegation-owned messenger files (
delegation-controller-messenger,gator-permissions-controller-messenger).Narrows
rootMessengerparameters toRootMessenger<AllowedActions, AllowedEvents>, simplifiesnew Messenger<Namespace, Actions, Events, Root>({…})to typed variable declarations, convertsDelegationControllerInitMessengerfromReturnType<typeof …>to an explicitMessenger<'DelegationControllerInit', never, Events>type, and adds an explicit return type togetDelegationControllerInitMessenger.Also removes the
export type { GatorPermissionsControllerMessenger }re-export from the gator-permissions messenger file (replacingRootExtendedMessengerwith the narrowedRootMessenger<…>), 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)
Pre-merge reviewer checklist