Conversation
packages/keyring-internal-snap-client/src/v2/KeyringInternalSnapClientV2.ts
Outdated
Show resolved
Hide resolved
packages/keyring-internal-snap-client/src/v2/KeyringInternalSnapClientV2.ts
Outdated
Show resolved
Hide resolved
packages/keyring-internal-snap-client/src/v2/KeyringInternalSnapClientV2.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Mathieu Artu <mathieu.artu@gmail.com>
|
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. |
25a340c to
eee7698
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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); | ||
| } |
There was a problem hiding this comment.
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.


Similar implementation than
KeyringClientbut 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-apinow exportsKeyringRpcV2Methodplus typed request/response structs forgetAccounts,getAccount,createAccounts,deleteAccount,exportAccount, andsubmitRequest, along with anisKeyringRpcV2Methodguard.Adds a new
KeyringClientV2(andKeyringInternalSnapClientV2) that sends v2-formatted JSON-RPC requests and validates responses with structs, and addshandleKeyringRequestV2inkeyring-snap-sdkto dispatch v2 methods to aKeyringV2implementation (including explicit unsupported-method errors for optionalexportAccount).Minor cleanup: exports the new v2 modules from package
index.tsfiles, makesSnapControllerMessengerSenderpublic, and tightensisKeyringRpcMethodto a TypeScript type guard (plus test message fix).Written by Cursor Bugbot for commit eee7698. This will update automatically on new commits. Configure here.