feat: add decoding rules for erc20-token-allowance and native-token-allowance#8553
Open
jeffsmale90 wants to merge 7 commits intomainfrom
Open
feat: add decoding rules for erc20-token-allowance and native-token-allowance#8553jeffsmale90 wants to merge 7 commits intomainfrom
erc20-token-allowance and native-token-allowance#8553jeffsmale90 wants to merge 7 commits intomainfrom
Conversation
erc20-token-allowance and native-token-allowance
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
…ne to pass validation.
- erc-20-token-allowance - native-token-allowance
82e535e to
ad34e77
Compare
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
Adds Advanced Permission type decoding rules for new permission types:
erc20-token-allowance- grants a fixed allowance of a specified ERC20 tokennative-token-allowance- grants a fixed allowance of the native tokenPrevious to this change, the decoding logic required a single permission type to match the caveat types included in the delegation. Because these new permissions use the same caveats as the periodic permission types, the decoding logic is updated to filter permission types where the rules match, and require a single matching permission type to successfully validate and decode.
erc20-token-periodicandnative-token-periodicrules were updated to requireperiodDurationbe less than the maximum allowed by the snap (10 years).References
Checklist
Note
Medium Risk
Updates permission-type decoding to handle multiple rules sharing the same enforcer set and adds new allowance permission decoders; mistakes could cause misclassification/failed decoding of delegations. Adds stricter validation (e.g., max period duration) which may reject previously accepted caveats.
Overview
Adds new decoding rules for
native-token-allowanceanderc20-token-allowance(UINT256_MAX-based “allowance” variants of periodic enforcers), including comprehensive term validation and new unit tests.Updates the decode flow to allow multiple rules to match the same enforcer-address pattern (
findRulesWithMatchingCaveatAddresses) and then select a single validating rule viaselectUniqueRuleAndDecodedPermission, with improved error reporting for no match vs ambiguous match.Tightens validation for
native-token-periodicanderc20-token-periodicby enforcingperiodDuration <= MAX_PERIOD_DURATION(10 years). Also bumps@metamask/7715-permission-typesto^0.6.0and updates the changelog.Reviewed by Cursor Bugbot for commit c633a82. Bugbot is set up for automated code reviews on this repo. Configure here.