Skip to content

feat: add redeemer rule support across permissions#297

Merged
mj-kiwi merged 17 commits intomainfrom
feat/redeemer-rule
Apr 30, 2026
Merged

feat: add redeemer rule support across permissions#297
mj-kiwi merged 17 commits intomainfrom
feat/redeemer-rule

Conversation

@mj-kiwi
Copy link
Copy Markdown
Contributor

@mj-kiwi mj-kiwi commented Apr 21, 2026

Description

Add a redeemer rule

{
  "type": "redeemer",
  "data: {
    "addresses": Address[]
  }
}

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

  1. Go to this page...

Screenshots/Recordings

Before

After

redeemer.snap.mp4

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

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 redeemer rule (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-chain RedeemerEnforcer caveat (new redeemerEnforcer contract address + appendRedeemerCaveatIfPresent). Expiry caveat construction is refactored into appendExpiryCaveatIfPresent and updated for the newer createTimestampTerms parameter names.

In the demo site, permission request forms gain an optional redeemer-addresses input (parsed/deduped to checksum addresses) and requests send redeemer to requestExecutionPermissions; clipboard JSON output is updated to safely stringify bigint values. Dependency bumps include @metamask/delegation-core and @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.

mj-kiwi added 4 commits April 21, 2026 20:15
- 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
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 23, 2026

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​metamask/​smart-accounts-kit@​0.4.0-beta.0 ⏵ 1.3.082 +3100100 +696 +4100
Updated@​metamask/​delegation-core@​0.3.0 ⏵ 1.1.0100 +1100100 +194 +5100

View full report

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 23, 2026

Caution

MetaMask internal reviewing guidelines:

  • Do not ignore-all
  • Each alert has instructions on how to review if you don't know what it means. If lost, ask your Security Liaison or the supply-chain group
  • Copy-paste ignore lines for specific packages or a group of one kind with a note on what research you did to deem it safe.
    @SocketSecurity ignore npm/PACKAGE@VERSION
Action Severity Alert  (click "▶" to expand/collapse)
Block Medium
Network access: npm openapi-fetch in module globalThis["fetch"]

Module: globalThis["fetch"]

Location: Package overview

From: ?npm/@metamask/smart-accounts-kit@1.3.0npm/openapi-fetch@0.13.8

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/openapi-fetch@0.13.8. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@mj-kiwi mj-kiwi marked this pull request as ready for review April 27, 2026 08:49
@mj-kiwi mj-kiwi requested a review from a team as a code owner April 27, 2026 08:49
Comment thread packages/gator-permissions-snap/src/core/chainMetadata.ts Outdated
Comment thread packages/gator-permissions-snap/src/permissions/rules.ts Outdated
Copy link
Copy Markdown
Contributor

@jeffsmale90 jeffsmale90 left a comment

Choose a reason for hiding this comment

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

I reviewed the first half - will get back to the other half shortly!

Comment thread packages/gator-permissions-snap/src/core/permissionHandlerContent.tsx Outdated
Comment thread packages/gator-permissions-snap/src/ui/components/RedeemerField.tsx
Copy link
Copy Markdown
Contributor

@jeffsmale90 jeffsmale90 left a comment

Choose a reason for hiding this comment

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

Looking super good!

Comment thread packages/gator-permissions-snap/src/core/redeemerCaveat.ts Outdated
Comment thread packages/gator-permissions-snap/src/core/redeemerCaveat.ts Outdated
Comment thread packages/gator-permissions-snap/src/core/types.ts Outdated
Comment thread packages/gator-permissions-snap/src/permissions/rules.ts
Comment thread packages/gator-permissions-snap/src/permissions/rules.ts Outdated
Comment thread packages/gator-permissions-snap/test/core/permissionHandler.test.ts Outdated
Comment thread packages/gator-permissions-snap/src/core/rules.tsx Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread packages/gator-permissions-snap/src/core/permissionHandlerContent.tsx Outdated
Copy link
Copy Markdown
Contributor

@jeffsmale90 jeffsmale90 left a comment

Choose a reason for hiding this comment

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

Looking great!

@mj-kiwi
Copy link
Copy Markdown
Contributor Author

mj-kiwi commented Apr 30, 2026

@SocketSecurity ignore npm/openapi-fetch@0.13.8

@mj-kiwi mj-kiwi merged commit 56644fd into main Apr 30, 2026
15 of 16 checks passed
@mj-kiwi mj-kiwi deleted the feat/redeemer-rule branch April 30, 2026 06:26
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