Skip to content

feat(keyring-snap-bridge): populate v2 SnapKeyring capabilities from the manifest - #581

Merged
hmalik88 merged 11 commits into
mainfrom
hm/keyring-capabilities
Jul 1, 2026
Merged

hmalik88 merged 11 commits into
mainfrom
hm/keyring-capabilities

Conversation

@hmalik88

@hmalik88 hmalik88 commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor
  • Populate the v2 SnapKeyring.capabilities from the Snap manifest (endowment:keyring) on deserialize, via SnapController:getSnap, fulfilling the v2 Keyring contract's required capabilities field. Falls back to the empty default when the Snap declares none.
  • Guard v2 SnapKeyring operations (getAccounts/getAccount/createAccounts/deleteAccount/submitRequest) until deserialize has run; they now throw "SnapKeyring has not been initialized" instead of operating on an unbound keyring.
  • Bump @metamask/snaps-utils to ^12.2.1 (keyring-snap-bridge + keyring-internal-snap-client) for the capabilities field on the endowment:keyring manifest type.

Note

Medium Risk
Changes snap keyring lifecycle and when account operations are allowed; capabilities are taken from the manifest without local shape validation, so struct drift could cause runtime issues.

Overview
v2 SnapKeyring now sets capabilities during deserialize by reading the Snap manifest’s endowment:keyring entry via SnapController:getSnap, with EMPTY_CAPABILITIES as the typed default when the snap is missing or declares none (including clearing stale values on re-hydrate).

getAccounts, getAccount, createAccounts, deleteAccount, and submitRequest are blocked until deserialize finishes, throwing SnapKeyring has not been initialized instead of running on an unbound keyring.

@metamask/snaps-utils is bumped to ^12.2.1 in keyring-snap-bridge and keyring-internal-snap-client for manifest typing around capabilities.

Reviewed by Cursor Bugbot for commit 39a8b94. Bugbot is set up for automated code reviews on this repo. Configure here.

@hmalik88
hmalik88 requested a review from a team as a code owner June 30, 2026 12:36
@socket-security

socket-security Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​metamask/​snaps-utils@​12.1.3 ⏵ 12.2.198 +110076 +195 -3100
Updated@​metamask/​messenger@​1.1.1 ⏵ 1.2.0100 +110078 +190 -2100
Updated@​metamask/​snaps-sdk@​11.0.0 ⏵ 11.1.199 +210078 +192 -1100

View full report

Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.ts
Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.ts Outdated
@hmalik88
hmalik88 force-pushed the hm/keyring-capabilities branch from b040597 to c850aea Compare June 30, 2026 12:43
Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.ts Outdated
Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Reviewed by Cursor Bugbot for commit 9ac9ce9. Configure here.

Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.ts Outdated
Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.ts
Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.ts Outdated
Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.ts
Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.test.ts Outdated
Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.test.ts Outdated
Comment thread packages/keyring-snap-bridge/src/v2/SnapKeyring.test.ts Outdated
@hmalik88
hmalik88 added this pull request to the merge queue Jul 1, 2026
Merged via the queue into main with commit 8ac8519 Jul 1, 2026
40 checks passed
@hmalik88
hmalik88 deleted the hm/keyring-capabilities branch July 1, 2026 15:13
montelaidev pushed a commit that referenced this pull request Sep 21, 2026
…the manifest (#581)

- Populate the v2 `SnapKeyring.capabilities` from the Snap manifest
(`endowment:keyring`) on `deserialize`, via `SnapController:getSnap`,
fulfilling the v2 `Keyring` contract's required `capabilities` field.
Falls back to the empty default when the Snap declares none.
- Guard v2 `SnapKeyring` operations
(`getAccounts`/`getAccount`/`createAccounts`/`deleteAccount`/`submitRequest`)
until `deserialize` has run; they now throw `"SnapKeyring has not been
initialized"` instead of operating on an unbound keyring.
- Bump `@metamask/snaps-utils` to `^12.2.1` (`keyring-snap-bridge` +
`keyring-internal-snap-client`) for the `capabilities` field on the
`endowment:keyring` manifest type.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes snap keyring lifecycle and when account operations are
allowed; capabilities are taken from the manifest without local shape
validation, so struct drift could cause runtime issues.
> 
> **Overview**
> v2 **`SnapKeyring`** now sets **`capabilities`** during
**`deserialize`** by reading the Snap manifest’s **`endowment:keyring`**
entry via **`SnapController:getSnap`**, with **`EMPTY_CAPABILITIES`** as
the typed default when the snap is missing or declares none (including
clearing stale values on re-hydrate).
> 
> **`getAccounts`**, **`getAccount`**, **`createAccounts`**,
**`deleteAccount`**, and **`submitRequest`** are blocked until
**`deserialize`** finishes, throwing *SnapKeyring has not been
initialized* instead of running on an unbound keyring.
> 
> **`@metamask/snaps-utils`** is bumped to **`^12.2.1`** in
**`keyring-snap-bridge`** and **`keyring-internal-snap-client`** for
manifest typing around **`capabilities`**.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
39a8b94. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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