@metamask/smart-accounts-kit 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/dist/actions/index.cjs +4 -4
  3. package/dist/actions/index.d.cts +2 -2
  4. package/dist/actions/index.d.ts +2 -2
  5. package/dist/actions/index.mjs +3 -3
  6. package/dist/{caveats-CQbtzOKm.d.ts → caveats-BhjGBVHX.d.ts} +1 -1
  7. package/dist/{caveats-Cey0wm33.d.cts → caveats-CeHBbmt_.d.cts} +1 -1
  8. package/dist/{chunk-T4IAMAB2.cjs → chunk-6CEOFJY5.cjs} +173 -61
  9. package/dist/chunk-6CEOFJY5.cjs.map +1 -0
  10. package/dist/{chunk-VJXM3LWA.mjs → chunk-DVJX76J3.mjs} +2 -2
  11. package/dist/{chunk-ZA2XYCVX.mjs → chunk-EEIIVBNV.mjs} +22 -18
  12. package/dist/chunk-EEIIVBNV.mjs.map +1 -0
  13. package/dist/{chunk-G7VZ7E6W.mjs → chunk-FG2CQGSE.mjs} +3 -3
  14. package/dist/{chunk-L5DLMBDC.mjs → chunk-HQHXGWNJ.mjs} +4 -4
  15. package/dist/{chunk-UB2FLPP3.cjs → chunk-MVBU3LRV.cjs} +10 -10
  16. package/dist/{chunk-UB2FLPP3.cjs.map → chunk-MVBU3LRV.cjs.map} +1 -1
  17. package/dist/{chunk-734MOPHR.mjs → chunk-R2WT54GZ.mjs} +121 -9
  18. package/dist/chunk-R2WT54GZ.mjs.map +1 -0
  19. package/dist/{chunk-HFRQNSZE.cjs → chunk-RR2AMG4A.cjs} +102 -102
  20. package/dist/{chunk-HFRQNSZE.cjs.map → chunk-RR2AMG4A.cjs.map} +1 -1
  21. package/dist/{chunk-UZO5OYCD.cjs → chunk-SO5JAXGD.cjs} +11 -11
  22. package/dist/{chunk-UZO5OYCD.cjs.map → chunk-SO5JAXGD.cjs.map} +1 -1
  23. package/dist/{chunk-7BEEGBA2.cjs → chunk-TMO23YRP.cjs} +19 -15
  24. package/dist/chunk-TMO23YRP.cjs.map +1 -0
  25. package/dist/{chunk-3SHZ7PV2.cjs → chunk-XZ7UMCG3.cjs} +12 -12
  26. package/dist/{chunk-3SHZ7PV2.cjs.map → chunk-XZ7UMCG3.cjs.map} +1 -1
  27. package/dist/{chunk-YTNCEXUX.mjs → chunk-ZGBFPD4O.mjs} +2 -2
  28. package/dist/contracts/index.cjs +5 -5
  29. package/dist/contracts/index.d.cts +2 -2
  30. package/dist/contracts/index.d.ts +2 -2
  31. package/dist/contracts/index.mjs +4 -4
  32. package/dist/{delegation-Bx4FEAIU.d.ts → delegation-CR99q1-n.d.ts} +2 -6
  33. package/dist/{delegation-KbWHzRxV.d.cts → delegation-DoVULGYE.d.cts} +2 -6
  34. package/dist/experimental/index.cjs +7 -7
  35. package/dist/experimental/index.mjs +1 -1
  36. package/dist/{index-Uj_xXVko.d.cts → index-BToRQKyJ.d.cts} +27 -5
  37. package/dist/{index-D7fBuNV-.d.ts → index-Cg-JakqA.d.ts} +27 -5
  38. package/dist/{index-D2THBlfm.d.ts → index-DRKgDSZW.d.ts} +1 -1
  39. package/dist/{index-DE87r5KY.d.cts → index-DzL9ccjU.d.cts} +1 -1
  40. package/dist/index.cjs +22 -20
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +6 -6
  43. package/dist/index.d.ts +6 -6
  44. package/dist/index.mjs +9 -7
  45. package/dist/index.mjs.map +1 -1
  46. package/dist/utils/index.cjs +4 -4
  47. package/dist/utils/index.d.cts +2 -2
  48. package/dist/utils/index.d.ts +2 -2
  49. package/dist/utils/index.mjs +3 -3
  50. package/package.json +4 -4
  51. package/dist/chunk-734MOPHR.mjs.map +0 -1
  52. package/dist/chunk-7BEEGBA2.cjs.map +0 -1
  53. package/dist/chunk-T4IAMAB2.cjs.map +0 -1
  54. package/dist/chunk-ZA2XYCVX.mjs.map +0 -1
  55. /package/dist/{chunk-VJXM3LWA.mjs.map → chunk-DVJX76J3.mjs.map} +0 -0
  56. /package/dist/{chunk-G7VZ7E6W.mjs.map → chunk-FG2CQGSE.mjs.map} +0 -0
  57. /package/dist/{chunk-L5DLMBDC.mjs.map → chunk-HQHXGWNJ.mjs.map} +0 -0
  58. /package/dist/{chunk-YTNCEXUX.mjs.map → chunk-ZGBFPD4O.mjs.map} +0 -0
