Skip to content

Commit 7daadb1

Browse files
authored
feat(keyring-snap-bridge): add missing static SnapKeyring.type (v2) (#570)
Old v1 keyrings used to have this `static` field too. NOTE: Current v2 wrappers are using the v1 legacy type, and that's something we might want to change in the future. But the `SnapKeyring` v2 is different from those, since it is not wrapping any existing keyring, so we can use a v2 type here. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Small API surface addition with no behavior change to account or signing flows. > > **Overview** > Adds **`static readonly type`** on v2 **`SnapKeyring`**, set to **`KeyringType.Snap`** alongside the existing instance **`type`** field. This restores the same class-level type identifier pattern legacy v1 snap keyrings exposed, so callers can read the keyring kind without instantiating the class. > > Tests assert both **`SnapKeyring.type`** and **`keyring.type`** resolve to **`KeyringType.Snap`**. The package changelog records the addition under **Unreleased**. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 49fb77c. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent aed086a commit 7daadb1

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

packages/keyring-snap-bridge/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `static type` for v2 `SnapKeyring` ([#570](https://github.com/MetaMask/accounts/pull/570))
13+
1014
## [22.2.0]
1115

1216
### Added

packages/keyring-snap-bridge/src/v2/SnapKeyring.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ async function makeKeyring(
9292
}
9393

9494
describe('SnapKeyring', () => {
95+
describe('type', () => {
96+
it('returns `KeyringType.Snap`', async () => {
97+
expect(SnapKeyring.type).toBe(KeyringType.Snap);
98+
99+
const { keyring } = await makeKeyring();
100+
expect(keyring.type).toBe(KeyringType.Snap);
101+
});
102+
});
103+
95104
describe('snapId', () => {
96105
it('returns the snap ID set during deserialize', async () => {
97106
const { keyring } = await makeKeyring();

packages/keyring-snap-bridge/src/v2/SnapKeyring.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ export class SnapKeyring extends SnapKeyringV1 implements Keyring {
114114

115115
readonly type = `${KeyringType.Snap}` as const;
116116

117+
static readonly type = `${KeyringType.Snap}` as const;
118+
117119
/**
118120
* Capabilities are snap-specific. Initialized empty and can be updated
119121
* by the parent when snap metadata becomes available.

0 commit comments

Comments
 (0)