-
-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add optional createAccounts method based on KeyringV2
#448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
a1cd60d to
3840f34
Compare
There was a problem hiding this 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.
| } | ||
|
|
||
| // Save the state after adding all accounts. | ||
| await this.#callbacks.saveState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial failure leaves accounts in inconsistent state
Medium Severity
In createAccounts, if validation fails partway through the loop (e.g., account N is a generic AnyAccountType.Account when not allowed), accounts 0 through N-1 have already been added to this.#accounts in memory but saveState() is never called. Additionally, the Snap has already created all accounts via client.createAccounts() before validation. This leaves the system in an inconsistent state: some accounts exist in the bridge's memory (but unpersisted), while the Snap has created all accounts. On restart, the in-memory accounts would be lost but still exist on the Snap side.


Adding a new optional
createAccountsmethod that we could already leverage today without having the full implementation ofKeyringV2.Note
Medium Risk
Adds a new account-creation RPC path and Snap bridge state updates, which could affect account provisioning and persistence if responses are malformed or validation differs across clients. The change is mostly additive/optional but touches core account-management surfaces (
Keyring, RPC handler, Snap bridge/client).Overview
Adds an optional
Keyring.createAccounts(options: CreateAccountOptions)for batch account creation (KeyringV2-typed options) and introduces thekeyring_createAccountsRPC method with request/response validation structs.Implements batch creation in
SnapKeyring.createAccounts, calling through to the internal snap client, inserting returned accounts into the bridge’s internal map, validating genericAnyAccountType.Accountwhen disallowed, and persisting state once (no per-accountnotify:accountCreated/addAccountcallback).Extends
KeyringClientto sendkeyring_createAccountsand updateskeyring-snap-sdkrequest dispatch to route/guard the new method (throwsMethodNotSupportedErrorif unimplemented), with comprehensive new tests and changelog entries across packages.Written by Cursor Bugbot for commit ba6ed3d. This will update automatically on new commits. Configure here.