package/dist/index.cjs CHANGED
@@ -2,24 +2,24 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkT4IAMAB2cjs = require('./chunk-T4IAMAB2.cjs');
5
+ var _chunk6CEOFJY5cjs = require('./chunk-6CEOFJY5.cjs');
6
6
 
7
7
 
8
- var _chunkHFRQNSZEcjs = require('./chunk-HFRQNSZE.cjs');
9
- require('./chunk-3SHZ7PV2.cjs');
8
+ var _chunkRR2AMG4Acjs = require('./chunk-RR2AMG4A.cjs');
9
+ require('./chunk-XZ7UMCG3.cjs');
10
10
 
11
11
 
12
12
 
13
13
 
14
14
 
15
- var _chunkUB2FLPP3cjs = require('./chunk-UB2FLPP3.cjs');
15
+ var _chunkMVBU3LRVcjs = require('./chunk-MVBU3LRV.cjs');
16
16
 
17
17
 
18
18
 
19
19
 
20
20
 
21
21
  var _chunkSOFB2MXGcjs = require('./chunk-SOFB2MXG.cjs');
22
- require('./chunk-UZO5OYCD.cjs');
22
+ require('./chunk-SO5JAXGD.cjs');
23
23
 
24
24
 
25
25
 
@@ -38,8 +38,7 @@ var _chunkMOHCTPYQcjs = require('./chunk-MOHCTPYQ.cjs');
38
38
 
39
39
 
40
40
 
41
-
42
- var _chunk7BEEGBA2cjs = require('./chunk-7BEEGBA2.cjs');
41
+ var _chunkTMO23YRPcjs = require('./chunk-TMO23YRP.cjs');
43
42
 
44
43
  // src/toMetaMaskSmartAccount.ts
45
44
 
