@metamask/smart-accounts-kit 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/dist/actions/index.cjs +8 -4
  3. package/dist/actions/index.cjs.map +1 -1
  4. package/dist/actions/index.d.cts +4 -2
  5. package/dist/actions/index.d.ts +4 -2
  6. package/dist/actions/index.mjs +7 -3
  7. package/dist/{caveats-CeHBbmt_.d.cts → caveats-CaSt_VHs.d.cts} +1 -1
  8. package/dist/{caveats-BhjGBVHX.d.ts → caveats-DQ6HoAHe.d.ts} +1 -1
  9. package/dist/{chunk-XZ7UMCG3.cjs → chunk-7FYDQNJ3.cjs} +12 -12
  10. package/dist/{chunk-XZ7UMCG3.cjs.map → chunk-7FYDQNJ3.cjs.map} +1 -1
  11. package/dist/{chunk-R2WT54GZ.mjs → chunk-BGOSYTKV.mjs} +179 -57
  12. package/dist/chunk-BGOSYTKV.mjs.map +1 -0
  13. package/dist/{chunk-RR2AMG4A.cjs → chunk-DN4O5VOP.cjs} +102 -102
  14. package/dist/{chunk-RR2AMG4A.cjs.map → chunk-DN4O5VOP.cjs.map} +1 -1
  15. package/dist/{chunk-SO5JAXGD.cjs → chunk-FH6HZCHI.cjs} +11 -11
  16. package/dist/{chunk-SO5JAXGD.cjs.map → chunk-FH6HZCHI.cjs.map} +1 -1
  17. package/dist/{chunk-TMO23YRP.cjs → chunk-IBZSNB7D.cjs} +64 -20
  18. package/dist/chunk-IBZSNB7D.cjs.map +1 -0
  19. package/dist/{chunk-EEIIVBNV.mjs → chunk-MV2KHN75.mjs} +64 -20
  20. package/dist/{chunk-EEIIVBNV.mjs.map → chunk-MV2KHN75.mjs.map} +1 -1
  21. package/dist/{chunk-DVJX76J3.mjs → chunk-N66VAWMO.mjs} +2 -2
  22. package/dist/{chunk-MVBU3LRV.cjs → chunk-SCS3CFRE.cjs} +10 -10
  23. package/dist/{chunk-MVBU3LRV.cjs.map → chunk-SCS3CFRE.cjs.map} +1 -1
  24. package/dist/{chunk-HQHXGWNJ.mjs → chunk-TBHT26BV.mjs} +4 -4
  25. package/dist/{chunk-ZGBFPD4O.mjs → chunk-W7O2UQL5.mjs} +2 -2
  26. package/dist/{chunk-6CEOFJY5.cjs → chunk-XEOE25DE.cjs} +229 -107
  27. package/dist/chunk-XEOE25DE.cjs.map +1 -0
  28. package/dist/{chunk-FG2CQGSE.mjs → chunk-YXHUT56Z.mjs} +3 -3
  29. package/dist/contracts/index.cjs +5 -5
  30. package/dist/contracts/index.d.cts +3 -2
  31. package/dist/contracts/index.d.ts +3 -2
  32. package/dist/contracts/index.mjs +4 -4
  33. package/dist/delegation-BKkEyxZY.d.cts +64 -0
  34. package/dist/delegation-DbPGWKfP.d.ts +64 -0
  35. package/dist/experimental/index.cjs +7 -7
  36. package/dist/experimental/index.mjs +1 -1
  37. package/dist/{index-DRKgDSZW.d.ts → index-DXdlz7t4.d.ts} +2 -1
  38. package/dist/{index-BToRQKyJ.d.cts → index-DfDAuvr5.d.cts} +37 -4
  39. package/dist/{index-Cg-JakqA.d.ts → index-G78z6nwi.d.ts} +37 -4
  40. package/dist/{index-DzL9ccjU.d.cts → index-yU3olCJV.d.cts} +2 -1
  41. package/dist/index.cjs +19 -19
  42. package/dist/index.d.cts +6 -5
  43. package/dist/index.d.ts +6 -5
  44. package/dist/index.mjs +6 -6
  45. package/dist/{delegation-CR99q1-n.d.ts → resolveCaveats-DiqGB-T5.d.cts} +3 -52
  46. package/dist/{delegation-DoVULGYE.d.cts → resolveCaveats-s2snaFEo.d.ts} +3 -52
  47. package/dist/utils/index.cjs +4 -4
  48. package/dist/utils/index.d.cts +3 -2
  49. package/dist/utils/index.d.ts +3 -2
  50. package/dist/utils/index.mjs +3 -3
  51. package/package.json +2 -2
  52. package/dist/chunk-6CEOFJY5.cjs.map +0 -1
  53. package/dist/chunk-R2WT54GZ.mjs.map +0 -1
  54. package/dist/chunk-TMO23YRP.cjs.map +0 -1
  55. /package/dist/{chunk-DVJX76J3.mjs.map → chunk-N66VAWMO.mjs.map} +0 -0
  56. /package/dist/{chunk-HQHXGWNJ.mjs.map → chunk-TBHT26BV.mjs.map} +0 -0
  57. /package/dist/{chunk-ZGBFPD4O.mjs.map → chunk-W7O2UQL5.mjs.map} +0 -0
  58. /package/dist/{chunk-FG2CQGSE.mjs.map → chunk-YXHUT56Z.mjs.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/chunk-XEOE25DE.cjs","../src/actions/index.ts","../src/actions/erc7710RedeemDelegationAction.ts","../src/actions/erc7715Mapping.ts","../src/actions/erc7715GetGrantedExecutionPermissionsAction.ts","../src/actions/erc7715GetSupportedExecutionPermissionsAction.ts","../src/actions/erc7715RequestExecutionPermissionsAction.ts","../src/actions/redelegatePermissionContext.ts","../src/actions/signDelegation.ts","../src/actions/getCaveatAvailableAmount.ts","../src/actions/isValid7702Implementation.ts","../src/actions/signUserOperation.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC7BA,IAAA,gBAAA,EAAA,CAAA,CAAA;AAAA,wCAAA,eAAA,EAAA;AAAA,EAAA,qBAAA,EAAA,CAAA,EAAA,GAAA,qBAAA;AAAA,EAAA,qBAAA,EAAA,CAAA,EAAA,GAAA,qBAAA;AAAA,EAAA,oBAAA,EAAA,CAAA,EAAA,GAAA,oBAAA;AAAA,EAAA,sBAAA,EAAA,CAAA,EAAA,GAAA,sBAAA;AAAA,EAAA,6CAAA,EAAA,CAAA,EAAA,GAAA,6CAAA;AAAA,EAAA,wCAAA,EAAA,CAAA,EAAA,GAAA,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ACL,MAAA;AACA,IAAA;AACF,EAAA;AACF,EAAA;AAEE,IAAA;AAAO,MAAA;AACL,IAAA;AACF,EAAA;AACF,EAAA;AAEE,IAAA;AAAO,MAAA;AACL,IAAA;AACF,EAAA;AAEJ;AAyEO;AAA8D,EAAA;AAGd,EAAA;AAGI,EAAA;AAI3D;AA6BO;AAAyD,EAAA;AAIhE;ADwzBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/chunk-XEOE25DE.cjs","sourcesContent":[null,"import type { Client, WalletClient } from 'viem';\nimport type { BundlerClient } from 'viem/account-abstraction';\n\nimport type {\n SendTransactionWithDelegationParameters,\n SendUserOperationWithDelegationParameters,\n} from './erc7710RedeemDelegationAction';\nimport {\n sendTransactionWithDelegationAction,\n sendUserOperationWithDelegationAction,\n} from './erc7710RedeemDelegationAction';\nimport { erc7715GetGrantedExecutionPermissionsAction } from './erc7715GetGrantedExecutionPermissionsAction';\nimport { erc7715GetSupportedExecutionPermissionsAction } from './erc7715GetSupportedExecutionPermissionsAction';\nimport { erc7715RequestExecutionPermissionsAction } from './erc7715RequestExecutionPermissionsAction';\nimport type {\n MetaMaskExtensionClient,\n RequestExecutionPermissionsParameters,\n} from './erc7715RequestExecutionPermissionsAction';\nimport {\n redelegatePermissionContextAction,\n redelegatePermissionContextOpenAction,\n type RedelegatePermissionContextOpenParameters,\n type RedelegatePermissionContextParameters,\n} from './redelegatePermissionContext';\n\nexport {\n // Individual action functions\n getErc20PeriodTransferEnforcerAvailableAmount,\n getErc20StreamingEnforcerAvailableAmount,\n getMultiTokenPeriodEnforcerAvailableAmount,\n getNativeTokenPeriodTransferEnforcerAvailableAmount,\n getNativeTokenStreamingEnforcerAvailableAmount,\n // Action builder\n caveatEnforcerActions,\n // Parameter types\n type CaveatEnforcerParams,\n // Result types\n type PeriodTransferResult,\n type StreamingResult,\n} from './getCaveatAvailableAmount';\n\nexport { isValid7702Implementation } from './isValid7702Implementation';\n\n// Signing actions\nexport {\n signDelegation,\n signDelegationActions,\n type SignDelegationParameters,\n type SignDelegationReturnType,\n} from './signDelegation';\n\nexport {\n signUserOperation,\n signUserOperationActions,\n type SignUserOperationParameters,\n type SignUserOperationReturnType,\n} from './signUserOperation';\n\n// Redelegation actions\nexport {\n redelegatePermissionContextAction,\n redelegatePermissionContextOpenAction,\n type RedelegatePermissionContextParameters,\n type RedelegatePermissionContextOpenParameters,\n type RedelegatePermissionContextReturnType,\n} from './redelegatePermissionContext';\n\nexport {\n erc7715RequestExecutionPermissionsAction as requestExecutionPermissions,\n type MetaMaskExtensionClient,\n type MetaMaskExtensionSchema,\n type RequestExecutionPermissionsParameters,\n type RequestExecutionPermissionsReturnType,\n} from './erc7715RequestExecutionPermissionsAction';\n\nexport type { PermissionRequestParameter } from './erc7715Types';\n\nexport { erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions } from './erc7715GetSupportedExecutionPermissionsAction';\n\nexport { erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions } from './erc7715GetGrantedExecutionPermissionsAction';\n\nexport {\n type GetSupportedExecutionPermissionsResult,\n type GetGrantedExecutionPermissionsResult,\n type Rule,\n type SupportedPermissionInfo,\n type PermissionTypes,\n type NativeTokenStreamPermission,\n type NativeTokenPeriodicPermission,\n type NativeTokenAllowancePermission,\n type Erc20TokenStreamPermission,\n type Erc20TokenPeriodicPermission,\n type Erc20TokenAllowancePermission,\n type Erc20TokenRevocationPermission,\n type RpcGetSupportedExecutionPermissionsResult,\n type RpcGetGrantedExecutionPermissionsResult,\n type RpcSupportedPermissionInfo,\n} from './erc7715Types';\n\nexport type { DelegatedCall } from './erc7710RedeemDelegationAction';\n\n/**\n * Extends a viem client with ERC-7715 provider actions.\n *\n * @returns A function that decorates a client with ERC-7715 provider actions.\n *\n * @example\n * ```typescript\n * const providerClient = createClient({\n * chain: sepolia,\n * transport: custom(window.ethereum),\n * }).extend(erc7715ProviderActions());\n *\n * await providerClient.requestExecutionPermissions({\n * requests: [permissionRequest],\n * });\n *\n * const supported = await providerClient.getSupportedExecutionPermissions();\n * const granted = await providerClient.getGrantedExecutionPermissions();\n * ```\n */\nexport const erc7715ProviderActions = () => (client: Client) => ({\n requestExecutionPermissions: async (\n parameters: RequestExecutionPermissionsParameters,\n ) => {\n return erc7715RequestExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n parameters,\n );\n },\n getSupportedExecutionPermissions: async () => {\n return erc7715GetSupportedExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n );\n },\n getGrantedExecutionPermissions: async () => {\n return erc7715GetGrantedExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n );\n },\n});\n\n/**\n * Type for a viem Client extended with ERC-7715 provider actions.\n * Use this to type variables for deferred initialization.\n *\n * @example\n * ```typescript\n * let client: Erc7715Client | null = null;\n *\n * function setupClient() {\n * client = createClient({\n * chain: sepolia,\n * transport: custom(window.ethereum),\n * }).extend(erc7715ProviderActions());\n * }\n * ```\n */\nexport type Erc7715Client = Client &\n ReturnType<ReturnType<typeof erc7715ProviderActions>>;\n\n/**\n * Type for a viem WalletClient extended with ERC-7710 wallet actions.\n * Use this to type variables for deferred initialization.\n *\n * @example\n * ```typescript\n * let walletClient: Erc7710WalletClient | null = null;\n *\n * function setupClient() {\n * walletClient = createWalletClient({\n * account,\n * chain: sepolia,\n * transport: custom(window.ethereum),\n * }).extend(erc7710WalletActions());\n * }\n * ```\n */\nexport type Erc7710WalletClient = WalletClient &\n ReturnType<ReturnType<typeof erc7710WalletActions>>;\n\n/**\n * Extends a viem wallet client with ERC-7710 wallet actions.\n *\n * @returns A function that decorates a wallet client with ERC-7710 wallet actions.\n *\n * @example\n * ```typescript\n * const walletClient = createWalletClient({\n * account,\n * chain: sepolia,\n * transport: custom(window.ethereum),\n * }).extend(erc7710WalletActions());\n *\n * await walletClient.sendTransactionWithDelegation({\n * account,\n * chain: sepolia,\n * to: recipient,\n * value: 0n,\n * data: callData,\n * permissionContext,\n * delegationManager: environment.DelegationManager,\n * });\n *\n * await walletClient.redelegatePermissionContext({\n * environment,\n * permissionContext,\n * to: anotherDelegate,\n * // optional when client.chain is configured\n * chainId: sepolia.id,\n * });\n * ```\n */\nexport const erc7710WalletActions = () => (client: WalletClient) => ({\n sendTransactionWithDelegation: async (\n args: SendTransactionWithDelegationParameters,\n ) => sendTransactionWithDelegationAction(client, args),\n redelegatePermissionContext: async (\n parameters: RedelegatePermissionContextParameters,\n ) => redelegatePermissionContextAction(client, parameters),\n redelegatePermissionContextOpen: async (\n parameters: RedelegatePermissionContextOpenParameters,\n ) => redelegatePermissionContextOpenAction(client, parameters),\n});\n\n/**\n * Extends a viem bundler client with ERC-7710 bundler actions.\n *\n * @returns A function that decorates a bundler client with ERC-7710 bundler actions.\n *\n * @example\n * ```typescript\n * const bundlerClient = createBundlerClient({\n * account: smartAccount,\n * chain: sepolia,\n * transport: http(bundlerUrl),\n * }).extend(erc7710BundlerActions());\n *\n * const userOpHash = await bundlerClient.sendUserOperationWithDelegation({\n * publicClient,\n * calls: [\n * {\n * to: recipient,\n * data: callData,\n * value: 0n,\n * permissionContext,\n * delegationManager: environment.DelegationManager,\n * },\n * ],\n * });\n * ```\n */\nexport const erc7710BundlerActions = () => (client: Client) => ({\n sendUserOperationWithDelegation: async (\n args: SendUserOperationWithDelegationParameters,\n ) => sendUserOperationWithDelegationAction(client as BundlerClient, args),\n});\n","import { DelegationManager } from '@metamask/delegation-abis';\nimport type {\n Account,\n Chain,\n Hex,\n OneOf,\n PublicClient,\n SendTransactionParameters,\n SendTransactionRequest,\n Transport,\n WalletClient,\n} from 'viem';\nimport { concat, encodeFunctionData, isAddressEqual } from 'viem';\nimport type {\n BundlerClient,\n SendUserOperationParameters,\n SmartAccount,\n} from 'viem/account-abstraction';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { encodeDelegations } from '../delegation';\nimport {\n createExecution,\n encodeExecutionCalldatas,\n ExecutionMode,\n} from '../executions';\nimport { getSmartAccountsEnvironment } from '../smartAccountsEnvironment';\nimport type { Call, PermissionContext } from '../types';\n\nexport type DelegatedCall = Call &\n OneOf<\n { permissionContext: PermissionContext; delegationManager: Hex } | object\n >;\n\nexport type SendTransactionWithDelegationParameters<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TRequest extends SendTransactionRequest<TChain, TChainOverride> =\n SendTransactionRequest<TChain, TChainOverride>,\n> = SendTransactionParameters<TChain, TAccount, TChainOverride, TRequest> & {\n permissionContext: PermissionContext;\n delegationManager: Hex;\n};\n\n/**\n * Sends a transaction using delegation to execute operations on behalf of another account.\n *\n * @param client - The wallet client to use for sending the transaction.\n * @param args - Transaction parameters with delegation details.\n * @returns Transaction hash of the executed transaction.\n */\nexport async function sendTransactionWithDelegationAction<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: WalletClient<Transport, TChain, TAccount>,\n args: SendTransactionWithDelegationParameters<TChain, TAccount>,\n) {\n trackSmartAccountsKitFunctionCall('sendTransactionWithDelegationAction', {\n chainId: client.chain?.id ?? null,\n });\n\n if (!args.to) {\n throw new Error(\n '`to` is required. `sendTransactionWithDelegation` cannot be used to deploy contracts.',\n );\n }\n\n // Validate DelegationManager address\n const chainId = client.chain?.id;\n if (!chainId) {\n throw new Error('Chain ID is not set');\n }\n\n const { DelegationManager: expectedDelegationManager } =\n getSmartAccountsEnvironment(chainId);\n if (!isAddressEqual(args.delegationManager, expectedDelegationManager)) {\n throw new Error(\n `Invalid DelegationManager: expected ${expectedDelegationManager} for chain ${chainId}, but got ${args.delegationManager}`,\n );\n }\n\n const executions = [\n createExecution({\n target: args.to,\n value: args.value,\n callData: args.data,\n }),\n ];\n\n const calldata = encodeFunctionData({\n abi: DelegationManager,\n functionName: 'redeemDelegations',\n args: [\n [encodeDelegations(args.permissionContext)],\n [ExecutionMode.SingleDefault],\n encodeExecutionCalldatas([executions]),\n ],\n });\n\n const {\n value: _value,\n permissionContext: _permissionContext,\n delegationManager: _delegationManager,\n ...rest\n } = args;\n\n const hash = await client.sendTransaction({\n ...rest,\n to: args.delegationManager,\n data: calldata,\n } as unknown as SendTransactionParameters);\n\n return hash;\n}\n\nexport type SendUserOperationWithDelegationParameters<\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n TAccountOverride extends SmartAccount | undefined = SmartAccount | undefined,\n> = SendUserOperationParameters<TAccount, TAccountOverride, DelegatedCall[]> & {\n dependencies?: { factory: Hex; factoryData: Hex }[];\n calls: DelegatedCall[];\n publicClient: PublicClient<Transport, Chain>;\n};\n\n/**\n * Broadcasts a User Operation with delegation to the Bundler.\n *\n * @param client - Client to use for sending the user operation.\n * @param parameters - Parameters for the user operation with delegation.\n * @returns The User Operation hash of the broadcasted operation.\n * @example\n * import { createBundlerClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const bundlerClient = createBundlerClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const userOpHash = await sendUserOperationWithDelegationAction(bundlerClient, {\n * account: bobSmartAccount,\n * calls: [\n * {\n * to: aliceCounterContractAddress,\n * data: encodeFunctionData({\n * abi: CounterMetadata.abi,\n * functionName: 'increment',\n * }),\n * value: 0n,\n * permissionContext: '0x...',\n * delegationManager: '0x...',\n * },\n * ],\n * dependencies: [{ factory: '0x...', factoryData: '0x...' }], // Optional: for deploying accounts\n * })\n */\nexport async function sendUserOperationWithDelegationAction<\n TAccount extends SmartAccount | undefined,\n TAccountOverride extends SmartAccount | undefined = undefined,\n>(\n client: BundlerClient<Transport, Chain | undefined, TAccount>,\n parameters: SendUserOperationWithDelegationParameters<\n TAccount,\n TAccountOverride\n >,\n) {\n trackSmartAccountsKitFunctionCall('sendUserOperationWithDelegationAction', {\n chainId: client.chain?.id ?? null,\n callCount: parameters.calls.length,\n hasDependencies: parameters.dependencies !== undefined,\n });\n\n if (parameters.dependencies) {\n const { publicClient } = parameters;\n\n const includedAccountKeys: Record<Hex, boolean> = {};\n\n const chainId = publicClient.chain?.id;\n\n if (!chainId) {\n throw new Error('Chain ID is not set');\n }\n\n const { SimpleFactory } = getSmartAccountsEnvironment(chainId);\n\n const uniqueDependencies = parameters.dependencies.filter((dependency) => {\n if (!isAddressEqual(dependency.factory, SimpleFactory)) {\n throw new Error(\n `Invalid dependency: ${dependency.factory} is not allowed.`,\n );\n }\n\n // ensure that factory calls are not duplicated\n const accountKey = concat([dependency.factory, dependency.factoryData]);\n const isDuplicate = includedAccountKeys[accountKey];\n\n includedAccountKeys[accountKey] = true;\n return !isDuplicate;\n });\n\n const factoryCalls = (\n await Promise.all(\n uniqueDependencies.map(async ({ factory, factoryData }) => {\n const isDeployed = await publicClient\n .call({\n to: factory,\n data: factoryData,\n })\n .then(() => false)\n .catch(() => true);\n\n if (isDeployed) {\n return undefined;\n }\n return {\n to: factory,\n value: 0n,\n data: factoryData,\n };\n }),\n )\n ).filter((call: Call | undefined) => call !== undefined) as Call[];\n\n parameters.calls = [\n ...(factoryCalls as DelegatedCall[]),\n ...parameters.calls,\n ];\n }\n\n parameters.calls = parameters.calls.map((call) => {\n if (!('permissionContext' in call)) {\n return call;\n }\n\n const { permissionContext } = call;\n if (!permissionContext) {\n return call;\n }\n\n return {\n ...call,\n permissionContext: encodeDelegations(permissionContext),\n };\n });\n\n return client.sendUserOperation(\n parameters as unknown as SendUserOperationParameters,\n );\n}\n","import type {\n Erc20TokenAllowancePermission as RpcErc20TokenAllowancePermission,\n Erc20TokenPeriodicPermission as RpcErc20TokenPeriodicPermission,\n Erc20TokenStreamPermission as RpcErc20TokenStreamPermission,\n Erc20TokenRevocationPermission as RpcErc20TokenRevocationPermission,\n NativeTokenAllowancePermission as RpcNativeTokenAllowancePermission,\n NativeTokenPeriodicPermission as RpcNativeTokenPeriodicPermission,\n NativeTokenStreamPermission as RpcNativeTokenStreamPermission,\n PermissionRequest,\n PermissionTypes as RpcPermissionTypes,\n Rule,\n} from '@metamask/7715-permission-types';\nimport { getAddress, hexToNumber, isAddress, toHex, type Hex } from 'viem';\n\nimport { isDefined, toHexOrThrow } from '../utils';\nimport type {\n Erc20TokenAllowancePermission,\n Erc20TokenPeriodicPermission,\n Erc20TokenRevocationPermission,\n Erc20TokenStreamPermission,\n GetGrantedExecutionPermissionsResult,\n GetSupportedExecutionPermissionsResult,\n NativeTokenAllowancePermission,\n NativeTokenPeriodicPermission,\n NativeTokenStreamPermission,\n PermissionRequestParameter,\n PermissionTypes as DeveloperPermissionTypes,\n RpcGetGrantedExecutionPermissionsResult,\n RpcGetSupportedExecutionPermissionsResult,\n} from './erc7715Types';\n\n// =============================================================================\n// Developer → RPC (request formatting)\n// =============================================================================\n\n/**\n * Converts a developer permission request to RPC format for wallet submission.\n *\n * @param parameters the permission request parameters\n * @returns the permission request in RPC format\n */\nexport function permissionRequestToRpc(\n parameters: PermissionRequestParameter,\n): PermissionRequest<RpcPermissionTypes> {\n const { chainId, from, expiry, redeemer, payee } = parameters;\n\n const converter = getPermissionRequestToRpcConverter(\n parameters.permission.type,\n );\n\n const rules: Rule[] = [];\n if (isDefined(expiry)) {\n rules.push({\n type: 'expiry',\n data: {\n timestamp: expiry,\n },\n });\n }\n if (isDefined(redeemer)) {\n if (redeemer.length === 0) {\n throw new Error(\n 'Invalid redeemers: must specify at least one redeemer address',\n );\n }\n const addresses: Hex[] = [];\n for (const addr of redeemer) {\n if (!isAddress(addr)) {\n throw new Error('Invalid redeemers: must be a valid address');\n }\n addresses.push(getAddress(addr));\n }\n rules.push({\n type: 'redeemer',\n data: { addresses },\n });\n }\n if (isDefined(payee)) {\n if (payee.length === 0) {\n throw new Error(\n 'Invalid payees: must specify at least one payee address',\n );\n }\n const payeeAddresses: Hex[] = [];\n for (const addr of payee) {\n if (!isAddress(addr)) {\n throw new Error('Invalid payees: must be a valid address');\n }\n payeeAddresses.push(getAddress(addr));\n }\n rules.push({\n type: 'payee',\n data: { addresses: payeeAddresses },\n });\n }\n\n const optionalFields = {\n ...(from ? { from } : {}),\n };\n\n return {\n ...optionalFields,\n chainId: toHex(chainId),\n permission: converter(parameters.permission),\n to: parameters.to,\n rules,\n };\n}\n\ntype PermissionRequestToRpcConverter = (\n permission: DeveloperPermissionTypes,\n) => RpcPermissionTypes;\n\n/**\n * Get the permission request to RPC converter for the given permission type.\n *\n * @param permissionType the permission type\n * @returns the permission request to RPC converter for the given permission type\n */\nfunction getPermissionRequestToRpcConverter(\n permissionType: string,\n): PermissionRequestToRpcConverter {\n switch (permissionType) {\n case 'native-token-stream':\n return (permission) =>\n nativeTokenStreamPermissionToRpc(\n permission as NativeTokenStreamPermission,\n );\n case 'erc20-token-stream':\n return (permission) =>\n erc20TokenStreamPermissionToRpc(\n permission as Erc20TokenStreamPermission,\n );\n case 'native-token-periodic':\n return (permission) =>\n nativeTokenPeriodicPermissionToRpc(\n permission as NativeTokenPeriodicPermission,\n );\n case 'native-token-allowance':\n return (permission) =>\n nativeTokenAllowancePermissionToRpc(\n permission as NativeTokenAllowancePermission,\n );\n case 'erc20-token-periodic':\n return (permission) =>\n erc20TokenPeriodicPermissionToRpc(\n permission as Erc20TokenPeriodicPermission,\n );\n case 'erc20-token-allowance':\n return (permission) =>\n erc20TokenAllowancePermissionToRpc(\n permission as Erc20TokenAllowancePermission,\n );\n case 'erc20-token-revocation':\n return (permission) =>\n erc20TokenRevocationPermissionToRpc(\n permission as Erc20TokenRevocationPermission,\n );\n default:\n throw new Error(`Unsupported permission type: ${permissionType}`);\n }\n}\n\n/**\n * Convert native token stream permission to RPC format.\n *\n * @param permission the native token stream permission\n * @returns the native token stream permission in RPC format\n */\nfunction nativeTokenStreamPermissionToRpc(\n permission: NativeTokenStreamPermission,\n): RpcNativeTokenStreamPermission {\n const {\n data: {\n initialAmount,\n justification,\n maxAmount,\n startTime,\n amountPerSecond,\n },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(initialAmount) && {\n initialAmount: toHexOrThrow(initialAmount, 'initialAmount'),\n }),\n ...(isDefined(maxAmount) && {\n maxAmount: toHexOrThrow(maxAmount, 'maxAmount'),\n }),\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'native-token-stream',\n data: {\n amountPerSecond: toHexOrThrow(amountPerSecond, 'amountPerSecond'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC20 token stream permission to RPC format.\n *\n * @param permission the erc20 token stream permission\n * @returns the erc20 token stream permission in RPC format\n */\nfunction erc20TokenStreamPermissionToRpc(\n permission: Erc20TokenStreamPermission,\n): RpcErc20TokenStreamPermission {\n const {\n data: {\n tokenAddress,\n amountPerSecond,\n initialAmount,\n startTime,\n maxAmount,\n justification,\n },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(initialAmount) && {\n initialAmount: toHexOrThrow(initialAmount, 'initialAmount'),\n }),\n ...(isDefined(maxAmount) && {\n maxAmount: toHexOrThrow(maxAmount, 'maxAmount'),\n }),\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'erc20-token-stream',\n data: {\n tokenAddress: toHexOrThrow(tokenAddress, 'tokenAddress'),\n amountPerSecond: toHexOrThrow(amountPerSecond, 'amountPerSecond'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert native token periodic permission to RPC format.\n *\n * @param permission the native token periodic permission\n * @returns the native token periodic permission in RPC format\n */\nfunction nativeTokenPeriodicPermissionToRpc(\n permission: NativeTokenPeriodicPermission,\n): RpcNativeTokenPeriodicPermission {\n const {\n data: { periodAmount, periodDuration, startTime, justification },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'native-token-periodic',\n data: {\n periodAmount: toHexOrThrow(periodAmount, 'periodAmount'),\n periodDuration: Number(periodDuration),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC20 token periodic permission to RPC format.\n *\n * @param permission the erc20 token periodic permission\n * @returns the erc20 token periodic permission in RPC format\n */\nfunction erc20TokenPeriodicPermissionToRpc(\n permission: Erc20TokenPeriodicPermission,\n): RpcErc20TokenPeriodicPermission {\n const {\n data: {\n tokenAddress,\n periodAmount,\n periodDuration,\n startTime,\n justification,\n },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'erc20-token-periodic',\n data: {\n tokenAddress: toHexOrThrow(tokenAddress, 'tokenAddress'),\n periodAmount: toHexOrThrow(periodAmount, 'periodAmount'),\n periodDuration: Number(periodDuration),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert native token fixed allowance permission to RPC format.\n *\n * @param permission the native token fixed allowance permission\n * @returns the native token fixed allowance permission in RPC format\n */\nfunction nativeTokenAllowancePermissionToRpc(\n permission: NativeTokenAllowancePermission,\n): RpcNativeTokenAllowancePermission {\n const {\n data: { allowanceAmount, startTime, justification },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'native-token-allowance',\n data: {\n allowanceAmount: toHexOrThrow(allowanceAmount, 'allowanceAmount'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC-20 token fixed allowance permission to RPC format.\n *\n * @param permission the ERC-20 token fixed allowance permission\n * @returns the ERC-20 token fixed allowance permission in RPC format\n */\nfunction erc20TokenAllowancePermissionToRpc(\n permission: Erc20TokenAllowancePermission,\n): RpcErc20TokenAllowancePermission {\n const {\n data: { tokenAddress, allowanceAmount, startTime, justification },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'erc20-token-allowance',\n data: {\n tokenAddress: toHexOrThrow(tokenAddress, 'tokenAddress'),\n allowanceAmount: toHexOrThrow(allowanceAmount, 'allowanceAmount'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC20 token revocation permission to RPC format.\n *\n * @param permission the erc20 token revocation permission\n * @returns the erc20 token revocation permission in RPC format\n */\nfunction erc20TokenRevocationPermissionToRpc(\n permission: Erc20TokenRevocationPermission,\n): RpcErc20TokenRevocationPermission {\n const {\n data: { justification },\n isAdjustmentAllowed,\n } = permission;\n\n const data = {\n ...(justification ? { justification } : {}),\n };\n return {\n type: 'erc20-token-revocation',\n data,\n isAdjustmentAllowed,\n };\n}\n\n// =============================================================================\n// RPC → Developer friendly types (response conversion)\n// =============================================================================\n\n/**\n * Converts RPC permission responses to developer-friendly types.\n * Converts chainId from hex to number, and token amounts from hex to bigint.\n *\n * @param result the RPC permission responses\n * @returns the developer-friendly permission responses\n */\nexport function permissionResponsesFromRpc(\n result: RpcGetGrantedExecutionPermissionsResult,\n): GetGrantedExecutionPermissionsResult {\n return result.map((permission) => ({\n ...permission,\n chainId: hexToNumber(permission.chainId),\n permission: permissionTypeFromRpc(permission.permission),\n rules: normalizeRulesFromRpc(permission.rules),\n }));\n}\n\n/**\n * Checksums addresses in `redeemer` and `payee` rules; other rules are returned unchanged.\n *\n * @param rules - Rules from the wallet RPC response.\n * @returns The same list with normalized addresses, or null/undefined if that was the input.\n */\nfunction normalizeRulesFromRpc(\n rules: Rule[] | null | undefined,\n): Rule[] | null | undefined {\n if (rules === undefined || rules === null) {\n return rules;\n }\n return rules.map((rule) => {\n if (rule.type !== 'redeemer' && rule.type !== 'payee') {\n return rule;\n }\n const rawAddresses = (rule.data as { addresses?: unknown } | undefined)\n ?.addresses;\n if (!Array.isArray(rawAddresses)) {\n return rule;\n }\n return {\n type: rule.type,\n data: {\n addresses: rawAddresses.map((addr) => getAddress(addr as Hex)),\n },\n };\n });\n}\n\n/**\n * Converts RPC permission type data to developer-friendly types.\n * Converts hex amount fields to bigint.\n *\n * @param permission the RPC permission\n * @returns the developer-friendly permission\n */\nexport function permissionTypeFromRpc(\n permission: RpcPermissionTypes,\n): DeveloperPermissionTypes {\n const convertedData: Record<string, unknown> = { ...permission.data };\n\n if ('amountPerSecond' in convertedData && convertedData.amountPerSecond) {\n convertedData.amountPerSecond = BigInt(\n convertedData.amountPerSecond as `0x${string}`,\n );\n }\n\n if ('periodAmount' in convertedData && convertedData.periodAmount) {\n convertedData.periodAmount = BigInt(\n convertedData.periodAmount as `0x${string}`,\n );\n }\n\n if ('initialAmount' in convertedData && convertedData.initialAmount) {\n convertedData.initialAmount = BigInt(\n convertedData.initialAmount as `0x${string}`,\n );\n }\n\n if ('maxAmount' in convertedData && convertedData.maxAmount) {\n convertedData.maxAmount = BigInt(convertedData.maxAmount as `0x${string}`);\n }\n\n if ('allowanceAmount' in convertedData && convertedData.allowanceAmount) {\n convertedData.allowanceAmount = BigInt(\n convertedData.allowanceAmount as `0x${string}`,\n );\n }\n\n return {\n ...permission,\n data: convertedData,\n } as DeveloperPermissionTypes;\n}\n\n/**\n * Converts RPC supported permissions result to developer-friendly types.\n * Converts chain IDs from hex to numbers.\n *\n * @param result the RPC supported permissions result\n * @returns the developer-friendly supported permissions result\n */\nexport function rpcSupportedPermissionsToDeveloper(\n result: RpcGetSupportedExecutionPermissionsResult,\n): GetSupportedExecutionPermissionsResult {\n const converted: GetSupportedExecutionPermissionsResult = {};\n\n for (const [permissionType, permissionInfo] of Object.entries(result)) {\n converted[permissionType] = {\n chainIds: permissionInfo.chainIds.map((chainId) => hexToNumber(chainId)),\n ruleTypes: permissionInfo.ruleTypes,\n };\n }\n\n return converted;\n}\n","import { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { permissionResponsesFromRpc } from './erc7715Mapping';\nimport type {\n GetGrantedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n} from './erc7715Types';\n\nexport type { GetGrantedExecutionPermissionsResult } from './erc7715Types';\n\n/**\n * Retrieves all previously granted execution permissions from the wallet according to EIP-7715 specification.\n *\n * @param client - The client to use for the request.\n * @returns A promise that resolves to an array of granted permission responses.\n * @description\n * This function queries the wallet for all granted permissions that are not yet revoked.\n * Each permission response includes the chain ID, address, signer, permission details,\n * context, and dependency information.\n * @example\n * ```typescript\n * const grantedPermissions = await erc7715GetGrantedExecutionPermissionsAction(client);\n * // Returns an array of PermissionResponse objects with user-friendly types\n * ```\n */\nexport async function erc7715GetGrantedExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n): Promise<GetGrantedExecutionPermissionsResult> {\n trackSmartAccountsKitFunctionCall(\n 'erc7715GetGrantedExecutionPermissionsAction',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n\n const result = await client.request(\n {\n method: 'wallet_getGrantedExecutionPermissions',\n params: [],\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to get granted execution permissions');\n }\n\n return permissionResponsesFromRpc(result);\n}\n","import { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { rpcSupportedPermissionsToDeveloper } from './erc7715Mapping';\nimport type {\n GetSupportedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n} from './erc7715Types';\n\nexport type { GetSupportedExecutionPermissionsResult } from './erc7715Types';\n\n/**\n * Retrieves the supported execution permission types from the wallet according to EIP-7715 specification.\n *\n * @param client - The client to use for the request.\n * @returns A promise that resolves to a record of supported permission types with their chain IDs and rule types.\n * @description\n * This function queries the wallet for the permission types it supports.\n * The result is keyed by permission type and includes the supported chain IDs and rule types.\n * @example\n * ```typescript\n * const supported = await erc7715GetSupportedExecutionPermissionsAction(client);\n * // Returns:\n * // {\n * // \"native-token-allowance\": {\n * // \"chainIds\": [1, 137],\n * // \"ruleTypes\": [\"expiry\", \"redeemer\", \"payee\"]\n * // },\n * // \"erc20-token-allowance\": {\n * // \"chainIds\": [1],\n * // \"ruleTypes\": [\"expiry\"]\n * // }\n * // }\n * //\n * // Which strings appear in `ruleTypes` is defined by the wallet; when supported,\n * // `\"redeemer\"` indicates the wallet accepts a redeemer execution rule and\n * // `\"payee\"` indicates the wallet accepts a payee execution rule.\n * ```\n */\nexport async function erc7715GetSupportedExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n): Promise<GetSupportedExecutionPermissionsResult> {\n trackSmartAccountsKitFunctionCall(\n 'erc7715GetSupportedExecutionPermissionsAction',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n\n const result = await client.request(\n {\n method: 'wallet_getSupportedExecutionPermissions',\n params: [],\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to get supported execution permissions');\n }\n\n return rpcSupportedPermissionsToDeveloper(result);\n}\n","import { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport {\n permissionRequestToRpc,\n permissionResponsesFromRpc,\n} from './erc7715Mapping';\nimport type {\n GetGrantedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n PermissionRequestParameter,\n} from './erc7715Types';\n\nexport type {\n GetGrantedExecutionPermissionsResult,\n GetSupportedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n MetaMaskExtensionSchema,\n SupportedPermissionInfo,\n PermissionTypes,\n PermissionRequestParameter,\n} from './erc7715Types';\n\n/**\n * Parameters for the RequestExecutionPermissions action.\n *\n * @template Signer - The type of the signer, either an Address or Account.\n */\nexport type RequestExecutionPermissionsParameters =\n PermissionRequestParameter[];\n\n/**\n * Return type for the request execution permissions action.\n */\nexport type RequestExecutionPermissionsReturnType =\n GetGrantedExecutionPermissionsResult;\n\n/**\n * Grants permissions according to EIP-7715 specification.\n *\n * @template Signer - The type of the signer, either an Address or Account.\n * @param client - The client to use for the request.\n * @param parameters - The permissions requests to grant.\n * @returns A promise that resolves to the permission responses.\n * @description\n * This function formats the permissions requests and invokes the wallet method to grant permissions.\n * It will throw an error if the permissions could not be granted.\n */\nexport async function erc7715RequestExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n parameters: RequestExecutionPermissionsParameters,\n): Promise<RequestExecutionPermissionsReturnType> {\n trackSmartAccountsKitFunctionCall(\n 'erc7715RequestExecutionPermissionsAction',\n {\n chainId: client.chain?.id ?? null,\n requestCount: parameters.length,\n },\n );\n const formattedPermissionRequest = parameters.map(permissionRequestToRpc);\n\n const result = await client.request(\n {\n method: 'wallet_requestExecutionPermissions',\n params: formattedPermissionRequest,\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to grant permissions');\n }\n\n return permissionResponsesFromRpc(result);\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n Transport,\n WalletClient,\n} from 'viem';\nimport { BaseError } from 'viem';\nimport { parseAccount } from 'viem/accounts';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport type { Caveats } from '../caveatBuilder';\nimport type { ScopeConfig } from '../caveatBuilder/scope';\nimport {\n ANY_BENEFICIARY,\n createDelegation,\n createOpenDelegation,\n decodeDelegations,\n encodeDelegations,\n} from '../delegation';\nimport type {\n Delegation,\n PermissionContext,\n SmartAccountsEnvironment,\n} from '../types';\nimport { signDelegation } from './signDelegation';\n\ntype BaseRedelegatePermissionContextParameters = {\n /** Account to sign the delegation with */\n account?: Account | Address;\n /** Environment configuration */\n environment: SmartAccountsEnvironment;\n /** The permission context to redelegate from (i.e., from ERC-7715 response) */\n permissionContext: PermissionContext;\n /** The chain ID for the signature (falls back to `client.chain.id`) */\n chainId?: number;\n /** Optional scope - if not provided, inherits from parent */\n scope?: ScopeConfig;\n /** Additional caveats to apply to the redelegation */\n caveats?: Caveats;\n /** Optional salt for uniqueness */\n salt?: Hex;\n};\n\nexport type RedelegatePermissionContextParameters =\n BaseRedelegatePermissionContextParameters & {\n /** The address of the delegate to redelegate to */\n to: Address;\n };\n\nexport type RedelegatePermissionContextOpenParameters =\n BaseRedelegatePermissionContextParameters;\n\nexport type RedelegatePermissionContextReturnType = {\n /** The signed delegation that was created */\n delegation: Delegation;\n /** The new permission context with the redelegation prepended (encoded) */\n permissionContext: Hex;\n};\n\ntype SigningClient<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n> = Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n};\n\n/**\n * Shared workflow for creating, signing and prepending a redelegation to a\n * permission context. The caller decides whether to produce a specific or open\n * redelegation by supplying the appropriate `unsignedDelegation`.\n *\n * @param client - Wallet client with signing capability.\n * @param options - Workflow options.\n * @param options.account - Account to sign the delegation with.\n * @param options.environment - Environment configuration.\n * @param options.delegations - The decoded delegation chain (leaf first).\n * @param options.unsignedDelegation - The new (unsigned) redelegation to prepend.\n * @param options.chainId - The chain ID for the signature.\n * @returns The signed delegation and updated, encoded permission context.\n */\nasync function signAndPrependRedelegation(\n client: SigningClient<Chain | undefined, Account | undefined>,\n options: {\n account: Account;\n environment: SmartAccountsEnvironment;\n delegations: Delegation[];\n unsignedDelegation: Delegation;\n chainId: number;\n },\n): Promise<RedelegatePermissionContextReturnType> {\n const { account, environment, delegations, unsignedDelegation, chainId } =\n options;\n\n const signature = await signDelegation(client, {\n account,\n delegation: unsignedDelegation,\n delegationManager: environment.DelegationManager,\n chainId,\n // Redelegations always inherit from a parent delegation (enforced by\n // `resolveRedelegationArgs`), so the parent's caveats provide the\n // restriction even when the redelegation itself adds no extra caveats.\n // This mirrors `resolveCaveats`, which also allows empty caveats in this\n // case.\n allowInsecureUnrestrictedDelegation: true,\n });\n\n const signedDelegation: Delegation = {\n ...unsignedDelegation,\n signature,\n };\n\n const newPermissionContext = encodeDelegations([\n signedDelegation,\n ...delegations,\n ]);\n\n return {\n delegation: signedDelegation,\n permissionContext: newPermissionContext,\n };\n}\n\n/**\n * Resolves and validates shared inputs used by both redelegation actions.\n *\n * @param client - Wallet client with signing capability.\n * @param parameters - The base redelegation parameters.\n * @returns The resolved account, decoded chain and parent (leaf) delegation.\n */\nfunction resolveRedelegationArgs<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: SigningClient<TChain, TAccount>,\n parameters: BaseRedelegatePermissionContextParameters,\n): {\n account: Account;\n delegations: Delegation[];\n parentDelegation: Delegation;\n from: Hex;\n} {\n const { account: accountParam = client.account, permissionContext } =\n parameters;\n\n if (!accountParam) {\n throw new BaseError('Account not found. Please provide an account.');\n }\n\n const account = parseAccount(accountParam);\n const delegations = decodeDelegations(permissionContext);\n const parentDelegation = delegations[0];\n\n if (!parentDelegation) {\n throw new BaseError(\n 'Permission context must contain at least one delegation',\n );\n }\n\n const isParentOpenDelegation =\n parentDelegation.delegate.toLowerCase() === ANY_BENEFICIARY.toLowerCase();\n\n const from = isParentOpenDelegation\n ? account.address\n : parentDelegation.delegate;\n\n return { account, delegations, parentDelegation, from };\n}\n\n/**\n * Creates a redelegation to a specific delegate from an existing permission\n * context and returns both the signed delegation and the updated permission\n * context.\n *\n * This action handles the complete redelegation workflow:\n * 1. Extracts the leaf delegation from the permission context\n * 2. Creates a new delegation inheriting from it\n * 3. Signs the new delegation\n * 4. Prepends it to the delegation chain\n * 5. Returns the encoded permission context\n *\n * Use {@link redelegatePermissionContextOpenAction} to create an open\n * redelegation\n * (delegate set to `ANY_BENEFICIARY`).\n *\n * @param client - Wallet client with signing capability.\n * @param parameters - Redelegation parameters.\n * @returns Object containing the signed delegation and new permission context.\n *\n * @example\n * ```ts\n * const result = await redelegatePermissionContextAction(walletClient, {\n * environment,\n * permissionContext: erc7715Response.context,\n * chainId: 11155111,\n * to: charlie.address,\n * caveats: [timestampCaveat],\n * });\n *\n * await client.sendUserOperationWithDelegation({\n * calls: [{\n * to: contractAddress,\n * data: callData,\n * permissionContext: result.permissionContext,\n * delegationManager: environment.DelegationManager,\n * }],\n * });\n * ```\n */\nexport async function redelegatePermissionContextAction<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: SigningClient<TChain, TAccount>,\n parameters: RedelegatePermissionContextParameters,\n): Promise<RedelegatePermissionContextReturnType> {\n const { environment, scope, caveats, salt, to } = parameters;\n const chainId = resolveChainId(client, parameters.chainId);\n\n const { account, delegations, parentDelegation, from } =\n resolveRedelegationArgs(client, parameters);\n\n trackSmartAccountsKitFunctionCall('redelegatePermissionContext', {\n chainId,\n hasScope: scope !== undefined,\n hasCaveats: caveats !== undefined,\n });\n\n const unsignedDelegation = createDelegation({\n environment,\n from,\n to,\n scope,\n caveats,\n parentDelegation,\n salt,\n });\n\n return signAndPrependRedelegation(client, {\n account,\n environment,\n delegations,\n unsignedDelegation,\n chainId,\n });\n}\n\n/**\n * Creates an open redelegation (delegate set to `ANY_BENEFICIARY`) from an\n * existing permission context and returns both the signed delegation and the\n * updated permission context.\n *\n * Use {@link redelegatePermissionContextAction} when you want to delegate to a\n * specific address.\n *\n * @param client - Wallet client with signing capability.\n * @param parameters - Open redelegation parameters.\n * @returns Object containing the signed delegation and new permission context.\n *\n * @example\n * ```ts\n * const result = await redelegatePermissionContextOpenAction(walletClient, {\n * environment,\n * permissionContext: erc7715Response.context,\n * chainId: 11155111,\n * caveats: [limitedCallsCaveat],\n * });\n * ```\n */\nexport async function redelegatePermissionContextOpenAction<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: SigningClient<TChain, TAccount>,\n parameters: RedelegatePermissionContextOpenParameters,\n): Promise<RedelegatePermissionContextReturnType> {\n const { environment, scope, caveats, salt } = parameters;\n const chainId = resolveChainId(client, parameters.chainId);\n\n const { account, delegations, parentDelegation, from } =\n resolveRedelegationArgs(client, parameters);\n\n trackSmartAccountsKitFunctionCall('redelegatePermissionContextOpen', {\n chainId,\n hasScope: scope !== undefined,\n hasCaveats: caveats !== undefined,\n });\n\n const unsignedDelegation = createOpenDelegation({\n environment,\n from,\n scope,\n caveats,\n parentDelegation,\n salt,\n });\n\n return signAndPrependRedelegation(client, {\n account,\n environment,\n delegations,\n unsignedDelegation,\n chainId,\n });\n}\n\n/**\n * Resolves the chain id, falling back to the client's configured chain.\n *\n * @param client - The client to read the chain id from.\n * @param client.chain - The client's configured chain.\n * @param chainId - The explicit chain id, if provided.\n * @returns The resolved chain id.\n */\nfunction resolveChainId(\n client: { chain?: { id: number } | undefined },\n chainId: number | undefined,\n): number {\n if (chainId !== undefined) {\n return chainId;\n }\n if (!client.chain?.id) {\n throw new BaseError(\n 'Chain ID is required. Either provide it in parameters or configure the client with a chain.',\n );\n }\n return client.chain.id;\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n Transport,\n WalletClient,\n} from 'viem';\nimport { BaseError } from 'viem';\nimport { parseAccount } from 'viem/accounts';\n\nimport { prepareSignDelegationTypedData } from '../delegation';\nimport type { Delegation } from '../types';\n\nexport type SignDelegationParameters = {\n /** Account to sign with */\n account?: Account | Address;\n /** The delegation to sign */\n delegation: Omit<Delegation, 'signature'>;\n /** The address of the delegation manager contract */\n delegationManager: Address;\n /** The chain ID for the signature */\n chainId: number;\n /** The name of the contract */\n name?: string;\n /** The version of the contract */\n version?: string;\n /** Whether to allow insecure unrestricted delegation */\n allowInsecureUnrestrictedDelegation?: boolean;\n};\n\nexport type SignDelegationReturnType = Hex;\n\n/**\n * Signs a delegation using a wallet client.\n *\n * @param client - The wallet client to use for signing.\n * @param parameters - The parameters for signing the delegation.\n * @returns The signature of the delegation.\n * @example\n * ```ts\n * const signature = await signDelegation(walletClient, {\n * delegation: {\n * delegate: '0x...',\n * delegator: '0x...',\n * authority: '0x...',\n * caveats: [],\n * salt: '0x'\n * },\n * delegationManager: '0x...',\n * chainId: 1\n * });\n * ```\n */\nexport async function signDelegation<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n parameters: SignDelegationParameters,\n): Promise<SignDelegationReturnType> {\n const {\n account: accountParam = client.account,\n delegation,\n delegationManager,\n chainId,\n name = 'DelegationManager',\n version = '1',\n allowInsecureUnrestrictedDelegation = false,\n } = parameters;\n\n if (!accountParam) {\n throw new BaseError('Account not found. Please provide an account.');\n }\n\n const account = parseAccount(accountParam);\n\n const typedData = prepareSignDelegationTypedData({\n delegation,\n delegationManager,\n chainId,\n name,\n version,\n allowInsecureUnrestrictedDelegation,\n });\n\n return client.signTypedData({\n account,\n ...typedData,\n });\n}\n\n/**\n * Creates a sign delegation action that can be used to extend a wallet client.\n *\n * @returns A function that can be used with wallet client extend method.\n * @example\n * ```ts\n * const walletClient = createWalletClient({\n * chain: mainnet,\n * transport: http()\n * }).extend(signDelegationActions());\n * ```\n */\nexport function signDelegationActions() {\n return <\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n >(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n ) => ({\n signDelegation: async (\n parameters: Omit<SignDelegationParameters, 'chainId'> & {\n chainId?: number;\n },\n ) =>\n signDelegation(client, {\n chainId:\n parameters.chainId ??\n (() => {\n if (!client.chain?.id) {\n throw new BaseError(\n 'Chain ID is required. Either provide it in parameters or configure the client with a chain.',\n );\n }\n return client.chain.id;\n })(),\n ...parameters,\n }),\n });\n}\n","import type { Address, Hex, Client } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { hashDelegation } from '../delegation';\nimport * as ERC20PeriodTransferEnforcer from '../DelegationFramework/ERC20PeriodTransferEnforcer';\nimport * as ERC20StreamingEnforcer from '../DelegationFramework/ERC20StreamingEnforcer';\nimport * as MultiTokenPeriodEnforcer from '../DelegationFramework/MultiTokenPeriodEnforcer';\nimport * as NativeTokenPeriodTransferEnforcer from '../DelegationFramework/NativeTokenPeriodTransferEnforcer';\nimport * as NativeTokenStreamingEnforcer from '../DelegationFramework/NativeTokenStreamingEnforcer';\nimport type { SmartAccountsEnvironment, Delegation } from '../types';\n\n/**\n * Parameters for all caveat enforcer actions.\n */\nexport type CaveatEnforcerParams = {\n delegation: Delegation;\n};\n\n/**\n * Return type for period-based transfer enforcers\n */\nexport type PeriodTransferResult = {\n availableAmount: bigint;\n isNewPeriod: boolean;\n currentPeriod: bigint;\n};\n\n/**\n * Return type for streaming enforcers\n */\nexport type StreamingResult = {\n availableAmount: bigint;\n};\n\n/**\n * Finds a caveat that matches the specified enforcer address.\n *\n * @param config - The configuration object.\n * @param config.delegation - The delegation to search.\n * @param config.enforcerAddress - The enforcer address to match.\n * @param config.enforcerName - The name of the enforcer.\n * @returns The matching caveat.\n * @throws Error if no matching caveat is found.\n * @throws Error if multiple matching caveats are found.\n */\nfunction findMatchingCaveat({\n delegation,\n enforcerAddress,\n enforcerName,\n}: {\n delegation: Delegation;\n enforcerAddress: Address;\n enforcerName: keyof SmartAccountsEnvironment['caveatEnforcers'];\n}): { terms: Hex; args: Hex } {\n const matchingCaveats = delegation.caveats.filter(\n (caveat) => caveat.enforcer.toLowerCase() === enforcerAddress.toLowerCase(),\n );\n\n if (matchingCaveats.length === 0) {\n throw new Error(`No caveat found with enforcer matching ${enforcerName}`);\n }\n\n if (matchingCaveats.length > 1) {\n throw new Error(\n `Multiple caveats found with enforcer matching ${enforcerName}`,\n );\n }\n\n const [{ terms, args }] = matchingCaveats as unknown as [\n { terms: Hex; args: Hex },\n ];\n\n return {\n terms,\n args,\n };\n}\n\n/**\n * Gets the delegation manager address from environment.\n *\n * @param environment - The SmartAccountsEnvironment.\n * @returns The delegation manager address.\n */\nfunction getDelegationManager(environment: SmartAccountsEnvironment): Address {\n if (!environment.DelegationManager) {\n throw new Error('Delegation manager address not found');\n }\n\n return environment.DelegationManager;\n}\n\n/**\n * Gets the enforcer address from environment.\n *\n * @param config - The configuration object.\n * @param config.enforcerName - The name of the enforcer.\n * @param config.environment - The SmartAccountsEnvironment.\n * @returns The enforcer address.\n */\nfunction getEnforcerAddress({\n enforcerName,\n environment,\n}: {\n enforcerName: keyof SmartAccountsEnvironment['caveatEnforcers'];\n environment: SmartAccountsEnvironment;\n}): Address {\n const enforcerAddress = environment.caveatEnforcers[enforcerName];\n if (!enforcerAddress) {\n throw new Error(`${enforcerName} not found in environment`);\n }\n\n return enforcerAddress;\n}\n\n/**\n * Get available amount for ERC20 period transfer enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the ERC20 period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getErc20PeriodTransferEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n trackSmartAccountsKitFunctionCall(\n 'getErc20PeriodTransferEnforcerAvailableAmount',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n const enforcerName = 'ERC20PeriodTransferEnforcer';\n\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return ERC20PeriodTransferEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n });\n}\n\n/**\n * Get available amount for ERC20 streaming enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the ERC20 streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\nexport async function getErc20StreamingEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<StreamingResult> {\n trackSmartAccountsKitFunctionCall(\n 'getErc20StreamingEnforcerAvailableAmount',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n const enforcerName = 'ERC20StreamingEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return ERC20StreamingEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationManager,\n delegationHash,\n terms,\n });\n}\n\n/**\n * Get available amount for multi-token period enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the multi-token period enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getMultiTokenPeriodEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n trackSmartAccountsKitFunctionCall(\n 'getMultiTokenPeriodEnforcerAvailableAmount',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n const enforcerName = 'MultiTokenPeriodEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms, args } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return MultiTokenPeriodEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n args,\n });\n}\n\n/**\n * Get available amount for native token period transfer enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the native token period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getNativeTokenPeriodTransferEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n trackSmartAccountsKitFunctionCall(\n 'getNativeTokenPeriodTransferEnforcerAvailableAmount',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n const enforcerName = 'NativeTokenPeriodTransferEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return NativeTokenPeriodTransferEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n });\n}\n\n/**\n * Get available amount for native token streaming enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the native token streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\nexport async function getNativeTokenStreamingEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<StreamingResult> {\n trackSmartAccountsKitFunctionCall(\n 'getNativeTokenStreamingEnforcerAvailableAmount',\n {\n chainId: client.chain?.id ?? null,\n },\n );\n const enforcerName = 'NativeTokenStreamingEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return NativeTokenStreamingEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationManager,\n delegationHash,\n terms,\n });\n}\n\n/**\n * Caveat enforcer actions for extending viem clients.\n *\n * @param params - The parameters object.\n * @param params.environment - The SmartAccountsEnvironment.\n * @returns A function that takes a client and returns the client extension with caveat enforcer actions.\n */\nexport const caveatEnforcerActions =\n ({ environment }: { environment: SmartAccountsEnvironment }) =>\n (client: Client) => ({\n /**\n * Get available amount for ERC20 period transfer enforcer.\n *\n * @param params - The parameters for the ERC20 period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getErc20PeriodTransferEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getErc20PeriodTransferEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for ERC20 streaming enforcer.\n *\n * @param params - The parameters for the ERC20 streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\n getErc20StreamingEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<StreamingResult> => {\n return getErc20StreamingEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for multi-token period enforcer.\n *\n * @param params - The parameters for the multi-token period enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getMultiTokenPeriodEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getMultiTokenPeriodEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for native token period transfer enforcer.\n *\n * @param params - The parameters for the native token period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getNativeTokenPeriodTransferEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getNativeTokenPeriodTransferEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for native token streaming enforcer.\n *\n * @param params - The parameters for the native token streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\n getNativeTokenStreamingEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<StreamingResult> => {\n return getNativeTokenStreamingEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n });\n","import type { Client, Address, Hex } from 'viem';\nimport { isAddressEqual } from 'viem';\nimport { getCode } from 'viem/actions';\n\nimport type { SmartAccountsEnvironment } from '../types';\n\n// EIP-7702 delegation prefix (0xef0100)\nconst DELEGATION_PREFIX = '0xef0100' as const;\n\n/**\n * Parameters for checking if an account is delegated to the EIP-7702 implementation.\n */\nexport type IsValid7702ImplementationParameters = {\n /** The client to use for the query. */\n client: Client;\n /** The address to check for proper delegation. */\n accountAddress: Address;\n /** The SmartAccountsEnvironment containing contract addresses. */\n environment: SmartAccountsEnvironment;\n};\n\n/**\n * Extracts the delegated contract address from EIP-7702 delegation code.\n *\n * @param code - The code returned from getCode for a delegated account.\n * @returns The delegated contract address or null if not a valid delegation.\n */\nfunction extractDelegatedAddress(code: Hex | undefined): Address | null {\n if (code?.length !== 48) {\n // 0x (2 chars) + ef0100 (6 chars) + address (40 chars) = 48 chars\n return null;\n }\n\n if (!code.toLowerCase().startsWith(DELEGATION_PREFIX.toLowerCase())) {\n return null;\n }\n\n // Extract the 20-byte address after the delegation prefix\n const addressHex = code.slice(8); // Remove '0xef0100' prefix (8 chars)\n return `0x${addressHex}`;\n}\n\n/**\n * Checks if an account is properly delegated to the EIP-7702 implementation.\n *\n * This function validates EIP-7702 delegations by checking if the EOA has a 7702\n * contract assigned to it and comparing the delegated address against the 7702\n * implementation found in the environment.\n *\n * @param params - The parameters for checking the delegation.\n * @param params.client - The client to use for the query.\n * @param params.accountAddress - The address to check for proper delegation.\n * @param params.environment - The SmartAccountsEnvironment containing contract addresses.\n * @returns A promise that resolves to true if the account is properly delegated to the 7702 implementation, false otherwise.\n * @example\n * ```typescript\n * const isValid = await isValid7702Implementation({\n * client: publicClient,\n * accountAddress: '0x...',\n * environment: smartAccountEnvironment,\n * });\n *\n * if (isValid) {\n * console.log('Account is properly delegated to EIP-7702 implementation');\n * } else {\n * console.log('Account is not properly delegated');\n * }\n * ```\n */\nexport async function isValid7702Implementation({\n client,\n accountAddress,\n environment,\n}: IsValid7702ImplementationParameters): Promise<boolean> {\n try {\n // Get the code at the account address\n const code = await getCode(client, {\n address: accountAddress,\n });\n\n // Extract the delegated contract address from the EIP-7702 delegation code\n const delegatedAddress = extractDelegatedAddress(code);\n\n // If no valid delegation found, return false\n if (!delegatedAddress) {\n return false;\n }\n\n // Compare the delegated address with the 7702 implementation in the environment\n const expectedImplementation =\n environment.implementations.EIP7702StatelessDeleGatorImpl;\n if (!expectedImplementation) {\n return false;\n }\n\n return isAddressEqual(delegatedAddress, expectedImplementation);\n } catch {\n // If the call fails (e.g., no code at address, network error),\n // then it's not properly delegated to our implementation\n return false;\n }\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n Transport,\n WalletClient,\n} from 'viem';\nimport { BaseError } from 'viem';\nimport { parseAccount } from 'viem/accounts';\n\nimport { prepareSignUserOperationTypedData } from '../userOp';\nimport type { UserOperationV07 } from '../userOp';\n\nexport type SignUserOperationParameters = {\n /** Account to sign with */\n account?: Account | Address;\n /** The user operation to sign */\n userOperation: Omit<UserOperationV07, 'signature'>;\n /** The entry point contract address */\n entryPoint: { address: Address };\n /** The chain ID that the entry point is deployed on */\n chainId: number;\n /** The address of the smart account */\n address: Address;\n /** The name of the domain of the implementation contract */\n name: 'HybridDeleGator' | 'MultiSigDeleGator';\n /** The version of the domain of the implementation contract */\n version?: string;\n};\n\nexport type SignUserOperationReturnType = Hex;\n\n/**\n * Signs a user operation using a wallet client.\n *\n * @param client - The wallet client to use for signing.\n * @param parameters - The parameters for signing the user operation.\n * @returns The signature of the user operation.\n * @example\n * ```ts\n * const signature = await signUserOperation(walletClient, {\n * userOperation: {\n * sender: '0x...',\n * nonce: 0n,\n * callData: '0x',\n * callGasLimit: 1000000n,\n * verificationGasLimit: 1000000n,\n * preVerificationGas: 21000n,\n * maxFeePerGas: 1000000000n,\n * maxPriorityFeePerGas: 1000000000n\n * },\n * entryPoint: { address: '0x...' },\n * chainId: 1,\n * address: '0x...',\n * name: 'HybridDeleGator'\n * });\n * ```\n */\nexport async function signUserOperation<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n parameters: SignUserOperationParameters,\n): Promise<SignUserOperationReturnType> {\n const {\n account: accountParam = client.account,\n userOperation,\n entryPoint,\n chainId,\n name,\n address,\n version = '1',\n } = parameters;\n\n if (!accountParam) {\n throw new BaseError('Account not found. Please provide an account.');\n }\n\n const account = parseAccount(accountParam);\n\n const typedData = prepareSignUserOperationTypedData({\n userOperation,\n entryPoint,\n chainId,\n name,\n address,\n version,\n });\n\n return client.signTypedData({\n account,\n ...typedData,\n });\n}\n\n/**\n * Creates a sign user operation action that can be used to extend a wallet client.\n *\n * @returns A function that can be used with wallet client extend method.\n * @example\n * ```ts\n * const walletClient = createWalletClient({\n * chain: mainnet,\n * transport: http()\n * }).extend(signUserOperationActions());\n * ```\n */\nexport function signUserOperationActions() {\n return <\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n >(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n ) => ({\n signUserOperation: async (\n parameters: Omit<SignUserOperationParameters, 'chainId'> & {\n chainId?: number;\n },\n ) =>\n signUserOperation(client, {\n chainId:\n parameters.chainId ??\n (() => {\n if (!client.chain?.id) {\n throw new BaseError(\n 'Chain ID is required. Either provide it in parameters or configure the client with a chain.',\n );\n }\n return client.chain.id;\n })(),\n ...parameters,\n }),\n });\n}\n"]}
@@ -5,14 +5,14 @@ import {
5
5
  encode4,
6
6
  encode5,
7
7
  encodeProxyCreationCode
8
- } from "./chunk-ZGBFPD4O.mjs";
8
+ } from "./chunk-W7O2UQL5.mjs";
9
9
  import {
10
10
  createExecution,
11
11
  encodeExecutionCalldatas
12
12
  } from "./chunk-4QXIOE7F.mjs";
13
13
  import {
14
14
  encodeDelegations
15
- } from "./chunk-EEIIVBNV.mjs";
15
+ } from "./chunk-MV2KHN75.mjs";
16
16
 
