You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(keyring-snap-bridge): populate v2 SnapKeyring capabilities from 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 -->
Copy file name to clipboardExpand all lines: packages/keyring-snap-bridge/CHANGELOG.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [Unreleased]
9
9
10
+
### Added
11
+
12
+
- Populate v2 `SnapKeyring``capabilities` from the Snap manifest (`endowment:keyring`) on `deserialize` ([#581](https://github.com/MetaMask/accounts/pull/581))
13
+
- Guard v2 `SnapKeyring` operations until `deserialize` has run (throws "SnapKeyring has not been initialized") ([#581](https://github.com/MetaMask/accounts/pull/581))
14
+
15
+
### Changed
16
+
17
+
- Bump `@metamask/snaps-utils` from `^12.1.3` to `^12.2.1` ([#581](https://github.com/MetaMask/accounts/pull/581))
0 commit comments