@@ -62,7 +61,7 @@ var signatureTypes = ["ECDSA"];
62
61
  var aggregateSignature = ({
63
62
  signatures
64
63
  }) => {
65
- _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0, "aggregateSignature", {
64
+ _chunkTMO23YRPcjs.trackSmartAccountsKitFunctionCall.call(void 0, "aggregateSignature", {
66
65
  signatureCount: signatures.length
67
66
  });
68
67
  if (signatures.length === 0) {
@@ -118,7 +117,7 @@ var resolveHybridSigner = (config) => {
118
117
  if (webAuthnAccount.type !== "webAuthn") {
119
118
  throw new Error("Account is not a webAuthn account");
120
119
  }
121
- const encodeSignature = (result) => _chunkUB2FLPP3cjs.encodeDeleGatorSignature.call(void 0,
120
+ const encodeSignature = (result) => _chunkMVBU3LRVcjs.encodeDeleGatorSignature.call(void 0,
122
121
  keyId,
123
122
  result.signature,
124
123
  result.webauthn.clientDataJSON,
@@ -126,7 +125,7 @@ var resolveHybridSigner = (config) => {
126
125
  );
127
126
  const signMessage = async (args) => webAuthnAccount.signMessage(args).then(encodeSignature);
128
127
  const signTypedData = async (typedDataDefinition) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);
129
- const getStubSignature = async () => _chunkUB2FLPP3cjs.createDummyWebAuthnSignature.call(void 0, keyId);
128
+ const getStubSignature = async () => _chunkMVBU3LRVcjs.createDummyWebAuthnSignature.call(void 0, keyId);
130
129
  return {
131
130
  signMessage,
132
131
  signTypedData,
@@ -237,7 +236,7 @@ async function toMetaMaskSmartAccount(params) {
237
236
  implementation,
238
237
  nonceKeyManager
239
238
  } = params;
240
- _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0, "toMetaMaskSmartAccount", {
239
+ _chunkTMO23YRPcjs.trackSmartAccountsKitFunctionCall.call(void 0, "toMetaMaskSmartAccount", {
241
240
  implementation,
242
241
  hasAddress: params.address !== void 0,
243
242
  hasEnvironment: params.environment !== void 0,
@@ -259,7 +258,7 @@ async function toMetaMaskSmartAccount(params) {
259
258
  if (implementation === "Stateless7702" /* Stateless7702 */) {
260
259
  throw new Error("Stateless7702 does not support counterfactual accounts");
261
260
  }
262
- const accountData = await _chunkUB2FLPP3cjs.getCounterfactualAccountData.call(void 0, {
261
+ const accountData = await _chunkMVBU3LRVcjs.getCounterfactualAccountData.call(void 0, {
263
262
  factory: environment.SimpleFactory,
264
263
  implementations: environment.implementations,
265
264
  implementation,
@@ -306,7 +305,7 @@ async function toMetaMaskSmartAccount(params) {
306
305
  );
307
306
  }
308
307
  const { delegation, chainId } = delegationParams;
309
- const delegationStruct = _chunk7BEEGBA2cjs.toDelegationStruct.call(void 0, {
308
+ const delegationStruct = _chunkTMO23YRPcjs.toDelegationStruct.call(void 0, {
310
309
  ...delegation,
311
310
  signature: "0x"
312
311
  });
@@ -317,7 +316,7 @@ async function toMetaMaskSmartAccount(params) {
317
316
  version: "1",
318
317
  verifyingContract: environment.DelegationManager
319
318
  },
320
- types: _chunk7BEEGBA2cjs.SIGNABLE_DELEGATION_TYPED_DATA,
319
+ types: _chunkTMO23YRPcjs.SIGNABLE_DELEGATION_TYPED_DATA,
321
320
  primaryType: "Delegation",
322
321
  message: delegationStruct
323
322
  });
@@ -349,7 +348,7 @@ async function toMetaMaskSmartAccount(params) {
349
348
  return signature;
350
349
  };
351
350
  const getAddress = async () => address;
352
- const encodeCalls = async (calls) => _chunkUB2FLPP3cjs.encodeCallsForCaller.call(void 0, address, calls);
351
+ const encodeCalls = async (calls) => _chunkMVBU3LRVcjs.encodeCallsForCaller.call(void 0, address, calls);
353
352
  const signerMethods = _nullishCoalesce(signer, () => ( {
354
353
  signMessage: async () => {
355
354
  throw new Error(
@@ -383,7 +382,7 @@ async function toMetaMaskSmartAccount(params) {
383
382
  if (implementation === "Stateless7702" /* Stateless7702 */) {
384
383
  return {
385
384
  ...smartAccount,
386
- isDeployed: async () => _chunkT4IAMAB2cjs.isValid7702Implementation.call(void 0, {
385
+ isDeployed: async () => _chunk6CEOFJY5cjs.isValid7702Implementation.call(void 0, {
387
386
  client,
388
387
  accountAddress: address,
389
388
  environment
@@ -393,15 +392,18 @@ async function toMetaMaskSmartAccount(params) {
393
392
  return smartAccount;
394
393
  }
395
394
 
395
+ // src/index.ts
396
+ var _delegationcore = require('@metamask/delegation-core');
397
+
396
398
  // src/actions/caveatEnforcerClient.ts
397
399
  function createCaveatEnforcerClient({
398
400
  client,
399
401
  environment
400
402
  }) {
401
- _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0, "createCaveatEnforcerClient", {
403
+ _chunkTMO23YRPcjs.trackSmartAccountsKitFunctionCall.call(void 0, "createCaveatEnforcerClient", {
402
404
  chainId: _nullishCoalesce(_optionalChain([client, 'access', _2 => _2.chain, 'optionalAccess', _3 => _3.id]), () => ( null))
403
405
  });
404
- return client.extend(_chunkT4IAMAB2cjs.caveatEnforcerActions.call(void 0, { environment }));
406
+ return client.extend(_chunk6CEOFJY5cjs.caveatEnforcerActions.call(void 0, { environment }));
405
407
  }
406
408
 
407
409
  // src/actions/infuraBundlerClient.ts
@@ -429,7 +431,7 @@ var infuraBundlerActions = () => (client) => ({
429
431
  }
430
432
  });
431
433
  function createInfuraBundlerClient(config) {
432
- _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0, "createInfuraBundlerClient", {
434
+ _chunkTMO23YRPcjs.trackSmartAccountsKitFunctionCall.call(void 0, "createInfuraBundlerClient", {
433
435
  chainId: _nullishCoalesce(_optionalChain([config, 'access', _4 => _4.chain, 'optionalAccess', _5 => _5.id]), () => ( null))
434
436
  });
435
437
  const baseBundlerClient = _accountabstraction.createBundlerClient.call(void 0, config);
@@ -460,5 +462,5 @@ function createInfuraBundlerClient(config) {
460
462
 
461
463
 
462
464
 
463
- exports.ANY_BENEFICIARY = _chunk7BEEGBA2cjs.ANY_BENEFICIARY; exports.BalanceChangeType = _chunk7BEEGBA2cjs.BalanceChangeType; exports.CaveatType = _chunk7BEEGBA2cjs.CaveatType; exports.ExecutionMode = _chunkMOHCTPYQcjs.ExecutionMode; exports.Implementation = _chunk7BEEGBA2cjs.Implementation; exports.PREFERRED_VERSION = _chunkSOFB2MXGcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunk7BEEGBA2cjs.ROOT_AUTHORITY; exports.ScopeType = _chunk7BEEGBA2cjs.ScopeType; exports.TransferWindow = _chunk7BEEGBA2cjs.TransferWindow; exports.actions = _chunkT4IAMAB2cjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunkHFRQNSZEcjs.contracts_exports; exports.createCaveat = _chunk7BEEGBA2cjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunk7BEEGBA2cjs.createDelegation; exports.createExecution = _chunkMOHCTPYQcjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunk7BEEGBA2cjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunkSOFB2MXGcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunk7BEEGBA2cjs.signDelegation; exports.signUserOperation = _chunkSOFB2MXGcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
465
+ exports.ANY_BENEFICIARY = _chunkTMO23YRPcjs.ANY_BENEFICIARY; exports.BalanceChangeType = _delegationcore.BalanceChangeType; exports.CaveatType = _chunkTMO23YRPcjs.CaveatType; exports.ExecutionMode = _chunkMOHCTPYQcjs.ExecutionMode; exports.Implementation = _chunkTMO23YRPcjs.Implementation; exports.PREFERRED_VERSION = _chunkSOFB2MXGcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunkTMO23YRPcjs.ROOT_AUTHORITY; exports.ScopeType = _chunkTMO23YRPcjs.ScopeType; exports.TransferWindow = _chunkTMO23YRPcjs.TransferWindow; exports.actions = _chunk6CEOFJY5cjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunkRR2AMG4Acjs.contracts_exports; exports.createCaveat = _chunkTMO23YRPcjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunkTMO23YRPcjs.createDelegation; exports.createExecution = _chunkMOHCTPYQcjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunkTMO23YRPcjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunkSOFB2MXGcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunkTMO23YRPcjs.signDelegation; exports.signUserOperation = _chunkSOFB2MXGcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
464
466
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/index.cjs","../src/toMetaMaskSmartAccount.ts","../src/signer.ts","../src/signatures.ts","../src/actions/caveatEnforcerClient.ts","../src/actions/infuraBundlerClient.ts"],"names":["signTypedData","signMessage","getStubSignature","signUserOperation","signDelegation"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC3CA;AACE;AACA;AACA;AAAA,2DACK;AAEP;AACE;AACA;AACA;AAAA,8DACK;AD4CP;AACA;AEvDA,4BAAuB;AFyDvB;AACA;AGzDA;AAIA,IAAM,eAAA,EAAiB,CAAC,OAAO,CAAA;AAoBxB,IAAM,mBAAA,EAAqB,CAAC;AAAA,EACjC;AACF,CAAA,EAAA,GAEW;AACT,EAAA,iEAAA,oBAAkC,EAAsB;AAAA,IACtD,cAAA,EAAgB,UAAA,CAAW;AAAA,EAC7B,CAAC,CAAA;AAED,EAAA,GAAA,CAAI,UAAA,CAAW,OAAA,IAAW,CAAA,EAAG;AAC3B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,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AACA,IAAA;AACG,IAAA;AACJ,EAAA;AAGG,EAAA;AACK,IAAA;AACF,MAAA;AAED,MAAA;AACE,QAAA;AACgB,QAAA;AAChB,QAAA;AACD,MAAA;AACL,IAAA;AACF,EAAA;AAGO,EAAA;AACT;ADoJsD;AACA;AI1WpD;AACA,EAAA;AACA,EAAA;AAIqD;AACnB,EAAA;AACH,IAAA;AAC9B,EAAA;AAE4C,EAAA;AAC/C;AJwWsD;AACA;AKrZtD;AACE;AAIK;AA2CiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYmB,EAAA;AACjD,IAAA;AAOa,IAAA;AACzB,MAAA;AACC,MAAA;AACV,IAAA;AACH,EAAA;AACF;AA0DqD;AACjB,EAAA;AACH,IAAA;AAC9B,EAAA;AAEmD,EAAA;AAG3B,EAAA;AACF,IAAA;AACvB,EAAA;AACF;ALwSsD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/index.cjs","sourcesContent":[null,"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"]}
1
+ {"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/index.cjs","../src/toMetaMaskSmartAccount.ts","../src/signer.ts","../src/signatures.ts","../src/index.ts","../src/actions/caveatEnforcerClient.ts","../src/actions/infuraBundlerClient.ts"],"names":["signTypedData","signMessage","getStubSignature","signUserOperation","signDelegation"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC1CA;AACE;AACA;AACA;AAAA,2DACK;AAEP;AACE;AACA;AACA;AAAA,8DACK;AD2CP;AACA;AEtDA,4BAAuB;AFwDvB;AACA;AGxDA;AAIA,IAAM,eAAA,EAAiB,CAAC,OAAO,CAAA;AAoBxB,IAAM,mBAAA,EAAqB,CAAC;AAAA,EACjC;AACF,CAAA,EAAA,GAEW;AACT,EAAA,iEAAA,oBAAkC,EAAsB;AAAA,IACtD,cAAA,EAAgB,UAAA,CAAW;AAAA,EAC7B,CAAC,CAAA;AAED,EAAA,GAAA,CAAI,UAAA,CAAW,OAAA,IAAW,CAAA,EAAG;AAC3B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAA,CAAA,MAAW,EAAE,KAAK,EAAA,GAAK,UAAA,EAAY;AACjC,IAAA,GAAA,CAAI,CAAC,cAAA,CAAe,QAAA,CAAS,IAAI,CAAA,EAAG;AAClC,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,wBAAA,EAA2B,IAAI,CAAA,CAAA;AACjD,IAAA;AACF,EAAA;AAGyC,EAAA;AACR,IAAA;AACjC,EAAA;AAGgD,EAAA;AAClD;AH4Bs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C/C;AL0WsD;AACA;AMvZtD;AACE;AAIK;AA2CiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYmB,EAAA;AACjD,IAAA;AAOa,IAAA;AACzB,MAAA;AACC,MAAA;AACV,IAAA;AACH,EAAA;AACF;AA0DqD;AACjB,EAAA;AACH,IAAA;AAC9B,EAAA;AAEmD,EAAA;AAG3B,EAAA;AACF,IAAA;AACvB,EAAA;AACF;AN0SsD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/index.cjs","sourcesContent":[null,"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"]}
package/dist/index.d.cts CHANGED
@@ -1,14 +1,14 @@
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 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-DoVULGYE.cjs';
4
+ export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-CeHBbmt_.cjs';
5
+ export { ANY_BENEFICIARY, BalanceChangeType, ROOT_AUTHORITY } from '@metamask/delegation-core';
5
6
  import { Address, Hex, Transport, Chain, Account, Client } from 'viem';
6
7
  export { s as signUserOperation } from './userOp-DKgjzz7B.cjs';
7
- export { i as contracts } from './index-DE87r5KY.cjs';
8
- import { c as caveatEnforcerActions } from './index-Uj_xXVko.cjs';
9
- export { i as actions } from './index-Uj_xXVko.cjs';
8
+ export { i as contracts } from './index-DzL9ccjU.cjs';
9
+ import { c as caveatEnforcerActions } from './index-BToRQKyJ.cjs';
10
+ export { i as actions } from './index-BToRQKyJ.cjs';
10
11
  import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
11
- export { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
12
12
  import '@metamask/delegation-abis';
13
13
  import 'viem/chains';
14
14
  import '@metamask/7715-permission-types';
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
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 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-CR99q1-n.js';
4
+ export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-BhjGBVHX.js';
5
+ export { ANY_BENEFICIARY, BalanceChangeType, ROOT_AUTHORITY } from '@metamask/delegation-core';
5
6
  import { Address, Hex, Transport, Chain, Account, Client } from 'viem';
6
7
  export { s as signUserOperation } from './userOp-DKgjzz7B.js';
7
- export { i as contracts } from './index-D2THBlfm.js';
8
- import { c as caveatEnforcerActions } from './index-D7fBuNV-.js';
9
- export { i as actions } from './index-D7fBuNV-.js';
8
+ export { i as contracts } from './index-DRKgDSZW.js';
9
+ import { c as caveatEnforcerActions } from './index-Cg-JakqA.js';
10
+ export { i as actions } from './index-Cg-JakqA.js';
10
11
  import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
11
- export { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
12
12
  import '@metamask/delegation-abis';
13
13
  import 'viem/chains';
14
14
  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-734MOPHR.mjs";
5
+ } from "./chunk-R2WT54GZ.mjs";
6
6
  import {
7
7
  contracts_exports
8
- } from "./chunk-L5DLMBDC.mjs";
9
- import "./chunk-VJXM3LWA.mjs";
8
+ } from "./chunk-HQHXGWNJ.mjs";
9
+ import "./chunk-DVJX76J3.mjs";
10
10
  import {
11
11
  createDummyWebAuthnSignature,
12
12
  encodeCallsForCaller,
13
13
  encodeDeleGatorSignature,
14
14
  getCounterfactualAccountData
15
- } from "./chunk-G7VZ7E6W.mjs";
15
+ } from "./chunk-FG2CQGSE.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-YTNCEXUX.mjs";
22
+ import "./chunk-ZGBFPD4O.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-ZA2XYCVX.mjs";
41
+ } from "./chunk-EEIIVBNV.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,iBAA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B,YAAY;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,eAAe,MAAM,eAAe;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAAA;AAAA,IACA,gBAAAD;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AAGD,MAAI,wDAAiD;AACnD,WAAO;AAAA,MACL,GAAG;AAAA,MACH,YAAY,YACV,0BAA0B;AAAA,QACxB;AAAA,QACA,gBAAgB;AAAA,QAChB;AAAA,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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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A;AAAA,IACA;AAAA,IACA,mBAAAA;AAAA,IACA,gBAAAD;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AAGD,MAAI,wDAAiD;AACnD,WAAO;AAAA,MACL,GAAG;AAAA,MACH,YAAY,YACV,0BAA0B;AAAA,QACxB;AAAA,QACA,gBAAgB;AAAA,QAChB;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACF;AAGA,SAAO;AACT;;;AGhMA,SAAS,yBAAyB;;;ACzB3B,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"]}
@@ -3,13 +3,13 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkUB2FLPP3cjs = require('../chunk-UB2FLPP3.cjs');
6
+ var _chunkMVBU3LRVcjs = require('../chunk-MVBU3LRV.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
  var _chunkSOFB2MXGcjs = require('../chunk-SOFB2MXG.cjs');
12
- require('../chunk-UZO5OYCD.cjs');
12
+ require('../chunk-SO5JAXGD.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 _chunk7BEEGBA2cjs = require('../chunk-7BEEGBA2.cjs');
35
+ var _chunkTMO23YRPcjs = require('../chunk-TMO23YRP.cjs');
36
36
 
37
37
 
38
38
 
@@ -60,5 +60,5 @@ var _chunk7BEEGBA2cjs = require('../chunk-7BEEGBA2.cjs');
60
60
 
61
61
 
62
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;
63
+ exports.CaveatBuilder = _chunkTMO23YRPcjs.CaveatBuilder; exports.DELEGATION_ABI_TYPE = _chunkTMO23YRPcjs.DELEGATION_ABI_TYPE; exports.DELEGATION_ABI_TYPE_COMPONENTS = _chunkTMO23YRPcjs.DELEGATION_ABI_TYPE_COMPONENTS; exports.DELEGATION_ARRAY_ABI_TYPE = _chunkTMO23YRPcjs.DELEGATION_ARRAY_ABI_TYPE; exports.DELEGATION_TYPEHASH = _chunkTMO23YRPcjs.DELEGATION_TYPEHASH; exports.SIGNABLE_DELEGATION_TYPED_DATA = _chunkTMO23YRPcjs.SIGNABLE_DELEGATION_TYPED_DATA; exports.SIGNABLE_USER_OP_TYPED_DATA = _chunkSOFB2MXGcjs.SIGNABLE_USER_OP_TYPED_DATA; exports.SIGNATURE_ABI_PARAMS = _chunkMVBU3LRVcjs.SIGNATURE_ABI_PARAMS; exports.createCaveatBuilder = _chunkTMO23YRPcjs.createCaveatBuilder; exports.decodeCaveat = _chunkTMO23YRPcjs.decodeCaveat; exports.decodeDelegation = _chunkTMO23YRPcjs.decodeDelegation; exports.decodeDelegations = _chunkTMO23YRPcjs.decodeDelegations; exports.deploySmartAccountsEnvironment = _chunkSOFB2MXGcjs.deploySmartAccountsEnvironment; exports.encodeBatchExecution = _chunkMOHCTPYQcjs.encodeBatchExecution; exports.encodeCalls = _chunkMVBU3LRVcjs.encodeCalls; exports.encodeCallsForCaller = _chunkMVBU3LRVcjs.encodeCallsForCaller; exports.encodeDelegation = _chunkTMO23YRPcjs.encodeDelegation; exports.encodeDelegations = _chunkTMO23YRPcjs.encodeDelegations; exports.encodeExecutionCalldata = _chunkMOHCTPYQcjs.encodeExecutionCalldata; exports.encodeExecutionCalldatas = _chunkMOHCTPYQcjs.encodeExecutionCalldatas; exports.encodeSingleExecution = _chunkMOHCTPYQcjs.encodeSingleExecution; exports.getCounterfactualAccountData = _chunkMVBU3LRVcjs.getCounterfactualAccountData; exports.hashDelegation = _chunkTMO23YRPcjs.hashDelegation; exports.overrideDeployedEnvironment = _chunkSOFB2MXGcjs.overrideDeployedEnvironment; exports.toDelegation = _chunkTMO23YRPcjs.toDelegation; exports.toDelegationStruct = _chunkTMO23YRPcjs.toDelegationStruct;
64
64
  //# sourceMappingURL=index.cjs.map