@metamask/smart-accounts-kit 1.1.0 → 1.2.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 (66) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +34 -2
  3. package/dist/actions/index.cjs +5 -5
  4. package/dist/actions/index.mjs +4 -4
  5. package/dist/{smartAccountsEnvironment-BIcho7e0.d.cts → caveats-CQbtzOKm.d.ts} +9 -2
  6. package/dist/{smartAccountsEnvironment-Bso0CIWt.d.ts → caveats-Cey0wm33.d.cts} +9 -2
  7. package/dist/{chunk-UUOH2WAW.cjs → chunk-3SHZ7PV2.cjs} +12 -12
  8. package/dist/{chunk-UUOH2WAW.cjs.map → chunk-3SHZ7PV2.cjs.map} +1 -1
  9. package/dist/{chunk-TPBFVDVM.mjs → chunk-4QXIOE7F.mjs} +8 -6
  10. package/dist/chunk-4QXIOE7F.mjs.map +1 -0
  11. package/dist/{chunk-NOCLGZGB.mjs → chunk-734MOPHR.mjs} +63 -5
  12. package/dist/chunk-734MOPHR.mjs.map +1 -0
  13. package/dist/{chunk-YDLLC6PP.cjs → chunk-7BEEGBA2.cjs} +519 -16
  14. package/dist/chunk-7BEEGBA2.cjs.map +1 -0
  15. package/dist/{chunk-45GHWVQA.mjs → chunk-G7VZ7E6W.mjs} +4 -4
  16. package/dist/{chunk-F2RG26RH.cjs → chunk-HFRQNSZE.cjs} +105 -105
  17. package/dist/{chunk-F2RG26RH.cjs.map → chunk-HFRQNSZE.cjs.map} +1 -1
  18. package/dist/{chunk-YSBBRLMT.mjs → chunk-L5DLMBDC.mjs} +5 -5
  19. package/dist/{chunk-VLKX4BR6.cjs → chunk-MOHCTPYQ.cjs} +8 -6
  20. package/dist/chunk-MOHCTPYQ.cjs.map +1 -0
  21. package/dist/{chunk-QMRKCB7T.cjs → chunk-T4IAMAB2.cjs} +102 -44
  22. package/dist/chunk-T4IAMAB2.cjs.map +1 -0
  23. package/dist/{chunk-BYWRJGSK.cjs → chunk-UB2FLPP3.cjs} +16 -16
  24. package/dist/{chunk-BYWRJGSK.cjs.map → chunk-UB2FLPP3.cjs.map} +1 -1
  25. package/dist/{chunk-23YXLKTX.cjs → chunk-UZO5OYCD.cjs} +14 -14
  26. package/dist/{chunk-23YXLKTX.cjs.map → chunk-UZO5OYCD.cjs.map} +1 -1
  27. package/dist/{chunk-YTELOQ4I.mjs → chunk-VJXM3LWA.mjs} +2 -2
  28. package/dist/{chunk-WV2R7BXP.mjs → chunk-YTNCEXUX.mjs} +3 -3
  29. package/dist/{chunk-C5ZEEH2Z.mjs → chunk-ZA2XYCVX.mjs} +517 -14
  30. package/dist/chunk-ZA2XYCVX.mjs.map +1 -0
  31. package/dist/contracts/index.cjs +6 -6
  32. package/dist/contracts/index.d.cts +2 -2
  33. package/dist/contracts/index.d.ts +2 -2
  34. package/dist/contracts/index.mjs +5 -5
  35. package/dist/{delegation-DgmIOh21.d.ts → delegation-Bx4FEAIU.d.ts} +1 -1
  36. package/dist/{delegation-Ci3me5Rg.d.cts → delegation-KbWHzRxV.d.cts} +1 -1
  37. package/dist/experimental/index.cjs +36 -4
  38. package/dist/experimental/index.cjs.map +1 -1
  39. package/dist/experimental/index.d.cts +4 -1
  40. package/dist/experimental/index.d.ts +4 -1
  41. package/dist/experimental/index.mjs +35 -3
  42. package/dist/experimental/index.mjs.map +1 -1
  43. package/dist/{index-UF6eCzBC.d.ts → index-D2THBlfm.d.ts} +1 -1
  44. package/dist/{index-CSjEW7MJ.d.cts → index-DE87r5KY.d.cts} +1 -1
  45. package/dist/index.cjs +33 -17
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +7 -9
  48. package/dist/index.d.ts +7 -9
  49. package/dist/index.mjs +24 -8
  50. package/dist/index.mjs.map +1 -1
  51. package/dist/utils/index.cjs +7 -5
  52. package/dist/utils/index.cjs.map +1 -1
  53. package/dist/utils/index.d.cts +2 -2
  54. package/dist/utils/index.d.ts +2 -2
  55. package/dist/utils/index.mjs +6 -4
  56. package/package.json +5 -4
  57. package/dist/chunk-C5ZEEH2Z.mjs.map +0 -1
  58. package/dist/chunk-NOCLGZGB.mjs.map +0 -1
  59. package/dist/chunk-QMRKCB7T.cjs.map +0 -1
  60. package/dist/chunk-TPBFVDVM.mjs.map +0 -1
  61. package/dist/chunk-VLKX4BR6.cjs.map +0 -1
  62. package/dist/chunk-YDLLC6PP.cjs.map +0 -1
  63. /package/dist/{chunk-45GHWVQA.mjs.map → chunk-G7VZ7E6W.mjs.map} +0 -0
  64. /package/dist/{chunk-YSBBRLMT.mjs.map → chunk-L5DLMBDC.mjs.map} +0 -0
  65. /package/dist/{chunk-YTELOQ4I.mjs.map → chunk-VJXM3LWA.mjs.map} +0 -0
  66. /package/dist/{chunk-WV2R7BXP.mjs.map → chunk-YTNCEXUX.mjs.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,10 +1,10 @@
1
- import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, C as Caveat, S as SmartAccountsEnvironment } from './types-BWaH4KH1.cjs';
2
- export { A as AccountSignerConfig, 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-Ci3me5Rg.cjs';
4
- export { P as PREFERRED_VERSION, g as getSmartAccountsEnvironment } from './smartAccountsEnvironment-BIcho7e0.cjs';
5
- import { Hex, Address, Transport, Chain, Account, Client } from 'viem';
1
+ import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './types-BWaH4KH1.cjs';
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';
5
+ import { Address, Hex, Transport, Chain, Account, Client } from 'viem';
6
6
  export { s as signUserOperation } from './userOp-DKgjzz7B.cjs';
7
- export { i as contracts } from './index-CSjEW7MJ.cjs';
7
+ export { i as contracts } from './index-DE87r5KY.cjs';
8
8
  import { c as caveatEnforcerActions } from './index-Uj_xXVko.cjs';
9
9
  export { i as actions } from './index-Uj_xXVko.cjs';
10
10
  import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
@@ -15,8 +15,6 @@ import '@metamask/7715-permission-types';
15
15
 
16
16
  declare function toMetaMaskSmartAccount<TImplementation extends Implementation>(params: ToMetaMaskSmartAccountParameters<TImplementation>): Promise<ToMetaMaskSmartAccountReturnType<TImplementation>>;
17
17
 
18
- declare const createCaveat: (enforcer: Hex, terms: Hex, args?: Hex) => Caveat;
19
-
20
18
  declare const signatureTypes: readonly ["ECDSA"];
21
19
  type SignatureType = (typeof signatureTypes)[number];
22
20
  type PartialSignature = {
@@ -51,4 +49,4 @@ type InfuraBundlerClient<TTransport extends Transport = Transport, TChain extend
51
49
  };
52
50
  declare function createInfuraBundlerClient<TTransport extends Transport, TChain extends Chain | undefined = undefined, TAccount extends SmartAccount | undefined = undefined>(config: BundlerClientConfig<TTransport, TChain, TAccount>): InfuraBundlerClient<TTransport, TChain, TAccount>;
53
51
 
54
- export { type AggregateSignatureParams, Caveat, type CaveatEnforcerClient, type GasPriceTier, Implementation, type InfuraBundlerClient, type PartialSignature, type SignatureType, SmartAccountsEnvironment, ToMetaMaskSmartAccountReturnType, type UserOperationGasPriceResponse, aggregateSignature, createCaveat, createCaveatEnforcerClient, createInfuraBundlerClient, toMetaMaskSmartAccount };
52
+ export { type AggregateSignatureParams, type CaveatEnforcerClient, type GasPriceTier, Implementation, type InfuraBundlerClient, type PartialSignature, type SignatureType, SmartAccountsEnvironment, ToMetaMaskSmartAccountReturnType, type UserOperationGasPriceResponse, aggregateSignature, createCaveatEnforcerClient, createInfuraBundlerClient, toMetaMaskSmartAccount };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, C as Caveat, S as SmartAccountsEnvironment } from './types-BWaH4KH1.js';
2
- export { A as AccountSignerConfig, 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-DgmIOh21.js';
4
- export { P as PREFERRED_VERSION, g as getSmartAccountsEnvironment } from './smartAccountsEnvironment-Bso0CIWt.js';
5
- import { Hex, Address, Transport, Chain, Account, Client } from 'viem';
1
+ import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './types-BWaH4KH1.js';
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';
5
+ import { Address, Hex, Transport, Chain, Account, Client } from 'viem';
6
6
  export { s as signUserOperation } from './userOp-DKgjzz7B.js';
7
- export { i as contracts } from './index-UF6eCzBC.js';
7
+ export { i as contracts } from './index-D2THBlfm.js';
8
8
  import { c as caveatEnforcerActions } from './index-D7fBuNV-.js';
9
9
  export { i as actions } from './index-D7fBuNV-.js';
10
10
  import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
@@ -15,8 +15,6 @@ import '@metamask/7715-permission-types';
15
15
 
16
16
  declare function toMetaMaskSmartAccount<TImplementation extends Implementation>(params: ToMetaMaskSmartAccountParameters<TImplementation>): Promise<ToMetaMaskSmartAccountReturnType<TImplementation>>;
17
17
 
18
- declare const createCaveat: (enforcer: Hex, terms: Hex, args?: Hex) => Caveat;
19
-
20
18
  declare const signatureTypes: readonly ["ECDSA"];
21
19
  type SignatureType = (typeof signatureTypes)[number];
22
20
  type PartialSignature = {
@@ -51,4 +49,4 @@ type InfuraBundlerClient<TTransport extends Transport = Transport, TChain extend
51
49
  };
52
50
  declare function createInfuraBundlerClient<TTransport extends Transport, TChain extends Chain | undefined = undefined, TAccount extends SmartAccount | undefined = undefined>(config: BundlerClientConfig<TTransport, TChain, TAccount>): InfuraBundlerClient<TTransport, TChain, TAccount>;
53
51
 
54
- export { type AggregateSignatureParams, Caveat, type CaveatEnforcerClient, type GasPriceTier, Implementation, type InfuraBundlerClient, type PartialSignature, type SignatureType, SmartAccountsEnvironment, ToMetaMaskSmartAccountReturnType, type UserOperationGasPriceResponse, aggregateSignature, createCaveat, createCaveatEnforcerClient, createInfuraBundlerClient, toMetaMaskSmartAccount };
52
+ export { type AggregateSignatureParams, type CaveatEnforcerClient, type GasPriceTier, Implementation, type InfuraBundlerClient, type PartialSignature, type SignatureType, SmartAccountsEnvironment, ToMetaMaskSmartAccountReturnType, type UserOperationGasPriceResponse, aggregateSignature, createCaveatEnforcerClient, createInfuraBundlerClient, toMetaMaskSmartAccount };
package/dist/index.mjs CHANGED
@@ -2,28 +2,28 @@ import {
2
2
  actions_exports,
3
3
  caveatEnforcerActions,
4
4
  isValid7702Implementation
5
- } from "./chunk-NOCLGZGB.mjs";
5
+ } from "./chunk-734MOPHR.mjs";
6
6
  import {
7
7
  contracts_exports
8
- } from "./chunk-YSBBRLMT.mjs";
9
- import "./chunk-YTELOQ4I.mjs";
8
+ } from "./chunk-L5DLMBDC.mjs";
9
+ import "./chunk-VJXM3LWA.mjs";
10
10
  import {
11
11
  createDummyWebAuthnSignature,
12
12
  encodeCallsForCaller,
13
13
  encodeDeleGatorSignature,
14
14
  getCounterfactualAccountData
15
- } from "./chunk-45GHWVQA.mjs";
15
+ } from "./chunk-G7VZ7E6W.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-WV2R7BXP.mjs";
22
+ import "./chunk-YTNCEXUX.mjs";
23
23
  import {
24
24
  ExecutionMode,
25
25
  createExecution
26
- } from "./chunk-TPBFVDVM.mjs";
26
+ } from "./chunk-4QXIOE7F.mjs";
27
27
  import {
28
28
  ANY_BENEFICIARY,
29
29
  BalanceChangeType,
@@ -37,8 +37,9 @@ import {
37
37
  createDelegation,
38
38
  createOpenDelegation,
39
39
  signDelegation,
40
- toDelegationStruct
41
- } from "./chunk-C5ZEEH2Z.mjs";
40
+ toDelegationStruct,
41
+ trackSmartAccountsKitFunctionCall
42
+ } from "./chunk-ZA2XYCVX.mjs";
42
43
 
