feat: Add more chain-agnostic-permission utility functions from sip-26 usage#5609
feat: Add more chain-agnostic-permission utility functions from sip-26 usage#5609
Conversation
Attempt to address [some concerns about time complexity raised by @FrederikBolding](#29887 (comment)) rename and reorganize these helpers for easier navigation. I have [an open PR against core here](MetaMask/core#5609) where I've made the improvements + name changes that can be reviewed and merged immediately after 12.17.0 cut
f83ad4d to
7221a6e
Compare
dd7f242 to
caaeb88
Compare
|
@metamaskbot publish-previews |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
|
@metamaskbot publish-previews |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
| - Add and Export `isKnownSessionPropertyValue` validation utility function ([#5647](https://github.com/MetaMask/core/pull/5647)) | ||
| - Add and Export `getCaipAccountIdsFromScopesObjects` filtering utility function ([#5647](https://github.com/MetaMask/core/pull/5647)) | ||
| - Add and Export `getAllScopesFromScopesObjects` filtering utility function ([#5647](https://github.com/MetaMask/core/pull/5647)) | ||
| - Add and Export `getSupportedScopeObjects` filtering utility function ([#5647](https://github.com/MetaMask/core/pull/5647)) | ||
| - Added `getCaipAccountIdsFromScopesObjects`, `getCaipAccountIdsFromCaip25CaveatValue`, `isInternalAccountInPermittedAccountIds`, and `isCaipAccountIdInPermittedAccountIds` account id functions. ([#5609](https://github.com/MetaMask/core/pull/5609)) | ||
| - Added `getSupportedScopeObjects`, `getAllScopesFromScopesObjects`, `getAllScopesFromCaip25CaveatValue`, `getAllNonWalletNamespacesFromCaip25CaveatValue`, `getAllScopesFromPermission`, `getAllScopesFromCaip25CaveatValue`, and `isNamespaceInScopesObject` | ||
| scope functions. ([#5609](https://github.com/MetaMask/core/pull/5609)) | ||
| - Added `isKnownSessionPropertyValue` and `getCaip25CaveatFromPermission` misc functions. ([#5609](https://github.com/MetaMask/core/pull/5609)) |
There was a problem hiding this comment.
I guess I did this... not sure why I overwrote entries in the 0.4.0 changelog rather than add these to the unreleased section?
There was a problem hiding this comment.
oh i think i did this. These came from Joao's earlier PR
|
@metamaskbot publish-previews |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
packages/chain-agnostic-permission/src/adapters/caip-permission-adapter-permittedChains.ts
Outdated
Show resolved
Hide resolved
packages/chain-agnostic-permission/src/adapters/caip-permission-adapter-permittedChains.ts
Outdated
Show resolved
Hide resolved
| @@ -3,9 +3,14 @@ import type { CaipAccountId } from '@metamask/utils'; | |||
| import { | |||
There was a problem hiding this comment.
Doesn't have to be in this PR, but we should rename this adapter files
There was a problem hiding this comment.
yeah, let's do it in a follow up PR, but totally agree
## @metamask/chain-agnostic-permission ## [0.7.0] ### Changed - Bump `@metamask/api-specs` to `^0.14.0` ([#5817](#5817)) - Bump `@metamask/network-controller` to `^23.5.0` ([#5765](#5765), [#5812](#5812)) - Bump `@metamask/controller-utils` to `^11.8.0` ([#5765](#5765), [#5812](#5812)) ## @metamask/multichain-api-middleware ## [0.3.0] ### Changed - feat: Add more chain-agnostic-permission utility functions from sip-26 usage ([#5609](#5609)) - Bump `@metamask/chain-agnostic-permission` to `^0.6.0` ([#5715](https://github.com/MetaMask/core/pull/5715),[#5760](https://github.com/MetaMask/core/pull/5760)) - Bump `@metamask/api-specs` to `^0.14.0` ([#5817](#5817)) - Bump `@metamask/controller-utils` to `^11.9.0` ([#5765](#5765), [#5812](#5812)) - Bump `@metamask/network-controller` to `^23.5.0` ([#5765](#5765), [#5812](#5812)) ## @metamask/multichain ## [4.1.0] ### Changed - Bump `@metamask/api-specs` to `^0.14.0` ([#5817](#5817)) - Bump `@metamask/controller-utils` to `^11.9.0` ([#5583](#5583), [#5765](#5765), [#5812](#5812)) ## 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), highlighting breaking changes as necessary - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Moves caip-25 helpers added in sip-26 branch into the core package [](https://codespaces.new/MetaMask/metamask-extension/pull/32152?quickstart=1) ## **Related issues** See: MetaMask/core#5609 ## **Manual testing steps** No user facing changes ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Moves caip-25 helpers added in sip-26 branch into the core package [](https://codespaces.new/MetaMask/metamask-extension/pull/32152?quickstart=1) ## **Related issues** See: MetaMask/core#5609 ## **Manual testing steps** No user facing changes ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Moves caip-25 helpers added in sip-26 branch into the core package [](https://codespaces.new/MetaMask/metamask-extension/pull/32152?quickstart=1) ## **Related issues** See: MetaMask/core#5609 ## **Manual testing steps** No user facing changes ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
Changelog
Added
getCaipAccountIdsFromScopesObjects,getCaipAccountIdsFromCaip25CaveatValue,isInternalAccountInPermittedAccountIds, andisCaipAccountIdInPermittedAccountIdsaccount id functions. (#5609)getSupportedScopeObjects,getAllScopesFromScopesObjects,getAllScopesFromCaip25CaveatValue,getAllNonWalletNamespacesFromCaip25CaveatValue,getAllScopesFromPermission,getAllScopesFromCaip25CaveatValue, andisNamespaceInScopesObjectscope functions. (#5609)
isKnownSessionPropertyValueandgetCaip25CaveatFromPermissionmisc functions. (#5609)Changed
setPermittedAccountstosetNonSCACaipAccountIdsInCaip25CaveatValue. (#5609)setPermittedChainIdstooverwriteCaipChainIdsInCaip25CaveatValue. (#5609)addPermittedChainIdtoaddCaipChainIdInCaip25CaveatValue. (#5609)Extension: MetaMask/metamask-extension#32152