Skip to content

refactor: Use permission decoders from @metamask/7715-permission-types - #9164

Open
jeffsmale90 wants to merge 15 commits into
mainfrom
chore/permission_decoding_externalised_permissions
Open

refactor: Use permission decoders from @metamask/7715-permission-types#9164
jeffsmale90 wants to merge 15 commits into
mainfrom
chore/permission_decoding_externalised_permissions

Conversation

@jeffsmale90

@jeffsmale90 jeffsmale90 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Explanation

MetaMask/smart-accounts-kit#259 adds permission decoder definitions to @metamask/7715-permission-types released in 0.8.0.

This PR updates @metamask/gator-permissions-controller to consume these permission definitions instead of defining the permission decoders directly in the controller.

Note: erc20-token-revocation permission type is no longer supported.

References

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
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

High Risk
Breaking removal of a permission type and relocation of delegation decode logic to an external package affects how permissions are interpreted; misconfiguration or version skew could mis-decode or reject delegations.

Overview
Moves Gator permission decoding onto @metamask/7715-permission-types ^1.0.0 by building decoders from makePermissionDecoderConfigs instead of local per-type decoder modules (stream/periodic/allowance, payee/expiry/redeemer rules, etc.). Chain enforcer addresses are mapped through new toEnforcerAddressesByName / delegationContractsByChainId before decode and status sync.

Breaking: erc20-token-revocation is removed from default supportedPermissionTypes, README examples, and tests. Decode failures from missing contracts or checksum errors are wrapped as PermissionDecodingError with the underlying cause preserved.

Tests shift to controller-level decode coverage for supported types (including allowance and token-approval-revocation) and slimmer unit tests around decoder selection; large integration-style decoder test suites in this package are dropped.

Reviewed by Cursor Bugbot for commit 0ba2af8. Bugbot is set up for automated code reviews on this repo. Configure here.

@jeffsmale90 jeffsmale90 changed the title Chore/permission decoding externalised permissions refactor: @metamask/gator-permissions-controller consumes Advanced Permission definitions from @metamask/7715-permission-types Jun 17, 2026
@jeffsmale90
jeffsmale90 force-pushed the chore/permission_decoding_externalised_permissions branch from 7a4724f to 7eda56a Compare July 14, 2026 02:29
@socket-security

socket-security Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​metamask/​7715-permission-types@​0.7.1 ⏵ 1.0.010010079 +896 +6100

View full report

@jeffsmale90 jeffsmale90 changed the title refactor: @metamask/gator-permissions-controller consumes Advanced Permission definitions from @metamask/7715-permission-types refactor: @metamask/gator-permissions-controller consumes Advanced Permission definitions from @metamask/7715-permission-types Jul 14, 2026
@jeffsmale90
jeffsmale90 force-pushed the chore/permission_decoding_externalised_permissions branch from cb23bf0 to c3fbd8e Compare July 14, 2026 02:54
@jeffsmale90
jeffsmale90 marked this pull request as ready for review July 14, 2026 02:54
@jeffsmale90
jeffsmale90 requested review from a team as code owners July 14, 2026 02:54
@jeffsmale90 jeffsmale90 changed the title refactor: @metamask/gator-permissions-controller consumes Advanced Permission definitions from @metamask/7715-permission-types refactor: Use permission decoders from @metamask/7715-permission-types Jul 14, 2026
@jeffsmale90
jeffsmale90 marked this pull request as draft July 14, 2026 21:25
@jeffsmale90
jeffsmale90 force-pushed the chore/permission_decoding_externalised_permissions branch from 2719213 to c436c43 Compare July 15, 2026 01:57
@jeffsmale90
jeffsmale90 marked this pull request as ready for review July 15, 2026 01:57
@jeffsmale90
jeffsmale90 force-pushed the chore/permission_decoding_externalised_permissions branch from c436c43 to 174d64e Compare July 15, 2026 02:02

@mj-kiwi mj-kiwi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid refactor, just a few minor notes.

Comment thread packages/gator-permissions-controller/package.json Outdated
Comment thread packages/gator-permissions-controller/CHANGELOG.md
Comment thread packages/gator-permissions-controller/README.md
Comment thread packages/gator-permissions-controller/src/decodePermission/utils.ts Outdated
Comment thread packages/gator-permissions-controller/src/decodePermission/types.ts Outdated
Comment thread packages/gator-permissions-controller/src/decodePermission/types.ts Outdated
Comment thread packages/gator-permissions-controller/src/decodePermission/utils.ts Outdated
@jeffsmale90
jeffsmale90 force-pushed the chore/permission_decoding_externalised_permissions branch 3 times, most recently from a4ef722 to 7bc7040 Compare July 21, 2026 02:26
@jeffsmale90
jeffsmale90 force-pushed the chore/permission_decoding_externalised_permissions branch from 7bc7040 to 7cbbc65 Compare July 21, 2026 02:46
mj-kiwi
mj-kiwi previously approved these changes Jul 27, 2026

@mj-kiwi mj-kiwi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

throw new Error(`Contracts not found for chainId: ${chainId}`);
}

const contracts = toEnforcerAddressesByName(deploymentContracts);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

toEnforcerAddressesByName(deploymentContracts) is now called before the try block in decodePermissionFromPermissionContextForOrigin. This means a "Contract not found" error would escape unwrapped instead of being
caught and rethrown as PermissionDecodingError, which the method's @throws doc promises. Could we move this call back inside the try block, similar to how resolveGrantedPermissionOnChainStatus in permissionOnChainStatus.ts handles it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call!

@mj-kiwi mj-kiwi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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.

2 participants