Skip to content

Conversation

@jeffsmale90
Copy link
Collaborator

@jeffsmale90 jeffsmale90 commented Jan 30, 2026

📝 Description

Updates various methods that accept a delegation array or permission context to accept either encoded Hex or decoded Delegation[].

🔄 What Changed?

  • BREAKING Rename permissionsContext parameter in ERC7710 action to permissionContext (singular)
  • Adds new PermissionContext type that describes either a decoded Delegation[] or abi encoded Hex string, added to public API
  • Accept PermissionContext in ERC-7710 actions and DelegationManager redeem paths
  • encodeDelegations/decodeDelegations now both accept PermissionContext

Additionally removes unused internal functions

  • prepDelegationHashForPasskeySign
  • getCaveatArrayPacketHash
  • deployWithSimpleFactory

Hint: view the changes by separate commit to see these broken out.

🚀 Why?

Depending on the specific implementation, a consumer may have the data either encoded or decoded. By accepting the data in whatever format the user has, it removes the need for the consumer to encode or decode.

By standardising the terminology it makes the overall API easier to use.

  • Automated tests added/updated
  • All existing tests pass

Changes

New public type PermissionContext

Added PermissionContext (exported from @metamask/smart-accounts-kit):

export type PermissionContext = Delegation[] | Hex;

This represents either a decoded delegation chain (Delegation[]) or an ABI‑encoded hex string.

🚨 Breaking DelegatedCall type: permissionsContext renamed to permissionContext.

Before:

type DelegatedCall = Call & OneOf<{ permissionsContext: Hex; delegationManager: Hex } | object>;

After:

type DelegatedCall = Call & OneOf<{ permissionContext: PermissionContext; delegationManager: Hex } | object>;

🚨 BREAKING Redemption type: permissionsContext renamed to permissionContext

permissionContext is also now typed as PermissionContext instead of Hex, meaning a value of Delegation[] may be provided.

Before:

type Redemption = {
  permissionContext: Delegation[];
  executions: ExecutionStruct[];
  mode: ExecutionMode;
};

After:

type Redemption = {
  permissionContext: PermissionContext;
  executions: ExecutionStruct[];
  mode: ExecutionMode;
};

🚨 Breaking: SendTransactionWithDelegation and SendUserOperationWithDelegation

  • SendTransactionWithDelegation: Renamed field and widened type
    • permissionContext: HexpermissionsContext: PermissionContext (accepts ABI-encoded Hex or decoded Delegation[])
// Before
type SendTransactionWithDelegationParams = {
  // ...
  permissionContext: Hex;
};

// After
type SendTransactionWithDelegationParams = {
  // ...
  permissionsContext: PermissionContext;
};
  • SendUserOperationWithDelegation: field in DelegatedCall type renamed and widened
    • In calls: DelegatedCall, permissionsContext: HexpermissionContext: PermissionContext (now supports Delegation[])
// Before
type DelegatedCall = Call &
  OneOf<{ permissionsContext: Hex; delegationManager: Hex } | object>;

// After
type DelegatedCall = Call &
  OneOf<{ permissionContext: PermissionContext; delegationManager: Hex } | object>;

DelegationManager redeemDelegations utilities now accept PermissionContext

EncodeRedeemDelegationsParameters used in the redeemDelegation utilities (encode, execute, and simulate) delegations: Delegation[][] is now PermissionContext[].

Before:

type EncodeRedeemDelegationsParameters = {
  delegations: Delegation[][];
  modes: ExecutionMode[];
  executions: ExecutionStruct[][];
};

After:

type EncodeRedeemDelegationsParameters = {
  delegations: PermissionContext[];
  modes: ExecutionMode[];
  executions: ExecutionStruct[][];
};

encode/decode helper signatures now accept PermissionContext

encodeDelegations now accepts PermissionContext:

export const encodeDelegations = (delegations: PermissionContext): Hex;

decodeDelegations now accepts PermissionContext:

export const decodeDelegations = (delegations: PermissionContext): Delegation[];

📋 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
Medium risk because it is a breaking API change that widens inputs across ERC-7710 actions and redeemDelegations, and it changes encoding/decoding behavior that affects on-chain calldata generation.

Overview
Introduces a new public PermissionContext type (Hex or Delegation[]) and updates delegation flows to accept either encoded or decoded delegation chains.

Breaking API rename: switches permissionsContextpermissionContext in ERC-7710 delegated calls/params, and updates Redemption.permissionContext plus DelegationManager.redeemDelegations encode/simulate/execute to take PermissionContext and encode as needed.

Updates encoding utilities so encodeDelegations/decodeDelegations are idempotent over PermissionContext, adjusts encodeCalls to encode delegated calls via encodeDelegations, and removes a few unused internal helpers; e2e/unit tests and changelog are updated accordingly.

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

@jeffsmale90 jeffsmale90 marked this pull request as ready for review January 30, 2026 00:53
@jeffsmale90 jeffsmale90 requested a review from a team as a code owner January 30, 2026 00:53
@jeffsmale90 jeffsmale90 force-pushed the feat/accept-permission-context branch from f4c926d to 1ac52a5 Compare January 30, 2026 01:36
- Adds new PermissionContext type that describes either a decoded Delegation[] or abi encoded Hex string, added to public API
- Rename permissionsContext parameter in ERC7710 action to permissionContext (singular)
- Accept PermissionContext in ERC-7710 actions and DelegationManager redeem paths
- encodeDelegations/decodeDelegations now both accept PermissionContext
- prepDelegationHashForPasskeySign
- getCaveatArrayPacketHash
- deployWithSimpleFactory
@jeffsmale90 jeffsmale90 force-pushed the feat/accept-permission-context branch from 1ac52a5 to 25da42d Compare February 3, 2026 02:19
if (Array.isArray(delegations)) {
return delegations;
}
// decodeDelegationsCore returns DelegationStruct, so we need to map it back to Delegation
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should validate the Hex String before decoding it?

return encodeDelegationsCore(delegationStructs);
return encodeDelegationsCore(delegationStructs);
}
return delegations;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here。 should we assume that delegations is always a valid hex, or do we need to add a check?

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.

Looks good to me. Just noticed there aren’t any tests covering decodeDelegations() for both Delegation[] and hex inputs.

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