From c093b1aec511415b3d2add5cfc6ea89588bf561b Mon Sep 17 00:00:00 2001 From: Julien Fontanel Date: Thu, 24 Sep 2026 14:21:05 +0200 Subject: [PATCH 1/3] feat(stellar-wallet-snap): use the shared wrapSnapHandlers and noopAssetHandlers --- .../stellar-wallet-snap/snap.manifest.json | 2 +- packages/stellar-wallet-snap/src/context.ts | 1 - .../handlers/clientRequest/clientRequest.ts | 14 +--- .../src/handlers/cronjob/cronjob.ts | 15 ++-- .../src/handlers/keyring/keyring.ts | 28 +++---- .../src/handlers/user-input/userInput.ts | 5 +- .../stellar-wallet-snap/src/index.test.ts | 74 +++++++++++++++++++ packages/stellar-wallet-snap/src/index.ts | 71 ++++++++---------- 8 files changed, 126 insertions(+), 84 deletions(-) create mode 100644 packages/stellar-wallet-snap/src/index.test.ts diff --git a/packages/stellar-wallet-snap/snap.manifest.json b/packages/stellar-wallet-snap/snap.manifest.json index a96e17e27..8a854cc6d 100644 --- a/packages/stellar-wallet-snap/snap.manifest.json +++ b/packages/stellar-wallet-snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/internal-snaps.git" }, "source": { - "shasum": "E8ptwYRcKs5dUP6eKBAJu4cRzIYNfGVI1kDp1znZkYI=", + "shasum": "MGLWLhlYBn+se/MUt9Lq70AkSl4F4oZaVAVXRgqtoLQ=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/stellar-wallet-snap/src/context.ts b/packages/stellar-wallet-snap/src/context.ts index d27f6a734..9f61335cb 100644 --- a/packages/stellar-wallet-snap/src/context.ts +++ b/packages/stellar-wallet-snap/src/context.ts @@ -320,7 +320,6 @@ const clientRequestMethodHandlers: Record< }; const clientRequestHandler = new ClientRequestHandler({ - logger, handlers: clientRequestMethodHandlers, }); diff --git a/packages/stellar-wallet-snap/src/handlers/clientRequest/clientRequest.ts b/packages/stellar-wallet-snap/src/handlers/clientRequest/clientRequest.ts index fb0be93e3..aa32a3125 100644 --- a/packages/stellar-wallet-snap/src/handlers/clientRequest/clientRequest.ts +++ b/packages/stellar-wallet-snap/src/handlers/clientRequest/clientRequest.ts @@ -1,26 +1,19 @@ -import type { Logger } from '@metamask/snap-networks-utils'; import { MethodNotFoundError } from '@metamask/snaps-sdk'; import type { Json, JsonRpcRequest } from '@metamask/utils'; import { ensureError } from '@metamask/utils'; -import { withCatchAndThrowSnapError } from '../../utils'; import type { ClientRequestMethod } from './api'; import { ClientRequestMethodStruct } from './api'; import type { IClientRequestHandler } from './base'; export class ClientRequestHandler { - readonly #logger: Logger; - readonly #handlers: Record; constructor({ - logger, handlers, }: { - logger: Logger; handlers: Record; }) { - this.#logger = logger.withPrefix('[👋 ClientRequestHandler]'); this.#handlers = handlers; } @@ -35,12 +28,7 @@ export class ClientRequestHandler { * @throws {InvalidParamsError} If the params are invalid. */ async handle(request: JsonRpcRequest): Promise { - const result = - (await withCatchAndThrowSnapError(async () => { - return this.#handleClientRequest(request); - }, this.#logger.error.bind(this.#logger))) ?? null; - - return result; + return (await this.#handleClientRequest(request)) ?? null; } /** diff --git a/packages/stellar-wallet-snap/src/handlers/cronjob/cronjob.ts b/packages/stellar-wallet-snap/src/handlers/cronjob/cronjob.ts index ec3be2b43..82ae14b45 100644 --- a/packages/stellar-wallet-snap/src/handlers/cronjob/cronjob.ts +++ b/packages/stellar-wallet-snap/src/handlers/cronjob/cronjob.ts @@ -1,6 +1,5 @@ import type { JsonRpcRequest } from '@metamask/snaps-sdk'; -import { withCatchAndThrowSnapError } from '../../utils'; import { getClientStatus } from '../../utils/snap'; import type { BackgroundEventMethod, ICronjobRequestHandler } from './api'; import { BackgroundEventMethodStruct } from './api'; @@ -18,16 +17,14 @@ export class CronjobHandler { } async handle(request: JsonRpcRequest): Promise { - await withCatchAndThrowSnapError(async () => { - const { active, locked } = await getClientStatus(); + const { active, locked } = await getClientStatus(); - // if the client is not active or locked, we dont execute the cronjob - if (!active || locked) { - return; - } + // if the client is not active or locked, we dont execute the cronjob + if (!active || locked) { + return; + } - await this.#handleRequest(request); - }); + await this.#handleRequest(request); } async #handleRequest(request: JsonRpcRequest): Promise { diff --git a/packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts b/packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts index d319c1e98..78c32cac6 100644 --- a/packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts +++ b/packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts @@ -62,7 +62,6 @@ import { isSlip44Id, rethrowIfInstanceElseThrow, validateRequest, - withCatchAndThrowSnapError, } from '../../utils'; import { getSupportedScopes } from '../../utils/scopes'; import { SyncAccountsHandler } from '../cronjob/syncAccounts'; @@ -118,22 +117,17 @@ export class KeyringHandler implements KeyringSnapRpc { } async handle(origin: string, request: JsonRpcRequest): Promise { - const result = - (await withCatchAndThrowSnapError(async () => { - this.#logger.debug('Handle keyring request', { - origin, - method: request.method, - }); - validateOrigin(origin, request.method, originPermissions); - const keyringRequestResult = await handleKeyringRequest(this, request); - this.#logger.debug('Keyring request handled', { - origin, - method: request.method, - }); - return keyringRequestResult; - }, this.#logger.error.bind(this.#logger))) ?? null; - - return result; + this.#logger.debug('Handle keyring request', { + origin, + method: request.method, + }); + validateOrigin(origin, request.method, originPermissions); + const result = await handleKeyringRequest(this, request); + this.#logger.debug('Keyring request handled', { + origin, + method: request.method, + }); + return result ?? null; } async getAccount(accountId: GetAccountRequest): Promise { diff --git a/packages/stellar-wallet-snap/src/handlers/user-input/userInput.ts b/packages/stellar-wallet-snap/src/handlers/user-input/userInput.ts index 85fb07841..1844a528d 100644 --- a/packages/stellar-wallet-snap/src/handlers/user-input/userInput.ts +++ b/packages/stellar-wallet-snap/src/handlers/user-input/userInput.ts @@ -9,7 +9,6 @@ import { createEventHandlers as createSignMessageEvents } from '../../ui/confirm import { createEventHandlers as createSignTransactionEvents } from '../../ui/confirmation/views/ConfirmSignTransaction/events'; import { createEventHandlers as createMaliciousAcknowledgementEvents } from '../../ui/confirmation/views/MaliciousAcknowledgement/events'; import { createEventHandlers as createMemoEditEvents } from '../../ui/confirmation/views/MemoEdit/events'; -import { withCatchAndThrowSnapError } from '../../utils'; import type { UserInputUiEventHandler } from './api'; export class UserInputHandler { @@ -63,8 +62,6 @@ export class UserInputHandler { return; } - await withCatchAndThrowSnapError(async () => - handler({ id, event, context }), - ); + await handler({ id, event, context }); } } diff --git a/packages/stellar-wallet-snap/src/index.test.ts b/packages/stellar-wallet-snap/src/index.test.ts new file mode 100644 index 000000000..1e175b801 --- /dev/null +++ b/packages/stellar-wallet-snap/src/index.test.ts @@ -0,0 +1,74 @@ +import { SnapError } from '@metamask/snaps-sdk'; + +import { onClientRequest, onCronjob, onKeyringRequest, onUserInput } from '.'; +import { logger } from './utils/logger'; + +const mockHandle = jest.fn(); + +jest.mock('./utils/logger'); + +jest.mock('./context', () => { + const handler = { + handle: async (...args: unknown[]): Promise => mockHandle(...args), + }; + return { + keyringHandler: handler, + userInputHandler: handler, + clientRequestHandler: handler, + cronjobHandler: handler, + }; +}); + +describe('wrapped entrypoints', () => { + const snapRequest = jest.fn(); + const request = { jsonrpc: '2.0', id: 1, method: 'foo' } as const; + + beforeEach(() => { + jest.clearAllMocks(); + snapRequest.mockResolvedValue(undefined); + Object.assign(globalThis, { snap: { request: snapRequest } }); + mockHandle.mockRejectedValue(new Error('Handler failed')); + }); + + it.each([ + [ + 'onKeyringRequest', + async (): Promise => + onKeyringRequest({ origin: 'https://example.com', request } as never), + ['[🔑 KeyringHandler]'], + ], + [ + 'onClientRequest', + async (): Promise => onClientRequest({ request } as never), + ['[👋 ClientRequestHandler]'], + ], + [ + 'onCronjob', + async (): Promise => onCronjob({ request } as never), + [], + ], + [ + 'onUserInput', + async (): Promise => + onUserInput({ id: 'id', event: {}, context: null } as never), + [], + ], + ])( + 'normalizes, tracks, and logs %s errors', + async (_name, callHandler: () => Promise, prefixes: string[]) => { + await expect(callHandler()).rejects.toBeInstanceOf(SnapError); + + expect(snapRequest).toHaveBeenCalledWith({ + method: 'snap_trackError', + params: { + error: expect.objectContaining({ message: 'Handler failed' }), + }, + }); + expect(logger.error).toHaveBeenCalledWith( + ...prefixes, + { error: expect.any(SnapError) }, + expect.stringContaining('[SnapError]'), + ); + }, + ); +}); diff --git a/packages/stellar-wallet-snap/src/index.ts b/packages/stellar-wallet-snap/src/index.ts index 336558e56..badb0ead4 100644 --- a/packages/stellar-wallet-snap/src/index.ts +++ b/packages/stellar-wallet-snap/src/index.ts @@ -1,13 +1,7 @@ -import type { - OnUserInputHandler, - OnKeyringRequestHandler, - OnClientRequestHandler, - OnCronjobHandler, - OnAssetHistoricalPriceHandler, - OnAssetsConversionHandler, - OnAssetsLookupHandler, - OnAssetsMarketDataHandler, -} from '@metamask/snaps-sdk'; +import { + noopAssetHandlers, + wrapSnapHandlers, +} from '@metamask/snap-networks-utils'; import { keyringHandler, @@ -15,32 +9,31 @@ import { clientRequestHandler, cronjobHandler, } from './context'; - -export const onAssetsLookup: OnAssetsLookupHandler = async () => ({ - assets: {}, -}); - -export const onAssetsConversion: OnAssetsConversionHandler = async () => ({ - conversionRates: {}, -}); - -export const onAssetHistoricalPrice: OnAssetHistoricalPriceHandler = async () => - null; - -export const onAssetsMarketData: OnAssetsMarketDataHandler = async () => ({ - marketData: {}, -}); - -export const onKeyringRequest: OnKeyringRequestHandler = async ({ - origin, - request, -}) => keyringHandler.handle(origin, request); - -export const onUserInput: OnUserInputHandler = async (params) => - userInputHandler.handle(params); - -export const onClientRequest: OnClientRequestHandler = async ({ request }) => - clientRequestHandler.handle(request); - -export const onCronjob: OnCronjobHandler = async ({ request }) => - cronjobHandler.handle(request); +import { logger, withCatchAndThrowSnapError } from './utils'; + +const keyringLogger = logger.withPrefix('[🔑 KeyringHandler]'); +const clientRequestLogger = logger.withPrefix('[👋 ClientRequestHandler]'); + +export const { onKeyringRequest, onUserInput, onClientRequest, onCronjob } = + wrapSnapHandlers( + withCatchAndThrowSnapError, + { + onKeyringRequest: async ({ origin, request }) => + keyringHandler.handle(origin, request), + onUserInput: async (params) => userInputHandler.handle(params), + onClientRequest: async ({ request }) => + clientRequestHandler.handle(request), + onCronjob: async ({ request }) => cronjobHandler.handle(request), + }, + { + onKeyringRequest: keyringLogger.error.bind(keyringLogger), + onClientRequest: clientRequestLogger.error.bind(clientRequestLogger), + }, + ); + +export const { + onAssetsLookup, + onAssetsConversion, + onAssetHistoricalPrice, + onAssetsMarketData, +} = noopAssetHandlers; From d77f56d2aca591f9581f9023e264452ee2c12260 Mon Sep 17 00:00:00 2001 From: Julien Fontanel Date: Thu, 24 Sep 2026 14:44:40 +0200 Subject: [PATCH 2/3] chore: add unit tests --- .../clientRequest/clientRequest.test.ts | 47 ++++++++ .../src/handlers/user-input/userInput.test.ts | 104 ++++++++++++++++ .../stellar-wallet-snap/src/index.test.ts | 114 +++++++++++++----- 3 files changed, 237 insertions(+), 28 deletions(-) create mode 100644 packages/stellar-wallet-snap/src/handlers/clientRequest/clientRequest.test.ts create mode 100644 packages/stellar-wallet-snap/src/handlers/user-input/userInput.test.ts diff --git a/packages/stellar-wallet-snap/src/handlers/clientRequest/clientRequest.test.ts b/packages/stellar-wallet-snap/src/handlers/clientRequest/clientRequest.test.ts new file mode 100644 index 000000000..2e865c33d --- /dev/null +++ b/packages/stellar-wallet-snap/src/handlers/clientRequest/clientRequest.test.ts @@ -0,0 +1,47 @@ +import { MethodNotFoundError } from '@metamask/snaps-sdk'; + +import { ClientRequestMethod } from './api'; +import { ClientRequestHandler } from './clientRequest'; + +describe('ClientRequestHandler', () => { + const mockHandle = jest.fn(); + + function setup(): ClientRequestHandler { + mockHandle.mockReset(); + return new ClientRequestHandler({ + handlers: { + [ClientRequestMethod.ComputeFee]: { handle: mockHandle }, + } as never, + }); + } + + const request = { + jsonrpc: '2.0', + id: 1, + method: ClientRequestMethod.ComputeFee, + } as const; + + it('routes the request to the handler for its method', async () => { + const handler = setup(); + mockHandle.mockResolvedValue({ fee: '100' }); + + expect(await handler.handle(request)).toStrictEqual({ fee: '100' }); + expect(mockHandle).toHaveBeenCalledWith(request); + }); + + it('returns null when the method handler returns nothing', async () => { + const handler = setup(); + mockHandle.mockResolvedValue(undefined); + + expect(await handler.handle(request)).toBeNull(); + }); + + it('throws MethodNotFoundError for an unknown method', async () => { + const handler = setup(); + + await expect( + handler.handle({ ...request, method: 'unknownMethod' }), + ).rejects.toThrow(MethodNotFoundError); + expect(mockHandle).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/stellar-wallet-snap/src/handlers/user-input/userInput.test.ts b/packages/stellar-wallet-snap/src/handlers/user-input/userInput.test.ts new file mode 100644 index 000000000..5506ff0cd --- /dev/null +++ b/packages/stellar-wallet-snap/src/handlers/user-input/userInput.test.ts @@ -0,0 +1,104 @@ +import { logger } from '../../utils/logger'; +import type { UserInputUiEventHandler } from './api'; +import { UserInputHandler } from './userInput'; + +const mockEventHandler = jest.fn(); + +type MockEventsModule = { + createEventHandlers: () => Record; +}; + +/** + * Builds a mocked `events` module exposing the given UI event handlers. + * + * @param handlers - The UI event handlers keyed by event name. + * @returns The mocked module. + */ +function mockEventsModule( + handlers: Record = {}, +): MockEventsModule { + return { createEventHandlers: (): typeof handlers => handlers }; +} + +jest.mock('../../utils/logger'); + +jest.mock( + '../../ui/confirmation/views/ConfirmSignMessage/events', + (): MockEventsModule => + mockEventsModule({ + testEvent: async (...args): Promise => mockEventHandler(...args), + }), +); +jest.mock( + '../../ui/confirmation/views/ConfirmSendTransaction/events', + (): MockEventsModule => mockEventsModule(), +); +jest.mock( + '../../ui/confirmation/views/ConfirmSignAuthEntry/events', + (): MockEventsModule => mockEventsModule(), +); +jest.mock( + '../../ui/confirmation/views/ConfirmSignChangeTrustOptIn/events', + (): MockEventsModule => mockEventsModule(), +); +jest.mock( + '../../ui/confirmation/views/ConfirmSignChangeTrustOptOut/events', + (): MockEventsModule => mockEventsModule(), +); +jest.mock( + '../../ui/confirmation/views/ConfirmSignTransaction/events', + (): MockEventsModule => mockEventsModule(), +); +jest.mock( + '../../ui/confirmation/views/MaliciousAcknowledgement/events', + (): MockEventsModule => mockEventsModule(), +); +jest.mock( + '../../ui/confirmation/views/MemoEdit/events', + (): MockEventsModule => mockEventsModule(), +); + +describe('UserInputHandler', () => { + const handler = new UserInputHandler({ logger }); + + beforeEach(() => { + mockEventHandler.mockReset().mockResolvedValue(undefined); + }); + + it('routes the event to the handler matching its name', async () => { + const params = { + id: 'interface-id', + event: { type: 'ButtonClickEvent', name: 'testEvent' }, + context: null, + } as never; + + await handler.handle(params); + + expect(mockEventHandler).toHaveBeenCalledWith(params); + }); + + it('propagates errors from the event handler', async () => { + mockEventHandler.mockRejectedValue(new Error('Event failed')); + + await expect( + handler.handle({ + id: 'interface-id', + event: { type: 'ButtonClickEvent', name: 'testEvent' }, + context: null, + } as never), + ).rejects.toThrow('Event failed'); + }); + + it.each([ + ['has no name', { type: 'ButtonClickEvent' }], + ['has no matching handler', { type: 'ButtonClickEvent', name: 'unknown' }], + ])('ignores an event that %s', async (_case, event) => { + await handler.handle({ + id: 'interface-id', + event, + context: null, + } as never); + + expect(mockEventHandler).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/stellar-wallet-snap/src/index.test.ts b/packages/stellar-wallet-snap/src/index.test.ts index 1e175b801..2b4adb590 100644 --- a/packages/stellar-wallet-snap/src/index.test.ts +++ b/packages/stellar-wallet-snap/src/index.test.ts @@ -1,62 +1,111 @@ +import { noopAssetHandlers } from '@metamask/snap-networks-utils'; import { SnapError } from '@metamask/snaps-sdk'; -import { onClientRequest, onCronjob, onKeyringRequest, onUserInput } from '.'; +import { + onAssetHistoricalPrice, + onAssetsConversion, + onAssetsLookup, + onAssetsMarketData, + onClientRequest, + onCronjob, + onKeyringRequest, + onUserInput, +} from '.'; import { logger } from './utils/logger'; -const mockHandle = jest.fn(); +const mockKeyringHandle = jest.fn(); +const mockUserInputHandle = jest.fn(); +const mockClientRequestHandle = jest.fn(); +const mockCronjobHandle = jest.fn(); jest.mock('./utils/logger'); -jest.mock('./context', () => { - const handler = { - handle: async (...args: unknown[]): Promise => mockHandle(...args), - }; - return { - keyringHandler: handler, - userInputHandler: handler, - clientRequestHandler: handler, - cronjobHandler: handler, - }; -}); +jest.mock('./context', () => ({ + keyringHandler: { + handle: async (...args: unknown[]): Promise => + mockKeyringHandle(...args), + }, + userInputHandler: { + handle: async (...args: unknown[]): Promise => + mockUserInputHandle(...args), + }, + clientRequestHandler: { + handle: async (...args: unknown[]): Promise => + mockClientRequestHandle(...args), + }, + cronjobHandler: { + handle: async (...args: unknown[]): Promise => + mockCronjobHandle(...args), + }, +})); -describe('wrapped entrypoints', () => { +describe('entrypoints', () => { const snapRequest = jest.fn(); + const origin = 'https://example.com'; const request = { jsonrpc: '2.0', id: 1, method: 'foo' } as const; + const userInputParams = { id: 'id', event: {}, context: null }; - beforeEach(() => { - jest.clearAllMocks(); - snapRequest.mockResolvedValue(undefined); - Object.assign(globalThis, { snap: { request: snapRequest } }); - mockHandle.mockRejectedValue(new Error('Handler failed')); - }); - - it.each([ + const entrypoints: [ + string, + () => Promise, + jest.Mock, + unknown[], + string[], + ][] = [ [ 'onKeyringRequest', async (): Promise => - onKeyringRequest({ origin: 'https://example.com', request } as never), + onKeyringRequest({ origin, request } as never), + mockKeyringHandle, + [origin, request], ['[🔑 KeyringHandler]'], ], [ 'onClientRequest', async (): Promise => onClientRequest({ request } as never), + mockClientRequestHandle, + [request], ['[👋 ClientRequestHandler]'], ], [ 'onCronjob', async (): Promise => onCronjob({ request } as never), + mockCronjobHandle, + [request], [], ], [ 'onUserInput', - async (): Promise => - onUserInput({ id: 'id', event: {}, context: null } as never), + async (): Promise => onUserInput(userInputParams as never), + mockUserInputHandle, + [userInputParams], [], ], - ])( + ]; + + beforeEach(() => { + jest.clearAllMocks(); + snapRequest.mockResolvedValue(undefined); + Object.assign(globalThis, { snap: { request: snapRequest } }); + }); + + it.each(entrypoints)( + 'delegates %s to its handler', + async (_name, callEntrypoint, handle, expectedArgs) => { + handle.mockResolvedValue('result'); + + expect(await callEntrypoint()).toBe('result'); + expect(handle).toHaveBeenCalledWith(...expectedArgs); + expect(snapRequest).not.toHaveBeenCalled(); + }, + ); + + it.each(entrypoints)( 'normalizes, tracks, and logs %s errors', - async (_name, callHandler: () => Promise, prefixes: string[]) => { - await expect(callHandler()).rejects.toBeInstanceOf(SnapError); + async (_name, callEntrypoint, handle, _expectedArgs, prefixes) => { + handle.mockRejectedValue(new Error('Handler failed')); + + await expect(callEntrypoint()).rejects.toBeInstanceOf(SnapError); expect(snapRequest).toHaveBeenCalledWith({ method: 'snap_trackError', @@ -71,4 +120,13 @@ describe('wrapped entrypoints', () => { ); }, ); + + it('exports the shared no-op asset handlers', () => { + expect({ + onAssetsLookup, + onAssetsConversion, + onAssetHistoricalPrice, + onAssetsMarketData, + }).toStrictEqual(noopAssetHandlers); + }); }); From 2efe0e296231dc6aae269752c47e23f2e12f43a0 Mon Sep 17 00:00:00 2001 From: Julien Fontanel Date: Fri, 25 Sep 2026 11:31:40 +0200 Subject: [PATCH 3/3] chore: put KEYRING_HANDLER_LOGGER_PREFIX in constant --- packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts | 4 +++- packages/stellar-wallet-snap/src/index.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts b/packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts index 78c32cac6..12c835268 100644 --- a/packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts +++ b/packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts @@ -80,6 +80,8 @@ import { import type { IKeyringRequestHandler } from './base'; import { ExportAccountException } from './exceptions'; +export const KEYRING_HANDLER_LOGGER_PREFIX = '[🔑 KeyringHandler]'; + export class KeyringHandler implements KeyringSnapRpc { readonly #logger: Logger; @@ -108,7 +110,7 @@ export class KeyringHandler implements KeyringSnapRpc { walletService: WalletService; handlers: Record; }) { - this.#logger = logger.withPrefix('[🔑 KeyringHandler]'); + this.#logger = logger.withPrefix(KEYRING_HANDLER_LOGGER_PREFIX); this.#accountService = accountService; this.#onChainAccountService = onChainAccountService; this.#transactionService = transactionService; diff --git a/packages/stellar-wallet-snap/src/index.ts b/packages/stellar-wallet-snap/src/index.ts index badb0ead4..2e667179e 100644 --- a/packages/stellar-wallet-snap/src/index.ts +++ b/packages/stellar-wallet-snap/src/index.ts @@ -9,9 +9,10 @@ import { clientRequestHandler, cronjobHandler, } from './context'; +import { KEYRING_HANDLER_LOGGER_PREFIX } from './handlers'; import { logger, withCatchAndThrowSnapError } from './utils'; -const keyringLogger = logger.withPrefix('[🔑 KeyringHandler]'); +const keyringLogger = logger.withPrefix(KEYRING_HANDLER_LOGGER_PREFIX); const clientRequestLogger = logger.withPrefix('[👋 ClientRequestHandler]'); export const { onKeyringRequest, onUserInput, onClientRequest, onCronjob } =