Skip to content

Conversation

@ccharly
Copy link
Contributor

@ccharly ccharly commented Jan 28, 2026

Adding a new optional createAccounts method that we could already leverage today without having the full implementation of KeyringV2.


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 the keyring_createAccounts RPC 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 generic AnyAccountType.Account when disallowed, and persisting state once (no per-account notify:accountCreated/addAccount callback).

Extends KeyringClient to send keyring_createAccounts and updates keyring-snap-sdk request dispatch to route/guard the new method (throws MethodNotSupportedError if 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.

@ccharly ccharly force-pushed the cc/feat/snap-keyring-createAccounts branch from a1cd60d to 3840f34 Compare February 3, 2026 17:13
@ccharly ccharly marked this pull request as ready for review February 3, 2026 17:14
@ccharly ccharly requested a review from a team as a code owner February 3, 2026 17:14
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.

}

// Save the state after adding all accounts.
await this.#callbacks.saveState();
Copy link

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.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants