From bb0d2599fa6963c6cefd3197948664188dc81272 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Mon, 23 Mar 2026 15:49:48 +0100 Subject: [PATCH 1/8] Refactor `MultichainRouter` to use messenger exposed methods --- packages/snaps-controllers/CHANGELOG.md | 3 +- .../MultichainRouter-method-action-types.ts | 70 +++++++++++++++++++ .../src/multichain/MultichainRouter.ts | 65 +++++------------ .../snaps-controllers/src/multichain/index.ts | 9 ++- .../src/test-utils/controller.tsx | 4 +- scripts/generate-method-action-types.mts | 6 +- 6 files changed, 104 insertions(+), 53 deletions(-) create mode 100644 packages/snaps-controllers/src/multichain/MultichainRouter-method-action-types.ts diff --git a/packages/snaps-controllers/CHANGELOG.md b/packages/snaps-controllers/CHANGELOG.md index dd6302c997..31051c4bb4 100644 --- a/packages/snaps-controllers/CHANGELOG.md +++ b/packages/snaps-controllers/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- **BREAKING:** All action types were renamed from `DoSomething` to `ControllerNameDoSomethingAction` ([#3907](https://github.com/MetaMask/snaps/pull/3907), [#3911](https://github.com/MetaMask/snaps/pull/3911), [#3912](https://github.com/MetaMask/snaps/pull/3912)) +- **BREAKING:** All action types were renamed from `DoSomething` to `ControllerNameDoSomethingAction` ([#3907](https://github.com/MetaMask/snaps/pull/3907), [#3911](https://github.com/MetaMask/snaps/pull/3911), [#3912](https://github.com/MetaMask/snaps/pull/3912), [#3913](https://github.com/MetaMask/snaps/pull/3913)) - `SnapController` actions: - `GetSnap` is now `SnapControllerGetSnapAction`. - Note: The method is now called `getSnap` instead of `get`. @@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `SnapTerminated` is now `SnapControllerSnapTerminatedEvent`. - `SnapEnabled` is now `SnapControllerSnapEnabledEvent`. - `SnapDisabled` is now `SnapControllerSnapDisabledEvent`. +- **BREAKING:** `MutlichainRouter` now requires `SnapController:getRunnableSnaps` instead of `SnapController:getAllSnaps` ([#3913](https://github.com/MetaMask/snaps/pull/3913)) ### Removed diff --git a/packages/snaps-controllers/src/multichain/MultichainRouter-method-action-types.ts b/packages/snaps-controllers/src/multichain/MultichainRouter-method-action-types.ts new file mode 100644 index 0000000000..93543aafe6 --- /dev/null +++ b/packages/snaps-controllers/src/multichain/MultichainRouter-method-action-types.ts @@ -0,0 +1,70 @@ +/** + * This file is auto generated by `scripts/generate-method-action-types.ts`. + * Do not edit manually. + */ + +import type { MultichainRouter } from './MultichainRouter'; + +/** + * Handle an incoming JSON-RPC request tied to a specific scope by routing + * to either a protocol Snap or an account Snap. + * + * Note: Addresses are considered case-sensitive by the MultichainRouter as + * not all non-EVM chains are case-insensitive. + * + * @param options - An options bag. + * @param options.connectedAddresses - Addresses currently connected to the + * origin for the requested scope. + * @param options.origin - The origin of the RPC request. + * @param options.request - The JSON-RPC request. + * @param options.scope - The CAIP-2 scope for the request. + * @returns The response from the chosen Snap. + * @throws If no handler was found. + */ +export type MultichainRouterHandleRequestAction = { + type: `MultichainRouter:handleRequest`; + handler: MultichainRouter['handleRequest']; +}; + +/** + * Get a list of supported methods for a given scope. + * This combines both protocol and account Snaps supported methods. + * + * @param scope - The CAIP-2 scope. + * @returns A list of supported methods. + */ +export type MultichainRouterGetSupportedMethodsAction = { + type: `MultichainRouter:getSupportedMethods`; + handler: MultichainRouter['getSupportedMethods']; +}; + +/** + * Get a list of supported accounts for a given scope. + * + * @param scope - The CAIP-2 scope. + * @returns A list of CAIP-10 addresses. + */ +export type MultichainRouterGetSupportedAccountsAction = { + type: `MultichainRouter:getSupportedAccounts`; + handler: MultichainRouter['getSupportedAccounts']; +}; + +/** + * Determine whether a given CAIP-2 scope is supported by the router. + * + * @param scope - The CAIP-2 scope. + * @returns True if the router can service the scope, otherwise false. + */ +export type MultichainRouterIsSupportedScopeAction = { + type: `MultichainRouter:isSupportedScope`; + handler: MultichainRouter['isSupportedScope']; +}; + +/** + * Union of all MultichainRouter action types. + */ +export type MultichainRouterMethodActions = + | MultichainRouterHandleRequestAction + | MultichainRouterGetSupportedMethodsAction + | MultichainRouterGetSupportedAccountsAction + | MultichainRouterIsSupportedScopeAction; diff --git a/packages/snaps-controllers/src/multichain/MultichainRouter.ts b/packages/snaps-controllers/src/multichain/MultichainRouter.ts index fefa0aa408..e535bf2151 100644 --- a/packages/snaps-controllers/src/multichain/MultichainRouter.ts +++ b/packages/snaps-controllers/src/multichain/MultichainRouter.ts @@ -22,31 +22,11 @@ import { } from '@metamask/utils'; import { nanoid } from 'nanoid'; +import type { MultichainRouterMethodActions } from './MultichainRouter-method-action-types'; import type { - SnapControllerGetAllSnapsAction, + SnapControllerGetRunnableSnapsAction, SnapControllerHandleRequestAction, } from '../snaps'; -import { getRunnableSnaps } from '../snaps'; - -export type MultichainRouterHandleRequestAction = { - type: `${typeof name}:handleRequest`; - handler: MultichainRouter['handleRequest']; -}; - -export type MultichainRouterGetSupportedMethodsAction = { - type: `${typeof name}:getSupportedMethods`; - handler: MultichainRouter['getSupportedMethods']; -}; - -export type MultichainRouterGetSupportedAccountsAction = { - type: `${typeof name}:getSupportedAccounts`; - handler: MultichainRouter['getSupportedAccounts']; -}; - -export type MultichainRouterIsSupportedScopeAction = { - type: `${typeof name}:isSupportedScope`; - handler: MultichainRouter['isSupportedScope']; -}; type SnapKeyring = { submitRequest: (request: { @@ -68,14 +48,10 @@ export type AccountsControllerListMultichainAccountsAction = { handler: (chainId?: CaipChainId) => InternalAccount[]; }; -export type MultichainRouterActions = - | MultichainRouterHandleRequestAction - | MultichainRouterGetSupportedMethodsAction - | MultichainRouterGetSupportedAccountsAction - | MultichainRouterIsSupportedScopeAction; +export type MultichainRouterActions = MultichainRouterMethodActions; export type MultichainRouterAllowedActions = - | SnapControllerGetAllSnapsAction + | SnapControllerGetRunnableSnapsAction | SnapControllerHandleRequestAction | GetPermissions | AccountsControllerListMultichainAccountsAction; @@ -99,6 +75,13 @@ type ProtocolSnap = { const name = 'MultichainRouter'; +const MESSENGER_EXPOSED_METHODS = [ + 'handleRequest', + 'getSupportedMethods', + 'getSupportedAccounts', + 'isSupportedScope', +] as const; + export class MultichainRouter { name: typeof name = name; @@ -112,24 +95,9 @@ export class MultichainRouter { this.#messenger = messenger; this.#withSnapKeyring = withSnapKeyring; - this.#messenger.registerActionHandler( - `${name}:handleRequest`, - async (...args) => this.handleRequest(...args), - ); - - this.#messenger.registerActionHandler( - `${name}:getSupportedMethods`, - (...args) => this.getSupportedMethods(...args), - ); - - this.#messenger.registerActionHandler( - `${name}:getSupportedAccounts`, - (...args) => this.getSupportedAccounts(...args), - ); - - this.#messenger.registerActionHandler( - `${name}:isSupportedScope`, - (...args) => this.isSupportedScope(...args), + this.#messenger.registerMethodActionHandlers( + this, + MESSENGER_EXPOSED_METHODS, ); } @@ -263,8 +231,9 @@ export class MultichainRouter { * @returns A list of all the protocol Snaps available and their RPC methods. */ #getProtocolSnaps(scope: CaipChainId) { - const allSnaps = this.#messenger.call('SnapController:getAllSnaps'); - const filteredSnaps = getRunnableSnaps(allSnaps); + const filteredSnaps = this.#messenger.call( + 'SnapController:getRunnableSnaps', + ); return filteredSnaps.reduce((accumulator, snap) => { const permissions = this.#messenger.call( diff --git a/packages/snaps-controllers/src/multichain/index.ts b/packages/snaps-controllers/src/multichain/index.ts index 8c696c379e..8a8c7ecea4 100644 --- a/packages/snaps-controllers/src/multichain/index.ts +++ b/packages/snaps-controllers/src/multichain/index.ts @@ -1 +1,8 @@ -export * from './MultichainRouter'; +export { MultichainRouter } from './MultichainRouter'; +export type { + MultichainRouterGetSupportedAccountsAction, + MultichainRouterGetSupportedMethodsAction, + MultichainRouterHandleRequestAction, + MultichainRouterIsSupportedScopeAction, + MultichainRouterMethodActions, +} from './MultichainRouter-method-action-types'; diff --git a/packages/snaps-controllers/src/test-utils/controller.tsx b/packages/snaps-controllers/src/test-utils/controller.tsx index ef26f2925d..e74899b7d3 100644 --- a/packages/snaps-controllers/src/test-utils/controller.tsx +++ b/packages/snaps-controllers/src/test-utils/controller.tsx @@ -54,13 +54,13 @@ import type { Json } from '@metamask/utils'; import { MOCK_CRONJOB_PERMISSION } from './cronjob'; import { getNodeEES, getNodeEESMessenger } from './execution-environment'; import { MockSnapsRegistry } from './registry'; -import type { CronjobControllerMessenger } from '../cronjob'; +import type { CronjobControllerMessenger } from '../cronjob/CronjobController'; import type { SnapInsightsControllerMessenger } from '../insights'; import type { SnapInterfaceControllerMessenger, StoredInterface, } from '../interface/SnapInterfaceController'; -import type { MultichainRouterMessenger } from '../multichain'; +import type { MultichainRouterMessenger } from '../multichain/MultichainRouter'; import type { AbstractExecutionService, ExecutionServiceMessenger, diff --git a/scripts/generate-method-action-types.mts b/scripts/generate-method-action-types.mts index 27f3a5a436..33b71f0808 100644 --- a/scripts/generate-method-action-types.mts +++ b/scripts/generate-method-action-types.mts @@ -372,7 +372,11 @@ function createASTVisitor(context: VisitorContext): (node: ts.Node) => void { // Find the controller or service class if (ts.isClassDeclaration(node) && node.name) { const classText = node.name.text; - if (classText.includes('Controller') || classText.includes('Service')) { + if ( + classText.includes('Controller') || + classText.includes('Service') || + classText.includes('Router') + ) { context.className = classText; // Extract method info for exposed methods From fdf43f08f6d24f3b25f83827334873a915aea140 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Mon, 23 Mar 2026 15:50:50 +0100 Subject: [PATCH 2/8] Remove unused type --- packages/snaps-controllers/src/multichain/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/snaps-controllers/src/multichain/index.ts b/packages/snaps-controllers/src/multichain/index.ts index 8a8c7ecea4..7f11c1ab79 100644 --- a/packages/snaps-controllers/src/multichain/index.ts +++ b/packages/snaps-controllers/src/multichain/index.ts @@ -4,5 +4,4 @@ export type { MultichainRouterGetSupportedMethodsAction, MultichainRouterHandleRequestAction, MultichainRouterIsSupportedScopeAction, - MultichainRouterMethodActions, } from './MultichainRouter-method-action-types'; From 7d054793c47f580dc56239c2109aead90238fab2 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Mon, 23 Mar 2026 15:52:19 +0100 Subject: [PATCH 3/8] Update changelog --- packages/snaps-controllers/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/snaps-controllers/CHANGELOG.md b/packages/snaps-controllers/CHANGELOG.md index 31051c4bb4..f38497110e 100644 --- a/packages/snaps-controllers/CHANGELOG.md +++ b/packages/snaps-controllers/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- **BREAKING:** All action types were renamed from `DoSomething` to `ControllerNameDoSomethingAction` ([#3907](https://github.com/MetaMask/snaps/pull/3907), [#3911](https://github.com/MetaMask/snaps/pull/3911), [#3912](https://github.com/MetaMask/snaps/pull/3912), [#3913](https://github.com/MetaMask/snaps/pull/3913)) +- **BREAKING:** All action types were renamed from `DoSomething` to `ControllerNameDoSomethingAction` ([#3907](https://github.com/MetaMask/snaps/pull/3907), [#3911](https://github.com/MetaMask/snaps/pull/3911), [#3912](https://github.com/MetaMask/snaps/pull/3912)) - `SnapController` actions: - `GetSnap` is now `SnapControllerGetSnapAction`. - Note: The method is now called `getSnap` instead of `get`. From 907b6d3afd51fd5d5373c952962fd917e611a487 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Mon, 23 Mar 2026 16:00:47 +0100 Subject: [PATCH 4/8] Update packages/snaps-controllers/CHANGELOG.md Co-authored-by: Frederik Bolding --- packages/snaps-controllers/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/snaps-controllers/CHANGELOG.md b/packages/snaps-controllers/CHANGELOG.md index f38497110e..cad71435e2 100644 --- a/packages/snaps-controllers/CHANGELOG.md +++ b/packages/snaps-controllers/CHANGELOG.md @@ -64,7 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `SnapTerminated` is now `SnapControllerSnapTerminatedEvent`. - `SnapEnabled` is now `SnapControllerSnapEnabledEvent`. - `SnapDisabled` is now `SnapControllerSnapDisabledEvent`. -- **BREAKING:** `MutlichainRouter` now requires `SnapController:getRunnableSnaps` instead of `SnapController:getAllSnaps` ([#3913](https://github.com/MetaMask/snaps/pull/3913)) +- **BREAKING:** `MultichainRouter` now requires `SnapController:getRunnableSnaps` instead of `SnapController:getAllSnaps` ([#3913](https://github.com/MetaMask/snaps/pull/3913)) ### Removed From ff7663cb3cf3a3b72068a0cd4e3f9140015dd956 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Mon, 23 Mar 2026 16:01:31 +0100 Subject: [PATCH 5/8] Fix `getRunnableSnaps` delegation --- packages/snaps-controllers/src/test-utils/controller.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/snaps-controllers/src/test-utils/controller.tsx b/packages/snaps-controllers/src/test-utils/controller.tsx index e74899b7d3..393942d276 100644 --- a/packages/snaps-controllers/src/test-utils/controller.tsx +++ b/packages/snaps-controllers/src/test-utils/controller.tsx @@ -1012,7 +1012,7 @@ export const getRestrictedMultichainRouterMessenger = ( messenger.delegate({ actions: [ 'PermissionController:getPermissions', - 'SnapController:getAllSnaps', + 'SnapController:getRunnableSnaps', 'SnapController:handleRequest', 'AccountsController:listMultichainAccounts', ], From 83bbddb26da7f7e7a63b489a7fcab0df3219f831 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 24 Mar 2026 10:07:17 +0100 Subject: [PATCH 6/8] Update test mocks --- .../src/multichain/MultichainRouter.test.ts | 72 ++++++++++++------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/packages/snaps-controllers/src/multichain/MultichainRouter.test.ts b/packages/snaps-controllers/src/multichain/MultichainRouter.test.ts index b0a0895edd..badfd1233b 100644 --- a/packages/snaps-controllers/src/multichain/MultichainRouter.test.ts +++ b/packages/snaps-controllers/src/multichain/MultichainRouter.test.ts @@ -181,9 +181,12 @@ describe('MultichainRouter', () => { () => [], ); - rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => { - return [getTruncatedSnap()]; - }); + rootMessenger.registerActionHandler( + 'SnapController:getRunnableSnaps', + () => { + return [getTruncatedSnap()]; + }, + ); rootMessenger.registerActionHandler( 'PermissionController:getPermissions', @@ -252,9 +255,12 @@ describe('MultichainRouter', () => { () => [], ); - rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => { - return []; - }); + rootMessenger.registerActionHandler( + 'SnapController:getRunnableSnaps', + () => { + return []; + }, + ); await expect( messenger.call('MultichainRouter:handleRequest', { @@ -435,9 +441,12 @@ describe('MultichainRouter', () => { withSnapKeyring, }); - rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => { - return [getTruncatedSnap()]; - }); + rootMessenger.registerActionHandler( + 'SnapController:getRunnableSnaps', + () => { + return [getTruncatedSnap()]; + }, + ); rootMessenger.registerActionHandler( 'AccountsController:listMultichainAccounts', @@ -465,9 +474,12 @@ describe('MultichainRouter', () => { withSnapKeyring, }); - rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => { - return [getTruncatedSnap()]; - }); + rootMessenger.registerActionHandler( + 'SnapController:getRunnableSnaps', + () => { + return [getTruncatedSnap()]; + }, + ); rootMessenger.registerActionHandler( 'AccountsController:listMultichainAccounts', @@ -495,9 +507,12 @@ describe('MultichainRouter', () => { withSnapKeyring, }); - rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => { - return [getTruncatedSnap()]; - }); + rootMessenger.registerActionHandler( + 'SnapController:getRunnableSnaps', + () => { + return [getTruncatedSnap()]; + }, + ); rootMessenger.registerActionHandler( 'AccountsController:listMultichainAccounts', @@ -552,9 +567,12 @@ describe('MultichainRouter', () => { withSnapKeyring, }); - rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => { - return [getTruncatedSnap()]; - }); + rootMessenger.registerActionHandler( + 'SnapController:getRunnableSnaps', + () => { + return [getTruncatedSnap()]; + }, + ); rootMessenger.registerActionHandler( 'PermissionController:getPermissions', @@ -582,9 +600,12 @@ describe('MultichainRouter', () => { withSnapKeyring, }); - rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => { - return [getTruncatedSnap()]; - }); + rootMessenger.registerActionHandler( + 'SnapController:getRunnableSnaps', + () => { + return [getTruncatedSnap()]; + }, + ); rootMessenger.registerActionHandler( 'PermissionController:getPermissions', @@ -612,9 +633,12 @@ describe('MultichainRouter', () => { withSnapKeyring, }); - rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => { - return []; - }); + rootMessenger.registerActionHandler( + 'SnapController:getRunnableSnaps', + () => { + return []; + }, + ); rootMessenger.registerActionHandler( 'AccountsController:listMultichainAccounts', From 80bcf93636c21af446a9b82d03327eb031f1eff4 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 24 Mar 2026 10:17:05 +0100 Subject: [PATCH 7/8] Rename `MultichainRouter` to `MultichainRoutingService` --- packages/snaps-controllers/CHANGELOG.md | 4 +- ...hainRoutingService-method-action-types.ts} | 40 +-- ...st.ts => MultichainRoutingService.test.ts} | 229 +++++++++++------- ...nRouter.ts => MultichainRoutingService.ts} | 27 ++- .../snaps-controllers/src/multichain/index.ts | 12 +- .../src/test-utils/controller.tsx | 18 +- 6 files changed, 189 insertions(+), 141 deletions(-) rename packages/snaps-controllers/src/multichain/{MultichainRouter-method-action-types.ts => MultichainRoutingService-method-action-types.ts} (54%) rename packages/snaps-controllers/src/multichain/{MultichainRouter.test.ts => MultichainRoutingService.test.ts} (72%) rename packages/snaps-controllers/src/multichain/{MultichainRouter.ts => MultichainRoutingService.ts} (93%) diff --git a/packages/snaps-controllers/CHANGELOG.md b/packages/snaps-controllers/CHANGELOG.md index cad71435e2..28ea6c8921 100644 --- a/packages/snaps-controllers/CHANGELOG.md +++ b/packages/snaps-controllers/CHANGELOG.md @@ -64,7 +64,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `SnapTerminated` is now `SnapControllerSnapTerminatedEvent`. - `SnapEnabled` is now `SnapControllerSnapEnabledEvent`. - `SnapDisabled` is now `SnapControllerSnapDisabledEvent`. -- **BREAKING:** `MultichainRouter` now requires `SnapController:getRunnableSnaps` instead of `SnapController:getAllSnaps` ([#3913](https://github.com/MetaMask/snaps/pull/3913)) +- **BREAKING:**: Rename `MultichainRouter` to `MultichainRoutingService` and update action types accordingly ([#3913](https://github.com/MetaMask/snaps/pull/3913)) + - This is consistent with the naming of other services. +- **BREAKING:** `MultichainRoutingService` now requires `SnapController:getRunnableSnaps` instead of `SnapController:getAllSnaps` ([#3913](https://github.com/MetaMask/snaps/pull/3913)) ### Removed diff --git a/packages/snaps-controllers/src/multichain/MultichainRouter-method-action-types.ts b/packages/snaps-controllers/src/multichain/MultichainRoutingService-method-action-types.ts similarity index 54% rename from packages/snaps-controllers/src/multichain/MultichainRouter-method-action-types.ts rename to packages/snaps-controllers/src/multichain/MultichainRoutingService-method-action-types.ts index 93543aafe6..e851e9c737 100644 --- a/packages/snaps-controllers/src/multichain/MultichainRouter-method-action-types.ts +++ b/packages/snaps-controllers/src/multichain/MultichainRoutingService-method-action-types.ts @@ -3,13 +3,13 @@ * Do not edit manually. */ -import type { MultichainRouter } from './MultichainRouter'; +import type { MultichainRoutingService } from './MultichainRoutingService'; /** * Handle an incoming JSON-RPC request tied to a specific scope by routing * to either a protocol Snap or an account Snap. * - * Note: Addresses are considered case-sensitive by the MultichainRouter as + * Note: Addresses are considered case-sensitive by the MultichainRoutingService as * not all non-EVM chains are case-insensitive. * * @param options - An options bag. @@ -21,9 +21,9 @@ import type { MultichainRouter } from './MultichainRouter'; * @returns The response from the chosen Snap. * @throws If no handler was found. */ -export type MultichainRouterHandleRequestAction = { - type: `MultichainRouter:handleRequest`; - handler: MultichainRouter['handleRequest']; +export type MultichainRoutingServiceHandleRequestAction = { + type: `MultichainRoutingService:handleRequest`; + handler: MultichainRoutingService['handleRequest']; }; /** @@ -33,9 +33,9 @@ export type MultichainRouterHandleRequestAction = { * @param scope - The CAIP-2 scope. * @returns A list of supported methods. */ -export type MultichainRouterGetSupportedMethodsAction = { - type: `MultichainRouter:getSupportedMethods`; - handler: MultichainRouter['getSupportedMethods']; +export type MultichainRoutingServiceGetSupportedMethodsAction = { + type: `MultichainRoutingService:getSupportedMethods`; + handler: MultichainRoutingService['getSupportedMethods']; }; /** @@ -44,9 +44,9 @@ export type MultichainRouterGetSupportedMethodsAction = { * @param scope - The CAIP-2 scope. * @returns A list of CAIP-10 addresses. */ -export type MultichainRouterGetSupportedAccountsAction = { - type: `MultichainRouter:getSupportedAccounts`; - handler: MultichainRouter['getSupportedAccounts']; +export type MultichainRoutingServiceGetSupportedAccountsAction = { + type: `MultichainRoutingService:getSupportedAccounts`; + handler: MultichainRoutingService['getSupportedAccounts']; }; /** @@ -55,16 +55,16 @@ export type MultichainRouterGetSupportedAccountsAction = { * @param scope - The CAIP-2 scope. * @returns True if the router can service the scope, otherwise false. */ -export type MultichainRouterIsSupportedScopeAction = { - type: `MultichainRouter:isSupportedScope`; - handler: MultichainRouter['isSupportedScope']; +export type MultichainRoutingServiceIsSupportedScopeAction = { + type: `MultichainRoutingService:isSupportedScope`; + handler: MultichainRoutingService['isSupportedScope']; }; /** - * Union of all MultichainRouter action types. + * Union of all MultichainRoutingService action types. */ -export type MultichainRouterMethodActions = - | MultichainRouterHandleRequestAction - | MultichainRouterGetSupportedMethodsAction - | MultichainRouterGetSupportedAccountsAction - | MultichainRouterIsSupportedScopeAction; +export type MultichainRoutingServiceMethodActions = + | MultichainRoutingServiceHandleRequestAction + | MultichainRoutingServiceGetSupportedMethodsAction + | MultichainRoutingServiceGetSupportedAccountsAction + | MultichainRoutingServiceIsSupportedScopeAction; diff --git a/packages/snaps-controllers/src/multichain/MultichainRouter.test.ts b/packages/snaps-controllers/src/multichain/MultichainRoutingService.test.ts similarity index 72% rename from packages/snaps-controllers/src/multichain/MultichainRouter.test.ts rename to packages/snaps-controllers/src/multichain/MultichainRoutingService.test.ts index badfd1233b..bbdb8d374f 100644 --- a/packages/snaps-controllers/src/multichain/MultichainRouter.test.ts +++ b/packages/snaps-controllers/src/multichain/MultichainRoutingService.test.ts @@ -4,11 +4,11 @@ import { MOCK_SNAP_ID, } from '@metamask/snaps-utils/test-utils'; -import { MultichainRouter } from './MultichainRouter'; +import { MultichainRoutingService } from './MultichainRoutingService'; import { METAMASK_ORIGIN } from '../snaps/constants'; import { - getMultichainRouterRootMessenger, - getRestrictedMultichainRouterMessenger, + getMultichainRoutingServiceRootMessenger, + getRestrictedMultichainRoutingServiceMessenger, BTC_CAIP2, BTC_CONNECTED_ACCOUNTS, MOCK_SOLANA_SNAP_PERMISSIONS, @@ -19,11 +19,12 @@ import { getMockWithSnapKeyring, } from '../test-utils'; -describe('MultichainRouter', () => { +describe('MultichainRoutingService', () => { describe('handleRequest', () => { it('can route signing requests to account Snaps without address resolution', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring({ submitRequest: jest.fn().mockResolvedValue({ txid: '53de51e2fa75c3cfa51132865f7d430138b1cd92a8f5267ec836ec565b422969', @@ -31,7 +32,7 @@ describe('MultichainRouter', () => { }); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -51,19 +52,22 @@ describe('MultichainRouter', () => { }, ); - const result = await messenger.call('MultichainRouter:handleRequest', { - origin: METAMASK_ORIGIN, - connectedAddresses: BTC_CONNECTED_ACCOUNTS, - scope: BTC_CAIP2, - request: { - jsonrpc: '2.0', - id: 1, - method: 'sendBitcoin', - params: { - message: 'foo', + const result = await messenger.call( + 'MultichainRoutingService:handleRequest', + { + origin: METAMASK_ORIGIN, + connectedAddresses: BTC_CONNECTED_ACCOUNTS, + scope: BTC_CAIP2, + request: { + jsonrpc: '2.0', + id: 1, + method: 'sendBitcoin', + params: { + message: 'foo', + }, }, }, - }); + ); expect(result).toStrictEqual({ txid: '53de51e2fa75c3cfa51132865f7d430138b1cd92a8f5267ec836ec565b422969', @@ -71,8 +75,9 @@ describe('MultichainRouter', () => { }); it('can route signing requests to account Snaps using address resolution', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring({ submitRequest: jest.fn().mockResolvedValue({ signature: '0x', @@ -80,7 +85,7 @@ describe('MultichainRouter', () => { }); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -105,30 +110,34 @@ describe('MultichainRouter', () => { }, ); - const result = await messenger.call('MultichainRouter:handleRequest', { - origin: METAMASK_ORIGIN, - connectedAddresses: SOLANA_CONNECTED_ACCOUNTS, - scope: SOLANA_CAIP2, - request: { - jsonrpc: '2.0', - id: 1, - method: 'signAndSendTransaction', - params: { - message: 'foo', + const result = await messenger.call( + 'MultichainRoutingService:handleRequest', + { + origin: METAMASK_ORIGIN, + connectedAddresses: SOLANA_CONNECTED_ACCOUNTS, + scope: SOLANA_CAIP2, + request: { + jsonrpc: '2.0', + id: 1, + method: 'signAndSendTransaction', + params: { + message: 'foo', + }, }, }, - }); + ); expect(result).toStrictEqual({ signature: '0x' }); }); it('disallows routing to unconnected accounts', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -149,7 +158,7 @@ describe('MultichainRouter', () => { ); await expect( - messenger.call('MultichainRouter:handleRequest', { + messenger.call('MultichainRoutingService:handleRequest', { origin: METAMASK_ORIGIN, connectedAddresses: [], scope: SOLANA_CAIP2, @@ -166,12 +175,13 @@ describe('MultichainRouter', () => { }); it('can route protocol requests to protocol Snaps', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -201,16 +211,19 @@ describe('MultichainRouter', () => { }), ); - const result = await messenger.call('MultichainRouter:handleRequest', { - origin: METAMASK_ORIGIN, - connectedAddresses: [], - scope: SOLANA_CAIP2, - request: { - jsonrpc: '2.0', - id: 1, - method: 'getVersion', + const result = await messenger.call( + 'MultichainRoutingService:handleRequest', + { + origin: METAMASK_ORIGIN, + connectedAddresses: [], + scope: SOLANA_CAIP2, + request: { + jsonrpc: '2.0', + id: 1, + method: 'getVersion', + }, }, - }); + ); expect(result).toStrictEqual({ 'feature-set': 2891131721, @@ -240,12 +253,13 @@ describe('MultichainRouter', () => { }); it('throws if no suitable Snaps are found', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -263,7 +277,7 @@ describe('MultichainRouter', () => { ); await expect( - messenger.call('MultichainRouter:handleRequest', { + messenger.call('MultichainRoutingService:handleRequest', { origin: METAMASK_ORIGIN, connectedAddresses: [], scope: SOLANA_CAIP2, @@ -277,12 +291,13 @@ describe('MultichainRouter', () => { }); it('throws if address resolution fails', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -309,7 +324,7 @@ describe('MultichainRouter', () => { ); await expect( - messenger.call('MultichainRouter:handleRequest', { + messenger.call('MultichainRoutingService:handleRequest', { origin: METAMASK_ORIGIN, connectedAddresses: SOLANA_CONNECTED_ACCOUNTS, scope: SOLANA_CAIP2, @@ -326,12 +341,13 @@ describe('MultichainRouter', () => { }); it('throws if address resolution returns an address that isnt available', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -361,7 +377,7 @@ describe('MultichainRouter', () => { ); await expect( - messenger.call('MultichainRouter:handleRequest', { + messenger.call('MultichainRoutingService:handleRequest', { origin: METAMASK_ORIGIN, connectedAddresses: SOLANA_CONNECTED_ACCOUNTS, scope: SOLANA_CAIP2, @@ -378,12 +394,13 @@ describe('MultichainRouter', () => { }); it(`throws if address resolution returns a lower case address that isn't available`, async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -412,7 +429,7 @@ describe('MultichainRouter', () => { ); await expect( - messenger.call('MultichainRouter:handleRequest', { + messenger.call('MultichainRoutingService:handleRequest', { origin: METAMASK_ORIGIN, connectedAddresses: SOLANA_CONNECTED_ACCOUNTS, scope: SOLANA_CAIP2, @@ -431,12 +448,13 @@ describe('MultichainRouter', () => { describe('getSupportedMethods', () => { it('returns a set of both protocol and account Snap methods', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -459,17 +477,21 @@ describe('MultichainRouter', () => { ); expect( - messenger.call('MultichainRouter:getSupportedMethods', SOLANA_CAIP2), + messenger.call( + 'MultichainRoutingService:getSupportedMethods', + SOLANA_CAIP2, + ), ).toStrictEqual(['signAndSendTransaction', 'getVersion']); }); it('handles lack of protocol Snaps', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -492,17 +514,21 @@ describe('MultichainRouter', () => { ); expect( - messenger.call('MultichainRouter:getSupportedMethods', SOLANA_CAIP2), + messenger.call( + 'MultichainRoutingService:getSupportedMethods', + SOLANA_CAIP2, + ), ).toStrictEqual(['signAndSendTransaction']); }); it('handles lack of account Snaps', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -525,19 +551,23 @@ describe('MultichainRouter', () => { ); expect( - messenger.call('MultichainRouter:getSupportedMethods', SOLANA_CAIP2), + messenger.call( + 'MultichainRoutingService:getSupportedMethods', + SOLANA_CAIP2, + ), ).toStrictEqual(['getVersion']); }); }); describe('getSupportedAccounts', () => { it('returns a set of accounts for the requested scope', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -548,7 +578,10 @@ describe('MultichainRouter', () => { ); expect( - messenger.call('MultichainRouter:getSupportedAccounts', SOLANA_CAIP2), + messenger.call( + 'MultichainRoutingService:getSupportedAccounts', + SOLANA_CAIP2, + ), ).toStrictEqual([ 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:7S3P4HxJpyyigGzodYwHtCxZyUQe9JiBMHyRWXArAaKv', ]); @@ -557,12 +590,13 @@ describe('MultichainRouter', () => { describe('isSupportedScope', () => { it('returns true if an account Snap exists', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -585,17 +619,21 @@ describe('MultichainRouter', () => { ); expect( - messenger.call('MultichainRouter:isSupportedScope', SOLANA_CAIP2), + messenger.call( + 'MultichainRoutingService:isSupportedScope', + SOLANA_CAIP2, + ), ).toBe(true); }); it('returns true if a protocol Snap exists', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -618,17 +656,21 @@ describe('MultichainRouter', () => { ); expect( - messenger.call('MultichainRouter:isSupportedScope', SOLANA_CAIP2), + messenger.call( + 'MultichainRoutingService:isSupportedScope', + SOLANA_CAIP2, + ), ).toBe(true); }); it('returns false if no Snap is found', async () => { - const rootMessenger = getMultichainRouterRootMessenger(); - const messenger = getRestrictedMultichainRouterMessenger(rootMessenger); + const rootMessenger = getMultichainRoutingServiceRootMessenger(); + const messenger = + getRestrictedMultichainRoutingServiceMessenger(rootMessenger); const withSnapKeyring = getMockWithSnapKeyring(); /* eslint-disable-next-line no-new */ - new MultichainRouter({ + new MultichainRoutingService({ messenger, withSnapKeyring, }); @@ -646,7 +688,10 @@ describe('MultichainRouter', () => { ); expect( - messenger.call('MultichainRouter:isSupportedScope', SOLANA_CAIP2), + messenger.call( + 'MultichainRoutingService:isSupportedScope', + SOLANA_CAIP2, + ), ).toBe(false); }); }); diff --git a/packages/snaps-controllers/src/multichain/MultichainRouter.ts b/packages/snaps-controllers/src/multichain/MultichainRoutingService.ts similarity index 93% rename from packages/snaps-controllers/src/multichain/MultichainRouter.ts rename to packages/snaps-controllers/src/multichain/MultichainRoutingService.ts index e535bf2151..1f5fc7a983 100644 --- a/packages/snaps-controllers/src/multichain/MultichainRouter.ts +++ b/packages/snaps-controllers/src/multichain/MultichainRoutingService.ts @@ -22,7 +22,7 @@ import { } from '@metamask/utils'; import { nanoid } from 'nanoid'; -import type { MultichainRouterMethodActions } from './MultichainRouter-method-action-types'; +import type { MultichainRoutingServiceMethodActions } from './MultichainRoutingService-method-action-types'; import type { SnapControllerGetRunnableSnapsAction, SnapControllerHandleRequestAction, @@ -48,23 +48,24 @@ export type AccountsControllerListMultichainAccountsAction = { handler: (chainId?: CaipChainId) => InternalAccount[]; }; -export type MultichainRouterActions = MultichainRouterMethodActions; +export type MultichainRoutingServiceActions = + MultichainRoutingServiceMethodActions; -export type MultichainRouterAllowedActions = +export type MultichainRoutingServiceAllowedActions = | SnapControllerGetRunnableSnapsAction | SnapControllerHandleRequestAction | GetPermissions | AccountsControllerListMultichainAccountsAction; -export type MultichainRouterEvents = never; +export type MultichainRoutingServiceEvents = never; -export type MultichainRouterMessenger = Messenger< +export type MultichainRoutingServiceMessenger = Messenger< typeof name, - MultichainRouterActions | MultichainRouterAllowedActions + MultichainRoutingServiceActions | MultichainRoutingServiceAllowedActions >; -export type MultichainRouterArgs = { - messenger: MultichainRouterMessenger; +export type MultichainRoutingServiceArgs = { + messenger: MultichainRoutingServiceMessenger; withSnapKeyring: WithSnapKeyringFunction; }; @@ -73,7 +74,7 @@ type ProtocolSnap = { methods: string[]; }; -const name = 'MultichainRouter'; +const name = 'MultichainRoutingService'; const MESSENGER_EXPOSED_METHODS = [ 'handleRequest', @@ -82,16 +83,16 @@ const MESSENGER_EXPOSED_METHODS = [ 'isSupportedScope', ] as const; -export class MultichainRouter { +export class MultichainRoutingService { name: typeof name = name; state = null; - readonly #messenger: MultichainRouterMessenger; + readonly #messenger: MultichainRoutingServiceMessenger; readonly #withSnapKeyring: WithSnapKeyringFunction; - constructor({ messenger, withSnapKeyring }: MultichainRouterArgs) { + constructor({ messenger, withSnapKeyring }: MultichainRoutingServiceArgs) { this.#messenger = messenger; this.#withSnapKeyring = withSnapKeyring; @@ -260,7 +261,7 @@ export class MultichainRouter { * Handle an incoming JSON-RPC request tied to a specific scope by routing * to either a protocol Snap or an account Snap. * - * Note: Addresses are considered case-sensitive by the MultichainRouter as + * Note: Addresses are considered case-sensitive by the MultichainRoutingService as * not all non-EVM chains are case-insensitive. * * @param options - An options bag. diff --git a/packages/snaps-controllers/src/multichain/index.ts b/packages/snaps-controllers/src/multichain/index.ts index 7f11c1ab79..7a1ce9328d 100644 --- a/packages/snaps-controllers/src/multichain/index.ts +++ b/packages/snaps-controllers/src/multichain/index.ts @@ -1,7 +1,7 @@ -export { MultichainRouter } from './MultichainRouter'; +export { MultichainRoutingService } from './MultichainRoutingService'; export type { - MultichainRouterGetSupportedAccountsAction, - MultichainRouterGetSupportedMethodsAction, - MultichainRouterHandleRequestAction, - MultichainRouterIsSupportedScopeAction, -} from './MultichainRouter-method-action-types'; + MultichainRoutingServiceGetSupportedAccountsAction, + MultichainRoutingServiceGetSupportedMethodsAction, + MultichainRoutingServiceHandleRequestAction, + MultichainRoutingServiceIsSupportedScopeAction, +} from './MultichainRoutingService-method-action-types'; diff --git a/packages/snaps-controllers/src/test-utils/controller.tsx b/packages/snaps-controllers/src/test-utils/controller.tsx index 393942d276..42c735cf56 100644 --- a/packages/snaps-controllers/src/test-utils/controller.tsx +++ b/packages/snaps-controllers/src/test-utils/controller.tsx @@ -60,7 +60,7 @@ import type { SnapInterfaceControllerMessenger, StoredInterface, } from '../interface/SnapInterfaceController'; -import type { MultichainRouterMessenger } from '../multichain/MultichainRouter'; +import type { MultichainRoutingServiceMessenger } from '../multichain/MultichainRoutingService'; import type { AbstractExecutionService, ExecutionServiceMessenger, @@ -986,14 +986,14 @@ export async function waitForStateChange( }); } -type MultichainRouterRootMessenger = Messenger< +type MultichainRoutingServiceRootMessenger = Messenger< MockAnyNamespace, - MessengerActions + MessengerActions >; // Mock controller messenger for Multichain Router -export const getMultichainRouterRootMessenger = () => { - const messenger: MultichainRouterRootMessenger = +export const getMultichainRoutingServiceRootMessenger = () => { + const messenger: MultichainRoutingServiceRootMessenger = new MockControllerMessenger(); jest.spyOn(messenger, 'call'); @@ -1001,11 +1001,11 @@ export const getMultichainRouterRootMessenger = () => { return messenger; }; -export const getRestrictedMultichainRouterMessenger = ( - messenger: MultichainRouterRootMessenger = getMultichainRouterRootMessenger(), +export const getRestrictedMultichainRoutingServiceMessenger = ( + messenger: MultichainRoutingServiceRootMessenger = getMultichainRoutingServiceRootMessenger(), ) => { - const controllerMessenger: MultichainRouterMessenger = new Messenger({ - namespace: 'MultichainRouter', + const controllerMessenger: MultichainRoutingServiceMessenger = new Messenger({ + namespace: 'MultichainRoutingService', parent: messenger, }); From 5b0d48282577a392a60cd769902db2e847bd606c Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 24 Mar 2026 10:19:09 +0100 Subject: [PATCH 8/8] Revert change to generate method action types script --- scripts/generate-method-action-types.mts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/generate-method-action-types.mts b/scripts/generate-method-action-types.mts index 33b71f0808..27f3a5a436 100644 --- a/scripts/generate-method-action-types.mts +++ b/scripts/generate-method-action-types.mts @@ -372,11 +372,7 @@ function createASTVisitor(context: VisitorContext): (node: ts.Node) => void { // Find the controller or service class if (ts.isClassDeclaration(node) && node.name) { const classText = node.name.text; - if ( - classText.includes('Controller') || - classText.includes('Service') || - classText.includes('Router') - ) { + if (classText.includes('Controller') || classText.includes('Service')) { context.className = classText; // Extract method info for exposed methods