@metamask/smart-accounts-kit 1.3.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 (61) hide show
  1. package/CHANGELOG.md +20 -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-Cey0wm33.d.cts → caveats-CaSt_VHs.d.cts} +1 -1
  8. package/dist/{caveats-CQbtzOKm.d.ts → caveats-DQ6HoAHe.d.ts} +1 -1
  9. package/dist/{chunk-GZ7HHI2D.cjs → chunk-7FYDQNJ3.cjs} +12 -12
  10. package/dist/{chunk-GZ7HHI2D.cjs.map → chunk-7FYDQNJ3.cjs.map} +1 -1
  11. package/dist/{chunk-FKI4OME5.mjs → chunk-BGOSYTKV.mjs} +254 -60
  12. package/dist/chunk-BGOSYTKV.mjs.map +1 -0
  13. package/dist/{chunk-57I2FJY7.cjs → chunk-DN4O5VOP.cjs} +102 -102
  14. package/dist/{chunk-57I2FJY7.cjs.map → chunk-DN4O5VOP.cjs.map} +1 -1
  15. package/dist/{chunk-DLCTHNAE.cjs → chunk-FH6HZCHI.cjs} +11 -11
  16. package/dist/{chunk-DLCTHNAE.cjs.map → chunk-FH6HZCHI.cjs.map} +1 -1
  17. package/dist/{chunk-SZOX7K2V.cjs → chunk-IBZSNB7D.cjs} +81 -33
  18. package/dist/chunk-IBZSNB7D.cjs.map +1 -0
  19. package/dist/{chunk-Z4D7ZWVB.mjs → chunk-MV2KHN75.mjs} +84 -36
  20. package/dist/chunk-MV2KHN75.mjs.map +1 -0
  21. package/dist/{chunk-AC2BQSYP.mjs → chunk-N66VAWMO.mjs} +2 -2
  22. package/dist/{chunk-3PBVHNYP.cjs → chunk-SCS3CFRE.cjs} +10 -10
  23. package/dist/{chunk-3PBVHNYP.cjs.map → chunk-SCS3CFRE.cjs.map} +1 -1
  24. package/dist/{chunk-26PADMXR.mjs → chunk-TBHT26BV.mjs} +4 -4
  25. package/dist/{chunk-KBSFVKUB.mjs → chunk-W7O2UQL5.mjs} +2 -2
  26. package/dist/{chunk-AJWMPR7X.cjs → chunk-XEOE25DE.cjs} +298 -104
  27. package/dist/chunk-XEOE25DE.cjs.map +1 -0
  28. package/dist/{chunk-LQXOM3TA.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-D2THBlfm.d.ts → index-DXdlz7t4.d.ts} +2 -1
  38. package/dist/{index-BDC55AA9.d.cts → index-DfDAuvr5.d.cts} +58 -5
  39. package/dist/{index-DhG2lH80.d.ts → index-G78z6nwi.d.ts} +58 -5
  40. package/dist/{index-DE87r5KY.d.cts → index-yU3olCJV.d.cts} +2 -1
  41. package/dist/index.cjs +22 -20
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +7 -6
  44. package/dist/index.d.ts +7 -6
  45. package/dist/index.mjs +9 -7
  46. package/dist/index.mjs.map +1 -1
  47. package/dist/{delegation-Bx4FEAIU.d.ts → resolveCaveats-DiqGB-T5.d.cts} +4 -57
  48. package/dist/{delegation-KbWHzRxV.d.cts → resolveCaveats-s2snaFEo.d.ts} +4 -57
  49. package/dist/utils/index.cjs +4 -4
  50. package/dist/utils/index.d.cts +3 -2
  51. package/dist/utils/index.d.ts +3 -2
  52. package/dist/utils/index.mjs +3 -3
  53. package/package.json +4 -4
  54. package/dist/chunk-AJWMPR7X.cjs.map +0 -1
  55. package/dist/chunk-FKI4OME5.mjs.map +0 -1
  56. package/dist/chunk-SZOX7K2V.cjs.map +0 -1
  57. package/dist/chunk-Z4D7ZWVB.mjs.map +0 -1
  58. /package/dist/{chunk-AC2BQSYP.mjs.map → chunk-N66VAWMO.mjs.map} +0 -0
  59. /package/dist/{chunk-26PADMXR.mjs.map → chunk-TBHT26BV.mjs.map} +0 -0
  60. /package/dist/{chunk-KBSFVKUB.mjs.map → chunk-W7O2UQL5.mjs.map} +0 -0
  61. /package/dist/{chunk-LQXOM3TA.mjs.map → chunk-YXHUT56Z.mjs.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,14 +1,15 @@
1
1
  import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './types-BWaH4KH1.cjs';
2
2
  export { A as AccountSignerConfig, C as Caveat, b as CaveatType, D as Delegation, H as HybridDeleGatorDeployParams, c as HybridSignerConfig, M as MetaMaskSmartAccount, d as MetaMaskSmartAccountImplementation, e as MultiSigDeleGatorDeployParams, f as MultiSigSignerConfig, P as PermissionContext, g as ScopeType, h as SignDelegationParams, i as SignUserOperationParams, j as TransferWindow, W as WalletSignerConfig, k as WebAuthnSignerConfig } from './types-BWaH4KH1.cjs';
3
- export { B as BalanceChangeType, C as Caveats, a as CreateDelegationOptions, b as CreateExecutionArgs, c as CreateOpenDelegationOptions, E as ExecutionMode, d as ExecutionStruct, e as createDelegation, f as createExecution, g as createOpenDelegation, s as signDelegation } from './delegation-KbWHzRxV.cjs';
4
- export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-Cey0wm33.cjs';
3
+ export { C as CreateDelegationOptions, a as CreateOpenDelegationOptions, c as createDelegation, b as createOpenDelegation, s as signDelegation } from './delegation-BKkEyxZY.cjs';
4
+ export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-CaSt_VHs.cjs';
5
+ export { C as Caveats, a as CreateExecutionArgs, E as ExecutionMode, b as ExecutionStruct, c as createExecution } from './resolveCaveats-DiqGB-T5.cjs';
6
+ export { ANY_BENEFICIARY, BalanceChangeType, ROOT_AUTHORITY } from '@metamask/delegation-core';
5
7
  import { Address, Hex, Transport, Chain, Account, Client } from 'viem';
6
8
  export { s as signUserOperation } from './userOp-DKgjzz7B.cjs';
7
- export { i as contracts } from './index-DE87r5KY.cjs';
8
- import { c as caveatEnforcerActions } from './index-BDC55AA9.cjs';
9
- export { i as actions } from './index-BDC55AA9.cjs';
9
+ export { i as contracts } from './index-yU3olCJV.cjs';
10
+ import { c as caveatEnforcerActions } from './index-DfDAuvr5.cjs';
11
+ export { i as actions } from './index-DfDAuvr5.cjs';
10
12
  import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
11
- export { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
12
13
  import '@metamask/delegation-abis';
13
14
  import 'viem/chains';
14
15
  import '@metamask/7715-permission-types';
package/dist/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './types-BWaH4KH1.js';
2
2
  export { A as AccountSignerConfig, C as Caveat, b as CaveatType, D as Delegation, H as HybridDeleGatorDeployParams, c as HybridSignerConfig, M as MetaMaskSmartAccount, d as MetaMaskSmartAccountImplementation, e as MultiSigDeleGatorDeployParams, f as MultiSigSignerConfig, P as PermissionContext, g as ScopeType, h as SignDelegationParams, i as SignUserOperationParams, j as TransferWindow, W as WalletSignerConfig, k as WebAuthnSignerConfig } from './types-BWaH4KH1.js';
3
- export { B as BalanceChangeType, C as Caveats, a as CreateDelegationOptions, b as CreateExecutionArgs, c as CreateOpenDelegationOptions, E as ExecutionMode, d as ExecutionStruct, e as createDelegation, f as createExecution, g as createOpenDelegation, s as signDelegation } from './delegation-Bx4FEAIU.js';
4
- export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-CQbtzOKm.js';
3
+ export { C as CreateDelegationOptions, a as CreateOpenDelegationOptions, c as createDelegation, b as createOpenDelegation, s as signDelegation } from './delegation-DbPGWKfP.js';
4
+ export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-DQ6HoAHe.js';
5
+ export { C as Caveats, a as CreateExecutionArgs, E as ExecutionMode, b as ExecutionStruct, c as createExecution } from './resolveCaveats-s2snaFEo.js';
6
+ export { ANY_BENEFICIARY, BalanceChangeType, ROOT_AUTHORITY } from '@metamask/delegation-core';
5
7
  import { Address, Hex, Transport, Chain, Account, Client } from 'viem';
6
8
  export { s as signUserOperation } from './userOp-DKgjzz7B.js';
7
- export { i as contracts } from './index-D2THBlfm.js';
8
- import { c as caveatEnforcerActions } from './index-DhG2lH80.js';
9
- export { i as actions } from './index-DhG2lH80.js';
9
+ export { i as contracts } from './index-DXdlz7t4.js';
10
+ import { c as caveatEnforcerActions } from './index-G78z6nwi.js';
11
+ export { i as actions } from './index-G78z6nwi.js';
10
12
  import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
11
- export { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
12
13
  import '@metamask/delegation-abis';
13
14
  import 'viem/chains';
14
15
  import '@metamask/7715-permission-types';
package/dist/index.mjs CHANGED
@@ -2,31 +2,30 @@ import {
2
2
  actions_exports,
3
3
  caveatEnforcerActions,
4
4
  isValid7702Implementation
5
- } from "./chunk-FKI4OME5.mjs";
5
+ } from "./chunk-BGOSYTKV.mjs";
6
6
  import {
7
7
  contracts_exports
8
- } from "./chunk-26PADMXR.mjs";
9
- import "./chunk-AC2BQSYP.mjs";
8
+ } from "./chunk-TBHT26BV.mjs";
9
+ import "./chunk-N66VAWMO.mjs";
10
10
  import {
11
11
  createDummyWebAuthnSignature,
12
12
  encodeCallsForCaller,
13
13
  encodeDeleGatorSignature,
14
14
  getCounterfactualAccountData
15
- } from "./chunk-LQXOM3TA.mjs";
15
+ } from "./chunk-YXHUT56Z.mjs";
16
16
  import {
17
17
  PREFERRED_VERSION,
18
18
  SIGNABLE_USER_OP_TYPED_DATA,
19
19
  getSmartAccountsEnvironment,
20
20
  signUserOperation
21
21
  } from "./chunk-QCULIK3O.mjs";
