Skip to content

Function call scope no longer accepts native token value#118

Merged
jeffsmale90 merged 1 commit into
mainfrom
feat/function-call-scope-has-valueLte
Dec 15, 2025
Merged

Function call scope no longer accepts native token value#118
jeffsmale90 merged 1 commit into
mainfrom
feat/function-call-scope-has-valueLte

Conversation

@jeffsmale90

@jeffsmale90 jeffsmale90 commented Dec 11, 2025

Copy link
Copy Markdown
Collaborator

📝 Description

When configuring a function call scope, native token value is not restricted. This is ok, so long as the targeted function is not payable.

This change adds a valueLte caveat with maximum value of 0, ensuring that no native token value is allowed.

A delegator may specify a maxValue for the caveat, allowing up to a specified amount of native value, for cases where a payable method is being called.

createDelegation({
  scope: {
    type: "functionCall",
    targets: ["0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"], // USDC address on Sepolia.
    selectors: ["approve(address, uint256)"],
    valueLte: { maxValue: 10000n }
  },
  ...
});

🧪 How to Test?

Describe how to test these changes:

Create a delegation using the functionCall scope without specifying a valueLte, such as https://docs.metamask.io/smart-accounts-kit/reference/delegation/delegation-scopes/#example-7

Attempt to redeem the delegation with value greater than 0 specified in the transaction. Expect the delegation to fail with an error related to maxValue.

Create a delegation with valueLte: { maxValue: 10000n } and redeem in the same way above. Expect the delegation to succeed, with native value up to 10000n.

⚠️ Breaking Changes

List any breaking changes:

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

Unless specified in its config, a delegation created with the function call scope will no longer allow native value greater than 0.

📋 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

Enforces a valueLte caveat (default 0) in functionCall scope and updates types and tests, including new encoding lengths.

  • Scope/Caveats:
    • createFunctionCallCaveatBuilder now always adds valueLte (default { maxValue: 0n }), with optional override via config.valueLte.
    • FunctionCallScopeConfig updated to include optional allowedCalldata, exactCalldata, and valueLte in base config; types/imports adjusted.
  • Tests:
    • functionCallScope.test.ts: expect ValueLteEnforcer caveat (default 0 or configured), add test for custom valueLte.
    • DelegationManager encoding tests: update expected encoded lengths (disableDelegation/enableDelegation: 1930; redeemDelegations: 2890).

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

@jeffsmale90 jeffsmale90 requested a review from a team as a code owner December 11, 2025 21:51
Comment thread shared/config/base.tsconfig.json Outdated
@jeffsmale90 jeffsmale90 force-pushed the feat/function-call-scope-has-valueLte branch 2 times, most recently from 7f8b7a6 to 99f8bee Compare December 11, 2025 22:23
@jeffsmale90 jeffsmale90 force-pushed the feat/function-call-scope-has-valueLte branch from 99f8bee to 0346c84 Compare December 11, 2025 22:55
@jeffsmale90 jeffsmale90 merged commit 4ac7a08 into main Dec 15, 2025
17 checks passed
@jeffsmale90 jeffsmale90 deleted the feat/function-call-scope-has-valueLte branch December 15, 2025 20:13
@jeffsmale90 jeffsmale90 mentioned this pull request Dec 16, 2025
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