43
44
  // src/toMetaMaskSmartAccount.ts
44
45
  import {
@@ -61,6 +62,9 @@ var signatureTypes = ["ECDSA"];
61
62
  var aggregateSignature = ({
62
63
  signatures
63
64
  }) => {
65
+ trackSmartAccountsKitFunctionCall("aggregateSignature", {
66
+ signatureCount: signatures.length
67
+ });
64
68
  if (signatures.length === 0) {
65
69
  return "0x";
66
70
  }
@@ -233,6 +237,12 @@ async function toMetaMaskSmartAccount(params) {
233
237
  implementation,
234
238
  nonceKeyManager
235
239
  } = params;
240
+ trackSmartAccountsKitFunctionCall("toMetaMaskSmartAccount", {
241
+ implementation,
242
+ hasAddress: params.address !== void 0,
243
+ hasEnvironment: params.environment !== void 0,
244
+ chainId: chain?.id ?? null
245
+ });
236
246
  if (!chain) {
237
247
  throw new Error("Chain not specified");
238
248
  }
@@ -388,6 +398,9 @@ function createCaveatEnforcerClient({
388
398
  client,
389
399
  environment
390
400
  }) {
401
+ trackSmartAccountsKitFunctionCall("createCaveatEnforcerClient", {
402
+ chainId: client.chain?.id ?? null
403
+ });
391
404
  return client.extend(caveatEnforcerActions({ environment }));
392
405
  }
393
406
 
@@ -416,6 +429,9 @@ var infuraBundlerActions = () => (client) => ({
416
429
  }
417
430
  });
418
431
  function createInfuraBundlerClient(config) {
432
+ trackSmartAccountsKitFunctionCall("createInfuraBundlerClient", {
433
+ chainId: config.chain?.id ?? null
434
+ });
419
435
  const baseBundlerClient = createBundlerClient(config);
420
436
  return baseBundlerClient.extend(
421
437
  infuraBundlerActions()
@@ -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 { 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 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\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 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 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 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\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 // 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;AAEvB,IAAM,iBAAiB,CAAC,OAAO;AAoBxB,IAAM,qBAAqB,CAAC;AAAA,EACjC;AACF,MAEW;AACT,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;;;ADnBA,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;A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,2BAId;AAAA,EACA;AAAA,EACA;AACF,GAGuD;AACrD,SAAO,OAAO,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC;AAC7D;;;ACvCA;AAAA,EACE;AAAA,OAIK;AAyCP,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;AAEnD,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/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,EAC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AE,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"]}
@@ -3,19 +3,19 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkBYWRJGSKcjs = require('../chunk-BYWRJGSK.cjs');
6
+ var _chunkUB2FLPP3cjs = require('../chunk-UB2FLPP3.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
  var _chunkSOFB2MXGcjs = require('../chunk-SOFB2MXG.cjs');
12
- require('../chunk-23YXLKTX.cjs');
12
+ require('../chunk-UZO5OYCD.cjs');
13
13
 
14
14
 
15
15
 
16
16
 
17
17
 
18
- var _chunkVLKX4BR6cjs = require('../chunk-VLKX4BR6.cjs');
18
+ var _chunkMOHCTPYQcjs = require('../chunk-MOHCTPYQ.cjs');
19
19
 
20
20
 
21
21
 
@@ -31,8 +31,8 @@ var _chunkVLKX4BR6cjs = require('../chunk-VLKX4BR6.cjs');
31
31
 
32
32
 
33
33
 
34
- var _chunkYDLLC6PPcjs = require('../chunk-YDLLC6PP.cjs');
35
34
 
35
+ var _chunk7BEEGBA2cjs = require('../chunk-7BEEGBA2.cjs');
36
36
 
37
37
 
38
38
 
@@ -58,5 +58,7 @@ var _chunkYDLLC6PPcjs = require('../chunk-YDLLC6PP.cjs');
58
58
 
59
59
 
60
60
 
61
- exports.CaveatBuilder = _chunkYDLLC6PPcjs.CaveatBuilder; exports.DELEGATION_ABI_TYPE = _chunkYDLLC6PPcjs.DELEGATION_ABI_TYPE; exports.DELEGATION_ABI_TYPE_COMPONENTS = _chunkYDLLC6PPcjs.DELEGATION_ABI_TYPE_COMPONENTS; exports.DELEGATION_ARRAY_ABI_TYPE = _chunkYDLLC6PPcjs.DELEGATION_ARRAY_ABI_TYPE; exports.DELEGATION_TYPEHASH = _chunkYDLLC6PPcjs.DELEGATION_TYPEHASH; exports.SIGNABLE_DELEGATION_TYPED_DATA = _chunkYDLLC6PPcjs.SIGNABLE_DELEGATION_TYPED_DATA; exports.SIGNABLE_USER_OP_TYPED_DATA = _chunkSOFB2MXGcjs.SIGNABLE_USER_OP_TYPED_DATA; exports.SIGNATURE_ABI_PARAMS = _chunkBYWRJGSKcjs.SIGNATURE_ABI_PARAMS; exports.createCaveatBuilder = _chunkYDLLC6PPcjs.createCaveatBuilder; exports.decodeDelegation = _chunkYDLLC6PPcjs.decodeDelegation; exports.decodeDelegations = _chunkYDLLC6PPcjs.decodeDelegations; exports.deploySmartAccountsEnvironment = _chunkSOFB2MXGcjs.deploySmartAccountsEnvironment; exports.encodeBatchExecution = _chunkVLKX4BR6cjs.encodeBatchExecution; exports.encodeCalls = _chunkBYWRJGSKcjs.encodeCalls; exports.encodeCallsForCaller = _chunkBYWRJGSKcjs.encodeCallsForCaller; exports.encodeDelegation = _chunkYDLLC6PPcjs.encodeDelegation; exports.encodeDelegations = _chunkYDLLC6PPcjs.encodeDelegations; exports.encodeExecutionCalldata = _chunkVLKX4BR6cjs.encodeExecutionCalldata; exports.encodeExecutionCalldatas = _chunkVLKX4BR6cjs.encodeExecutionCalldatas; exports.encodeSingleExecution = _chunkVLKX4BR6cjs.encodeSingleExecution; exports.getCounterfactualAccountData = _chunkBYWRJGSKcjs.getCounterfactualAccountData; exports.hashDelegation = _chunkYDLLC6PPcjs.hashDelegation; exports.overrideDeployedEnvironment = _chunkSOFB2MXGcjs.overrideDeployedEnvironment; exports.toDelegation = _chunkYDLLC6PPcjs.toDelegation; exports.toDelegationStruct = _chunkYDLLC6PPcjs.toDelegationStruct;
61
+
62
+
63
+ exports.CaveatBuilder = _chunk7BEEGBA2cjs.CaveatBuilder; exports.DELEGATION_ABI_TYPE = _chunk7BEEGBA2cjs.DELEGATION_ABI_TYPE; exports.DELEGATION_ABI_TYPE_COMPONENTS = _chunk7BEEGBA2cjs.DELEGATION_ABI_TYPE_COMPONENTS; exports.DELEGATION_ARRAY_ABI_TYPE = _chunk7BEEGBA2cjs.DELEGATION_ARRAY_ABI_TYPE; exports.DELEGATION_TYPEHASH = _chunk7BEEGBA2cjs.DELEGATION_TYPEHASH; exports.SIGNABLE_DELEGATION_TYPED_DATA = _chunk7BEEGBA2cjs.SIGNABLE_DELEGATION_TYPED_DATA; exports.SIGNABLE_USER_OP_TYPED_DATA = _chunkSOFB2MXGcjs.SIGNABLE_USER_OP_TYPED_DATA; exports.SIGNATURE_ABI_PARAMS = _chunkUB2FLPP3cjs.SIGNATURE_ABI_PARAMS; exports.createCaveatBuilder = _chunk7BEEGBA2cjs.createCaveatBuilder; exports.decodeCaveat = _chunk7BEEGBA2cjs.decodeCaveat; exports.decodeDelegation = _chunk7BEEGBA2cjs.decodeDelegation; exports.decodeDelegations = _chunk7BEEGBA2cjs.decodeDelegations; exports.deploySmartAccountsEnvironment = _chunkSOFB2MXGcjs.deploySmartAccountsEnvironment; exports.encodeBatchExecution = _chunkMOHCTPYQcjs.encodeBatchExecution; exports.encodeCalls = _chunkUB2FLPP3cjs.encodeCalls; exports.encodeCallsForCaller = _chunkUB2FLPP3cjs.encodeCallsForCaller; exports.encodeDelegation = _chunk7BEEGBA2cjs.encodeDelegation; exports.encodeDelegations = _chunk7BEEGBA2cjs.encodeDelegations; exports.encodeExecutionCalldata = _chunkMOHCTPYQcjs.encodeExecutionCalldata; exports.encodeExecutionCalldatas = _chunkMOHCTPYQcjs.encodeExecutionCalldatas; exports.encodeSingleExecution = _chunkMOHCTPYQcjs.encodeSingleExecution; exports.getCounterfactualAccountData = _chunkUB2FLPP3cjs.getCounterfactualAccountData; exports.hashDelegation = _chunk7BEEGBA2cjs.hashDelegation; exports.overrideDeployedEnvironment = _chunkSOFB2MXGcjs.overrideDeployedEnvironment; exports.toDelegation = _chunk7BEEGBA2cjs.toDelegation; exports.toDelegationStruct = _chunk7BEEGBA2cjs.toDelegationStruct;
62
64
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/utils/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,8wDAAC","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/utils/index.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/utils/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,q0DAAC","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/utils/index.cjs"}
@@ -1,8 +1,8 @@
1
- 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-Ci3me5Rg.cjs';
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';
2
3
  export { S as SIGNABLE_USER_OP_TYPED_DATA } from '../userOp-DKgjzz7B.cjs';
3
4
  import { Address, Hex } from 'viem';
4
5
  import { l as Call, I as Implementation, S as SmartAccountsEnvironment, m as DeployParams } from '../types-BWaH4KH1.cjs';
5
- export { d as deploySmartAccountsEnvironment, o as overrideDeployedEnvironment } from '../smartAccountsEnvironment-BIcho7e0.cjs';
6
6
  export { DELEGATION_TYPEHASH } from '@metamask/delegation-core';
7
7
  import '@metamask/delegation-abis';
8
8
  import 'viem/account-abstraction';
@@ -1,8 +1,8 @@
1
- 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-DgmIOh21.js';
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';
2
3
  export { S as SIGNABLE_USER_OP_TYPED_DATA } from '../userOp-DKgjzz7B.js';
3
4
  import { Address, Hex } from 'viem';
4
5
  import { l as Call, I as Implementation, S as SmartAccountsEnvironment, m as DeployParams } from '../types-BWaH4KH1.js';
5
- export { d as deploySmartAccountsEnvironment, o as overrideDeployedEnvironment } from '../smartAccountsEnvironment-Bso0CIWt.js';
6
6
  export { DELEGATION_TYPEHASH } from '@metamask/delegation-core';
7
7
  import '@metamask/delegation-abis';
8
8
  import 'viem/account-abstraction';
@@ -3,19 +3,19 @@ import {
3
3
  encodeCalls,
4
4
  encodeCallsForCaller,
5
5
  getCounterfactualAccountData
6
- } from "../chunk-45GHWVQA.mjs";
6
+ } from "../chunk-G7VZ7E6W.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-WV2R7BXP.mjs";
12
+ import "../chunk-YTNCEXUX.mjs";
13
13
  import {
14
14
  encodeBatchExecution,
15
15
  encodeExecutionCalldata,
16
16
  encodeExecutionCalldatas,
17
17
  encodeSingleExecution
18
- } from "../chunk-TPBFVDVM.mjs";
18
+ } from "../chunk-4QXIOE7F.mjs";
19
19
  import {
20
20
  CaveatBuilder,
21
21
  DELEGATION_ABI_TYPE,
@@ -24,6 +24,7 @@ import {
24
24
  DELEGATION_TYPEHASH,
25
25
  SIGNABLE_DELEGATION_TYPED_DATA,
26
26
  createCaveatBuilder,
27
+ decodeCaveat,
27
28
  decodeDelegation,
28
29
  decodeDelegations,
29
30
  encodeDelegation,
@@ -31,7 +32,7 @@ import {
31
32
  hashDelegation,
32
33
  toDelegation,
33
34
  toDelegationStruct
34
- } from "../chunk-C5ZEEH2Z.mjs";
35
+ } from "../chunk-ZA2XYCVX.mjs";
35
36
  export {
36
37
  CaveatBuilder,
37
38
  DELEGATION_ABI_TYPE,
@@ -42,6 +43,7 @@ export {
42
43
  SIGNABLE_USER_OP_TYPED_DATA,
43
44
  SIGNATURE_ABI_PARAMS,
44
45
  createCaveatBuilder,
46
+ decodeCaveat,
45
47
  decodeDelegation,
46
48
  decodeDelegations,
47
49
  deploySmartAccountsEnvironment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/smart-accounts-kit",
3
- "version": "1.1.0",
3
+ "version": "1.2.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)",
@@ -126,9 +126,9 @@
126
126
  "dependencies": {
127
127
  "@metamask/7715-permission-types": "^0.5.0",
128
128
  "@metamask/delegation-abis": "^1.0.0",
129
- "@metamask/delegation-core": "^1.0.0",
130
- "@metamask/delegation-deployments": "^1.1.0",
131
- "buffer": "^6.0.3",
129
+ "@metamask/delegation-core": "^1.1.0",
130
+ "@metamask/delegation-deployments": "^1.2.0",
131
+ "openapi-fetch": "^0.13.5",
132
132
  "ox": "0.8.1"
133
133
  },
134
134
  "devDependencies": {
@@ -150,6 +150,7 @@
150
150
  "eslint-plugin-n": "^17.10.3",
151
151
  "eslint-plugin-prettier": "^5.5.4",
152
152
  "eslint-plugin-promise": "^7.1.0",
153
+ "nock": "^14.0.4",
153
154
  "prettier": "^3.5.3",
154
155
  "sinon": "^18.0.0",
155
156
  "ts-node": "^10.9.2",