Skip to content

Add Solana accountChanged event support#5491

Merged
adonesky1 merged 20 commits intomainfrom
ad/solana-accountsChanged-adaptations
Mar 21, 2025
Merged

Add Solana accountChanged event support#5491
adonesky1 merged 20 commits intomainfrom
ad/solana-accountsChanged-adaptations

Conversation

@adonesky1
Copy link
Copy Markdown
Contributor

@adonesky1 adonesky1 commented Mar 17, 2025

Explanation

Changes in support of the PR here on extension to add support for a metamask_accountChanged notification via wallet_notify notification

☝️ the PR linked includes preview builds of the changes in this PR.

More context from the extension PR description:

Add support for metamask_accountChanged notification via wallet_notify (CAIP-319) notification to enable our wallet-standard implementation to forward account changed events via the wallet standard change event

This is not a pattern we want to continue since the Multichain API should not require account changing. This is a one off bespoke implementation to support a Solana wallet-standard interface.

References

Ticket: https://github.com/MetaMask/MetaMask-planning/issues/4193

Next PR: MetaMask/metamask-extension#30949

Changelog

@metamask/chain-agnostic-permission

  • BREAKING: Updated Caip25CaveatValue type to make sessionProperties a required field instead of optional
  • ADDED: Added validation for session properties in CAIP-25 caveat
  • ADDED: Added KnownSessionProperties enum with initial SolanaAccountChangedNotifications property
  • ADDED: Added isSupportedSessionProperty function to validate session properties
  • ADDED: Added getPermittedAccountsForScopes helper function to get permitted accounts for specific scopes
  • ADDED: Updated merger function to properly merge session properties

@metamask/multichain-api-middleware

  • ADDED: Added MultichainApiNotifications enum to standardize notification method names

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 highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Base automatically changed from extract-wallet-api-packages to main March 18, 2025 14:13
@adonesky1 adonesky1 force-pushed the ad/solana-accountsChanged-adaptations branch 2 times, most recently from 4d67a61 to 4001385 Compare March 18, 2025 20:21
@adonesky1 adonesky1 force-pushed the ad/solana-accountsChanged-adaptations branch from 5def1a0 to 06e7371 Compare March 20, 2025 17:46
@adonesky1
Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@adonesky1 adonesky1 marked this pull request as ready for review March 20, 2025 19:05
@adonesky1 adonesky1 requested a review from a team as a code owner March 20, 2025 19:05
@adonesky1
Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "27.0.0-preview-8f23873",
  "@metamask-previews/address-book-controller": "6.0.3-preview-8f23873",
  "@metamask-previews/announcement-controller": "7.0.3-preview-8f23873",
  "@metamask-previews/approval-controller": "7.1.3-preview-8f23873",
  "@metamask-previews/assets-controllers": "55.0.1-preview-8f23873",
  "@metamask-previews/base-controller": "8.0.0-preview-8f23873",
  "@metamask-previews/bridge-controller": "9.0.0-preview-8f23873",
  "@metamask-previews/bridge-status-controller": "9.0.0-preview-8f23873",
  "@metamask-previews/build-utils": "3.0.3-preview-8f23873",
  "@metamask-previews/chain-agnostic-permission": "0.1.0-preview-8f23873",
  "@metamask-previews/composable-controller": "11.0.0-preview-8f23873",
  "@metamask-previews/controller-utils": "11.6.0-preview-8f23873",
  "@metamask-previews/earn-controller": "0.9.0-preview-8f23873",
  "@metamask-previews/eip1193-permission-middleware": "0.1.0-preview-8f23873",
  "@metamask-previews/ens-controller": "16.0.0-preview-8f23873",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-8f23873",
  "@metamask-previews/gas-fee-controller": "23.0.0-preview-8f23873",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-8f23873",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-8f23873",
  "@metamask-previews/keyring-controller": "21.0.0-preview-8f23873",
  "@metamask-previews/logging-controller": "6.0.4-preview-8f23873",
  "@metamask-previews/message-manager": "12.0.1-preview-8f23873",
  "@metamask-previews/multichain": "4.0.0-preview-8f23873",
  "@metamask-previews/multichain-api-middleware": "0.1.0-preview-8f23873",
  "@metamask-previews/multichain-network-controller": "0.3.0-preview-8f23873",
  "@metamask-previews/multichain-transactions-controller": "0.8.0-preview-8f23873",
  "@metamask-previews/name-controller": "8.0.3-preview-8f23873",
  "@metamask-previews/network-controller": "23.0.0-preview-8f23873",
  "@metamask-previews/notification-services-controller": "5.0.0-preview-8f23873",
  "@metamask-previews/permission-controller": "11.0.6-preview-8f23873",
  "@metamask-previews/permission-log-controller": "3.0.3-preview-8f23873",
  "@metamask-previews/phishing-controller": "12.4.1-preview-8f23873",
  "@metamask-previews/polling-controller": "13.0.0-preview-8f23873",
  "@metamask-previews/preferences-controller": "17.0.0-preview-8f23873",
  "@metamask-previews/profile-sync-controller": "11.0.0-preview-8f23873",
  "@metamask-previews/queued-request-controller": "10.0.0-preview-8f23873",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-8f23873",
  "@metamask-previews/remote-feature-flag-controller": "1.6.0-preview-8f23873",
  "@metamask-previews/sample-controllers": "0.0.0-preview-8f23873",
  "@metamask-previews/selected-network-controller": "22.0.0-preview-8f23873",
  "@metamask-previews/signature-controller": "27.0.0-preview-8f23873",
  "@metamask-previews/token-search-discovery-controller": "2.1.0-preview-8f23873",
  "@metamask-previews/transaction-controller": "51.0.0-preview-8f23873",
  "@metamask-previews/user-operation-controller": "30.0.0-preview-8f23873"
}

@adonesky1 adonesky1 changed the title add solana accountChanged event helpers Add Solana accountChanged event support Mar 20, 2025
Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me!

@adonesky1 adonesky1 enabled auto-merge (squash) March 21, 2025 14:26
@adonesky1 adonesky1 merged commit 5303a6d into main Mar 21, 2025
193 checks passed
@adonesky1 adonesky1 deleted the ad/solana-accountsChanged-adaptations branch March 21, 2025 14:31
github-merge-queue bot pushed a commit that referenced this pull request Dec 4, 2025
## Explanation

Add Tron accountChanged event support, following the previous work done
for Solana.

## References

Previous PR: #5491

## Changelog

### @metamask/chain-agnostic-permission
- ADDED: Added `TronAccountChangedNotifications` property to
`KnownSessionProperties` enum

## 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]
> Add Tron accountChanged session property and update related tests and
changelog.
> 
> - **@metamask/chain-agnostic-permission**:
> - **Session Properties**: Add `TronAccountChangedNotifications` to
`KnownSessionProperties` in
`packages/chain-agnostic-permission/src/scope/constants.ts`.
> - **Tests**: Update snapshot for `KnownSessionProperties` in
`packages/chain-agnostic-permission/src/scope/constants.test.ts`.
> - **Changelog**: Document addition in
`packages/chain-agnostic-permission/CHANGELOG.md`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
a1bf7bf. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=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.

4 participants