feat: add decoding rules for erc20-token-allowance and native-token-allowance#8553
Merged
jeffsmale90 merged 10 commits intomainfrom May 3, 2026
Merged
feat: add decoding rules for erc20-token-allowance and native-token-allowance#8553jeffsmale90 merged 10 commits intomainfrom
erc20-token-allowance and native-token-allowance#8553jeffsmale90 merged 10 commits intomainfrom
Conversation
erc20-token-allowance and native-token-allowance
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
82e535e to
ad34e77
Compare
…ne to pass validation.
- erc-20-token-allowance - native-token-allowance
c633a82 to
fe6301c
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 925b27f. Configure here.
8d4e794 to
a9868cb
Compare
mj-kiwi
approved these changes
May 1, 2026
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 identification to handle multiple candidate rules sharing the same enforcer set, which can change how delegations are classified and surfaced to the UI. While well-covered by new unit tests, decoding/validation logic changes can impact permission interpretation across supported chains.
Overview
Adds decoding support for new advanced permission types
native-token-allowanceanderc20-token-allowance, including strict term validation/decoding (e.g.,UINT256_MAXperiod duration, non-zero amounts, positive start times) and corresponding test coverage.Refactors permission-type selection during
decodePermissionFromPermissionContextForOriginto first gather all rules matching the caveat enforcer addresses and then disambiguate by validating caveat terms viaselectUniqueRuleAndDecodedPermission, with clearer error cases for no match, no valid candidate, or ambiguous validation.Tightens decoding constraints for existing
native-token-periodic/erc20-token-periodicby enforcingperiodDuration <= MAX_PERIOD_DURATION(10 years) and bumps@metamask/7715-permission-typesto^0.6.0.Reviewed by Cursor Bugbot for commit a9868cb. Bugbot is set up for automated code reviews on this repo. Configure here.