22
- import "./chunk-KBSFVKUB.mjs";
22
+ import "./chunk-W7O2UQL5.mjs";
23
23
  import {
24
24
  ExecutionMode,
25
25
  createExecution
26
26
  } from "./chunk-4QXIOE7F.mjs";
27
27
  import {
28
28
  ANY_BENEFICIARY,
29
- BalanceChangeType,
30
29
  CaveatType,
31
30
  Implementation,
32
31
  ROOT_AUTHORITY,
@@ -39,7 +38,7 @@ import {
39
38
  signDelegation,
40
39
  toDelegationStruct,
41
40
  trackSmartAccountsKitFunctionCall
42
- } from "./chunk-Z4D7ZWVB.mjs";
41
+ } from "./chunk-MV2KHN75.mjs";
43
42
 
44
43
  // src/toMetaMaskSmartAccount.ts
45
44
  import {
@@ -393,6 +392,9 @@ async function toMetaMaskSmartAccount(params) {
393
392
  return smartAccount;
394
393
  }
395
394
 
395
+ // src/index.ts
396
+ import { BalanceChangeType } from "@metamask/delegation-core";
397
+
396
398
  // src/actions/caveatEnforcerClient.ts
397
399
  function createCaveatEnforcerClient({
398
400
  client,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/toMetaMaskSmartAccount.ts","../src/signer.ts","../src/signatures.ts","../src/actions/caveatEnforcerClient.ts","../src/actions/infuraBundlerClient.ts"],"sourcesContent":["import {\n EIP7702StatelessDeleGator,\n HybridDeleGator,\n MultiSigDeleGator,\n} from '@metamask/delegation-abis';\nimport { type Address, type Hex } from 'viem';\nimport {\n entryPoint07Abi,\n toPackedUserOperation,\n toSmartAccount,\n} from 'viem/account-abstraction';\n\nimport { isValid7702Implementation } from './actions/isValid7702Implementation';\nimport { trackSmartAccountsKitFunctionCall } from './analytics';\nimport { Implementation } from './constants';\nimport { getCounterfactualAccountData } from './counterfactualAccountData';\nimport {\n SIGNABLE_DELEGATION_TYPED_DATA,\n toDelegationStruct,\n} from './delegation';\nimport { encodeCallsForCaller } from './encodeCalls';\nimport { resolveSigner } from './signer';\nimport { getSmartAccountsEnvironment } from './smartAccountsEnvironment';\nimport type {\n Call,\n ToMetaMaskSmartAccountParameters,\n ToMetaMaskSmartAccountReturnType,\n SignDelegationParams,\n SignUserOperationParams,\n AbiByImplementation,\n} from './types';\nimport { SIGNABLE_USER_OP_TYPED_DATA } from './userOp';\n\nconst ENTRYPOINT_VERSION = '0.7' as const;\n\n/**\n * Creates a MetaMask DeleGator smart account instance.\n *\n * @template TImplementation - The type of implementation, extending Implementation.\n * @param params - The parameters for creating the smart account.\n * @returns A promise that resolves to a MetaMaskSmartAccount instance.\n * @description\n * This function sets up a MetaMask DeleGator smart account with the specified implementation.\n * It handles both deployed accounts, and counterfactual accounts.\n * A caller may specify a SmartAccountsEnvironment, otherwise the environment will be inferred from the chain.\n */\nexport async function toMetaMaskSmartAccount<\n TImplementation extends Implementation,\n>(\n params: ToMetaMaskSmartAccountParameters<TImplementation>,\n): Promise<ToMetaMaskSmartAccountReturnType<TImplementation>> {\n const {\n client,\n client: { chain },\n implementation,\n nonceKeyManager,\n } = params;\n\n trackSmartAccountsKitFunctionCall('toMetaMaskSmartAccount', {\n implementation,\n hasAddress: params.address !== undefined,\n hasEnvironment: params.environment !== undefined,\n chainId: chain?.id ?? null,\n });\n\n if (!chain) {\n throw new Error('Chain not specified');\n }\n\n const signer = resolveSigner({\n implementation,\n signer: params.signer,\n });\n\n const environment =\n params.environment ?? getSmartAccountsEnvironment(chain.id);\n\n let address: Address, factoryData: Hex | undefined;\n\n if (params.address) {\n factoryData = undefined;\n address = params.address;\n } else {\n if (implementation === Implementation.Stateless7702) {\n throw new Error('Stateless7702 does not support counterfactual accounts');\n }\n\n const accountData = await getCounterfactualAccountData({\n factory: environment.SimpleFactory,\n implementations: environment.implementations,\n implementation,\n deployParams: params.deployParams,\n deploySalt: params.deploySalt,\n });\n\n address = accountData.address;\n factoryData = accountData.factoryData;\n }\n\n const entryPoint = {\n abi: entryPoint07Abi,\n address: environment.EntryPoint,\n version: ENTRYPOINT_VERSION,\n } as const;\n\n const { abi, contractName } = {\n [Implementation.Hybrid]: {\n contractName: 'HybridDeleGator',\n abi: HybridDeleGator,\n },\n [Implementation.MultiSig]: {\n contractName: 'MultiSigDeleGator',\n abi: MultiSigDeleGator,\n },\n [Implementation.Stateless7702]: {\n contractName: 'EIP7702StatelessDeleGator',\n abi: EIP7702StatelessDeleGator,\n },\n }[implementation] as {\n contractName: string;\n abi: AbiByImplementation[TImplementation];\n };\n\n const getFactoryArgs = async () => {\n if (factoryData === undefined) {\n throw new Error(\n 'Deploy params were not provided, so factory args cannot be inferred',\n );\n }\n return {\n factoryData,\n factory: environment.SimpleFactory,\n };\n };\n\n const signDelegation = async (delegationParams: SignDelegationParams) => {\n if (!signer) {\n throw new Error(\n 'Cannot sign delegation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n }\n\n const { delegation, chainId } = delegationParams;\n\n const delegationStruct = toDelegationStruct({\n ...delegation,\n signature: '0x',\n });\n\n const signature = await signer.signTypedData({\n domain: {\n chainId: chainId ?? chain.id,\n name: 'DelegationManager',\n version: '1',\n verifyingContract: environment.DelegationManager,\n },\n types: SIGNABLE_DELEGATION_TYPED_DATA,\n primaryType: 'Delegation',\n message: delegationStruct,\n });\n\n return signature;\n };\n\n const signUserOperation = async (userOpParams: SignUserOperationParams) => {\n if (!signer) {\n throw new Error(\n 'Cannot sign user operation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n }\n\n const { chainId } = userOpParams;\n\n const packedUserOp = toPackedUserOperation({\n sender: address,\n ...userOpParams,\n signature: '0x',\n });\n\n const signature = await signer.signTypedData({\n domain: {\n chainId: chainId ?? chain.id,\n name: contractName,\n version: '1',\n verifyingContract: address,\n },\n types: SIGNABLE_USER_OP_TYPED_DATA,\n primaryType: 'PackedUserOperation',\n message: { ...packedUserOp, entryPoint: entryPoint.address },\n });\n\n return signature;\n };\n\n const getAddress = async () => address;\n\n const encodeCalls = async (calls: readonly Call[]) =>\n encodeCallsForCaller(address, calls);\n\n const signerMethods = signer ?? {\n signMessage: async () => {\n throw new Error(\n 'Cannot sign message: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n signTypedData: async () => {\n throw new Error(\n 'Cannot sign typed data: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n getStubSignature: async () => {\n throw new Error(\n 'Cannot get stub signature: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n };\n\n const smartAccount = await toSmartAccount({\n abi,\n client,\n entryPoint,\n environment,\n getAddress,\n getFactoryArgs,\n encodeCalls,\n signUserOperation,\n signDelegation,\n nonceKeyManager,\n ...signerMethods,\n });\n\n // Override isDeployed only for EIP-7702 implementation to check proper delegation code\n if (implementation === Implementation.Stateless7702) {\n return {\n ...smartAccount,\n isDeployed: async () =>\n isValid7702Implementation({\n client,\n accountAddress: address,\n environment,\n }),\n };\n }\n\n // For other implementations, use the default isDeployed behavior\n return smartAccount;\n}\n","import { concat } from 'viem';\nimport type {\n Address,\n SignableMessage,\n TypedData,\n TypedDataDefinition,\n} from 'viem';\nimport type { WebAuthnAccount } from 'viem/account-abstraction';\n\nimport { Implementation } from './constants';\nimport { aggregateSignature } from './signatures';\nimport type {\n AccountSignerConfig,\n HybridSignerConfig,\n InternalSigner,\n MultiSigSignerConfig,\n SignerConfigByImplementation,\n Stateless7702SignerConfig,\n WalletSignerConfig,\n} from './types';\nimport {\n createDummyWebAuthnSignature,\n encodeDeleGatorSignature,\n} from './webAuthn';\n\n// A valid ECDSA signature, this must be able to ecrecover an address, otherwise the contracts will revert in isValidSignature\nconst EOA_STUB_SIGNATURE =\n '0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000011b' as const;\n\nconst resolveSignerFromWalletConfig = (\n config: WalletSignerConfig,\n): InternalSigner => {\n return {\n signMessage: config.walletClient.signMessage,\n signTypedData: async (typedData) => {\n // todo: figure out this type so that we don't need the type assertion\n return config.walletClient.signTypedData(typedData as any);\n },\n getStubSignature: async () => EOA_STUB_SIGNATURE,\n };\n};\n\nconst resolveSignerFromAccountConfig = (config: AccountSignerConfig) => {\n return {\n signMessage: config.account.signMessage,\n signTypedData: config.account.signTypedData,\n getStubSignature: async () => EOA_STUB_SIGNATURE,\n };\n};\n\nconst resolveHybridSigner = (config: HybridSignerConfig): InternalSigner => {\n if ('walletClient' in config) {\n return resolveSignerFromWalletConfig(config);\n } else if ('account' in config) {\n const { signMessage, signTypedData, getStubSignature } =\n resolveSignerFromAccountConfig(config);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n }\n const { keyId, webAuthnAccount } = config;\n\n if (webAuthnAccount.type !== 'webAuthn') {\n throw new Error('Account is not a webAuthn account');\n }\n\n const encodeSignature = (\n result: Awaited<ReturnType<WebAuthnAccount['signMessage']>>,\n ) =>\n encodeDeleGatorSignature(\n keyId,\n result.signature,\n result.webauthn.clientDataJSON,\n result.webauthn.authenticatorData,\n );\n\n const signMessage = async (args: { message: SignableMessage }) =>\n webAuthnAccount.signMessage(args).then(encodeSignature);\n const signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(\n typedDataDefinition: TypedDataDefinition<TTypedData, TPrimaryType>,\n ) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);\n\n const getStubSignature = async () => createDummyWebAuthnSignature(keyId);\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n};\n\nconst resolveMultiSigSigner = (\n config: MultiSigSignerConfig,\n): InternalSigner => {\n const resolvedSigners = config.map((signer) => {\n let individualSignMessage: InternalSigner['signMessage'];\n let individualSignTypedData: InternalSigner['signTypedData'];\n let address: Address;\n if ('walletClient' in signer) {\n const { signMessage, signTypedData } =\n resolveSignerFromWalletConfig(signer);\n individualSignMessage = signMessage;\n individualSignTypedData = signTypedData;\n\n address = signer.walletClient.account.address;\n } else {\n const { signMessage, signTypedData } =\n resolveSignerFromAccountConfig(signer);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n\n individualSignMessage = signMessage;\n individualSignTypedData = signTypedData;\n\n address = signer.account.address;\n }\n return {\n address,\n individualSignMessage,\n individualSignTypedData,\n };\n });\n\n const signMessage = async (args: { message: SignableMessage }) => {\n const addressAndSignatures = resolvedSigners.map(\n async ({ individualSignMessage, address }) => ({\n signature: await individualSignMessage(args),\n signer: address,\n type: 'ECDSA' as const,\n }),\n );\n\n const signatures = await Promise.all(addressAndSignatures);\n\n return aggregateSignature({\n signatures,\n });\n };\n\n const signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(\n typedDataDefinition: TypedDataDefinition<TTypedData, TPrimaryType>,\n ) => {\n const addressAndSignatures = resolvedSigners.map(\n async ({ individualSignTypedData, address }) => ({\n signature: await individualSignTypedData(typedDataDefinition),\n signer: address,\n type: 'ECDSA' as const,\n }),\n );\n\n const signatures = await Promise.all(addressAndSignatures);\n\n return aggregateSignature({\n signatures,\n });\n };\n\n const getStubSignature = async () =>\n concat(resolvedSigners.map(() => EOA_STUB_SIGNATURE));\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n};\n\nconst resolveStateless7702Signer = (\n config: Stateless7702SignerConfig,\n): InternalSigner => {\n if ('walletClient' in config) {\n return resolveSignerFromWalletConfig(config);\n } else if ('account' in config) {\n const { signMessage, signTypedData, getStubSignature } =\n resolveSignerFromAccountConfig(config);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n }\n\n throw new Error('Invalid signer config');\n};\n\n/**\n * Resolve a signer from a configuration object.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner;\n\n/**\n * Resolve a signer from a configuration object. If no signer is provided, return null.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer or null if no signer is provided.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer?: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner | null;\n\n/**\n * Resolve a signer from a configuration object. If no signer is provided, return null.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer or null if no signer is provided.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer?: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner | null {\n const { implementation, signer } = config;\n\n if (!signer) {\n return null;\n }\n\n if (implementation === Implementation.Hybrid) {\n return resolveHybridSigner(signer as HybridSignerConfig);\n } else if (implementation === Implementation.MultiSig) {\n return resolveMultiSigSigner(signer as MultiSigSignerConfig);\n } else if (implementation === Implementation.Stateless7702) {\n return resolveStateless7702Signer(signer as Stateless7702SignerConfig);\n }\n throw new Error(`Implementation type '${implementation}' not supported`);\n}\n","import type { Address, Hex } from 'viem';\nimport { concat } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from './analytics';\n\nconst signatureTypes = ['ECDSA'] as const;\n\nexport type SignatureType = (typeof signatureTypes)[number];\n\n/**\n * Represents a partial signature that can be aggregated with others.\n */\nexport type PartialSignature = {\n signer: Address;\n signature: Hex;\n type: SignatureType;\n};\n\n/**\n * Aggregates signatures into a single signature as expected by the MultiSig implementation.\n *\n * @param params - The parameters for signature aggregation.\n * @param params.signatures - The array of partial signatures to aggregate.\n * @returns The aggregated signature.\n */\nexport const aggregateSignature = ({\n signatures,\n}: {\n signatures: PartialSignature[];\n}): Hex => {\n trackSmartAccountsKitFunctionCall('aggregateSignature', {\n signatureCount: signatures.length,\n });\n\n if (signatures.length === 0) {\n return '0x';\n }\n\n for (const { type } of signatures) {\n if (!signatureTypes.includes(type)) {\n throw new Error(`Invalid signature type: ${type}`);\n }\n }\n\n // Sort signatures by signer address as required by MultiSig implementation\n const sortedSignatures = [...signatures].sort((a, b) =>\n a.signer.localeCompare(b.signer),\n );\n\n // Concatenate all signatures\n return concat(sortedSignatures.map(({ signature }) => signature));\n};\n\n/**\n * Type definition for the aggregateSignature function parameters.\n */\nexport type AggregateSignatureParams = {\n signatures: PartialSignature[];\n};\n","import type { Client, Transport, Chain, Account } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport type { SmartAccountsEnvironment } from '../types';\nimport {\n caveatEnforcerActions,\n type CaveatEnforcerParams,\n type PeriodTransferResult,\n type StreamingResult,\n} from './getCaveatAvailableAmount';\n\n/**\n * Type for client extended with caveat enforcer actions.\n */\nexport type CaveatEnforcerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n> = Client<TTransport, TChain, TAccount> &\n ReturnType<ReturnType<typeof caveatEnforcerActions>>;\n\n/**\n * Create a viem client extended with caveat enforcer actions.\n *\n * @param params - The parameters object.\n * @param params.client - The viem client.\n * @param params.environment - The SmartAccountsEnvironment.\n * @returns The extended client with caveat enforcer actions.\n */\nexport function createCaveatEnforcerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n>({\n client,\n environment,\n}: {\n client: Client<TTransport, TChain, TAccount>;\n environment: SmartAccountsEnvironment;\n}): CaveatEnforcerClient<TTransport, TChain, TAccount> {\n trackSmartAccountsKitFunctionCall('createCaveatEnforcerClient', {\n chainId: client.chain?.id ?? null,\n });\n\n return client.extend(caveatEnforcerActions({ environment }));\n}\n\n// Re-export types for convenience\nexport type { CaveatEnforcerParams, PeriodTransferResult, StreamingResult };\n","import type { Transport, Chain, Hex, Client, Account } from 'viem';\nimport {\n createBundlerClient,\n type BundlerClient,\n type BundlerClientConfig,\n type SmartAccount,\n} from 'viem/account-abstraction';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\n\n/**\n * Gas price tiers returned by pimlico_getUserOperationGasPrice\n */\nexport type GasPriceTier = {\n /** Maximum fee per gas in hex format */\n maxFeePerGas: Hex;\n /** Maximum priority fee per gas in hex format */\n maxPriorityFeePerGas: Hex;\n};\n\n/**\n * Response from pimlico_getUserOperationGasPrice RPC method\n */\nexport type UserOperationGasPriceResponse = {\n /** Slow gas price tier */\n slow: GasPriceTier;\n /** Standard gas price tier */\n standard: GasPriceTier;\n /** Fast gas price tier */\n fast: GasPriceTier;\n};\n\n/**\n * Pimlico bundler schema for type-safe RPC method calls\n */\n/* eslint-disable @typescript-eslint/naming-convention */\ntype PimlicoBundlerSchema = [\n {\n Method: 'pimlico_getUserOperationGasPrice';\n Parameters: [];\n ReturnType: UserOperationGasPriceResponse;\n },\n];\n\n/**\n * Infura bundler actions for extending bundler clients.\n *\n * @returns A function that takes a client and returns the client extension with Infura bundler actions.\n */\nconst infuraBundlerActions = () => (client: Client) => ({\n /**\n * Get user operation gas prices from Infura bundler.\n * Calls the pimlico_getUserOperationGasPrice RPC method.\n *\n * @returns Promise resolving to gas price tiers (slow, standard, fast).\n * @example\n * ```typescript\n * const gasPrices = await bundlerClient.getUserOperationGasPrice();\n * console.log(gasPrices.standard.maxFeePerGas);\n * ```\n */\n async getUserOperationGasPrice(): Promise<UserOperationGasPriceResponse> {\n const pimlicoClient = client as Client<\n Transport,\n Chain | undefined,\n Account | undefined,\n PimlicoBundlerSchema\n >;\n\n return await pimlicoClient.request({\n method: 'pimlico_getUserOperationGasPrice',\n params: [],\n });\n },\n});\n\n/**\n * Type for bundler client extended with Infura bundler actions.\n */\nexport type InfuraBundlerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n> = BundlerClient<TTransport, TChain, TAccount> & {\n /**\n * Get user operation gas prices from Infura bundler.\n * Calls the pimlico_getUserOperationGasPrice RPC method.\n *\n * @returns Promise resolving to gas price tiers (slow, standard, fast).\n */\n getUserOperationGasPrice(): Promise<UserOperationGasPriceResponse>;\n};\n\n/**\n * Creates an Infura bundler client extended with Infura bundler actions.\n *\n * This is a wrapper around viem's createBundlerClient that extends it with\n * the getUserOperationGasPrice method for retrieving gas prices from Pimlico's\n * bundler infrastructure via Infura's proxy.\n *\n * @param config - Configuration for the bundler client.\n * @returns Extended bundler client with Infura bundler actions.\n * @example\n * ```typescript\n * import { createPublicClient, http } from 'viem';\n * import { sepolia } from 'viem/chains';\n * import { createInfuraBundlerClient } from '@metamask/smart-accounts-kit';\n *\n * const publicClient = createPublicClient({\n * chain: sepolia,\n * transport: http('https://sepolia.infura.io/v3/YOUR_API_KEY'),\n * });\n *\n * const bundlerClient = createInfuraBundlerClient({\n * client: publicClient,\n * transport: http('https://sepolia.infura.io/v3/YOUR_API_KEY'),\n * chain: sepolia,\n * });\n *\n * // Use standard bundler methods\n * const userOpHash = await bundlerClient.sendUserOperation({...});\n *\n * // Use Infura specific methods\n * const gasPrices = await bundlerClient.getUserOperationGasPrice();\n * ```\n */\nexport function createInfuraBundlerClient<\n TTransport extends Transport,\n TChain extends Chain | undefined = undefined,\n TAccount extends SmartAccount | undefined = undefined,\n>(\n config: BundlerClientConfig<TTransport, TChain, TAccount>,\n): InfuraBundlerClient<TTransport, TChain, TAccount> {\n trackSmartAccountsKitFunctionCall('createInfuraBundlerClient', {\n chainId: config.chain?.id ?? null,\n });\n // Create the base bundler client using viem's function\n const baseBundlerClient = createBundlerClient(config);\n\n // Extend the client with Infura bundler actions\n return baseBundlerClient.extend(\n infuraBundlerActions(),\n ) as unknown as InfuraBundlerClient<TTransport, TChain, TAccount>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACVP,SAAS,UAAAA,eAAc;;;ACCvB,SAAS,cAAc;AAIvB,IAAM,iBAAiB,CAAC,OAAO;AAoBxB,IAAM,qBAAqB,CAAC;AAAA,EACjC;AACF,MAEW;AACT,oCAAkC,sBAAsB;AAAA,IACtD,gBAAgB,WAAW;AAAA,EAC7B,CAAC;AAED,MAAI,WAAW,WAAW,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,aAAW,EAAE,KAAK,KAAK,YAAY;AACjC,QAAI,CAAC,eAAe,SAAS,IAAI,GAAG;AAClC,YAAM,IAAI,MAAM,2BAA2B,IAAI,EAAE;AAAA,IACnD;AAAA,EACF;AAGA,QAAM,mBAAmB,CAAC,GAAG,UAAU,EAAE;AAAA,IAAK,CAAC,GAAG,MAChD,EAAE,OAAO,cAAc,EAAE,MAAM;AAAA,EACjC;AAGA,SAAO,OAAO,iBAAiB,IAAI,CAAC,EAAE,UAAU,MAAM,SAAS,CAAC;AAClE;;;ADzBA,IAAM,qBACJ;AAEF,IAAM,gCAAgC,CACpC,WACmB;AACnB,SAAO;AAAA,IACL,aAAa,OAAO,aAAa;AAAA,IACjC,eAAe,OAAO,cAAc;AAElC,aAAO,OAAO,aAAa,cAAc,SAAgB;AAAA,IAC3D;AAAA,IACA,kBAAkB,YAAY;AAAA,EAChC;AACF;AAEA,IAAM,iCAAiC,CAAC,WAAgC;AACtE,SAAO;AAAA,IACL,aAAa,OAAO,QAAQ;AAAA,IAC5B,eAAe,OAAO,QAAQ;AAAA,IA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A,MACF,CAAC;AAAA,IACL;AAAA,EACF;AAGA,SAAO;AACT;;;AGzNO,SAAS,2BAId;AAAA,EACA;AAAA,EACA;AACF,GAGuD;AACrD,oCAAkC,8BAA8B;AAAA,IAC9D,SAAS,OAAO,OAAO,MAAM;AAAA,EAC/B,CAAC;AAED,SAAO,OAAO,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC;AAC7D;;;AC5CA;AAAA,EACE;AAAA,OAIK;AA2CP,IAAM,uBAAuB,MAAM,CAAC,YAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYtD,MAAM,2BAAmE;AACvE,UAAM,gBAAgB;AAOtB,WAAO,MAAM,cAAc,QAAQ;AAAA,MACjC,QAAQ;AAAA,MACR,QAAQ,CAAC;AAAA,IACX,CAAC;AAAA,EACH;AACF;AAoDO,SAAS,0BAKd,QACmD;AACnD,oCAAkC,6BAA6B;AAAA,IAC7D,SAAS,OAAO,OAAO,MAAM;AAAA,EAC/B,CAAC;AAED,QAAM,oBAAoB,oBAAoB,MAAM;AAGpD,SAAO,kBAAkB;AAAA,IACvB,qBAAqB;AAAA,EACvB;AACF;","names":["concat","signMessage","signTypedData","getStubSignature","concat","signDelegation","signUserOperation"]}
1
+ {"version":3,"sources":["../src/toMetaMaskSmartAccount.ts","../src/signer.ts","../src/signatures.ts","../src/index.ts","../src/actions/caveatEnforcerClient.ts","../src/actions/infuraBundlerClient.ts"],"sourcesContent":["import {\n EIP7702StatelessDeleGator,\n HybridDeleGator,\n MultiSigDeleGator,\n} from '@metamask/delegation-abis';\nimport { type Address, type Hex } from 'viem';\nimport {\n entryPoint07Abi,\n toPackedUserOperation,\n toSmartAccount,\n} from 'viem/account-abstraction';\n\nimport { isValid7702Implementation } from './actions/isValid7702Implementation';\nimport { trackSmartAccountsKitFunctionCall } from './analytics';\nimport { Implementation } from './constants';\nimport { getCounterfactualAccountData } from './counterfactualAccountData';\nimport {\n SIGNABLE_DELEGATION_TYPED_DATA,\n toDelegationStruct,\n} from './delegation';\nimport { encodeCallsForCaller } from './encodeCalls';\nimport { resolveSigner } from './signer';\nimport { getSmartAccountsEnvironment } from './smartAccountsEnvironment';\nimport type {\n Call,\n ToMetaMaskSmartAccountParameters,\n ToMetaMaskSmartAccountReturnType,\n SignDelegationParams,\n SignUserOperationParams,\n AbiByImplementation,\n} from './types';\nimport { SIGNABLE_USER_OP_TYPED_DATA } from './userOp';\n\nconst ENTRYPOINT_VERSION = '0.7' as const;\n\n/**\n * Creates a MetaMask DeleGator smart account instance.\n *\n * @template TImplementation - The type of implementation, extending Implementation.\n * @param params - The parameters for creating the smart account.\n * @returns A promise that resolves to a MetaMaskSmartAccount instance.\n * @description\n * This function sets up a MetaMask DeleGator smart account with the specified implementation.\n * It handles both deployed accounts, and counterfactual accounts.\n * A caller may specify a SmartAccountsEnvironment, otherwise the environment will be inferred from the chain.\n */\nexport async function toMetaMaskSmartAccount<\n TImplementation extends Implementation,\n>(\n params: ToMetaMaskSmartAccountParameters<TImplementation>,\n): Promise<ToMetaMaskSmartAccountReturnType<TImplementation>> {\n const {\n client,\n client: { chain },\n implementation,\n nonceKeyManager,\n } = params;\n\n trackSmartAccountsKitFunctionCall('toMetaMaskSmartAccount', {\n implementation,\n hasAddress: params.address !== undefined,\n hasEnvironment: params.environment !== undefined,\n chainId: chain?.id ?? null,\n });\n\n if (!chain) {\n throw new Error('Chain not specified');\n }\n\n const signer = resolveSigner({\n implementation,\n signer: params.signer,\n });\n\n const environment =\n params.environment ?? getSmartAccountsEnvironment(chain.id);\n\n let address: Address, factoryData: Hex | undefined;\n\n if (params.address) {\n factoryData = undefined;\n address = params.address;\n } else {\n if (implementation === Implementation.Stateless7702) {\n throw new Error('Stateless7702 does not support counterfactual accounts');\n }\n\n const accountData = await getCounterfactualAccountData({\n factory: environment.SimpleFactory,\n implementations: environment.implementations,\n implementation,\n deployParams: params.deployParams,\n deploySalt: params.deploySalt,\n });\n\n address = accountData.address;\n factoryData = accountData.factoryData;\n }\n\n const entryPoint = {\n abi: entryPoint07Abi,\n address: environment.EntryPoint,\n version: ENTRYPOINT_VERSION,\n } as const;\n\n const { abi, contractName } = {\n [Implementation.Hybrid]: {\n contractName: 'HybridDeleGator',\n abi: HybridDeleGator,\n },\n [Implementation.MultiSig]: {\n contractName: 'MultiSigDeleGator',\n abi: MultiSigDeleGator,\n },\n [Implementation.Stateless7702]: {\n contractName: 'EIP7702StatelessDeleGator',\n abi: EIP7702StatelessDeleGator,\n },\n }[implementation] as {\n contractName: string;\n abi: AbiByImplementation[TImplementation];\n };\n\n const getFactoryArgs = async () => {\n if (factoryData === undefined) {\n throw new Error(\n 'Deploy params were not provided, so factory args cannot be inferred',\n );\n }\n return {\n factoryData,\n factory: environment.SimpleFactory,\n };\n };\n\n const signDelegation = async (delegationParams: SignDelegationParams) => {\n if (!signer) {\n throw new Error(\n 'Cannot sign delegation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n }\n\n const { delegation, chainId } = delegationParams;\n\n const delegationStruct = toDelegationStruct({\n ...delegation,\n signature: '0x',\n });\n\n const signature = await signer.signTypedData({\n domain: {\n chainId: chainId ?? chain.id,\n name: 'DelegationManager',\n version: '1',\n verifyingContract: environment.DelegationManager,\n },\n types: SIGNABLE_DELEGATION_TYPED_DATA,\n primaryType: 'Delegation',\n message: delegationStruct,\n });\n\n return signature;\n };\n\n const signUserOperation = async (userOpParams: SignUserOperationParams) => {\n if (!signer) {\n throw new Error(\n 'Cannot sign user operation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n }\n\n const { chainId } = userOpParams;\n\n const packedUserOp = toPackedUserOperation({\n sender: address,\n ...userOpParams,\n signature: '0x',\n });\n\n const signature = await signer.signTypedData({\n domain: {\n chainId: chainId ?? chain.id,\n name: contractName,\n version: '1',\n verifyingContract: address,\n },\n types: SIGNABLE_USER_OP_TYPED_DATA,\n primaryType: 'PackedUserOperation',\n message: { ...packedUserOp, entryPoint: entryPoint.address },\n });\n\n return signature;\n };\n\n const getAddress = async () => address;\n\n const encodeCalls = async (calls: readonly Call[]) =>\n encodeCallsForCaller(address, calls);\n\n const signerMethods = signer ?? {\n signMessage: async () => {\n throw new Error(\n 'Cannot sign message: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n signTypedData: async () => {\n throw new Error(\n 'Cannot sign typed data: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n getStubSignature: async () => {\n throw new Error(\n 'Cannot get stub signature: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n };\n\n const smartAccount = await toSmartAccount({\n abi,\n client,\n entryPoint,\n environment,\n getAddress,\n getFactoryArgs,\n encodeCalls,\n signUserOperation,\n signDelegation,\n nonceKeyManager,\n ...signerMethods,\n });\n\n // Override isDeployed only for EIP-7702 implementation to check proper delegation code\n if (implementation === Implementation.Stateless7702) {\n return {\n ...smartAccount,\n isDeployed: async () =>\n isValid7702Implementation({\n client,\n accountAddress: address,\n environment,\n }),\n };\n }\n\n // For other implementations, use the default isDeployed behavior\n return smartAccount;\n}\n","import { concat } from 'viem';\nimport type {\n Address,\n SignableMessage,\n TypedData,\n TypedDataDefinition,\n} from 'viem';\nimport type { WebAuthnAccount } from 'viem/account-abstraction';\n\nimport { Implementation } from './constants';\nimport { aggregateSignature } from './signatures';\nimport type {\n AccountSignerConfig,\n HybridSignerConfig,\n InternalSigner,\n MultiSigSignerConfig,\n SignerConfigByImplementation,\n Stateless7702SignerConfig,\n WalletSignerConfig,\n} from './types';\nimport {\n createDummyWebAuthnSignature,\n encodeDeleGatorSignature,\n} from './webAuthn';\n\n// A valid ECDSA signature, this must be able to ecrecover an address, otherwise the contracts will revert in isValidSignature\nconst EOA_STUB_SIGNATURE =\n '0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000011b' as const;\n\nconst resolveSignerFromWalletConfig = (\n config: WalletSignerConfig,\n): InternalSigner => {\n return {\n signMessage: config.walletClient.signMessage,\n signTypedData: async (typedData) => {\n // todo: figure out this type so that we don't need the type assertion\n return config.walletClient.signTypedData(typedData as any);\n },\n getStubSignature: async () => EOA_STUB_SIGNATURE,\n };\n};\n\nconst resolveSignerFromAccountConfig = (config: AccountSignerConfig) => {\n return {\n signMessage: config.account.signMessage,\n signTypedData: config.account.signTypedData,\n getStubSignature: async () => EOA_STUB_SIGNATURE,\n };\n};\n\nconst resolveHybridSigner = (config: HybridSignerConfig): InternalSigner => {\n if ('walletClient' in config) {\n return resolveSignerFromWalletConfig(config);\n } else if ('account' in config) {\n const { signMessage, signTypedData, getStubSignature } =\n resolveSignerFromAccountConfig(config);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n }\n const { keyId, webAuthnAccount } = config;\n\n if (webAuthnAccount.type !== 'webAuthn') {\n throw new Error('Account is not a webAuthn account');\n }\n\n const encodeSignature = (\n result: Awaited<ReturnType<WebAuthnAccount['signMessage']>>,\n ) =>\n encodeDeleGatorSignature(\n keyId,\n result.signature,\n result.webauthn.clientDataJSON,\n result.webauthn.authenticatorData,\n );\n\n const signMessage = async (args: { message: SignableMessage }) =>\n webAuthnAccount.signMessage(args).then(encodeSignature);\n const signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(\n typedDataDefinition: TypedDataDefinition<TTypedData, TPrimaryType>,\n ) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);\n\n const getStubSignature = async () => createDummyWebAuthnSignature(keyId);\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n};\n\nconst resolveMultiSigSigner = (\n config: MultiSigSignerConfig,\n): InternalSigner => {\n const resolvedSigners = config.map((signer) => {\n let individualSignMessage: InternalSigner['signMessage'];\n let individualSignTypedData: InternalSigner['signTypedData'];\n let address: Address;\n if ('walletClient' in signer) {\n const { signMessage, signTypedData } =\n resolveSignerFromWalletConfig(signer);\n individualSignMessage = signMessage;\n individualSignTypedData = signTypedData;\n\n address = signer.walletClient.account.address;\n } else {\n const { signMessage, signTypedData } =\n resolveSignerFromAccountConfig(signer);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n\n individualSignMessage = signMessage;\n individualSignTypedData = signTypedData;\n\n address = signer.account.address;\n }\n return {\n address,\n individualSignMessage,\n individualSignTypedData,\n };\n });\n\n const signMessage = async (args: { message: SignableMessage }) => {\n const addressAndSignatures = resolvedSigners.map(\n async ({ individualSignMessage, address }) => ({\n signature: await individualSignMessage(args),\n signer: address,\n type: 'ECDSA' as const,\n }),\n );\n\n const signatures = await Promise.all(addressAndSignatures);\n\n return aggregateSignature({\n signatures,\n });\n };\n\n const signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(\n typedDataDefinition: TypedDataDefinition<TTypedData, TPrimaryType>,\n ) => {\n const addressAndSignatures = resolvedSigners.map(\n async ({ individualSignTypedData, address }) => ({\n signature: await individualSignTypedData(typedDataDefinition),\n signer: address,\n type: 'ECDSA' as const,\n }),\n );\n\n const signatures = await Promise.all(addressAndSignatures);\n\n return aggregateSignature({\n signatures,\n });\n };\n\n const getStubSignature = async () =>\n concat(resolvedSigners.map(() => EOA_STUB_SIGNATURE));\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n};\n\nconst resolveStateless7702Signer = (\n config: Stateless7702SignerConfig,\n): InternalSigner => {\n if ('walletClient' in config) {\n return resolveSignerFromWalletConfig(config);\n } else if ('account' in config) {\n const { signMessage, signTypedData, getStubSignature } =\n resolveSignerFromAccountConfig(config);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n }\n\n throw new Error('Invalid signer config');\n};\n\n/**\n * Resolve a signer from a configuration object.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner;\n\n/**\n * Resolve a signer from a configuration object. If no signer is provided, return null.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer or null if no signer is provided.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer?: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner | null;\n\n/**\n * Resolve a signer from a configuration object. If no signer is provided, return null.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer or null if no signer is provided.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer?: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner | null {\n const { implementation, signer } = config;\n\n if (!signer) {\n return null;\n }\n\n if (implementation === Implementation.Hybrid) {\n return resolveHybridSigner(signer as HybridSignerConfig);\n } else if (implementation === Implementation.MultiSig) {\n return resolveMultiSigSigner(signer as MultiSigSignerConfig);\n } else if (implementation === Implementation.Stateless7702) {\n return resolveStateless7702Signer(signer as Stateless7702SignerConfig);\n }\n throw new Error(`Implementation type '${implementation}' not supported`);\n}\n","import type { Address, Hex } from 'viem';\nimport { concat } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from './analytics';\n\nconst signatureTypes = ['ECDSA'] as const;\n\nexport type SignatureType = (typeof signatureTypes)[number];\n\n/**\n * Represents a partial signature that can be aggregated with others.\n */\nexport type PartialSignature = {\n signer: Address;\n signature: Hex;\n type: SignatureType;\n};\n\n/**\n * Aggregates signatures into a single signature as expected by the MultiSig implementation.\n *\n * @param params - The parameters for signature aggregation.\n * @param params.signatures - The array of partial signatures to aggregate.\n * @returns The aggregated signature.\n */\nexport const aggregateSignature = ({\n signatures,\n}: {\n signatures: PartialSignature[];\n}): Hex => {\n trackSmartAccountsKitFunctionCall('aggregateSignature', {\n signatureCount: signatures.length,\n });\n\n if (signatures.length === 0) {\n return '0x';\n }\n\n for (const { type } of signatures) {\n if (!signatureTypes.includes(type)) {\n throw new Error(`Invalid signature type: ${type}`);\n }\n }\n\n // Sort signatures by signer address as required by MultiSig implementation\n const sortedSignatures = [...signatures].sort((a, b) =>\n a.signer.localeCompare(b.signer),\n );\n\n // Concatenate all signatures\n return concat(sortedSignatures.map(({ signature }) => signature));\n};\n\n/**\n * Type definition for the aggregateSignature function parameters.\n */\nexport type AggregateSignatureParams = {\n signatures: PartialSignature[];\n};\n","export { toMetaMaskSmartAccount } from './toMetaMaskSmartAccount';\n\nexport {\n createDelegation,\n createOpenDelegation,\n signDelegation,\n ROOT_AUTHORITY,\n ANY_BENEFICIARY,\n} from './delegation';\n\nexport type {\n CreateDelegationOptions,\n CreateOpenDelegationOptions,\n} from './delegation';\n\nexport type {\n SmartAccountsEnvironment,\n MultiSigDeleGatorDeployParams,\n HybridDeleGatorDeployParams,\n SignUserOperationParams,\n SignDelegationParams,\n MetaMaskSmartAccountImplementation,\n ToMetaMaskSmartAccountReturnType,\n MetaMaskSmartAccount,\n WalletSignerConfig,\n AccountSignerConfig,\n WebAuthnSignerConfig,\n HybridSignerConfig,\n MultiSigSignerConfig,\n Delegation,\n Caveat,\n PermissionContext,\n} from './types';\n\nexport {\n PREFERRED_VERSION,\n getSmartAccountsEnvironment,\n} from './smartAccountsEnvironment';\n\nexport {\n Implementation,\n TransferWindow,\n ScopeType,\n CaveatType,\n} from './constants';\n\nexport { createExecution, ExecutionMode } from './executions';\n\nexport type { ExecutionStruct, CreateExecutionArgs } from './executions';\n\nexport type { Caveats } from './caveatBuilder';\n\nexport { createCaveat } from './caveats';\n\nexport { BalanceChangeType } from '@metamask/delegation-core';\n\nexport { aggregateSignature } from './signatures';\n\nexport { type SignatureType, type PartialSignature } from './signatures';\n\nexport type { AggregateSignatureParams } from './signatures';\n\nexport { signUserOperation } from './userOp';\n\nexport * as contracts from './contracts';\n\nexport * as actions from './actions';\n\nexport {\n createCaveatEnforcerClient,\n type CaveatEnforcerClient,\n} from './actions/caveatEnforcerClient';\n\nexport {\n createInfuraBundlerClient,\n type InfuraBundlerClient,\n type GasPriceTier,\n type UserOperationGasPriceResponse,\n} from './actions/infuraBundlerClient';\n","import type { Client, Transport, Chain, Account } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport type { SmartAccountsEnvironment } from '../types';\nimport {\n caveatEnforcerActions,\n type CaveatEnforcerParams,\n type PeriodTransferResult,\n type StreamingResult,\n} from './getCaveatAvailableAmount';\n\n/**\n * Type for client extended with caveat enforcer actions.\n */\nexport type CaveatEnforcerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n> = Client<TTransport, TChain, TAccount> &\n ReturnType<ReturnType<typeof caveatEnforcerActions>>;\n\n/**\n * Create a viem client extended with caveat enforcer actions.\n *\n * @param params - The parameters object.\n * @param params.client - The viem client.\n * @param params.environment - The SmartAccountsEnvironment.\n * @returns The extended client with caveat enforcer actions.\n */\nexport function createCaveatEnforcerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n>({\n client,\n environment,\n}: {\n client: Client<TTransport, TChain, TAccount>;\n environment: SmartAccountsEnvironment;\n}): CaveatEnforcerClient<TTransport, TChain, TAccount> {\n trackSmartAccountsKitFunctionCall('createCaveatEnforcerClient', {\n chainId: client.chain?.id ?? null,\n });\n\n return client.extend(caveatEnforcerActions({ environment }));\n}\n\n// Re-export types for convenience\nexport type { CaveatEnforcerParams, PeriodTransferResult, StreamingResult };\n","import type { Transport, Chain, Hex, Client, Account } from 'viem';\nimport {\n createBundlerClient,\n type BundlerClient,\n type BundlerClientConfig,\n type SmartAccount,\n} from 'viem/account-abstraction';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\n\n/**\n * Gas price tiers returned by pimlico_getUserOperationGasPrice\n */\nexport type GasPriceTier = {\n /** Maximum fee per gas in hex format */\n maxFeePerGas: Hex;\n /** Maximum priority fee per gas in hex format */\n maxPriorityFeePerGas: Hex;\n};\n\n/**\n * Response from pimlico_getUserOperationGasPrice RPC method\n */\nexport type UserOperationGasPriceResponse = {\n /** Slow gas price tier */\n slow: GasPriceTier;\n /** Standard gas price tier */\n standard: GasPriceTier;\n /** Fast gas price tier */\n fast: GasPriceTier;\n};\n\n/**\n * Pimlico bundler schema for type-safe RPC method calls\n */\n/* eslint-disable @typescript-eslint/naming-convention */\ntype PimlicoBundlerSchema = [\n {\n Method: 'pimlico_getUserOperationGasPrice';\n Parameters: [];\n ReturnType: UserOperationGasPriceResponse;\n },\n];\n\n/**\n * Infura bundler actions for extending bundler clients.\n *\n * @returns A function that takes a client and returns the client extension with Infura bundler actions.\n */\nconst infuraBundlerActions = () => (client: Client) => ({\n /**\n * Get user operation gas prices from Infura bundler.\n * Calls the pimlico_getUserOperationGasPrice RPC method.\n *\n * @returns Promise resolving to gas price tiers (slow, standard, fast).\n * @example\n * ```typescript\n * const gasPrices = await bundlerClient.getUserOperationGasPrice();\n * console.log(gasPrices.standard.maxFeePerGas);\n * ```\n */\n async getUserOperationGasPrice(): Promise<UserOperationGasPriceResponse> {\n const pimlicoClient = client as Client<\n Transport,\n Chain | undefined,\n Account | undefined,\n PimlicoBundlerSchema\n >;\n\n return await pimlicoClient.request({\n method: 'pimlico_getUserOperationGasPrice',\n params: [],\n });\n },\n});\n\n/**\n * Type for bundler client extended with Infura bundler actions.\n */\nexport type InfuraBundlerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n> = BundlerClient<TTransport, TChain, TAccount> & {\n /**\n * Get user operation gas prices from Infura bundler.\n * Calls the pimlico_getUserOperationGasPrice RPC method.\n *\n * @returns Promise resolving to gas price tiers (slow, standard, fast).\n */\n getUserOperationGasPrice(): Promise<UserOperationGasPriceResponse>;\n};\n\n/**\n * Creates an Infura bundler client extended with Infura bundler actions.\n *\n * This is a wrapper around viem's createBundlerClient that extends it with\n * the getUserOperationGasPrice method for retrieving gas prices from Pimlico's\n * bundler infrastructure via Infura's proxy.\n *\n * @param config - Configuration for the bundler client.\n * @returns Extended bundler client with Infura bundler actions.\n * @example\n * ```typescript\n * import { createPublicClient, http } from 'viem';\n * import { sepolia } from 'viem/chains';\n * import { createInfuraBundlerClient } from '@metamask/smart-accounts-kit';\n *\n * const publicClient = createPublicClient({\n * chain: sepolia,\n * transport: http('https://sepolia.infura.io/v3/YOUR_API_KEY'),\n * });\n *\n * const bundlerClient = createInfuraBundlerClient({\n * client: publicClient,\n * transport: http('https://sepolia.infura.io/v3/YOUR_API_KEY'),\n * chain: sepolia,\n * });\n *\n * // Use standard bundler methods\n * const userOpHash = await bundlerClient.sendUserOperation({...});\n *\n * // Use Infura specific methods\n * const gasPrices = await bundlerClient.getUserOperationGasPrice();\n * ```\n */\nexport function createInfuraBundlerClient<\n TTransport extends Transport,\n TChain extends Chain | undefined = undefined,\n TAccount extends SmartAccount | undefined = undefined,\n>(\n config: BundlerClientConfig<TTransport, TChain, TAccount>,\n): InfuraBundlerClient<TTransport, TChain, TAccount> {\n trackSmartAccountsKitFunctionCall('createInfuraBundlerClient', {\n chainId: config.chain?.id ?? null,\n });\n // Create the base bundler client using viem's function\n const baseBundlerClient = createBundlerClient(config);\n\n // Extend the client with Infura bundler actions\n return baseBundlerClient.extend(\n infuraBundlerActions(),\n ) as unknown as InfuraBundlerClient<TTransport, TChain, TAccount>;\n}\n"],"mappings":";;;;;;;;;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9D,SAAS,OAAO,OAAO,MAAM;AAAA,EAC/B,CAAC;AAED,SAAO,OAAO,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC;AAC7D;;;AC5CA;AAAA,EACE;AAAA,OAIK;AA2CP,IAAM,uBAAuB,MAAM,CAAC,YAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYtD,MAAM,2BAAmE;AACvE,UAAM,gBAAgB;AAOtB,WAAO,MAAM,cAAc,QAAQ;AAAA,MACjC,QAAQ;AAAA,MACR,QAAQ,CAAC;AAAA,IACX,CAAC;AAAA,EACH;AACF;AAoDO,SAAS,0BAKd,QACmD;AACnD,oCAAkC,6BAA6B;AAAA,IAC7D,SAAS,OAAO,OAAO,MAAM;AAAA,EAC/B,CAAC;AAED,QAAM,oBAAoB,oBAAoB,MAAM;AAGpD,SAAO,kBAAkB;AAAA,IACvB,qBAAqB;AAAA,EACvB;AACF;","names":["concat","signMessage","signTypedData","getStubSignature","concat","signDelegation","signUserOperation"]}
@@ -1,5 +1,6 @@
1
- import { Hex, AbiFunction, Address, AbiParameter, TypedData } from 'viem';
2
- import { S as SmartAccountsEnvironment, C as Caveat, b as CaveatType, g as ScopeType, D as Delegation, P as PermissionContext } from './types-BWaH4KH1.js';
1
+ import { S as SmartAccountsEnvironment, C as Caveat, b as CaveatType, g as ScopeType } from './types-BWaH4KH1.cjs';
2
+ import { Hex, AbiFunction, Address } from 'viem';
3
+ import { BalanceChangeType } from '@metamask/delegation-core';
3
4
 
4
5
  type AllowedCalldataBuilderConfig = {
5
6
  startIndex: number;
@@ -54,11 +55,6 @@ type DeployedBuilderConfig = {
54
55
  };
55
56
  declare const deployedBuilder: (environment: SmartAccountsEnvironment, config: DeployedBuilderConfig) => Caveat;
56
57
 
57
- declare enum BalanceChangeType {
58
- Increase = 0,
59
- Decrease = 1
60
- }
61
-
62
58
  type Erc1155BalanceChangeBuilderConfig = {
63
59
  tokenAddress: Address;
64
60
  recipient: Address;
@@ -350,53 +346,4 @@ type ScopeConfig = ConvertScopeConfigsToInputs<ScopeConfigBase>;
350
346
 
351
347
  type Caveats = CaveatBuilder | (Caveat | CoreCaveatConfiguration)[];
352
348
 
353
- declare const DELEGATION_ABI_TYPE_COMPONENTS: ({
354
- type: string;
355
- name: string;
356
- components?: undefined;
357
- } | {
358
- type: string;
359
- name: string;
360
- components: {
361
- type: string;
362
- name: string;
363
- }[];
364
- })[];
365
- declare const toDelegationStruct: (delegation: Delegation) => DelegationStruct;
366
- declare const toDelegation: (delegationStruct: DelegationStruct) => Delegation;
367
- type DelegationStruct = Omit<Delegation, 'salt'> & {
368
- salt: bigint;
369
- };
370
- declare const encodeDelegations: (delegations: PermissionContext) => Hex;
371
- declare const encodeDelegation: (delegation: Delegation) => Hex;
372
- declare const decodeDelegations: (delegations: PermissionContext) => Delegation[];
373
- declare const decodeDelegation: (encoded: Hex) => Delegation;
374
- declare const SIGNABLE_DELEGATION_TYPED_DATA: TypedData;
375
- declare const DELEGATION_ARRAY_ABI_TYPE: AbiParameter;
376
- declare const DELEGATION_ABI_TYPE: AbiParameter;
377
- declare const hashDelegation: (input: Delegation) => Hex;
378
- type BaseCreateDelegationOptions = {
379
- environment: SmartAccountsEnvironment;
380
- scope: ScopeConfig;
381
- from: Hex;
382
- caveats?: Caveats;
383
- parentDelegation?: Delegation | Hex;
384
- salt?: Hex;
385
- };
386
- type CreateDelegationOptions = BaseCreateDelegationOptions & {
387
- to: Hex;
388
- };
389
- type CreateOpenDelegationOptions = BaseCreateDelegationOptions;
390
- declare const createDelegation: (options: CreateDelegationOptions) => Delegation;
391
- declare const createOpenDelegation: (options: CreateOpenDelegationOptions) => Delegation;
392
- declare const signDelegation: ({ privateKey, delegation, delegationManager, chainId, name, version, allowInsecureUnrestrictedDelegation, }: {
393
- privateKey: Hex;
394
- delegation: Omit<Delegation, "signature">;
395
- delegationManager: Address;
396
- chainId: number;
397
- name?: string;
398
- version?: string;
399
- allowInsecureUnrestrictedDelegation?: boolean;
400
- }) => Promise<`0x${string}`>;
401
-
402
- export { type CoreCaveatConfiguration as A, BalanceChangeType as B, type Caveats as C, DELEGATION_ABI_TYPE as D, ExecutionMode as E, SIGNABLE_DELEGATION_TYPED_DATA as S, type CreateDelegationOptions as a, type CreateExecutionArgs as b, type CreateOpenDelegationOptions as c, type ExecutionStruct as d, createDelegation as e, createExecution as f, createOpenDelegation as g, CaveatBuilder as h, type CaveatBuilderConfig as i, type CoreCaveatBuilder as j, DELEGATION_ABI_TYPE_COMPONENTS as k, DELEGATION_ARRAY_ABI_TYPE as l, type DelegationStruct as m, createCaveatBuilder as n, decodeDelegation as o, decodeDelegations as p, encodeBatchExecution as q, encodeDelegation as r, signDelegation as s, encodeDelegations as t, encodeExecutionCalldata as u, encodeExecutionCalldatas as v, encodeSingleExecution as w, hashDelegation as x, toDelegation as y, toDelegationStruct as z };
349
+ export { type Caveats as C, ExecutionMode as E, type ScopeConfig as S, type CreateExecutionArgs as a, type ExecutionStruct as b, createExecution as c, CaveatBuilder as d, type CaveatBuilderConfig as e, type CoreCaveatBuilder as f, createCaveatBuilder as g, encodeBatchExecution as h, encodeExecutionCalldata as i, encodeExecutionCalldatas as j, encodeSingleExecution as k, type CoreCaveatConfiguration as l };
@@ -1,5 +1,6 @@
1
- import { Hex, AbiFunction, Address, AbiParameter, TypedData } from 'viem';
2
- import { S as SmartAccountsEnvironment, C as Caveat, b as CaveatType, g as ScopeType, D as Delegation, P as PermissionContext } from './types-BWaH4KH1.cjs';
1
+ import { S as SmartAccountsEnvironment, C as Caveat, b as CaveatType, g as ScopeType } from './types-BWaH4KH1.js';
2
+ import { Hex, AbiFunction, Address } from 'viem';
3
+ import { BalanceChangeType } from '@metamask/delegation-core';
3
4
 
4
5
  type AllowedCalldataBuilderConfig = {
5
6
  startIndex: number;
@@ -54,11 +55,6 @@ type DeployedBuilderConfig = {
54
55
  };
55
56
  declare const deployedBuilder: (environment: SmartAccountsEnvironment, config: DeployedBuilderConfig) => Caveat;
56
57
 
57
- declare enum BalanceChangeType {
58
- Increase = 0,
59
- Decrease = 1
60
- }
61
-
62
58
  type Erc1155BalanceChangeBuilderConfig = {
63
59
  tokenAddress: Address;
64
60
  recipient: Address;
@@ -350,53 +346,4 @@ type ScopeConfig = ConvertScopeConfigsToInputs<ScopeConfigBase>;
350
346
 
351
347
  type Caveats = CaveatBuilder | (Caveat | CoreCaveatConfiguration)[];
352
348
 
353
- declare const DELEGATION_ABI_TYPE_COMPONENTS: ({
354
- type: string;
355
- name: string;
356
- components?: undefined;
357
- } | {
358
- type: string;
359
- name: string;
360
- components: {
361
- type: string;
362
- name: string;
363
- }[];
364
- })[];
365
- declare const toDelegationStruct: (delegation: Delegation) => DelegationStruct;
366
- declare const toDelegation: (delegationStruct: DelegationStruct) => Delegation;
367
- type DelegationStruct = Omit<Delegation, 'salt'> & {
368
- salt: bigint;
369
- };
370
- declare const encodeDelegations: (delegations: PermissionContext) => Hex;
371
- declare const encodeDelegation: (delegation: Delegation) => Hex;
372
- declare const decodeDelegations: (delegations: PermissionContext) => Delegation[];
373
- declare const decodeDelegation: (encoded: Hex) => Delegation;
374
- declare const SIGNABLE_DELEGATION_TYPED_DATA: TypedData;
375
- declare const DELEGATION_ARRAY_ABI_TYPE: AbiParameter;
376
- declare const DELEGATION_ABI_TYPE: AbiParameter;
377
- declare const hashDelegation: (input: Delegation) => Hex;
378
- type BaseCreateDelegationOptions = {
379
- environment: SmartAccountsEnvironment;
380
- scope: ScopeConfig;
381
- from: Hex;
382
- caveats?: Caveats;
383
- parentDelegation?: Delegation | Hex;
384
- salt?: Hex;
385
- };
386
- type CreateDelegationOptions = BaseCreateDelegationOptions & {
387
- to: Hex;
388
- };
389
- type CreateOpenDelegationOptions = BaseCreateDelegationOptions;
390
- declare const createDelegation: (options: CreateDelegationOptions) => Delegation;
391
- declare const createOpenDelegation: (options: CreateOpenDelegationOptions) => Delegation;
392
- declare const signDelegation: ({ privateKey, delegation, delegationManager, chainId, name, version, allowInsecureUnrestrictedDelegation, }: {
393
- privateKey: Hex;
394
- delegation: Omit<Delegation, "signature">;
395
- delegationManager: Address;
396
- chainId: number;
397
- name?: string;
398
- version?: string;
399
- allowInsecureUnrestrictedDelegation?: boolean;
400
- }) => Promise<`0x${string}`>;
401
-
402
- export { type CoreCaveatConfiguration as A, BalanceChangeType as B, type Caveats as C, DELEGATION_ABI_TYPE as D, ExecutionMode as E, SIGNABLE_DELEGATION_TYPED_DATA as S, type CreateDelegationOptions as a, type CreateExecutionArgs as b, type CreateOpenDelegationOptions as c, type ExecutionStruct as d, createDelegation as e, createExecution as f, createOpenDelegation as g, CaveatBuilder as h, type CaveatBuilderConfig as i, type CoreCaveatBuilder as j, DELEGATION_ABI_TYPE_COMPONENTS as k, DELEGATION_ARRAY_ABI_TYPE as l, type DelegationStruct as m, createCaveatBuilder as n, decodeDelegation as o, decodeDelegations as p, encodeBatchExecution as q, encodeDelegation as r, signDelegation as s, encodeDelegations as t, encodeExecutionCalldata as u, encodeExecutionCalldatas as v, encodeSingleExecution as w, hashDelegation as x, toDelegation as y, toDelegationStruct as z };
349
+ export { type Caveats as C, ExecutionMode as E, type ScopeConfig as S, type CreateExecutionArgs as a, type ExecutionStruct as b, createExecution as c, CaveatBuilder as d, type CaveatBuilderConfig as e, type CoreCaveatBuilder as f, createCaveatBuilder as g, encodeBatchExecution as h, encodeExecutionCalldata as i, encodeExecutionCalldatas as j, encodeSingleExecution as k, type CoreCaveatConfiguration as l };
@@ -3,13 +3,13 @@
3
3
 
4
4
 
5
5
 
6
- var _chunk3PBVHNYPcjs = require('../chunk-3PBVHNYP.cjs');
6
+ var _chunkSCS3CFREcjs = require('../chunk-SCS3CFRE.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
  var _chunkSOFB2MXGcjs = require('../chunk-SOFB2MXG.cjs');
12
- require('../chunk-DLCTHNAE.cjs');
12
+ require('../chunk-FH6HZCHI.cjs');
13
13
 
14
14
 
15
15
 
@@ -32,7 +32,7 @@ var _chunkMOHCTPYQcjs = require('../chunk-MOHCTPYQ.cjs');
32
32
 
33
33
 
34
34
 
35
- var _chunkSZOX7K2Vcjs = require('../chunk-SZOX7K2V.cjs');
35
+ var _chunkIBZSNB7Dcjs = require('../chunk-IBZSNB7D.cjs');
36
36
 
37
37
 
38
38
 
@@ -60,5 +60,5 @@ var _chunkSZOX7K2Vcjs = require('../chunk-SZOX7K2V.cjs');
60
60
 
61
61
 
62
62
 
63
- exports.CaveatBuilder = _chunkSZOX7K2Vcjs.CaveatBuilder; exports.DELEGATION_ABI_TYPE = _chunkSZOX7K2Vcjs.DELEGATION_ABI_TYPE; exports.DELEGATION_ABI_TYPE_COMPONENTS = _chunkSZOX7K2Vcjs.DELEGATION_ABI_TYPE_COMPONENTS; exports.DELEGATION_ARRAY_ABI_TYPE = _chunkSZOX7K2Vcjs.DELEGATION_ARRAY_ABI_TYPE; exports.DELEGATION_TYPEHASH = _chunkSZOX7K2Vcjs.DELEGATION_TYPEHASH; exports.SIGNABLE_DELEGATION_TYPED_DATA = _chunkSZOX7K2Vcjs.SIGNABLE_DELEGATION_TYPED_DATA; exports.SIGNABLE_USER_OP_TYPED_DATA = _chunkSOFB2MXGcjs.SIGNABLE_USER_OP_TYPED_DATA; exports.SIGNATURE_ABI_PARAMS = _chunk3PBVHNYPcjs.SIGNATURE_ABI_PARAMS; exports.createCaveatBuilder = _chunkSZOX7K2Vcjs.createCaveatBuilder; exports.decodeCaveat = _chunkSZOX7K2Vcjs.decodeCaveat; exports.decodeDelegation = _chunkSZOX7K2Vcjs.decodeDelegation; exports.decodeDelegations = _chunkSZOX7K2Vcjs.decodeDelegations; exports.deploySmartAccountsEnvironment = _chunkSOFB2MXGcjs.deploySmartAccountsEnvironment; exports.encodeBatchExecution = _chunkMOHCTPYQcjs.encodeBatchExecution; exports.encodeCalls = _chunk3PBVHNYPcjs.encodeCalls; exports.encodeCallsForCaller = _chunk3PBVHNYPcjs.encodeCallsForCaller; exports.encodeDelegation = _chunkSZOX7K2Vcjs.encodeDelegation; exports.encodeDelegations = _chunkSZOX7K2Vcjs.encodeDelegations; exports.encodeExecutionCalldata = _chunkMOHCTPYQcjs.encodeExecutionCalldata; exports.encodeExecutionCalldatas = _chunkMOHCTPYQcjs.encodeExecutionCalldatas; exports.encodeSingleExecution = _chunkMOHCTPYQcjs.encodeSingleExecution; exports.getCounterfactualAccountData = _chunk3PBVHNYPcjs.getCounterfactualAccountData; exports.hashDelegation = _chunkSZOX7K2Vcjs.hashDelegation; exports.overrideDeployedEnvironment = _chunkSOFB2MXGcjs.overrideDeployedEnvironment; exports.toDelegation = _chunkSZOX7K2Vcjs.toDelegation; exports.toDelegationStruct = _chunkSZOX7K2Vcjs.toDelegationStruct;
63
+ exports.CaveatBuilder = _chunkIBZSNB7Dcjs.CaveatBuilder; exports.DELEGATION_ABI_TYPE = _chunkIBZSNB7Dcjs.DELEGATION_ABI_TYPE; exports.DELEGATION_ABI_TYPE_COMPONENTS = _chunkIBZSNB7Dcjs.DELEGATION_ABI_TYPE_COMPONENTS; exports.DELEGATION_ARRAY_ABI_TYPE = _chunkIBZSNB7Dcjs.DELEGATION_ARRAY_ABI_TYPE; exports.DELEGATION_TYPEHASH = _chunkIBZSNB7Dcjs.DELEGATION_TYPEHASH; exports.SIGNABLE_DELEGATION_TYPED_DATA = _chunkIBZSNB7Dcjs.SIGNABLE_DELEGATION_TYPED_DATA; exports.SIGNABLE_USER_OP_TYPED_DATA = _chunkSOFB2MXGcjs.SIGNABLE_USER_OP_TYPED_DATA; exports.SIGNATURE_ABI_PARAMS = _chunkSCS3CFREcjs.SIGNATURE_ABI_PARAMS; exports.createCaveatBuilder = _chunkIBZSNB7Dcjs.createCaveatBuilder; exports.decodeCaveat = _chunkIBZSNB7Dcjs.decodeCaveat; exports.decodeDelegation = _chunkIBZSNB7Dcjs.decodeDelegation; exports.decodeDelegations = _chunkIBZSNB7Dcjs.decodeDelegations; exports.deploySmartAccountsEnvironment = _chunkSOFB2MXGcjs.deploySmartAccountsEnvironment; exports.encodeBatchExecution = _chunkMOHCTPYQcjs.encodeBatchExecution; exports.encodeCalls = _chunkSCS3CFREcjs.encodeCalls; exports.encodeCallsForCaller = _chunkSCS3CFREcjs.encodeCallsForCaller; exports.encodeDelegation = _chunkIBZSNB7Dcjs.encodeDelegation; exports.encodeDelegations = _chunkIBZSNB7Dcjs.encodeDelegations; exports.encodeExecutionCalldata = _chunkMOHCTPYQcjs.encodeExecutionCalldata; exports.encodeExecutionCalldatas = _chunkMOHCTPYQcjs.encodeExecutionCalldatas; exports.encodeSingleExecution = _chunkMOHCTPYQcjs.encodeSingleExecution; exports.getCounterfactualAccountData = _chunkSCS3CFREcjs.getCounterfactualAccountData; exports.hashDelegation = _chunkIBZSNB7Dcjs.hashDelegation; exports.overrideDeployedEnvironment = _chunkSOFB2MXGcjs.overrideDeployedEnvironment; exports.toDelegation = _chunkIBZSNB7Dcjs.toDelegation; exports.toDelegationStruct = _chunkIBZSNB7Dcjs.toDelegationStruct;
64
64
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,6 @@
1
- export { d as decodeCaveat, a as deploySmartAccountsEnvironment, o as overrideDeployedEnvironment } from '../caveats-Cey0wm33.cjs';
2
- export { h as CaveatBuilder, i as CaveatBuilderConfig, j as CoreCaveatBuilder, D as DELEGATION_ABI_TYPE, k as DELEGATION_ABI_TYPE_COMPONENTS, l as DELEGATION_ARRAY_ABI_TYPE, m as DelegationStruct, d as ExecutionStruct, S as SIGNABLE_DELEGATION_TYPED_DATA, n as createCaveatBuilder, o as decodeDelegation, p as decodeDelegations, q as encodeBatchExecution, r as encodeDelegation, t as encodeDelegations, u as encodeExecutionCalldata, v as encodeExecutionCalldatas, w as encodeSingleExecution, x as hashDelegation, y as toDelegation, z as toDelegationStruct } from '../delegation-KbWHzRxV.cjs';
1
+ export { d as decodeCaveat, a as deploySmartAccountsEnvironment, o as overrideDeployedEnvironment } from '../caveats-CaSt_VHs.cjs';
2
+ export { D as DELEGATION_ABI_TYPE, d as DELEGATION_ABI_TYPE_COMPONENTS, e as DELEGATION_ARRAY_ABI_TYPE, f as DelegationStruct, S as SIGNABLE_DELEGATION_TYPED_DATA, g as decodeDelegation, h as decodeDelegations, i as encodeDelegation, j as encodeDelegations, k as hashDelegation, t as toDelegation, l as toDelegationStruct } from '../delegation-BKkEyxZY.cjs';
3
+ export { d as CaveatBuilder, e as CaveatBuilderConfig, f as CoreCaveatBuilder, b as ExecutionStruct, g as createCaveatBuilder, h as encodeBatchExecution, i as encodeExecutionCalldata, j as encodeExecutionCalldatas, k as encodeSingleExecution } from '../resolveCaveats-DiqGB-T5.cjs';
3
4
  export { S as SIGNABLE_USER_OP_TYPED_DATA } from '../userOp-DKgjzz7B.cjs';
4
5
  import { Address, Hex } from 'viem';
5
6
  import { l as Call, I as Implementation, S as SmartAccountsEnvironment, m as DeployParams } from '../types-BWaH4KH1.cjs';
@@ -1,5 +1,6 @@
1
- export { d as decodeCaveat, a as deploySmartAccountsEnvironment, o as overrideDeployedEnvironment } from '../caveats-CQbtzOKm.js';
2
- export { h as CaveatBuilder, i as CaveatBuilderConfig, j as CoreCaveatBuilder, D as DELEGATION_ABI_TYPE, k as DELEGATION_ABI_TYPE_COMPONENTS, l as DELEGATION_ARRAY_ABI_TYPE, m as DelegationStruct, d as ExecutionStruct, S as SIGNABLE_DELEGATION_TYPED_DATA, n as createCaveatBuilder, o as decodeDelegation, p as decodeDelegations, q as encodeBatchExecution, r as encodeDelegation, t as encodeDelegations, u as encodeExecutionCalldata, v as encodeExecutionCalldatas, w as encodeSingleExecution, x as hashDelegation, y as toDelegation, z as toDelegationStruct } from '../delegation-Bx4FEAIU.js';
1
+ export { d as decodeCaveat, a as deploySmartAccountsEnvironment, o as overrideDeployedEnvironment } from '../caveats-DQ6HoAHe.js';
2
+ export { D as DELEGATION_ABI_TYPE, d as DELEGATION_ABI_TYPE_COMPONENTS, e as DELEGATION_ARRAY_ABI_TYPE, f as DelegationStruct, S as SIGNABLE_DELEGATION_TYPED_DATA, g as decodeDelegation, h as decodeDelegations, i as encodeDelegation, j as encodeDelegations, k as hashDelegation, t as toDelegation, l as toDelegationStruct } from '../delegation-DbPGWKfP.js';
3
+ export { d as CaveatBuilder, e as CaveatBuilderConfig, f as CoreCaveatBuilder, b as ExecutionStruct, g as createCaveatBuilder, h as encodeBatchExecution, i as encodeExecutionCalldata, j as encodeExecutionCalldatas, k as encodeSingleExecution } from '../resolveCaveats-s2snaFEo.js';
3
4
  export { S as SIGNABLE_USER_OP_TYPED_DATA } from '../userOp-DKgjzz7B.js';
4
5
  import { Address, Hex } from 'viem';
5
6
  import { l as Call, I as Implementation, S as SmartAccountsEnvironment, m as DeployParams } from '../types-BWaH4KH1.js';
@@ -3,13 +3,13 @@ import {
3
3
  encodeCalls,
4
4
  encodeCallsForCaller,
5
5
  getCounterfactualAccountData
6
- } from "../chunk-LQXOM3TA.mjs";
6
+ } from "../chunk-YXHUT56Z.mjs";
7
7
  import {
8
8
  SIGNABLE_USER_OP_TYPED_DATA,
9
9
  deploySmartAccountsEnvironment,
10
10
  overrideDeployedEnvironment
11
11
  } from "../chunk-QCULIK3O.mjs";
12
- import "../chunk-KBSFVKUB.mjs";
12
+ import "../chunk-W7O2UQL5.mjs";
13
13
  import {
14
14
  encodeBatchExecution,
15
15
  encodeExecutionCalldata,
@@ -32,7 +32,7 @@ import {
32
32
  hashDelegation,
33
33
  toDelegation,
34
34
  toDelegationStruct
35
- } from "../chunk-Z4D7ZWVB.mjs";
35
+ } from "../chunk-MV2KHN75.mjs";
36
36
  export {
37
37
  CaveatBuilder,
38
38
  DELEGATION_ABI_TYPE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/smart-accounts-kit",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "description": "Toolkit for managing and interacting with MetaMask Smart Accounts, built on Viem",
6
6
  "license": "(MIT-0 OR Apache-2.0)",
@@ -124,10 +124,10 @@
124
124
  }
125
125
  },
126
126
  "dependencies": {
127
- "@metamask/7715-permission-types": "^0.5.0",
127
+ "@metamask/7715-permission-types": "^0.6.0",
128
128
  "@metamask/delegation-abis": "^1.0.0",
129
- "@metamask/delegation-core": "^1.1.0",
130
- "@metamask/delegation-deployments": "^1.2.0",
129
+ "@metamask/delegation-core": "^2.1.0",
130
+ "@metamask/delegation-deployments": "^1.3.0",
131
131
  "openapi-fetch": "^0.13.5",
132
132
  "ox": "0.8.1"
133
133
  },