Skip to content

feat: add KeyringClientV2 support#408

Merged
ccharly merged 35 commits intomainfrom
feat/keyring-client-v2
Apr 10, 2026
Merged

feat: add KeyringClientV2 support#408
ccharly merged 35 commits intomainfrom
feat/keyring-client-v2

Conversation

@ccharly
Copy link
Copy Markdown
Contributor

@ccharly ccharly commented Dec 4, 2025

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


Note

Medium Risk
Introduces a parallel v2 JSON-RPC surface (including exportAccount) across API, clients, and snap dispatch logic; mistakes could break RPC compatibility or unintentionally affect account export/request routing.

Overview
Adds keyring v2 RPC support end-to-end. @metamask/keyring-api now exports KeyringRpcV2Method plus superstruct-validated v2 request/response types and isKeyringRpcV2Method, and refines isKeyringRpcMethod to be a type predicate.

Introduces v2 client and dispatcher. @metamask/keyring-snap-client adds KeyringClientV2 (UUID ids, strict response masking) and @metamask/keyring-internal-snap-client adds KeyringInternalSnapClientV2 (Messenger-backed). @metamask/keyring-snap-sdk adds handleKeyringRequestV2 to validate and route v2 JSON-RPC calls, including guarding optional exportAccount. Tests and package exports/changelogs are updated accordingly.

Reviewed by Cursor Bugbot for commit cc83c17. Bugbot is set up for automated code reviews on this repo. 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
Comment thread packages/keyring-snap-sdk/src/v2/rpc-handler.ts Outdated
Comment thread packages/keyring-api/src/api/v2/keyring-rpc.test.ts Outdated
Comment thread packages/keyring-snap-sdk/src/v2/rpc-handler.ts
Comment thread packages/keyring-internal-snap-client/src/v2/KeyringInternalSnapClientV2.ts Outdated
Comment thread packages/keyring-internal-snap-client/src/v2/KeyringInternalSnapClientV2.ts Outdated
Comment thread packages/keyring-internal-snap-client/src/v2/KeyringInternalSnapClientV2.ts Outdated
Comment thread packages/keyring-snap-client/src/v2/KeyringClientV2.test.ts Outdated
Comment thread packages/keyring-api/src/api/v2/keyring-rpc.ts Outdated
ccharly and others added 2 commits December 8, 2025 16:02
Co-authored-by: Mathieu Artu <mathieu.artu@gmail.com>
Comment thread packages/keyring-snap-sdk/src/v2/rpc-handler.test.ts Outdated
@github-actions
Copy link
Copy Markdown

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
Copy Markdown

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

Comment thread packages/keyring-snap-sdk/src/v2/rpc-handler.ts
@github-actions github-actions Bot removed the Stale label Mar 21, 2026
danroc
danroc previously approved these changes Apr 10, 2026
Copy link
Copy Markdown
Contributor

@danroc danroc left a comment

Choose a reason for hiding this comment

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

Just nits, I'm approving in case you prefer to ignore them.

GetAccounts = 'keyring_getAccounts',
CreateAccounts = 'keyring_createAccounts',
// Inherited from v1 (but method signatures may differ...):
// NOTE: We use literals here to avoid circular dependencies.
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.

Note: We should probably consider moving those definitions in the future.

Comment thread packages/keyring-api/src/api/v2/keyring-rpc.ts Outdated
Comment thread packages/keyring-snap-client/src/v2/KeyringClientV2.ts Outdated
@ccharly ccharly enabled auto-merge April 10, 2026 08:36
@ccharly ccharly added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit 466bb6a Apr 10, 2026
39 checks passed
@ccharly ccharly deleted the feat/keyring-client-v2 branch April 10, 2026 08:42
montelaidev pushed a commit that referenced this pull request Apr 10, 2026
Similar implementation than `KeyringClient` but using the new unified
keyring API (keyring v2) methods.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Introduces a parallel v2 JSON-RPC surface (including `exportAccount`)
across API, clients, and snap dispatch logic; mistakes could break RPC
compatibility or unintentionally affect account export/request routing.
> 
> **Overview**
> **Adds keyring v2 RPC support end-to-end.** `@metamask/keyring-api`
now exports `KeyringRpcV2Method` plus superstruct-validated v2
request/response types and `isKeyringRpcV2Method`, and refines
`isKeyringRpcMethod` to be a type predicate.
> 
> **Introduces v2 client and dispatcher.**
`@metamask/keyring-snap-client` adds `KeyringClientV2` (UUID ids, strict
response masking) and `@metamask/keyring-internal-snap-client` adds
`KeyringInternalSnapClientV2` (Messenger-backed).
`@metamask/keyring-snap-sdk` adds `handleKeyringRequestV2` to validate
and route v2 JSON-RPC calls, including guarding optional
`exportAccount`. Tests and package exports/changelogs are updated
accordingly.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
cc83c17. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Mathieu Artu <mathieu.artu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants