Skip to content

Commit 16efc60

Browse files
feat: add Bip122AccountChangedNotifications to KnownSessionProperties (#7537)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> Add Bitcoin accountChanged event support, following the previous work done for Solana and Tron. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> Related to #7304 ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds `Bip122AccountChangedNotifications` to `KnownSessionProperties` and updates tests and changelog accordingly. > > - **chain-agnostic-permission**: > - **KnownSessionProperties**: Add `Bip122AccountChangedNotifications` (`bip122_accountChanged_notifications`) in `src/scope/constants.ts`. > - **Tests**: Update snapshots and validations to include Bip122 (and assert Tron) in `constants.test.ts` and `supported.test.ts` (`isKnownSessionPropertyValue`, `isSupportedSessionProperty`). > - **Changelog**: Document new session property under Unreleased. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 850e228. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 3e7286b commit 16efc60

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

packages/chain-agnostic-permission/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 `Bip122AccountChangedNotifications` property in `KnownSessionProperties` enum ([#7537](https://github.com/MetaMask/core/pull/7537))
13+
1014
### Changed
1115

1216
- Bump `@metamask/network-controller` from `^27.0.0` to `^27.1.0` ([#7534](https://github.com/MetaMask/core/pull/7534))

packages/chain-agnostic-permission/src/scope/constants.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ describe('KnownSessionProperties', () => {
6464
it('should match the snapshot', () => {
6565
expect(KnownSessionProperties).toMatchInlineSnapshot(`
6666
Object {
67+
"Bip122AccountChangedNotifications": "bip122_accountChanged_notifications",
6768
"SolanaAccountChangedNotifications": "solana_accountChanged_notifications",
6869
"TronAccountChangedNotifications": "tron_accountChanged_notifications",
6970
}
@@ -76,6 +77,12 @@ describe('isKnownSessionPropertyValue', () => {
7677
expect(
7778
isKnownSessionPropertyValue('solana_accountChanged_notifications'),
7879
).toBe(true);
80+
expect(
81+
isKnownSessionPropertyValue('tron_accountChanged_notifications'),
82+
).toBe(true);
83+
expect(
84+
isKnownSessionPropertyValue('bip122_accountChanged_notifications'),
85+
).toBe(true);
7986
});
8087
it('should return false for unknown session property values', () => {
8188
expect(isKnownSessionPropertyValue('unknown_session_property')).toBe(false);

packages/chain-agnostic-permission/src/scope/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export const KnownNotifications: Record<NonWalletKnownCaipNamespace, string[]> =
100100
export enum KnownSessionProperties {
101101
SolanaAccountChangedNotifications = 'solana_accountChanged_notifications',
102102
TronAccountChangedNotifications = 'tron_accountChanged_notifications',
103+
Bip122AccountChangedNotifications = 'bip122_accountChanged_notifications',
103104
}
104105

105106
/**

packages/chain-agnostic-permission/src/scope/supported.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,16 @@ describe('Scope Support', () => {
500500
KnownSessionProperties.SolanaAccountChangedNotifications,
501501
),
502502
).toBe(true);
503+
expect(
504+
isSupportedSessionProperty(
505+
KnownSessionProperties.TronAccountChangedNotifications,
506+
),
507+
).toBe(true);
508+
expect(
509+
isSupportedSessionProperty(
510+
KnownSessionProperties.Bip122AccountChangedNotifications,
511+
),
512+
).toBe(true);
503513
});
504514

505515
it('returns false for the session property', () => {

0 commit comments

Comments
 (0)