Skip to content

refactor: decompose rule decoders, and refactor permission decoding#8730

Open
jeffsmale90 wants to merge 6 commits intomainfrom
refactor/decompose-rule-decoders
Open

refactor: decompose rule decoders, and refactor permission decoding#8730
jeffsmale90 wants to merge 6 commits intomainfrom
refactor/decompose-rule-decoders

Conversation

@jeffsmale90
Copy link
Copy Markdown
Contributor

@jeffsmale90 jeffsmale90 commented May 7, 2026

Explanation

Refactor of permission decoding logic in order to:

  • clarify terminology (decoders rather than rules - rule is a highly overloaded term)
  • make rule (as in 7155 rules) more composable, rather than inherently part of the decoding process
  • prepare the permission decoders for potential decomposition into a separate package
    no functional change, therefore no changelog required

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Refactors core permission-type identification/decoding logic to a new decoder architecture; while intended to be behavior-preserving, mistakes could change how caveats are matched/validated or which rules/expiry values are surfaced to consumers.

Overview
Refactors permission decoding to use PermissionDecoders (and composable per-rule RuleDecoders) instead of monolithic PermissionRules, updating GatorPermissionsController and the decodePermission selection flow accordingly.

Adds new composable rule decoders for expiry, redeemer, and payee (native and ERC-20), introduces a new expiry rule type constant, and rewires all native/ERC-20 permission decoders to assemble these rule decoders while preserving existing validation of caveat terms.

Removes the legacy rules/ implementation (makePermissionRule, createPermissionRulesForContracts) and updates/extends tests to cover the new decoder and rule-decoder behavior (including stricter payee caveat error cases and ensuring ERC20 revocation now returns an explicit expiry rule in rules).

Reviewed by Cursor Bugbot for commit 240c8cd. Bugbot is set up for automated code reviews on this repo. Configure here.

@jeffsmale90 jeffsmale90 force-pushed the refactor/decompose-rule-decoders branch from 71e997b to 4d784ae Compare May 7, 2026 23:22
@jeffsmale90 jeffsmale90 force-pushed the refactor/decompose-rule-decoders branch from 4d784ae to 98adc20 Compare May 7, 2026 23:25
@jeffsmale90 jeffsmale90 changed the title Rename PermissionRule to PermissionDecoder. Decompose rule decoders f… refactor: decompose rule decoders, and refactor permission decoding May 7, 2026
@jeffsmale90 jeffsmale90 marked this pull request as ready for review May 7, 2026 23:40
@jeffsmale90 jeffsmale90 requested a review from a team as a code owner May 7, 2026 23:40
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 f94844b. Configure here.

if (rule.type === EXECUTION_PERMISSION_EXPIRY_RULE_TYPE) {
expiry = rule.data.timestamp as number;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Expiry now added to rules array, changing API output

Medium Severity

The expiryRule decoder now appends { type: 'expiry', data: { timestamp } } to the rules array of the decoded permission output. Previously, expiry was extracted internally and never surfaced in rules. This changes the shape of DecodedPermission returned to consumers — permissions with a TimestampEnforcer caveat now have a non-empty rules array where they previously had undefined. The PR description states "no functional change" and omits a changelog, but this is an observable API-level change that could affect downstream consumers checking rules.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f94844b. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant