From 6b6f171d9dd95c8e58ab3499c1343ac97f1334d4 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Tue, 18 Mar 2025 13:43:38 +0100 Subject: [PATCH] fix: Handle withKeyring breaking change in MultichainRouter --- .../src/multichain/MultichainRouter.ts | 6 +++--- .../snaps-controllers/src/test-utils/multichain.ts | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/snaps-controllers/src/multichain/MultichainRouter.ts b/packages/snaps-controllers/src/multichain/MultichainRouter.ts index 31e71f2d94..7665895aae 100644 --- a/packages/snaps-controllers/src/multichain/MultichainRouter.ts +++ b/packages/snaps-controllers/src/multichain/MultichainRouter.ts @@ -72,7 +72,7 @@ type SnapKeyring = { // Expecting a bound function that calls KeyringController.withKeyring selecting the Snap keyring type WithSnapKeyringFunction = ( - operation: (keyring: SnapKeyring) => Promise, + operation: ({ keyring }: { keyring: SnapKeyring }) => Promise, ) => Promise; export type AccountsControllerListMultichainAccountsAction = { @@ -165,7 +165,7 @@ export class MultichainRouter { request: JsonRpcRequest, ) { try { - const result = await this.#withSnapKeyring(async (keyring) => + const result = await this.#withSnapKeyring(async ({ keyring }) => keyring.resolveAccountAddress(snapId, scope, request), ); const address = result?.address; @@ -323,7 +323,7 @@ export class MultichainRouter { ); if (accountId) { - return this.#withSnapKeyring(async (keyring) => + return this.#withSnapKeyring(async ({ keyring }) => keyring.submitRequest({ account: accountId, scope, diff --git a/packages/snaps-controllers/src/test-utils/multichain.ts b/packages/snaps-controllers/src/test-utils/multichain.ts index 361190786a..695d66fd75 100644 --- a/packages/snaps-controllers/src/test-utils/multichain.ts +++ b/packages/snaps-controllers/src/test-utils/multichain.ts @@ -95,7 +95,11 @@ type MockSnapKeyring = { ) => Promise<{ address: CaipAccountId } | null>; }; -type MockOperationCallback = (keyring: MockSnapKeyring) => Promise; +type MockOperationCallback = ({ + keyring, +}: { + keyring: MockSnapKeyring; +}) => Promise; export const getMockWithSnapKeyring = ( { submitRequest = jest.fn(), resolveAccountAddress = jest.fn() } = { @@ -105,7 +109,9 @@ export const getMockWithSnapKeyring = ( ) => { return async (callback: MockOperationCallback) => callback({ - submitRequest, - resolveAccountAddress, + keyring: { + submitRequest, + resolveAccountAddress, + }, }); };