17
17
  // src/counterfactualAccountData.ts
18
18
  import { getContractAddress, pad } from "viem";
@@ -255,4 +255,4 @@ export {
255
255
  encodeDeleGatorSignature,
256
256
  createDummyWebAuthnSignature
257
257
  };
258
- //# sourceMappingURL=chunk-FG2CQGSE.mjs.map
258
+ //# sourceMappingURL=chunk-YXHUT56Z.mjs.map
@@ -14,21 +14,21 @@
14
14
 
15
15
 
16
16
 
17
- var _chunkRR2AMG4Acjs = require('../chunk-RR2AMG4A.cjs');
17
+ var _chunkDN4O5VOPcjs = require('../chunk-DN4O5VOP.cjs');
18
18
 
19
19
 
20
20
 
21
21
 
22
22
 
23
23
 
24
- var _chunkXZ7UMCG3cjs = require('../chunk-XZ7UMCG3.cjs');
24
+ var _chunk7FYDQNJ3cjs = require('../chunk-7FYDQNJ3.cjs');
25
25
 
26
26
 
27
27
 
28
28
 
29
- var _chunkSO5JAXGDcjs = require('../chunk-SO5JAXGD.cjs');
29
+ var _chunkFH6HZCHIcjs = require('../chunk-FH6HZCHI.cjs');
30
30
  require('../chunk-MOHCTPYQ.cjs');
