Skip to content

feat: add KeyringClientV2 support#408

Open
ccharly wants to merge 28 commits intomainfrom
feat/keyring-client-v2
Open

feat: add KeyringClientV2 support#408
ccharly wants to merge 28 commits intomainfrom
feat/keyring-client-v2

Conversation

@ccharly
Copy link
Contributor

@ccharly ccharly commented Dec 4, 2025

Similar implementation than KeyringClient but using the new unified keyring API (keyring v2) methods.


Note

Medium Risk
Adds a new v2 JSON-RPC surface (including exportAccount) plus new clients/dispatch logic, which could affect request routing and key export behavior if integrated incorrectly. Changes are mostly additive but touch security-adjacent account/export flows.

Overview
Introduces Keyring v2 JSON-RPC plumbing end-to-end. @metamask/keyring-api now exports KeyringRpcV2Method plus typed request/response structs for getAccounts, getAccount, createAccounts, deleteAccount, exportAccount, and submitRequest, along with an isKeyringRpcV2Method guard.

Adds a new KeyringClientV2 (and KeyringInternalSnapClientV2) that sends v2-formatted JSON-RPC requests and validates responses with structs, and adds handleKeyringRequestV2 in keyring-snap-sdk to dispatch v2 methods to a KeyringV2 implementation (including explicit unsupported-method errors for optional exportAccount).

Minor cleanup: exports the new v2 modules from package index.ts files, makes SnapControllerMessengerSender public, and tightens isKeyringRpcMethod to a TypeScript type guard (plus test message fix).

Written by Cursor Bugbot for commit eee7698. This will update automatically on new commits. Configure here.

@ccharly ccharly marked this pull request as ready for review December 5, 2025 15:02
@ccharly ccharly requested a review from a team as a code owner December 5, 2025 15:02
ccharly and others added 2 commits December 8, 2025 16:02
Co-authored-by: Mathieu Artu <mathieu.artu@gmail.com>
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

This PR is marked as stale because it has been open for 60 days with no activity. Please remove the stale label or leave a comment, or it will be closed in 14 days.

@github-actions github-actions bot added the Stale label Mar 7, 2026
@ccharly ccharly force-pushed the feat/keyring-client-v2 branch from 25a340c to eee7698 Compare March 20, 2026 14:26
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

: 'An unknown error occurred while handling the keyring (v2) request';

throw new Error(message);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing isSnapError check wraps Snap errors as generic Error

High Severity

The handleKeyringRequestV2 catch block is missing the isSnapError(error) check that the v1 handleKeyringRequest has. The v2 handler throws MethodNotSupportedError (which extends MethodNotSupportedRpcError from @metamask/snaps-sdk) in two places, but these structured Snap errors get caught and re-thrown as plain Error, losing their RPC error code and serialization data. The v1 handler correctly preserves Snap errors by checking isSnapError(error) and re-throwing them before the generic wrapping.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants