Skip to content

Conversation

@jeffsmale90
Copy link
Collaborator

@jeffsmale90 jeffsmale90 commented Jan 28, 2026

📝 Description

#133 updates the ScopeConfig type to require the type parameter be passed as an enum reference. This PR updates this configuration type to also allow the enum value to be passed.

This allows developers to pass either:

const scopeConfig = {
  type: ScopeType.Erc20TransferAmount,
  tokenAddress: '0x1234567890123456789012345678901234567890',
  maxAmount: 100n
};

const scopeConfig2 = {
  type: 'erc20TransferAmount',
  tokenAddress: '0x1234567890123456789012345678901234567890',
  maxAmount: 100n
};

🔄 What Changed?

Left the scope configurations and functions as is for simplicity, and just updated the ScopeConfig type (which is an argument on createDelegation() function) to accept both the enum reference and the enum value.

🚀 Why?

This change keeps the devex improvements from the original PR while aligning with established viem conventions. viem commonly uses string literal unions for parameters, and developers in that ecosystem generally expect to pass string values directly. Supporting both the enum reference and its string value preserves backwards compatibility, reduces friction for existing users, and adds flexibility without detracting from the value of the enum-based API.

🧪 How to Test?

Describe how to test these changes:

The createDelegation function should operate as documented, but optionally accept the enum ScopeType as the type parameter.

⚠️ Breaking Changes

This should no longer be breaking. If accepted, the parent PR may be marked as non-breaking.

📋 Checklist

Check off completed items:

  • Code follows the project's coding standards
  • Self-review completed
  • Documentation updated (if needed)
  • Tests added/updated
  • Changelog updated (if needed)
  • All CI checks pass

🔗 Related Issues

Link to related issues:
Closes #
Related to #

📚 Additional Notes

Any additional information, concerns, or context:


Note

Low Risk
Low risk: primarily a TypeScript typing/normalization change that widens accepted inputs for scope configs; runtime behavior is unchanged aside from accepting enum-equivalent strings.

Overview
Expands ScopeConfig inputs to accept either ScopeType enum members or their string values (e.g. 'erc20TransferAmount').

Adds a small normalization step in createCaveatBuilderFromScope to coerce the input type back to ScopeType before switching/dispatching to the specific caveat builder.

Updates tests to cover creating delegations with string scope types and removes a few unnecessary as Hex assertions in expectations.

Written by Cursor Bugbot for commit 4f32037. This will update automatically on new commits. Configure here.

@jeffsmale90 jeffsmale90 requested a review from a team as a code owner January 28, 2026 23:28
@jeffsmale90 jeffsmale90 mentioned this pull request Jan 28, 2026
10 tasks
@MoMannn MoMannn merged commit 9a2e7dc into chore--scope-types Jan 29, 2026
17 checks passed
@MoMannn MoMannn deleted the chore--scope-types-backwards-compat branch January 29, 2026 09:09
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.

3 participants