31
- require('../chunk-TMO23YRP.cjs');
31
+ require('../chunk-IBZSNB7D.cjs');
32
32
 
33
33
 
34
34
 
@@ -53,5 +53,5 @@ require('../chunk-TMO23YRP.cjs');
53
53
 
54
54
 
55
55
 
56
- exports.DeleGatorCore = _chunkRR2AMG4Acjs.DeleGatorCore_exports; exports.DelegationManager = _chunkRR2AMG4Acjs.DelegationManager_exports; exports.EIP712 = _chunkRR2AMG4Acjs.EIP712_exports; exports.ERC20PeriodTransferEnforcer = _chunkXZ7UMCG3cjs.ERC20PeriodTransferEnforcer_exports; exports.ERC20StreamingEnforcer = _chunkXZ7UMCG3cjs.ERC20StreamingEnforcer_exports; exports.ERC20TransferAmountEnforcer = _chunkRR2AMG4Acjs.ERC20TransferAmountEnforcer_exports; exports.EntryPoint = _chunkRR2AMG4Acjs.EntryPoint_exports; exports.HybridDeleGator = _chunkRR2AMG4Acjs.HybridDeleGator_exports; exports.IdEnforcer = _chunkRR2AMG4Acjs.IdEnforcer_exports; exports.LimitedCallsEnforcer = _chunkRR2AMG4Acjs.LimitedCallsEnforcer_exports; exports.MultiSigDeleGator = _chunkRR2AMG4Acjs.MultiSigDeleGator_exports; exports.MultiTokenPeriodEnforcer = _chunkXZ7UMCG3cjs.MultiTokenPeriodEnforcer_exports; exports.NativeTokenPeriodTransferEnforcer = _chunkXZ7UMCG3cjs.NativeTokenPeriodTransferEnforcer_exports; exports.NativeTokenStreamingEnforcer = _chunkXZ7UMCG3cjs.NativeTokenStreamingEnforcer_exports; exports.NativeTokenTransferAmountEnforcer = _chunkRR2AMG4Acjs.NativeTokenTransferAmountEnforcer_exports; exports.NonceEnforcer = _chunkRR2AMG4Acjs.NonceEnforcer_exports; exports.Ownable2Step = _chunkRR2AMG4Acjs.Ownable2Step_exports; exports.Pausable = _chunkRR2AMG4Acjs.Pausable_exports; exports.SimpleFactory = _chunkRR2AMG4Acjs.SimpleFactory_exports; exports.SpecificActionERC20TransferBatchEnforcer = _chunkRR2AMG4Acjs.SpecificActionERC20TransferBatchEnforcer_exports; exports.encodeProxyCreationCode = _chunkSO5JAXGDcjs.encodeProxyCreationCode; exports.isContractDeployed = _chunkSO5JAXGDcjs.isContractDeployed; exports.isImplementationExpected = _chunkSO5JAXGDcjs.isImplementationExpected;
56
+ exports.DeleGatorCore = _chunkDN4O5VOPcjs.DeleGatorCore_exports; exports.DelegationManager = _chunkDN4O5VOPcjs.DelegationManager_exports; exports.EIP712 = _chunkDN4O5VOPcjs.EIP712_exports; exports.ERC20PeriodTransferEnforcer = _chunk7FYDQNJ3cjs.ERC20PeriodTransferEnforcer_exports; exports.ERC20StreamingEnforcer = _chunk7FYDQNJ3cjs.ERC20StreamingEnforcer_exports; exports.ERC20TransferAmountEnforcer = _chunkDN4O5VOPcjs.ERC20TransferAmountEnforcer_exports; exports.EntryPoint = _chunkDN4O5VOPcjs.EntryPoint_exports; exports.HybridDeleGator = _chunkDN4O5VOPcjs.HybridDeleGator_exports; exports.IdEnforcer = _chunkDN4O5VOPcjs.IdEnforcer_exports; exports.LimitedCallsEnforcer = _chunkDN4O5VOPcjs.LimitedCallsEnforcer_exports; exports.MultiSigDeleGator = _chunkDN4O5VOPcjs.MultiSigDeleGator_exports; exports.MultiTokenPeriodEnforcer = _chunk7FYDQNJ3cjs.MultiTokenPeriodEnforcer_exports; exports.NativeTokenPeriodTransferEnforcer = _chunk7FYDQNJ3cjs.NativeTokenPeriodTransferEnforcer_exports; exports.NativeTokenStreamingEnforcer = _chunk7FYDQNJ3cjs.NativeTokenStreamingEnforcer_exports; exports.NativeTokenTransferAmountEnforcer = _chunkDN4O5VOPcjs.NativeTokenTransferAmountEnforcer_exports; exports.NonceEnforcer = _chunkDN4O5VOPcjs.NonceEnforcer_exports; exports.Ownable2Step = _chunkDN4O5VOPcjs.Ownable2Step_exports; exports.Pausable = _chunkDN4O5VOPcjs.Pausable_exports; exports.SimpleFactory = _chunkDN4O5VOPcjs.SimpleFactory_exports; exports.SpecificActionERC20TransferBatchEnforcer = _chunkDN4O5VOPcjs.SpecificActionERC20TransferBatchEnforcer_exports; exports.encodeProxyCreationCode = _chunkFH6HZCHIcjs.encodeProxyCreationCode; exports.isContractDeployed = _chunkFH6HZCHIcjs.isContractDeployed; exports.isImplementationExpected = _chunkFH6HZCHIcjs.isImplementationExpected;
57
57
  //# sourceMappingURL=index.cjs.map
