Skip to content

feat(stellar-wallet-snap): use the shared wrapSnapHandlers and noopAssetHandlers - #366

Merged
Julink-eth merged 3 commits into
mainfrom
feat/stellar-wrap-snap-handlers
Sep 25, 2026
Merged

Julink-eth merged 3 commits into
mainfrom
feat/stellar-wrap-snap-handlers

Conversation

@Julink-eth

Copy link
Copy Markdown
Contributor

Explanation

Migrate the Stellar Snap entrypoints to wrapSnapHandlers and noopAssetHandlers from @metamask/snap-networks-utils (added in #341).

  • onKeyringRequest, onUserInput, onClientRequest, and onCronjob are now wrapped once, at the entrypoint, by a single wrapSnapHandlers(withCatchAndThrowSnapError, { ... }) call in index.ts.
  • The inner withCatchAndThrowSnapError calls are removed from KeyringHandler, ClientRequestHandler, CronjobHandler, and UserInputHandler, so errors are not tracked twice. Their logic is unchanged: debug logs, validateOrigin, ?? null, the client-status check, and the early returns.
  • The prefixed error logs are kept through the logError overrides: [🔑 KeyringHandler] for onKeyringRequest and [👋 ClientRequestHandler] for onClientRequest. onCronjob and onUserInput keep using the base logger, as before.
  • ClientRequestHandler only used its logger for the removed wrap, so the logger constructor option is dropped (it is only constructed in context.ts).
  • The four no-op onAssets* stubs are replaced by noopAssetHandlers.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@Julink-eth

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

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.

Copilot review overview

🟢 Approval recommended

Only a non-blocking test-coverage nit remains.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Migrates Stellar Snap entrypoints to shared handler wrappers and no-op asset handlers.

Changes:

  • Centralizes error handling with wrapSnapHandlers.
  • Removes duplicate handler-level wrappers and the unused logger.
  • Replaces asset stubs with noopAssetHandlers.
  • Updates tests and the manifest checksum.
File Summary
packages/​stellar-wallet-snap/​src/​index.ts Adds shared wrappers and asset handlers.
packages/​stellar-wallet-snap/​src/​index.test.ts Tests wrapped entrypoint errors.
packages/​stellar-wallet-snap/​src/​handlers/​user-input/​userInput.ts Removes inner error wrapping.
packages/​stellar-wallet-snap/​src/​handlers/​keyring/​keyring.ts Removes inner error wrapping.
packages/​stellar-wallet-snap/​src/​handlers/​cronjob/​cronjob.ts Removes inner error wrapping.
packages/​stellar-wallet-snap/​src/​handlers/​clientRequest/​clientRequest.ts Removes inner wrapping and logger dependency.
packages/​stellar-wallet-snap/​src/​context.ts Updates client handler construction.
packages/​stellar-wallet-snap/​snap.manifest.json Updates the bundle checksum.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/stellar-wallet-snap/src/index.ts
@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@3.0.0-preview-c093b1a
@metamask-previews/snap-networks-utils@1.0.0-preview-c093b1a
@metamask-previews/solana-wallet-snap@6.0.0-preview-c093b1a
@metamask-previews/stellar-wallet-snap@1.0.0-preview-c093b1a
@metamask-previews/tron-wallet-snap@3.2.0-preview-c093b1a

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.

Copilot review overview

🟢 Approval recommended

No unresolved review issues were identified.

Review effort: Lite
Findings: None

Resolved since last review (1)

cronjobHandler.handle(request);
import { logger, withCatchAndThrowSnapError } from './utils';

const keyringLogger = logger.withPrefix('[🔑 KeyringHandler]');

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.

Is also defined in

this.#logger = logger.withPrefix('[🔑 KeyringHandler]');
maybe there is a possible aggregation to do there

@sonarqubecloud

Copy link
Copy Markdown

@Battambang Battambang 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.

lgtm

@Julink-eth
Julink-eth added this pull request to the merge queue Sep 25, 2026
Merged via the queue into main with commit 6a60758 Sep 25, 2026
55 checks passed
@Julink-eth
Julink-eth deleted the feat/stellar-wrap-snap-handlers branch September 25, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants