feat: add redeemer rule support across permissions#297
Conversation
- Introduced a new redeemer rule for ERC20 token revocation, token streams, and native token periodic permissions. - Updated types to include validation for redeemer errors. - Enhanced caveat creation functions to append redeemer caveats if present. - Modified context and rules to handle redeemer addresses and ensure they are included in permission requests. - Updated tests to cover new redeemer rule functionality and validation.
… deprecated formatExecutionPermissionRequestForWallet utility
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Caution MetaMask internal reviewing guidelines:
|
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
jeffsmale90
left a comment
There was a problem hiding this comment.
I reviewed the first half - will get back to the other half shortly!
…redeemer terms encoding
…uest orchestrator
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 ec69bde. Configure here.
… and update test cases to use null
|
@SocketSecurity ignore npm/openapi-fetch@0.13.8 |

Description
Add a redeemer rule
Get Supported Permissions
{ "native-token-stream": { "chainIds": [ 1, 4114, 4217, 80002, 80069, 80094, 5115, 84532, 338, 6342, 25, 8453, 10143, 10200, 56, 14601, 1301, 1328, 1329, 97, 100, 421614, 130, 560048, 137, 143, 146, 10, 42161, 42170, 42220, 42431, 11142220, 11155111, 11155420, 59144 ], "ruleTypes": [ "expiry", "redeemer" ] }, "native-token-periodic": { "chainIds": [ 1, 4114, 4217, 80002, 80069, 80094, 5115, 84532, 338, 6342, 25, 8453, 10143, 10200, 56, 14601, 1301, 1328, 1329, 97, 100, 421614, 130, 560048, 137, 143, 146, 10, 42161, 42170, 42220, 42431, 11142220, 11155111, 11155420, 59144 ], "ruleTypes": [ "expiry", "redeemer" ] }, "erc20-token-stream": { "chainIds": [ 1, 4114, 4217, 80002, 80069, 80094, 5115, 84532, 338, 6342, 25, 8453, 10143, 10200, 56, 14601, 1301, 1328, 1329, 97, 100, 421614, 130, 560048, 137, 143, 146, 10, 42161, 42170, 42220, 42431, 11142220, 11155111, 11155420, 59144 ], "ruleTypes": [ "expiry", "redeemer" ] }, "erc20-token-periodic": { "chainIds": [ 1, 4114, 4217, 80002, 80069, 80094, 5115, 84532, 338, 6342, 25, 8453, 10143, 10200, 56, 14601, 1301, 1328, 1329, 97, 100, 421614, 130, 560048, 137, 143, 146, 10, 42161, 42170, 42220, 42431, 11142220, 11155111, 11155420, 59144 ], "ruleTypes": [ "expiry", "redeemer" ] }, "erc20-token-revocation": { "chainIds": [ 1, 4114, 4217, 80002, 80069, 80094, 5115, 84532, 338, 6342, 25, 8453, 10143, 10200, 56, 14601, 1301, 1328, 1329, 97, 100, 421614, 130, 560048, 137, 143, 146, 10, 42161, 42170, 42220, 42431, 11142220, 11155111, 11155420, 59144 ], "ruleTypes": [ "expiry", "redeemer" ] } }Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
redeemer.snap.mp4
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches permission validation and delegation caveat generation (including a new enforcer address) and upgrades
@metamask/delegation-core, so incorrect rule handling could change who can redeem granted permissions.Overview
Adds a new
redeemerrule (list of allowed redeemer addresses) across supported permission types, including schema validation, RPC-supported rule type reporting, and end-to-end tests.In
gator-permissions-snap, the grant flow now preserves the dapp-provided redeemer constraint (applyRedeemerRule), surfaces redeemer addresses as read-only in confirmation UI (RedeemerField+ new i18n strings), and converts the rule into an on-chainRedeemerEnforcercaveat (newredeemerEnforcercontract address +appendRedeemerCaveatIfPresent). Expiry caveat construction is refactored intoappendExpiryCaveatIfPresentand updated for the newercreateTimestampTermsparameter names.In the demo
site, permission request forms gain an optional redeemer-addresses input (parsed/deduped to checksum addresses) and requests sendredeemertorequestExecutionPermissions; clipboard JSON output is updated to safely stringifybigintvalues. Dependency bumps include@metamask/delegation-coreand@metamask/smart-accounts-kit(lockfile updated accordingly).Reviewed by Cursor Bugbot for commit 9886549. Bugbot is set up for automated code reviews on this repo. Configure here.