@@ -1,8 +1,9 @@
1
- export { a as DeleGatorCore, b as DelegationManager, c as EIP712, d as ERC20PeriodTransferEnforcer, e as ERC20StreamingEnforcer, f as ERC20TransferAmountEnforcer, g as EntryPoint, h as HybridDeleGator, j as IdEnforcer, I as InitializedClient, k as LimitedCallsEnforcer, l as MultiSigDeleGator, m as MultiTokenPeriodEnforcer, n as NativeTokenPeriodTransferEnforcer, o as NativeTokenStreamingEnforcer, p as NativeTokenTransferAmountEnforcer, q as NonceEnforcer, r as Ownable2Step, P as P256Owner, s as Pausable, t as SimpleFactory, u as SpecificActionERC20TransferBatchEnforcer, v as encodeProxyCreationCode, w as isContractDeployed, x as isImplementationExpected } from '../index-DzL9ccjU.cjs';
1
+ export { a as DeleGatorCore, b as DelegationManager, c as EIP712, d as ERC20PeriodTransferEnforcer, e as ERC20StreamingEnforcer, f as ERC20TransferAmountEnforcer, g as EntryPoint, h as HybridDeleGator, j as IdEnforcer, I as InitializedClient, k as LimitedCallsEnforcer, l as MultiSigDeleGator, m as MultiTokenPeriodEnforcer, n as NativeTokenPeriodTransferEnforcer, o as NativeTokenStreamingEnforcer, p as NativeTokenTransferAmountEnforcer, q as NonceEnforcer, r as Ownable2Step, P as P256Owner, s as Pausable, t as SimpleFactory, u as SpecificActionERC20TransferBatchEnforcer, v as encodeProxyCreationCode, w as isContractDeployed, x as isImplementationExpected } from '../index-yU3olCJV.cjs';
2
2
  import '@metamask/delegation-core';
3
3
  import 'viem';
4
- import '../delegation-DoVULGYE.cjs';
4
+ import '../delegation-BKkEyxZY.cjs';
5
5
  import '../types-BWaH4KH1.cjs';
6
6
  import '@metamask/delegation-abis';
7
7
  import 'viem/account-abstraction';
8
8
  import 'viem/chains';
9
+ import '../resolveCaveats-DiqGB-T5.cjs';
@@ -1,8 +1,9 @@
1
- export { a as DeleGatorCore, b as DelegationManager, c as EIP712, d as ERC20PeriodTransferEnforcer, e as ERC20StreamingEnforcer, f as ERC20TransferAmountEnforcer, g as EntryPoint, h as HybridDeleGator, j as IdEnforcer, I as InitializedClient, k as LimitedCallsEnforcer, l as MultiSigDeleGator, m as MultiTokenPeriodEnforcer, n as NativeTokenPeriodTransferEnforcer, o as NativeTokenStreamingEnforcer, p as NativeTokenTransferAmountEnforcer, q as NonceEnforcer, r as Ownable2Step, P as P256Owner, s as Pausable, t as SimpleFactory, u as SpecificActionERC20TransferBatchEnforcer, v as encodeProxyCreationCode, w as isContractDeployed, x as isImplementationExpected } from '../index-DRKgDSZW.js';
1
+ export { a as DeleGatorCore, b as DelegationManager, c as EIP712, d as ERC20PeriodTransferEnforcer, e as ERC20StreamingEnforcer, f as ERC20TransferAmountEnforcer, g as EntryPoint, h as HybridDeleGator, j as IdEnforcer, I as InitializedClient, k as LimitedCallsEnforcer, l as MultiSigDeleGator, m as MultiTokenPeriodEnforcer, n as NativeTokenPeriodTransferEnforcer, o as NativeTokenStreamingEnforcer, p as NativeTokenTransferAmountEnforcer, q as NonceEnforcer, r as Ownable2Step, P as P256Owner, s as Pausable, t as SimpleFactory, u as SpecificActionERC20TransferBatchEnforcer, v as encodeProxyCreationCode, w as isContractDeployed, x as isImplementationExpected } from '../index-DXdlz7t4.js';
2
2
  import '@metamask/delegation-core';
3
3
  import 'viem';
4
- import '../delegation-CR99q1-n.js';
4
+ import '../delegation-DbPGWKfP.js';
5
5
  import '../types-BWaH4KH1.js';
6
6
  import '@metamask/delegation-abis';
7
7
  import 'viem/account-abstraction';
8
8
  import 'viem/chains';
9
+ import '../resolveCaveats-s2snaFEo.js';
@@ -14,21 +14,21 @@ import {
14
14
  Pausable_exports,
15
15
  SimpleFactory_exports,
16
16
  SpecificActionERC20TransferBatchEnforcer_exports
17
- } from "../chunk-HQHXGWNJ.mjs";
17
+ } from "../chunk-TBHT26BV.mjs";
18
18
  import {
19
19
  ERC20PeriodTransferEnforcer_exports,
20
20
  ERC20StreamingEnforcer_exports,
21
21
  MultiTokenPeriodEnforcer_exports,
22
22
  NativeTokenPeriodTransferEnforcer_exports,
23
23
  NativeTokenStreamingEnforcer_exports
24
- } from "../chunk-DVJX76J3.mjs";
24
+ } from "../chunk-N66VAWMO.mjs";
25
25
  import {
26
26
  encodeProxyCreationCode,
27
27
  isContractDeployed,
28
28
  isImplementationExpected
29
- } from "../chunk-ZGBFPD4O.mjs";
29
+ } from "../chunk-W7O2UQL5.mjs";
30
30
  import "../chunk-4QXIOE7F.mjs";
