Skip to content

Conversation

@jeffsmale90
Copy link
Collaborator

@jeffsmale90 jeffsmale90 commented Jan 29, 2026

📝 Description

This adds terms builder utilities to @metamask/delegation-core for all of the caveats that are currently covered by Caveat Builders in @metamask/smart-accounts-kit, ensuring a consistent pattern for all caveat builders.

🔄 What Changed?

  • Added new delegation-core terms builders and tests for previously missing caveats, then wired Smart Accounts Kit caveat builders to consume those terms builders.
  • Moved caveat utility helpers and toHexString into packages/delegation-core/src/internalUtils.ts, updated all caveat implementations and tests to use the internal helpers, and relocated utils tests accordingly.
  • Normalized address casing where appropriate to match existing ABI-encoding behavior and resolved linting issues (enum comparisons and MAX_UINT256 constant).

🚀 Why?

Previously terms builders were only implemented for caveat enforcers that were needed in lower level consumers, while all other caveat enforcers had encoding logic implemented directly in the caveat builder. This made it more difficult for consumers building lower level applications to leverage @metamask/delegation-core as it was likely that they would need to add the terms builders first.

🧪 How to Test?

Describe how to test these changes:

All existing test automation for Caveat Builders is unchanged - this validates that existing functionality has not changed.

Test automation has been added for all new terms builders.

Manual testing could import each of the terms builders and ensure that the interface is ergonomic and works as expected.

⚠️ Breaking Changes

List any breaking changes:

  • No breaking changes
  • Breaking changes (describe below):

📋 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

Medium Risk
Adds many new encoding helpers and rewires Smart Accounts Kit builders to depend on them; while mostly deterministic encoding/validation, any mismatch in address normalization or ABI packing could subtly change on-chain terms and break redeems.

Overview
Adds missing caveat terms builders to @metamask/delegation-core (e.g., allowed methods/targets, block/ID/limited calls, exact execution + batch encodings, token balance/transfer/payment/period limits, deployed/ownership/redeemer, and specific action ERC20 batch), each supporting hex or bytes output and input validation.

Centralizes encoding utilities by introducing internalUtils (toHexString, address/hex normalization, concatHex), updating existing caveats to use it, and removing the old utils.ts.

Tightens/clarifies behavior with an explicit required check for createExactCalldataTerms and adds extensive unit tests for all new builders/utilities. Smart Accounts Kit caveat builders are refactored to call the new delegation-core terms builders instead of duplicating encoding logic (viem concat/encodePacked/encodeAbiParameters).

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

…builders

  - rename src/utils.ts to src/internalUtils.ts to ensure these aren't accidentally added to external API
@jeffsmale90 jeffsmale90 marked this pull request as ready for review January 30, 2026 01:27
@jeffsmale90 jeffsmale90 requested a review from a team as a code owner January 30, 2026 01:27
Copy link

@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 2 potential issues.

Copy link
Contributor

@mj-kiwi mj-kiwi left a comment

Choose a reason for hiding this comment

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

LGTM

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