feat: enhance permission rules with payee enforcers#8668
Draft
feat: enhance permission rules with payee enforcers#8668
Conversation
- Added support for payee enforcers in makePermissionRule, allowing for extraction of allowedCalldata and allowedTargets addresses. - Updated native token rules (allowance, periodic, stream) to include payee enforcers. - Introduced new PayeeRule type for execution permission rules. - Modified utility functions to handle new payee enforcer logic. - Updated tests to validate the inclusion of new enforcers in permission rules.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
The snap now encodes payee-restricting caveats when creating permissions. This PR adds the decoding counterpart so the controller can read back payee restrictions from on-chain permission contexts.
AllowedTargetsEnforcer(native) orAllowedCalldataEnforcer(ERC-20) restricts the payment recipient to a single address.LogicalOrWrapperEnforcer.payeerule ({ type: 'payee', data: { addresses: Hex[] } }) following the same pattern as the existingredeemerrule.Scope: all 7 execution permission types (
native-token-stream,native-token-periodic,erc20-token-stream,erc20-token-periodic,native-token-allowance,erc20-token-allowance,erc20-token-revocation).References
Changelog entry
@metamask/gator-permissions-controllerAdded
AllowedTargetsEnforcer,AllowedCalldataEnforcer, andLogicalOrWrapperEnforceras optional caveats for payee extraction on execution permission types and extracts apayeerule containing the allowlisted addresses.EXECUTION_PERMISSION_PAYEE_RULE_TYPEconstant andPayeeRuletype.Checklist