31
- import "../chunk-EEIIVBNV.mjs";
31
+ import "../chunk-MV2KHN75.mjs";
32
32
  export {
33
33
  DeleGatorCore_exports as DeleGatorCore,
34
34
  DelegationManager_exports as DelegationManager,
@@ -0,0 +1,64 @@
1
+ import { Hex, Address, AbiParameter, TypedData } from 'viem';
2
+ import { S as SmartAccountsEnvironment, D as Delegation, P as PermissionContext } from './types-BWaH4KH1.cjs';
3
+ import { C as Caveats, S as ScopeConfig } from './resolveCaveats-DiqGB-T5.cjs';
4
+
5
+ declare const DELEGATION_ABI_TYPE_COMPONENTS: ({
6
+ type: string;
7
+ name: string;
8
+ components?: undefined;
9
+ } | {
10
+ type: string;
11
+ name: string;
12
+ components: {
13
+ type: string;
14
+ name: string;
15
+ }[];
16
+ })[];
17
+ declare const toDelegationStruct: (delegation: Delegation) => DelegationStruct;
18
+ declare const toDelegation: (delegationStruct: DelegationStruct) => Delegation;
19
+ type DelegationStruct = Omit<Delegation, 'salt'> & {
20
+ salt: bigint;
21
+ };
22
+ declare const encodeDelegations: (delegations: PermissionContext) => Hex;
23
+ declare const encodeDelegation: (delegation: Delegation) => Hex;
24
+ declare const decodeDelegations: (delegations: PermissionContext) => Delegation[];
25
+ declare const decodeDelegation: (encoded: Hex) => Delegation;
26
+ declare const SIGNABLE_DELEGATION_TYPED_DATA: TypedData;
27
+ declare const DELEGATION_ARRAY_ABI_TYPE: AbiParameter;
28
+ declare const DELEGATION_ABI_TYPE: AbiParameter;
29
+ declare const hashDelegation: (input: Delegation) => Hex;
30
+ type BaseCreateDelegationOptions = {
31
+ environment: SmartAccountsEnvironment;
32
+ from: Hex;
33
+ caveats?: Caveats;
34
+ salt?: Hex;
35
+ } & ({
36
+ scope: ScopeConfig;
37
+ parentDelegation?: never;
38
+ parentPermissionContext?: never;
39
+ } | {
40
+ scope?: ScopeConfig;
41
+ parentDelegation: Delegation | Hex;
42
+ parentPermissionContext?: never;
43
+ } | {
44
+ scope?: ScopeConfig;
45
+ parentDelegation?: never;
46
+ parentPermissionContext: PermissionContext;
47
+ });
48
+ type CreateDelegationOptions = BaseCreateDelegationOptions & {
49
+ to: Hex;
50
+ };
51
+ type CreateOpenDelegationOptions = BaseCreateDelegationOptions;
52
+ declare const createDelegation: (options: CreateDelegationOptions) => Delegation;
53
+ declare const createOpenDelegation: (options: CreateOpenDelegationOptions) => Delegation;
54
+ declare const signDelegation: ({ privateKey, delegation, delegationManager, chainId, name, version, allowInsecureUnrestrictedDelegation, }: {
55
+ privateKey: Hex;
56
+ delegation: Omit<Delegation, "signature">;
57
+ delegationManager: Address;
58
+ chainId: number;
59
+ name?: string;
60
+ version?: string;
61
+ allowInsecureUnrestrictedDelegation?: boolean;
62
+ }) => Promise<`0x${string}`>;
63
+
64
+ export { type CreateDelegationOptions as C, DELEGATION_ABI_TYPE as D, SIGNABLE_DELEGATION_TYPED_DATA as S, type CreateOpenDelegationOptions as a, createOpenDelegation as b, createDelegation as c, DELEGATION_ABI_TYPE_COMPONENTS as d, DELEGATION_ARRAY_ABI_TYPE as e, type DelegationStruct as f, decodeDelegation as g, decodeDelegations as h, encodeDelegation as i, encodeDelegations as j, hashDelegation as k, toDelegationStruct as l, signDelegation as s, toDelegation as t };
@@ -0,0 +1,64 @@
1
+ import { Hex, Address, AbiParameter, TypedData } from 'viem';
2
+ import { S as SmartAccountsEnvironment, D as Delegation, P as PermissionContext } from './types-BWaH4KH1.js';
3
+ import { C as Caveats, S as ScopeConfig } from './resolveCaveats-s2snaFEo.js';
4
+
5
+ declare const DELEGATION_ABI_TYPE_COMPONENTS: ({
6
+ type: string;
7
+ name: string;
8
+ components?: undefined;
9
+ } | {
10
+ type: string;
11
+ name: string;
12
+ components: {
13
+ type: string;
14
+ name: string;
15
+ }[];
16
+ })[];
17
+ declare const toDelegationStruct: (delegation: Delegation) => DelegationStruct;
18
+ declare const toDelegation: (delegationStruct: DelegationStruct) => Delegation;
19
+ type DelegationStruct = Omit<Delegation, 'salt'> & {
20
+ salt: bigint;
21
+ };
22
+ declare const encodeDelegations: (delegations: PermissionContext) => Hex;
23
+ declare const encodeDelegation: (delegation: Delegation) => Hex;
24
+ declare const decodeDelegations: (delegations: PermissionContext) => Delegation[];
25
+ declare const decodeDelegation: (encoded: Hex) => Delegation;
26
+ declare const SIGNABLE_DELEGATION_TYPED_DATA: TypedData;
27
+ declare const DELEGATION_ARRAY_ABI_TYPE: AbiParameter;
28
+ declare const DELEGATION_ABI_TYPE: AbiParameter;
29
+ declare const hashDelegation: (input: Delegation) => Hex;
30
+ type BaseCreateDelegationOptions = {
31
+ environment: SmartAccountsEnvironment;
32
+ from: Hex;
33
+ caveats?: Caveats;
34
+ salt?: Hex;
35
+ } & ({
36
+ scope: ScopeConfig;
37
+ parentDelegation?: never;
38
+ parentPermissionContext?: never;
39
+ } | {
40
+ scope?: ScopeConfig;
41
+ parentDelegation: Delegation | Hex;
42
+ parentPermissionContext?: never;
43
+ } | {
44
+ scope?: ScopeConfig;
45
+ parentDelegation?: never;
46
+ parentPermissionContext: PermissionContext;
47
+ });
48
+ type CreateDelegationOptions = BaseCreateDelegationOptions & {
49
+ to: Hex;
50
+ };
51
+ type CreateOpenDelegationOptions = BaseCreateDelegationOptions;
52
+ declare const createDelegation: (options: CreateDelegationOptions) => Delegation;
53
+ declare const createOpenDelegation: (options: CreateOpenDelegationOptions) => Delegation;
54
+ declare const signDelegation: ({ privateKey, delegation, delegationManager, chainId, name, version, allowInsecureUnrestrictedDelegation, }: {
55
+ privateKey: Hex;
56
+ delegation: Omit<Delegation, "signature">;
57
+ delegationManager: Address;
58
+ chainId: number;
59
+ name?: string;
60
+ version?: string;
61
+ allowInsecureUnrestrictedDelegation?: boolean;
62
+ }) => Promise<`0x${string}`>;
63
+
64
+ export { type CreateDelegationOptions as C, DELEGATION_ABI_TYPE as D, SIGNABLE_DELEGATION_TYPED_DATA as S, type CreateOpenDelegationOptions as a, createOpenDelegation as b, createDelegation as c, DELEGATION_ABI_TYPE_COMPONENTS as d, DELEGATION_ARRAY_ABI_TYPE as e, type DelegationStruct as f, decodeDelegation as g, decodeDelegations as h, encodeDelegation as i, encodeDelegations as j, hashDelegation as k, toDelegationStruct as l, signDelegation as s, toDelegation as t };
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
- var _chunkTMO23YRPcjs = require('../chunk-TMO23YRP.cjs');
4
+ var _chunkIBZSNB7Dcjs = require('../chunk-IBZSNB7D.cjs');
5
5
 
6
6
  // src/experimental/delegationStorage.ts
7
7
  var _viem = require('viem');
@@ -22,7 +22,7 @@ var DelegationStorageClient = class {
22
22
  #apiUrl;
23
23
  constructor(config) {
24
24
  const { apiUrl } = config.environment;
25
- _chunkTMO23YRPcjs.trackSmartAccountsKitFunctionCall.call(void 0,
25
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
26
26
  "experimental.DelegationStorageClient.constructor",
27
27
  {
28
28
  environment: getDelegationStorageEnvironment(apiUrl)
@@ -68,13 +68,13 @@ var DelegationStorageClient = class {
68
68
  * is not found.
69
69
  */
70
70
  async getDelegationChain(leafDelegationOrDelegationHash) {
71
- _chunkTMO23YRPcjs.trackSmartAccountsKitFunctionCall.call(void 0,
71
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
72
72
  "experimental.DelegationStorageClient.getDelegationChain",
73
73
  {
74
74
  inputKind: typeof leafDelegationOrDelegationHash === "string" ? "hash" : "delegation"
75
75
  }
76
76
  );
77
- const leafDelegationHash = typeof leafDelegationOrDelegationHash === "string" ? leafDelegationOrDelegationHash : _chunkTMO23YRPcjs.hashDelegation.call(void 0, leafDelegationOrDelegationHash);
77
+ const leafDelegationHash = typeof leafDelegationOrDelegationHash === "string" ? leafDelegationOrDelegationHash : _chunkIBZSNB7Dcjs.hashDelegation.call(void 0, leafDelegationOrDelegationHash);
78
78
  const response = await this.#fetcher(
79
79
  `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,
80
80
  {
@@ -104,7 +104,7 @@ var DelegationStorageClient = class {
104
104
  * empty array if the delegations are not found.
105
105
  */
106
106
  async fetchDelegations(deleGatorAddress, filterMode = "RECEIVED" /* Received */) {
107
- _chunkTMO23YRPcjs.trackSmartAccountsKitFunctionCall.call(void 0,
107
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
108
108
  "experimental.DelegationStorageClient.fetchDelegations",
109
109
  { filterMode }
110
110
  );
@@ -131,14 +131,14 @@ var DelegationStorageClient = class {
131
131
  * @returns A promise that resolves to the delegation hash indicating successful storage.
132
132
  */
133
133
  async storeDelegation(delegation) {
134
- _chunkTMO23YRPcjs.trackSmartAccountsKitFunctionCall.call(void 0,
134
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
135
135
  "experimental.DelegationStorageClient.storeDelegation",
136
136
  { caveatCount: delegation.caveats.length }
137
137
  );
138
138
  if (!delegation.signature || delegation.signature === "0x") {
139
139
  throw new Error("Delegation must be signed to be stored");
140
140
  }
141
- const delegationHash = _chunkTMO23YRPcjs.hashDelegation.call(void 0, delegation);
141
+ const delegationHash = _chunkIBZSNB7Dcjs.hashDelegation.call(void 0, delegation);
142
142
  const body = JSON.stringify(
143
143
  {
144
144
  ...delegation,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  hashDelegation,
3
3
  trackSmartAccountsKitFunctionCall
4
- } from "../chunk-EEIIVBNV.mjs";
4
+ } from "../chunk-MV2KHN75.mjs";
5
5
 
6
6
  // src/experimental/delegationStorage.ts
7
7
  import { toHex } from "viem";
@@ -1,8 +1,9 @@
1
1
  import { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
2
2
  import * as viem from 'viem';
3
3
  import { Client, Transport, Chain, Account, Address, Hex } from 'viem';
4
- import { m as DelegationStruct, E as ExecutionMode, d as ExecutionStruct } from './delegation-CR99q1-n.js';
4
+ import { f as DelegationStruct } from './delegation-DbPGWKfP.js';
5
5
  import { D as Delegation, P as PermissionContext } from './types-BWaH4KH1.js';
6
+ import { E as ExecutionMode, b as ExecutionStruct } from './resolveCaveats-s2snaFEo.js';
6
7
 
7
8
  declare const NAME$1 = "DelegationManager";
8
9
  declare const VERSION$1 = "1.3.0";