Skip to content

chore: add more chain agnostic utility functions for interfacing w/ caip25 permission - #5536

Merged
adonesky1 merged 22 commits into
mainfrom
ad/make-chain-agnostic-permission-utilities-more-chain-agnostic
Mar 25, 2025
Merged

chore: add more chain agnostic utility functions for interfacing w/ caip25 permission#5536
adonesky1 merged 22 commits into
mainfrom
ad/make-chain-agnostic-permission-utilities-more-chain-agnostic

Conversation

@adonesky1

@adonesky1adonesky1 commented Mar 24, 2025

Copy link
Copy Markdown
Contributor

Explanation

Currently the utility/helper functions we expose to interface with and help construct a valid caip25 permission caveat are very eth/evm centric (i.e. setPermittedAccounts, addPermittedEthChainId, getPermittedEthChainIds etc)

This PR adds some new helpers that are actually chain agnostic

References

see @david0xd 's PR here

and my extension PR ontop of it that uses these changes:
MetaMask/metamask-extension#31253

@metamask/chain-agnostic-permission

  • CHANGED: Renamed caip-permission-adapter-eth-accounts.ts to caip-permission-adapter-accounts.ts to better reflect its more generalized functionality.
  • ADDED: New setPermittedAccounts function that allows setting accounts for any CAIP namespace, not just EVM scopes.
  • ADDED: New addPermittedChainId and setPermittedChainIds functions for managing permitted chains across any CAIP namespace.
  • ADDED: New generateCaip25Caveat function to simplify modification of CAIP-25 permissions after UI confirmation.
  • ADDED: New isWalletScope utility function to detect wallet-related scopes.

CHANGED : BREAKING The caip25:endowment permission caveat validator now throws an error when both requiredScopes and optionalScopes contain no scopes.
Moved to another PR: https://github.com/MetaMask/core/pull/5548.diff

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

Loading
Sign up for freeto 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

@adonesky1@jiexi