@metamask/smart-accounts-kit 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/README.md +34 -2
  3. package/dist/actions/index.cjs +5 -5
  4. package/dist/actions/index.d.cts +2 -2
  5. package/dist/actions/index.d.ts +2 -2
  6. package/dist/actions/index.mjs +4 -4
  7. package/dist/{smartAccountsEnvironment-Czw9KUYZ.d.cts → caveats-CQbtzOKm.d.ts} +9 -2
  8. package/dist/{smartAccountsEnvironment-u1CcFcGE.d.ts → caveats-Cey0wm33.d.cts} +9 -2
  9. package/dist/{chunk-UUOH2WAW.cjs → chunk-3SHZ7PV2.cjs} +12 -12
  10. package/dist/{chunk-UUOH2WAW.cjs.map → chunk-3SHZ7PV2.cjs.map} +1 -1
  11. package/dist/{chunk-TPBFVDVM.mjs → chunk-4QXIOE7F.mjs} +8 -6
  12. package/dist/chunk-4QXIOE7F.mjs.map +1 -0
  13. package/dist/{chunk-NOCLGZGB.mjs → chunk-734MOPHR.mjs} +63 -5
  14. package/dist/chunk-734MOPHR.mjs.map +1 -0
  15. package/dist/{chunk-YDLLC6PP.cjs → chunk-7BEEGBA2.cjs} +519 -16
  16. package/dist/chunk-7BEEGBA2.cjs.map +1 -0
  17. package/dist/{chunk-45GHWVQA.mjs → chunk-G7VZ7E6W.mjs} +4 -4
  18. package/dist/{chunk-XN36L4RX.cjs → chunk-HFRQNSZE.cjs} +106 -107
  19. package/dist/chunk-HFRQNSZE.cjs.map +1 -0
  20. package/dist/{chunk-33AMUJBJ.mjs → chunk-L5DLMBDC.mjs} +5 -6
  21. package/dist/{chunk-VLKX4BR6.cjs → chunk-MOHCTPYQ.cjs} +8 -6
  22. package/dist/chunk-MOHCTPYQ.cjs.map +1 -0
  23. package/dist/{chunk-QMRKCB7T.cjs → chunk-T4IAMAB2.cjs} +102 -44
  24. package/dist/chunk-T4IAMAB2.cjs.map +1 -0
  25. package/dist/{chunk-BYWRJGSK.cjs → chunk-UB2FLPP3.cjs} +16 -16
  26. package/dist/{chunk-BYWRJGSK.cjs.map → chunk-UB2FLPP3.cjs.map} +1 -1
  27. package/dist/{chunk-23YXLKTX.cjs → chunk-UZO5OYCD.cjs} +14 -14
  28. package/dist/{chunk-23YXLKTX.cjs.map → chunk-UZO5OYCD.cjs.map} +1 -1
  29. package/dist/{chunk-YTELOQ4I.mjs → chunk-VJXM3LWA.mjs} +2 -2
  30. package/dist/{chunk-WV2R7BXP.mjs → chunk-YTNCEXUX.mjs} +3 -3
  31. package/dist/{chunk-C5ZEEH2Z.mjs → chunk-ZA2XYCVX.mjs} +517 -14
  32. package/dist/chunk-ZA2XYCVX.mjs.map +1 -0
  33. package/dist/contracts/index.cjs +6 -6
  34. package/dist/contracts/index.d.cts +3 -3
  35. package/dist/contracts/index.d.ts +3 -3
  36. package/dist/contracts/index.mjs +5 -5
  37. package/dist/{delegation-DIriDFkq.d.cts → delegation-Bx4FEAIU.d.ts} +2 -2
  38. package/dist/{delegation-CvVXs0PO.d.ts → delegation-KbWHzRxV.d.cts} +2 -2
  39. package/dist/experimental/index.cjs +36 -4
  40. package/dist/experimental/index.cjs.map +1 -1
  41. package/dist/experimental/index.d.cts +5 -2
  42. package/dist/experimental/index.d.ts +5 -2
  43. package/dist/experimental/index.mjs +35 -3
  44. package/dist/experimental/index.mjs.map +1 -1
  45. package/dist/{index-ChTryO1-.d.ts → index-D2THBlfm.d.ts} +3 -3
  46. package/dist/{index-5EdxVa_d.d.ts → index-D7fBuNV-.d.ts} +3 -3
  47. package/dist/{index-DC9baw8F.d.cts → index-DE87r5KY.d.cts} +3 -3
  48. package/dist/{index-Dvc4ir4O.d.cts → index-Uj_xXVko.d.cts} +3 -3
  49. package/dist/index.cjs +36 -26
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +10 -12
  52. package/dist/index.d.ts +10 -12
  53. package/dist/index.mjs +28 -18
  54. package/dist/index.mjs.map +1 -1
  55. package/dist/{types-qdEHxd5Q.d.ts → types-BWaH4KH1.d.cts} +3 -2
  56. package/dist/{types-qdEHxd5Q.d.cts → types-BWaH4KH1.d.ts} +3 -2
  57. package/dist/utils/index.cjs +7 -5
  58. package/dist/utils/index.cjs.map +1 -1
  59. package/dist/utils/index.d.cts +3 -3
  60. package/dist/utils/index.d.ts +3 -3
  61. package/dist/utils/index.mjs +6 -4
  62. package/package.json +5 -4
  63. package/dist/chunk-C5ZEEH2Z.mjs.map +0 -1
  64. package/dist/chunk-NOCLGZGB.mjs.map +0 -1
  65. package/dist/chunk-QMRKCB7T.cjs.map +0 -1
  66. package/dist/chunk-TPBFVDVM.mjs.map +0 -1
  67. package/dist/chunk-VLKX4BR6.cjs.map +0 -1
  68. package/dist/chunk-XN36L4RX.cjs.map +0 -1
  69. package/dist/chunk-YDLLC6PP.cjs.map +0 -1
  70. /package/dist/{chunk-45GHWVQA.mjs.map → chunk-G7VZ7E6W.mjs.map} +0 -0
  71. /package/dist/{chunk-33AMUJBJ.mjs.map → chunk-L5DLMBDC.mjs.map} +0 -0
  72. /package/dist/{chunk-YTELOQ4I.mjs.map → chunk-VJXM3LWA.mjs.map} +0 -0
  73. /package/dist/{chunk-WV2R7BXP.mjs.map → chunk-YTNCEXUX.mjs.map} +0 -0
@@ -1,9 +1,20 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkYDLLC6PPcjs = require('../chunk-YDLLC6PP.cjs');
3
+
4
+ var _chunk7BEEGBA2cjs = require('../chunk-7BEEGBA2.cjs');
4
5
 
5
6
  // src/experimental/delegationStorage.ts
6
7
  var _viem = require('viem');
8
+ var DelegationStorageEnvironment = {
9
+ dev: { apiUrl: "https://passkeys.dev-api.cx.metamask.io" },
10
+ prod: { apiUrl: "https://passkeys.api.cx.metamask.io" }
11
+ };
12
+ function getDelegationStorageEnvironment(apiUrl) {
13
+ const matchingEnvironment = Object.entries(DelegationStorageEnvironment).find(
14
+ ([_, env]) => env.apiUrl === apiUrl
15
+ );
16
+ return matchingEnvironment ? matchingEnvironment[0] : "custom";
17
+ }
7
18
  var DelegationStorageClient = class {
8
19
  #apiVersionPrefix = "api/v0";
9
20
  #config;
@@ -11,6 +22,12 @@ var DelegationStorageClient = class {
11
22
  #apiUrl;
12
23
  constructor(config) {
13
24
  const { apiUrl } = config.environment;
25
+ _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0,
26
+ "experimental.DelegationStorageClient.constructor",
27
+ {
28
+ environment: getDelegationStorageEnvironment(apiUrl)
29
+ }
30
+ );
14
31
  if (apiUrl.endsWith(this.#apiVersionPrefix)) {
15
32
  this.#apiUrl = apiUrl;
16
33
  } else {
@@ -51,7 +68,13 @@ var DelegationStorageClient = class {
51
68
  * is not found.
52
69
  */
53
70
  async getDelegationChain(leafDelegationOrDelegationHash) {
54
- const leafDelegationHash = typeof leafDelegationOrDelegationHash === "string" ? leafDelegationOrDelegationHash : _chunkYDLLC6PPcjs.hashDelegation.call(void 0, leafDelegationOrDelegationHash);
71
+ _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0,
72
+ "experimental.DelegationStorageClient.getDelegationChain",
73
+ {
74
+ inputKind: typeof leafDelegationOrDelegationHash === "string" ? "hash" : "delegation"
75
+ }
76
+ );
77
+ const leafDelegationHash = typeof leafDelegationOrDelegationHash === "string" ? leafDelegationOrDelegationHash : _chunk7BEEGBA2cjs.hashDelegation.call(void 0, leafDelegationOrDelegationHash);
55
78
  const response = await this.#fetcher(
56
79
  `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,
57
80
  {
@@ -81,6 +104,10 @@ var DelegationStorageClient = class {
81
104
  * empty array if the delegations are not found.
82
105
  */
83
106
  async fetchDelegations(deleGatorAddress, filterMode = "RECEIVED" /* Received */) {
107
+ _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0,
108
+ "experimental.DelegationStorageClient.fetchDelegations",
109
+ { filterMode }
110
+ );
84
111
  const response = await this.#fetcher(
85
112
  `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,
86
113
  {
@@ -104,10 +131,14 @@ var DelegationStorageClient = class {
104
131
  * @returns A promise that resolves to the delegation hash indicating successful storage.
105
132
  */
106
133
  async storeDelegation(delegation) {
134
+ _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0,
135
+ "experimental.DelegationStorageClient.storeDelegation",
136
+ { caveatCount: delegation.caveats.length }
137
+ );
107
138
  if (!delegation.signature || delegation.signature === "0x") {
108
139
  throw new Error("Delegation must be signed to be stored");
109
140
  }
110
- const delegationHash = _chunkYDLLC6PPcjs.hashDelegation.call(void 0, delegation);
141
+ const delegationHash = _chunk7BEEGBA2cjs.hashDelegation.call(void 0, delegation);
111
142
  const body = JSON.stringify(
112
143
  {
113
144
  ...delegation,
@@ -139,5 +170,6 @@ var DelegationStorageClient = class {
139
170
  };
140
171
 
141
172
 
142
- exports.DelegationStorageClient = DelegationStorageClient;
173
+
174
+ exports.DelegationStorageClient = DelegationStorageClient; exports.DelegationStorageEnvironment = DelegationStorageEnvironment;
143
175
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/experimental/index.cjs","../../src/experimental/delegationStorage.ts"],"names":[],"mappings":"AAAA;AACE;AACF,yDAA8B;AAC9B;AACA;ACJA,4BAAgC;AA6CzB,IAAM,wBAAA,EAAN,M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AAA;AAClB,IAAA;AAEO,IAAA;AACT,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQM,EAAA;AACY,IAAA;AACE,MAAA;AAClB,IAAA;AAEM,IAAA;AAEY,IAAA;AAChB,MAAA;AACK,QAAA;AACQ,QAAA;AACb,MAAA;AAEE,MAAA;AAGF,MAAA;AACF,IAAA;AAEiB,IAAA;AACP,MAAA;AACC,MAAA;AACP,QAAA;AACA,QAAA;AACA,QAAA;AACF,MAAA;AACA,MAAA;AACD,IAAA;AAEK,IAAA;AAGS,IAAA;AACG,MAAA;AAClB,IAAA;AAEiB,IAAA;AACL,MAAA;AACR,QAAA;AACF,MAAA;AACF,IAAA;AAEO,IAAA;AACT,EAAA;AACF;ADzEsB;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/experimental/index.cjs","sourcesContent":[null,"import { type Hex, toHex } from 'viem';\n\nimport { hashDelegation } from '../delegation';\nimport type { Delegation } from '../types';\n\ntype ErrorResponse = {\n error: string;\n data?: any;\n};\n\nexport type APIStoreDelegationResponse = {\n delegationHash: Hex;\n};\n\n/**\n * Represents the allowed filters when querying the data store for delegations.\n */\nexport enum DelegationStoreFilter {\n Given = 'GIVEN',\n Received = 'RECEIVED',\n All = 'ALL',\n}\n\n/**\n * Public Delegation Storage Service environments. To be used in the\n * DeleGationStorageService config.\n */\nexport const DelegationStorageEnvironment: {\n [K in 'dev' | 'prod']: Environment;\n} = {\n dev: { apiUrl: 'https://passkeys.dev-api.cx.metamask.io' },\n prod: { apiUrl: 'https://passkeys.api.cx.metamask.io' },\n};\n\nexport type Environment = {\n apiUrl: string;\n};\n\nexport type DelegationStorageConfig = {\n apiKey: string;\n apiKeyId: string;\n environment: Environment;\n fetcher?: typeof fetch;\n};\n\nexport class DelegationStorageClient {\n readonly #apiVersionPrefix = 'api/v0';\n\n readonly #config: DelegationStorageConfig;\n\n readonly #fetcher: typeof fetch;\n\n readonly #apiUrl: string;\n\n constructor(config: DelegationStorageConfig) {\n const { apiUrl } = config.environment;\n\n if (apiUrl.endsWith(this.#apiVersionPrefix)) {\n this.#apiUrl = apiUrl;\n } else {\n const separator = apiUrl.endsWith('/') ? '' : '/';\n this.#apiUrl = `${apiUrl}${separator}${this.#apiVersionPrefix}`;\n }\n this.#fetcher = this.#initializeFetcher(config);\n this.#config = config;\n }\n\n /**\n * Initializes the fetch function for HTTP requests.\n *\n * - Uses `config.fetcher` if provided.\n * - Falls back to global `fetch` if available.\n * - Throws an error if no fetch function is available.\n *\n * @param config - Configuration object that may include a custom fetch function.\n * @returns The fetch function to be used for HTTP requests.\n * @throws Error if no fetch function is available in the environment.\n */\n #initializeFetcher(config: DelegationStorageConfig): typeof fetch {\n if (config.fetcher) {\n return config.fetcher;\n } else if (typeof globalThis?.fetch === 'function') {\n return globalThis.fetch.bind(globalThis);\n }\n throw new Error(\n 'Fetch API is not available in this environment. Please provide a fetch function in the config.',\n );\n }\n\n /**\n * Fetches the delegation chain from the Delegation Storage Service, ending with\n * the specified leaf delegation.\n *\n * @param leafDelegationOrDelegationHash - The leaf delegation, or the hash\n * of the leaf delegation.\n * @returns A promise that resolves to the delegation chain - empty array if the delegation\n * is not found.\n */\n async getDelegationChain(\n leafDelegationOrDelegationHash: Hex | Delegation,\n ): Promise<Delegation[]> {\n const leafDelegationHash =\n typeof leafDelegationOrDelegationHash === 'string'\n ? leafDelegationOrDelegationHash\n : hashDelegation(leafDelegationOrDelegationHash);\n\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(\n `Failed to fetch delegation chain: ${responseData.error}`,\n );\n }\n\n return responseData;\n }\n\n /**\n * Fetches the delegations from the Delegation Storage Service, either `Received`\n * by, or `Given` by, (or both: `All`) the specified deleGatorAddress. Defaults\n * to `Received`.\n *\n * @param deleGatorAddress - The deleGatorAddress to retrieve the delegations for.\n * @param filterMode - The DelegationStoreFilter mode - defaults to Received.\n * @returns A promise that resolves to the list of delegations received by the deleGatorAddress,\n * empty array if the delegations are not found.\n */\n async fetchDelegations(\n deleGatorAddress: Hex,\n filterMode = DelegationStoreFilter.Received,\n ): Promise<Delegation[]> {\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(`Failed to fetch delegations: ${responseData.error}`);\n }\n\n return responseData;\n }\n\n /**\n * Stores the specified delegation in the Delegation Storage Service.\n *\n * @param delegation - The delegation to store.\n * @returns A promise that resolves to the delegation hash indicating successful storage.\n */\n async storeDelegation(delegation: Delegation): Promise<Hex> {\n if (!delegation.signature || delegation.signature === '0x') {\n throw new Error('Delegation must be signed to be stored');\n }\n\n const delegationHash = hashDelegation(delegation);\n\n const body = JSON.stringify(\n {\n ...delegation,\n metadata: [],\n },\n (_, value: any) =>\n typeof value === 'bigint' || typeof value === 'number'\n ? toHex(value)\n : value,\n 2,\n );\n\n const response = await this.#fetcher(`${this.#apiUrl}/delegation/store`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n 'Content-Type': 'application/json',\n },\n body,\n });\n\n const responseData: APIStoreDelegationResponse | ErrorResponse =\n await response.json();\n\n if ('error' in responseData) {\n throw new Error(responseData.error);\n }\n\n if (responseData.delegationHash !== delegationHash) {\n throw new Error(\n 'Failed to store the Delegation, the hash returned from the MM delegation storage API does not match the hash of the delegation',\n );\n }\n\n return responseData.delegationHash;\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/experimental/index.cjs","../../src/experimental/delegationStorage.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,yDAA8B;AAC9B;AACA;ACLA,4BAAgC;AA4BzB,IAAM,6BAAA,EAET;AAAA,EACF,GAAA,EAAK,EAAE,MAAA,EAAQ,0CAA0C,CAAA;AAAA,EACzD,IAAA,EAAM,EAAE,MAAA,EAAQ,sCAAsC;AACxD,CAAA;AASA,SAAS,+BAAA,CACP,MAAA,EAC2B;AAC3B,EAAA,MAAM,oBAAA,EAAsB,MAAA,CAAO,OAAA,CAAQ,4BAA4B,CAAA,CAAE,IAAA;AAAA,IACvE,CAAC,CAAC,CAAA,EAAG,GAAG,CAAA,EAAA,GAAM,GAAA,CAAI,OAAA,IAAW;AAAA,EAC/B,CAAA;AAEA,EAAA,OAAO,oBAAA,EAAsB,mBAAA,CAAoB,CAAC,EAAA,EAAI,QAAA;AACxD;AAaO,IAAM,wBAAA,EAAN,MAA8B;AAAA,EAC1B,CAAA,iBAAA,EAAoB,QAAA;AAAA,EAEpB,CAAA,MAAA;AAAA,EAEA,CAAA,OAAA;AAAA,EAEA,CAAA,MAAA;AAAA,EAET,WAAA,CAAY,MAAA,EAAiC;AAC3C,IAAA,MAAM,EAAE,OAAO,EAAA,EAAI,MAAA,CAAO,WAAA;AAE1B,IAAA,iEAAA;AAAA,MACE,kDAAA;AAAA,MACA;AAAA,QACE,WAAA,EAAa,+BAAA,CAAgC,MAAM;AAAA,MACrD;AAAA,IACF,CAAA;AAEA,IAAA,GAAA,CAAI,MAAA,CAAO,QAAA,CAAS,IAAA,CAAK,CAAA,gBAAiB,CAAA,EAAG;AAC3C,MAAA,IAAA,CAAK,CAAA,OAAA,EAAU,MAAA;AAAA,IACjB,EAAA,KAAO;AACL,MAAA,MAAM,UAAA,EAAY,MAAA,CAAO,QAAA,CAAS,GAAG,EAAA,EAAI,GAAA,EAAK,GAAA;AA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A,MAAA;AACD,IAAA;AAEK,IAAA;AAGS,IAAA;AACG,MAAA;AAClB,IAAA;AAEiB,IAAA;AACL,MAAA;AACR,QAAA;AACF,MAAA;AACF,IAAA;AAEO,IAAA;AACT,EAAA;AACF;ADpFsB;AACA;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/experimental/index.cjs","sourcesContent":[null,"import { type Hex, toHex } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { hashDelegation } from '../delegation';\nimport type { Delegation } from '../types';\n\ntype ErrorResponse = {\n error: string;\n data?: any;\n};\n\nexport type APIStoreDelegationResponse = {\n delegationHash: Hex;\n};\n\n/**\n * Represents the allowed filters when querying the data store for delegations.\n */\nexport enum DelegationStoreFilter {\n Given = 'GIVEN',\n Received = 'RECEIVED',\n All = 'ALL',\n}\n\n/**\n * Public Delegation Storage Service environments. To be used in the\n * DeleGationStorageService config.\n */\nexport const DelegationStorageEnvironment: {\n [K in 'dev' | 'prod']: Environment;\n} = {\n dev: { apiUrl: 'https://passkeys.dev-api.cx.metamask.io' },\n prod: { apiUrl: 'https://passkeys.api.cx.metamask.io' },\n};\n\n/**\n * Returns the DelegationStorageEnvironment ('dev' or 'prod') for a given apiUrl,\n * or 'custom' if the apiUrl does not match a known environment.\n *\n * @param apiUrl - The API URL to check.\n * @returns The environment key ('dev' or 'prod'), or 'custom'.\n */\nfunction getDelegationStorageEnvironment(\n apiUrl: string,\n): 'dev' | 'prod' | 'custom' {\n const matchingEnvironment = Object.entries(DelegationStorageEnvironment).find(\n ([_, env]) => env.apiUrl === apiUrl,\n ) as [keyof typeof DelegationStorageEnvironment, Environment] | undefined;\n\n return matchingEnvironment ? matchingEnvironment[0] : 'custom';\n}\n\nexport type Environment = {\n apiUrl: string;\n};\n\nexport type DelegationStorageConfig = {\n apiKey: string;\n apiKeyId: string;\n environment: Environment;\n fetcher?: typeof fetch;\n};\n\nexport class DelegationStorageClient {\n readonly #apiVersionPrefix = 'api/v0';\n\n readonly #config: DelegationStorageConfig;\n\n readonly #fetcher: typeof fetch;\n\n readonly #apiUrl: string;\n\n constructor(config: DelegationStorageConfig) {\n const { apiUrl } = config.environment;\n\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.constructor',\n {\n environment: getDelegationStorageEnvironment(apiUrl),\n },\n );\n\n if (apiUrl.endsWith(this.#apiVersionPrefix)) {\n this.#apiUrl = apiUrl;\n } else {\n const separator = apiUrl.endsWith('/') ? '' : '/';\n this.#apiUrl = `${apiUrl}${separator}${this.#apiVersionPrefix}`;\n }\n this.#fetcher = this.#initializeFetcher(config);\n this.#config = config;\n }\n\n /**\n * Initializes the fetch function for HTTP requests.\n *\n * - Uses `config.fetcher` if provided.\n * - Falls back to global `fetch` if available.\n * - Throws an error if no fetch function is available.\n *\n * @param config - Configuration object that may include a custom fetch function.\n * @returns The fetch function to be used for HTTP requests.\n * @throws Error if no fetch function is available in the environment.\n */\n #initializeFetcher(config: DelegationStorageConfig): typeof fetch {\n if (config.fetcher) {\n return config.fetcher;\n } else if (typeof globalThis?.fetch === 'function') {\n return globalThis.fetch.bind(globalThis);\n }\n throw new Error(\n 'Fetch API is not available in this environment. Please provide a fetch function in the config.',\n );\n }\n\n /**\n * Fetches the delegation chain from the Delegation Storage Service, ending with\n * the specified leaf delegation.\n *\n * @param leafDelegationOrDelegationHash - The leaf delegation, or the hash\n * of the leaf delegation.\n * @returns A promise that resolves to the delegation chain - empty array if the delegation\n * is not found.\n */\n async getDelegationChain(\n leafDelegationOrDelegationHash: Hex | Delegation,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.getDelegationChain',\n {\n inputKind:\n typeof leafDelegationOrDelegationHash === 'string'\n ? 'hash'\n : 'delegation',\n },\n );\n const leafDelegationHash =\n typeof leafDelegationOrDelegationHash === 'string'\n ? leafDelegationOrDelegationHash\n : hashDelegation(leafDelegationOrDelegationHash);\n\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(\n `Failed to fetch delegation chain: ${responseData.error}`,\n );\n }\n\n return responseData;\n }\n\n /**\n * Fetches the delegations from the Delegation Storage Service, either `Received`\n * by, or `Given` by, (or both: `All`) the specified deleGatorAddress. Defaults\n * to `Received`.\n *\n * @param deleGatorAddress - The deleGatorAddress to retrieve the delegations for.\n * @param filterMode - The DelegationStoreFilter mode - defaults to Received.\n * @returns A promise that resolves to the list of delegations received by the deleGatorAddress,\n * empty array if the delegations are not found.\n */\n async fetchDelegations(\n deleGatorAddress: Hex,\n filterMode = DelegationStoreFilter.Received,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.fetchDelegations',\n { filterMode },\n );\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(`Failed to fetch delegations: ${responseData.error}`);\n }\n\n return responseData;\n }\n\n /**\n * Stores the specified delegation in the Delegation Storage Service.\n *\n * @param delegation - The delegation to store.\n * @returns A promise that resolves to the delegation hash indicating successful storage.\n */\n async storeDelegation(delegation: Delegation): Promise<Hex> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.storeDelegation',\n { caveatCount: delegation.caveats.length },\n );\n if (!delegation.signature || delegation.signature === '0x') {\n throw new Error('Delegation must be signed to be stored');\n }\n\n const delegationHash = hashDelegation(delegation);\n\n const body = JSON.stringify(\n {\n ...delegation,\n metadata: [],\n },\n (_, value: any) =>\n typeof value === 'bigint' || typeof value === 'number'\n ? toHex(value)\n : value,\n 2,\n );\n\n const response = await this.#fetcher(`${this.#apiUrl}/delegation/store`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n 'Content-Type': 'application/json',\n },\n body,\n });\n\n const responseData: APIStoreDelegationResponse | ErrorResponse =\n await response.json();\n\n if ('error' in responseData) {\n throw new Error(responseData.error);\n }\n\n if (responseData.delegationHash !== delegationHash) {\n throw new Error(\n 'Failed to store the Delegation, the hash returned from the MM delegation storage API does not match the hash of the delegation',\n );\n }\n\n return responseData.delegationHash;\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Hex } from 'viem';
2
- import { D as Delegation } from '../types-qdEHxd5Q.cjs';
2
+ import { D as Delegation } from '../types-BWaH4KH1.cjs';
3
3
  import '@metamask/delegation-abis';
4
4
  import 'viem/account-abstraction';
5
5
  import 'viem/chains';
@@ -9,6 +9,9 @@ declare enum DelegationStoreFilter {
9
9
  Received = "RECEIVED",
10
10
  All = "ALL"
11
11
  }
12
+ declare const DelegationStorageEnvironment: {
13
+ [K in 'dev' | 'prod']: Environment;
14
+ };
12
15
  type Environment = {
13
16
  apiUrl: string;
14
17
  };
@@ -26,4 +29,4 @@ declare class DelegationStorageClient {
26
29
  storeDelegation(delegation: Delegation): Promise<Hex>;
27
30
  }
28
31
 
29
- export { DelegationStorageClient, type DelegationStorageConfig, DelegationStoreFilter, type Environment };
32
+ export { DelegationStorageClient, type DelegationStorageConfig, DelegationStorageEnvironment, DelegationStoreFilter, type Environment };
@@ -1,5 +1,5 @@
1
1
  import { Hex } from 'viem';
2
- import { D as Delegation } from '../types-qdEHxd5Q.js';
2
+ import { D as Delegation } from '../types-BWaH4KH1.js';
3
3
  import '@metamask/delegation-abis';
4
4
  import 'viem/account-abstraction';
5
5
  import 'viem/chains';
@@ -9,6 +9,9 @@ declare enum DelegationStoreFilter {
9
9
  Received = "RECEIVED",
10
10
  All = "ALL"
11
11
  }
12
+ declare const DelegationStorageEnvironment: {
13
+ [K in 'dev' | 'prod']: Environment;
14
+ };
12
15
  type Environment = {
13
16
  apiUrl: string;
14
17
  };
@@ -26,4 +29,4 @@ declare class DelegationStorageClient {
26
29
  storeDelegation(delegation: Delegation): Promise<Hex>;
27
30
  }
28
31
 
29
- export { DelegationStorageClient, type DelegationStorageConfig, DelegationStoreFilter, type Environment };
32
+ export { DelegationStorageClient, type DelegationStorageConfig, DelegationStorageEnvironment, DelegationStoreFilter, type Environment };
@@ -1,9 +1,20 @@
1
1
  import {
2
- hashDelegation
3
- } from "../chunk-C5ZEEH2Z.mjs";
2
+ hashDelegation,
3
+ trackSmartAccountsKitFunctionCall
4
+ } from "../chunk-ZA2XYCVX.mjs";
4
5
 
5
6
  // src/experimental/delegationStorage.ts
6
7
  import { toHex } from "viem";
8
+ var DelegationStorageEnvironment = {
9
+ dev: { apiUrl: "https://passkeys.dev-api.cx.metamask.io" },
10
+ prod: { apiUrl: "https://passkeys.api.cx.metamask.io" }
11
+ };
12
+ function getDelegationStorageEnvironment(apiUrl) {
13
+ const matchingEnvironment = Object.entries(DelegationStorageEnvironment).find(
14
+ ([_, env]) => env.apiUrl === apiUrl
15
+ );
16
+ return matchingEnvironment ? matchingEnvironment[0] : "custom";
17
+ }
7
18
  var DelegationStorageClient = class {
8
19
  #apiVersionPrefix = "api/v0";
9
20
  #config;
@@ -11,6 +22,12 @@ var DelegationStorageClient = class {
11
22
  #apiUrl;
12
23
  constructor(config) {
13
24
  const { apiUrl } = config.environment;
25
+ trackSmartAccountsKitFunctionCall(
26
+ "experimental.DelegationStorageClient.constructor",
27
+ {
28
+ environment: getDelegationStorageEnvironment(apiUrl)
29
+ }
30
+ );
14
31
  if (apiUrl.endsWith(this.#apiVersionPrefix)) {
15
32
  this.#apiUrl = apiUrl;
16
33
  } else {
@@ -51,6 +68,12 @@ var DelegationStorageClient = class {
51
68
  * is not found.
52
69
  */
53
70
  async getDelegationChain(leafDelegationOrDelegationHash) {
71
+ trackSmartAccountsKitFunctionCall(
72
+ "experimental.DelegationStorageClient.getDelegationChain",
73
+ {
74
+ inputKind: typeof leafDelegationOrDelegationHash === "string" ? "hash" : "delegation"
75
+ }
76
+ );
54
77
  const leafDelegationHash = typeof leafDelegationOrDelegationHash === "string" ? leafDelegationOrDelegationHash : hashDelegation(leafDelegationOrDelegationHash);
55
78
  const response = await this.#fetcher(
56
79
  `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,
@@ -81,6 +104,10 @@ var DelegationStorageClient = class {
81
104
  * empty array if the delegations are not found.
82
105
  */
83
106
  async fetchDelegations(deleGatorAddress, filterMode = "RECEIVED" /* Received */) {
107
+ trackSmartAccountsKitFunctionCall(
108
+ "experimental.DelegationStorageClient.fetchDelegations",
109
+ { filterMode }
110
+ );
84
111
  const response = await this.#fetcher(
85
112
  `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,
86
113
  {
@@ -104,6 +131,10 @@ var DelegationStorageClient = class {
104
131
  * @returns A promise that resolves to the delegation hash indicating successful storage.
105
132
  */
106
133
  async storeDelegation(delegation) {
134
+ trackSmartAccountsKitFunctionCall(
135
+ "experimental.DelegationStorageClient.storeDelegation",
136
+ { caveatCount: delegation.caveats.length }
137
+ );
107
138
  if (!delegation.signature || delegation.signature === "0x") {
108
139
  throw new Error("Delegation must be signed to be stored");
109
140
  }
@@ -138,6 +169,7 @@ var DelegationStorageClient = class {
138
169
  }
139
170
  };
140
171
  export {
141
- DelegationStorageClient
172
+ DelegationStorageClient,
173
+ DelegationStorageEnvironment
142
174
  };
143
175
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/experimental/delegationStorage.ts"],"sourcesContent":["import { type Hex, toHex } from 'viem';\n\nimport { hashDelegation } from '../delegation';\nimport type { Delegation } from '../types';\n\ntype ErrorResponse = {\n error: string;\n data?: any;\n};\n\nexport type APIStoreDelegationResponse = {\n delegationHash: Hex;\n};\n\n/**\n * Represents the allowed filters when querying the data store for delegations.\n */\nexport enum DelegationStoreFilter {\n Given = 'GIVEN',\n Received = 'RECEIVED',\n All = 'ALL',\n}\n\n/**\n * Public Delegation Storage Service environments. To be used in the\n * DeleGationStorageService config.\n */\nexport const DelegationStorageEnvironment: {\n [K in 'dev' | 'prod']: Environment;\n} = {\n dev: { apiUrl: 'https://passkeys.dev-api.cx.metamask.io' },\n prod: { apiUrl: 'https://passkeys.api.cx.metamask.io' },\n};\n\nexport type Environment = {\n apiUrl: string;\n};\n\nexport type DelegationStorageConfig = {\n apiKey: string;\n apiKeyId: string;\n environment: Environment;\n fetcher?: typeof fetch;\n};\n\nexport class DelegationStorageClient {\n readonly #apiVersionPrefix = 'api/v0';\n\n readonly #config: DelegationStorageConfig;\n\n readonly #fetcher: typeof fetch;\n\n readonly #apiUrl: string;\n\n constructor(config: DelegationStorageConfig) {\n const { apiUrl } = config.environment;\n\n if (apiUrl.endsWith(this.#apiVersionPrefix)) {\n this.#apiUrl = apiUrl;\n } else {\n const separator = apiUrl.endsWith('/') ? '' : '/';\n this.#apiUrl = `${apiUrl}${separator}${this.#apiVersionPrefix}`;\n }\n this.#fetcher = this.#initializeFetcher(config);\n this.#config = config;\n }\n\n /**\n * Initializes the fetch function for HTTP requests.\n *\n * - Uses `config.fetcher` if provided.\n * - Falls back to global `fetch` if available.\n * - Throws an error if no fetch function is available.\n *\n * @param config - Configuration object that may include a custom fetch function.\n * @returns The fetch function to be used for HTTP requests.\n * @throws Error if no fetch function is available in the environment.\n */\n #initializeFetcher(config: DelegationStorageConfig): typeof fetch {\n if (config.fetcher) {\n return config.fetcher;\n } else if (typeof globalThis?.fetch === 'function') {\n return globalThis.fetch.bind(globalThis);\n }\n throw new Error(\n 'Fetch API is not available in this environment. Please provide a fetch function in the config.',\n );\n }\n\n /**\n * Fetches the delegation chain from the Delegation Storage Service, ending with\n * the specified leaf delegation.\n *\n * @param leafDelegationOrDelegationHash - The leaf delegation, or the hash\n * of the leaf delegation.\n * @returns A promise that resolves to the delegation chain - empty array if the delegation\n * is not found.\n */\n async getDelegationChain(\n leafDelegationOrDelegationHash: Hex | Delegation,\n ): Promise<Delegation[]> {\n const leafDelegationHash =\n typeof leafDelegationOrDelegationHash === 'string'\n ? leafDelegationOrDelegationHash\n : hashDelegation(leafDelegationOrDelegationHash);\n\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(\n `Failed to fetch delegation chain: ${responseData.error}`,\n );\n }\n\n return responseData;\n }\n\n /**\n * Fetches the delegations from the Delegation Storage Service, either `Received`\n * by, or `Given` by, (or both: `All`) the specified deleGatorAddress. Defaults\n * to `Received`.\n *\n * @param deleGatorAddress - The deleGatorAddress to retrieve the delegations for.\n * @param filterMode - The DelegationStoreFilter mode - defaults to Received.\n * @returns A promise that resolves to the list of delegations received by the deleGatorAddress,\n * empty array if the delegations are not found.\n */\n async fetchDelegations(\n deleGatorAddress: Hex,\n filterMode = DelegationStoreFilter.Received,\n ): Promise<Delegation[]> {\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(`Failed to fetch delegations: ${responseData.error}`);\n }\n\n return responseData;\n }\n\n /**\n * Stores the specified delegation in the Delegation Storage Service.\n *\n * @param delegation - The delegation to store.\n * @returns A promise that resolves to the delegation hash indicating successful storage.\n */\n async storeDelegation(delegation: Delegation): Promise<Hex> {\n if (!delegation.signature || delegation.signature === '0x') {\n throw new Error('Delegation must be signed to be stored');\n }\n\n const delegationHash = hashDelegation(delegation);\n\n const body = JSON.stringify(\n {\n ...delegation,\n metadata: [],\n },\n (_, value: any) =>\n typeof value === 'bigint' || typeof value === 'number'\n ? toHex(value)\n : value,\n 2,\n );\n\n const response = await this.#fetcher(`${this.#apiUrl}/delegation/store`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n 'Content-Type': 'application/json',\n },\n body,\n });\n\n const responseData: APIStoreDelegationResponse | ErrorResponse =\n await response.json();\n\n if ('error' in responseData) {\n throw new Error(responseData.error);\n }\n\n if (responseData.delegationHash !== delegationHash) {\n throw new Error(\n 'Failed to store the Delegation, the hash returned from the MM delegation storage API does not match the hash of the delegation',\n );\n }\n\n return responseData.delegationHash;\n }\n}\n"],"mappings":";;;;;AAAA,SAAmB,aAAa;AA6CzB,IAAM,0BAAN,MAA8B;AAAA,EAC1B,oBAAoB;AAAA,EAEpB;AAAA,EAEA;AAAA,EAEA;AAAA,EAET,YAAY,QAAiC;AAC3C,UAAM,EAAE,OAAO,IAAI,OAAO;AAE1B,QAAI,OAAO,SAAS,KAAK,iBAAiB,GAAG;AAC3C,WAAK,UAAU;AAAA,IACjB,OAAO;AACL,YAAM,YAAY,OAAO,SAAS,GAAG,IAAI,KAAK;AAC9C,WAAK,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,iBAAiB;AAAA,IAC/D;AACA,SAAK,WAAW,KAAK,mBAAmB,MAAM;AAC9C,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,mBAAmB,QAA+C;AAChE,QAAI,OAAO,SAAS;AAClB,aAAO,OAAO;AAAA,IAChB,WAAW,OAAO,YAAY,UAAU,YAAY;AAClD,aAAO,WAAW,MAAM,KAAK,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;AAC1D,YAAM,IAAI,MAAM,wCAAwC;AAAA,IAC1D;AAEA,UAAM,iBAAiB,eAAe,UAAU;AAEhD,UAAM,OAAO,KAAK;AAAA,MAChB;AAAA,QACE,GAAG;AAAA,QACH,UAAU,CAAC;AAAA,MACb;AAAA,MACA,CAAC,GAAG,UACF,OAAO,UAAU,YAAY,OAAO,UAAU,WAC1C,MAAM,KAAK,IACX;AAAA,MACN;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,KAAK,SAAS,GAAG,KAAK,OAAO,qBAAqB;AAAA,MACvE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,eAAe,UAAU,KAAK,QAAQ,MAAM;AAAA,QAC5C,gBAAgB,KAAK,QAAQ;AAAA,QAC7B,gBAAgB;AAAA,MAClB;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,eACJ,MAAM,SAAS,KAAK;AAEtB,QAAI,WAAW,cAAc;AAC3B,YAAM,IAAI,MAAM,aAAa,KAAK;AAAA,IACpC;AAEA,QAAI,aAAa,mBAAmB,gBAAgB;AAClD,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,aAAa;AAAA,EACtB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/experimental/delegationStorage.ts"],"sourcesContent":["import { type Hex, toHex } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { hashDelegation } from '../delegation';\nimport type { Delegation } from '../types';\n\ntype ErrorResponse = {\n error: string;\n data?: any;\n};\n\nexport type APIStoreDelegationResponse = {\n delegationHash: Hex;\n};\n\n/**\n * Represents the allowed filters when querying the data store for delegations.\n */\nexport enum DelegationStoreFilter {\n Given = 'GIVEN',\n Received = 'RECEIVED',\n All = 'ALL',\n}\n\n/**\n * Public Delegation Storage Service environments. To be used in the\n * DeleGationStorageService config.\n */\nexport const DelegationStorageEnvironment: {\n [K in 'dev' | 'prod']: Environment;\n} = {\n dev: { apiUrl: 'https://passkeys.dev-api.cx.metamask.io' },\n prod: { apiUrl: 'https://passkeys.api.cx.metamask.io' },\n};\n\n/**\n * Returns the DelegationStorageEnvironment ('dev' or 'prod') for a given apiUrl,\n * or 'custom' if the apiUrl does not match a known environment.\n *\n * @param apiUrl - The API URL to check.\n * @returns The environment key ('dev' or 'prod'), or 'custom'.\n */\nfunction getDelegationStorageEnvironment(\n apiUrl: string,\n): 'dev' | 'prod' | 'custom' {\n const matchingEnvironment = Object.entries(DelegationStorageEnvironment).find(\n ([_, env]) => env.apiUrl === apiUrl,\n ) as [keyof typeof DelegationStorageEnvironment, Environment] | undefined;\n\n return matchingEnvironment ? matchingEnvironment[0] : 'custom';\n}\n\nexport type Environment = {\n apiUrl: string;\n};\n\nexport type DelegationStorageConfig = {\n apiKey: string;\n apiKeyId: string;\n environment: Environment;\n fetcher?: typeof fetch;\n};\n\nexport class DelegationStorageClient {\n readonly #apiVersionPrefix = 'api/v0';\n\n readonly #config: DelegationStorageConfig;\n\n readonly #fetcher: typeof fetch;\n\n readonly #apiUrl: string;\n\n constructor(config: DelegationStorageConfig) {\n const { apiUrl } = config.environment;\n\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.constructor',\n {\n environment: getDelegationStorageEnvironment(apiUrl),\n },\n );\n\n if (apiUrl.endsWith(this.#apiVersionPrefix)) {\n this.#apiUrl = apiUrl;\n } else {\n const separator = apiUrl.endsWith('/') ? '' : '/';\n this.#apiUrl = `${apiUrl}${separator}${this.#apiVersionPrefix}`;\n }\n this.#fetcher = this.#initializeFetcher(config);\n this.#config = config;\n }\n\n /**\n * Initializes the fetch function for HTTP requests.\n *\n * - Uses `config.fetcher` if provided.\n * - Falls back to global `fetch` if available.\n * - Throws an error if no fetch function is available.\n *\n * @param config - Configuration object that may include a custom fetch function.\n * @returns The fetch function to be used for HTTP requests.\n * @throws Error if no fetch function is available in the environment.\n */\n #initializeFetcher(config: DelegationStorageConfig): typeof fetch {\n if (config.fetcher) {\n return config.fetcher;\n } else if (typeof globalThis?.fetch === 'function') {\n return globalThis.fetch.bind(globalThis);\n }\n throw new Error(\n 'Fetch API is not available in this environment. Please provide a fetch function in the config.',\n );\n }\n\n /**\n * Fetches the delegation chain from the Delegation Storage Service, ending with\n * the specified leaf delegation.\n *\n * @param leafDelegationOrDelegationHash - The leaf delegation, or the hash\n * of the leaf delegation.\n * @returns A promise that resolves to the delegation chain - empty array if the delegation\n * is not found.\n */\n async getDelegationChain(\n leafDelegationOrDelegationHash: Hex | Delegation,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.getDelegationChain',\n {\n inputKind:\n typeof leafDelegationOrDelegationHash === 'string'\n ? 'hash'\n : 'delegation',\n },\n );\n const leafDelegationHash =\n typeof leafDelegationOrDelegationHash === 'string'\n ? leafDelegationOrDelegationHash\n : hashDelegation(leafDelegationOrDelegationHash);\n\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(\n `Failed to fetch delegation chain: ${responseData.error}`,\n );\n }\n\n return responseData;\n }\n\n /**\n * Fetches the delegations from the Delegation Storage Service, either `Received`\n * by, or `Given` by, (or both: `All`) the specified deleGatorAddress. Defaults\n * to `Received`.\n *\n * @param deleGatorAddress - The deleGatorAddress to retrieve the delegations for.\n * @param filterMode - The DelegationStoreFilter mode - defaults to Received.\n * @returns A promise that resolves to the list of delegations received by the deleGatorAddress,\n * empty array if the delegations are not found.\n */\n async fetchDelegations(\n deleGatorAddress: Hex,\n filterMode = DelegationStoreFilter.Received,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.fetchDelegations',\n { filterMode },\n );\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(`Failed to fetch delegations: ${responseData.error}`);\n }\n\n return responseData;\n }\n\n /**\n * Stores the specified delegation in the Delegation Storage Service.\n *\n * @param delegation - The delegation to store.\n * @returns A promise that resolves to the delegation hash indicating successful storage.\n */\n async storeDelegation(delegation: Delegation): Promise<Hex> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.storeDelegation',\n { caveatCount: delegation.caveats.length },\n );\n if (!delegation.signature || delegation.signature === '0x') {\n throw new Error('Delegation must be signed to be stored');\n }\n\n const delegationHash = hashDelegation(delegation);\n\n const body = JSON.stringify(\n {\n ...delegation,\n metadata: [],\n },\n (_, value: any) =>\n typeof value === 'bigint' || typeof value === 'number'\n ? toHex(value)\n : value,\n 2,\n );\n\n const response = await this.#fetcher(`${this.#apiUrl}/delegation/store`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n 'Content-Type': 'application/json',\n },\n body,\n });\n\n const responseData: APIStoreDelegationResponse | ErrorResponse =\n await response.json();\n\n if ('error' in responseData) {\n throw new Error(responseData.error);\n }\n\n if (responseData.delegationHash !== delegationHash) {\n throw new Error(\n 'Failed to store the Delegation, the hash returned from the MM delegation storage API does not match the hash of the delegation',\n );\n }\n\n return responseData.delegationHash;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAmB,aAAa;AA4BzB,IAAM,+BAET;AAAA,EACF,KAAK,EAAE,QAAQ,0CAA0C;AAAA,EACzD,MAAM,EAAE,QAAQ,sCAAsC;AACxD;AASA,SAAS,gCACP,QAC2B;AAC3B,QAAM,sBAAsB,OAAO,QAAQ,4BAA4B,EAAE;AAAA,IACvE,CAAC,CAAC,GA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AU,WAC1C,MAAM,KAAK,IACX;AAAA,MACN;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,KAAK,SAAS,GAAG,KAAK,OAAO,qBAAqB;AAAA,MACvE,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,eAAe,UAAU,KAAK,QAAQ,MAAM;AAAA,QAC5C,gBAAgB,KAAK,QAAQ;AAAA,QAC7B,gBAAgB;AAAA,MAClB;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,eACJ,MAAM,SAAS,KAAK;AAEtB,QAAI,WAAW,cAAc;AAC3B,YAAM,IAAI,MAAM,aAAa,KAAK;AAAA,IACpC;AAEA,QAAI,aAAa,mBAAmB,gBAAgB;AAClD,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,aAAa;AAAA,EACtB;AACF;","names":[]}
@@ -1,8 +1,8 @@
1
1
  import { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
2
2
  import * as viem from 'viem';
3
3
  import { Client, Transport, Chain, Account, Address, Hex } from 'viem';
4
- import { p as DelegationStruct, E as ExecutionMode, e as ExecutionStruct } from './delegation-CvVXs0PO.js';
5
- import { D as Delegation, P as PermissionContext } from './types-qdEHxd5Q.js';
4
+ import { m as DelegationStruct, E as ExecutionMode, d as ExecutionStruct } from './delegation-Bx4FEAIU.js';
5
+ import { D as Delegation, P as PermissionContext } from './types-BWaH4KH1.js';
6
6
 
7
7
  declare const NAME$1 = "DelegationManager";
8
8
  declare const VERSION$1 = "1.3.0";
@@ -22134,4 +22134,4 @@ declare namespace index {
22134
22134
  export { index$j as DeleGatorCore, index$k as DelegationManager, index$i as EIP712, index$g as ERC20PeriodTransferEnforcer, index$f as ERC20StreamingEnforcer, index$e as ERC20TransferAmountEnforcer, index$h as EntryPoint, index$d as HybridDeleGator, index$c as IdEnforcer, type index_InitializedClient as InitializedClient, index$b as LimitedCallsEnforcer, index$a as MultiSigDeleGator, index$9 as MultiTokenPeriodEnforcer, index$8 as NativeTokenPeriodTransferEnforcer, index$7 as NativeTokenStreamingEnforcer, index$6 as NativeTokenTransferAmountEnforcer, index$5 as NonceEnforcer, index$4 as Ownable2Step, type index_P256Owner as P256Owner, index$3 as Pausable, index$2 as SimpleFactory, index$1 as SpecificActionERC20TransferBatchEnforcer, index_encodeProxyCreationCode as encodeProxyCreationCode, index_isContractDeployed as isContractDeployed, index_isImplementationExpected as isImplementationExpected };
22135
22135
  }
22136
22136
 
22137
- export { type InitializedClient as I, type P256Owner as P, index$k as a, index$j as b, index$i as c, index$h as d, index$d as e, index$c as f, index$b as g, index$a as h, index as i, index$5 as j, index$4 as k, index$3 as l, index$2 as m, index$1 as n, index$g as o, index$f as p, index$e as q, index$9 as r, index$8 as s, index$7 as t, index$6 as u, isContractDeployed as v, isImplementationExpected as w, encodeProxyCreationCode as x };
22137
+ export { type InitializedClient as I, type P256Owner as P, index$j as a, index$k as b, index$i as c, index$g as d, index$f as e, index$e as f, index$h as g, index$d as h, index as i, index$c as j, index$b as k, index$a as l, index$9 as m, index$8 as n, index$7 as o, index$6 as p, index$5 as q, index$4 as r, index$3 as s, index$2 as t, index$1 as u, encodeProxyCreationCode as v, isContractDeployed as w, isImplementationExpected as x };
@@ -1,7 +1,7 @@
1
1
  import { PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
2
- import { Address, Hex, Client, Transport, Chain, Account, RpcSchema, SendTransactionRequest, SendTransactionParameters, OneOf, PublicClient, WalletClient } from 'viem';
2
+ import { Address, Hex, Client, Transport, Chain, Account, RpcSchema, OneOf, PublicClient, SendTransactionRequest, SendTransactionParameters, WalletClient } from 'viem';
3
3
  import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
4
- import { P as PermissionContext, l as Call, S as SmartAccountsEnvironment, D as Delegation } from './types-qdEHxd5Q.js';
4
+ import { l as Call, P as PermissionContext, S as SmartAccountsEnvironment, D as Delegation } from './types-BWaH4KH1.js';
5
5
  import { U as UserOperationV07 } from './userOp-DKgjzz7B.js';
6
6
 
7
7
  type BasePermission = {
@@ -268,4 +268,4 @@ declare namespace index {
268
268
  export { type index_CaveatEnforcerParams as CaveatEnforcerParams, type index_DelegatedCall as DelegatedCall, type index_Erc20TokenPeriodicPermission as Erc20TokenPeriodicPermission, type index_Erc20TokenRevocationPermission as Erc20TokenRevocationPermission, type index_Erc20TokenStreamPermission as Erc20TokenStreamPermission, type index_Erc7715Client as Erc7715Client, type index_GetGrantedExecutionPermissionsResult as GetGrantedExecutionPermissionsResult, type index_GetSupportedExecutionPermissionsResult as GetSupportedExecutionPermissionsResult, type index_MetaMaskExtensionClient as MetaMaskExtensionClient, type index_MetaMaskExtensionSchema as MetaMaskExtensionSchema, type index_NativeTokenPeriodicPermission as NativeTokenPeriodicPermission, type index_NativeTokenStreamPermission as NativeTokenStreamPermission, type index_PeriodTransferResult as PeriodTransferResult, type index_PermissionRequestParameter as PermissionRequestParameter, type index_PermissionTypes as PermissionTypes, type index_RequestExecutionPermissionsParameters as RequestExecutionPermissionsParameters, type index_RequestExecutionPermissionsReturnType as RequestExecutionPermissionsReturnType, type index_RpcGetGrantedExecutionPermissionsResult as RpcGetGrantedExecutionPermissionsResult, type index_RpcGetSupportedExecutionPermissionsResult as RpcGetSupportedExecutionPermissionsResult, type index_RpcSupportedPermissionInfo as RpcSupportedPermissionInfo, type index_SignDelegationParameters as SignDelegationParameters, type index_SignDelegationReturnType as SignDelegationReturnType, type index_SignUserOperationParameters as SignUserOperationParameters, type index_SignUserOperationReturnType as SignUserOperationReturnType, type index_StreamingResult as StreamingResult, type index_SupportedPermissionInfo as SupportedPermissionInfo, index_caveatEnforcerActions as caveatEnforcerActions, index_erc7710BundlerActions as erc7710BundlerActions, index_erc7710WalletActions as erc7710WalletActions, index_erc7715ProviderActions as erc7715ProviderActions, index_getErc20PeriodTransferEnforcerAvailableAmount as getErc20PeriodTransferEnforcerAvailableAmount, index_getErc20StreamingEnforcerAvailableAmount as getErc20StreamingEnforcerAvailableAmount, erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions, index_getMultiTokenPeriodEnforcerAvailableAmount as getMultiTokenPeriodEnforcerAvailableAmount, index_getNativeTokenPeriodTransferEnforcerAvailableAmount as getNativeTokenPeriodTransferEnforcerAvailableAmount, index_getNativeTokenStreamingEnforcerAvailableAmount as getNativeTokenStreamingEnforcerAvailableAmount, erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions, index_isValid7702Implementation as isValid7702Implementation, erc7715RequestExecutionPermissionsAction as requestExecutionPermissions, index_signDelegation as signDelegation, index_signDelegationActions as signDelegationActions, index_signUserOperation as signUserOperation, index_signUserOperationActions as signUserOperationActions };
269
269
  }
270
270
 
271
- export { type SupportedPermissionInfo as A, type PermissionTypes as B, type CaveatEnforcerParams as C, type NativeTokenPeriodicPermission as D, type Erc7715Client as E, type Erc20TokenStreamPermission as F, type GetSupportedExecutionPermissionsResult as G, type Erc20TokenPeriodicPermission as H, type Erc20TokenRevocationPermission as I, type RpcGetSupportedExecutionPermissionsResult as J, type RpcGetGrantedExecutionPermissionsResult as K, type RpcSupportedPermissionInfo as L, type MetaMaskExtensionClient as M, type NativeTokenStreamPermission as N, type DelegatedCall as O, type PeriodTransferResult as P, type RequestExecutionPermissionsParameters as R, type StreamingResult as S, erc7710WalletActions as a, erc7710BundlerActions as b, caveatEnforcerActions as c, getErc20StreamingEnforcerAvailableAmount as d, erc7715ProviderActions as e, getMultiTokenPeriodEnforcerAvailableAmount as f, getErc20PeriodTransferEnforcerAvailableAmount as g, getNativeTokenPeriodTransferEnforcerAvailableAmount as h, index as i, getNativeTokenStreamingEnforcerAvailableAmount as j, isValid7702Implementation as k, signDelegationActions as l, type SignDelegationParameters as m, type SignDelegationReturnType as n, signUserOperation as o, signUserOperationActions as p, type SignUserOperationParameters as q, type SignUserOperationReturnType as r, signDelegation as s, erc7715RequestExecutionPermissionsAction as t, type MetaMaskExtensionSchema as u, type RequestExecutionPermissionsReturnType as v, type PermissionRequestParameter as w, erc7715GetSupportedExecutionPermissionsAction as x, erc7715GetGrantedExecutionPermissionsAction as y, type GetGrantedExecutionPermissionsResult as z };
271
+ export { getNativeTokenPeriodTransferEnforcerAvailableAmount as A, getNativeTokenStreamingEnforcerAvailableAmount as B, type CaveatEnforcerParams as C, type DelegatedCall as D, type Erc20TokenPeriodicPermission as E, erc7715GetSupportedExecutionPermissionsAction as F, type GetGrantedExecutionPermissionsResult as G, isValid7702Implementation as H, erc7715RequestExecutionPermissionsAction as I, signDelegation as J, signDelegationActions as K, signUserOperation as L, type MetaMaskExtensionClient as M, type NativeTokenPeriodicPermission as N, signUserOperationActions as O, type PeriodTransferResult as P, type RequestExecutionPermissionsParameters as R, type SignDelegationParameters as S, type Erc20TokenRevocationPermission as a, type Erc20TokenStreamPermission as b, caveatEnforcerActions as c, type Erc7715Client as d, type GetSupportedExecutionPermissionsResult as e, type MetaMaskExtensionSchema as f, type NativeTokenStreamPermission as g, type PermissionRequestParameter as h, index as i, type PermissionTypes as j, type RequestExecutionPermissionsReturnType as k, type RpcGetGrantedExecutionPermissionsResult as l, type RpcGetSupportedExecutionPermissionsResult as m, type RpcSupportedPermissionInfo as n, type SignDelegationReturnType as o, type SignUserOperationParameters as p, type SignUserOperationReturnType as q, type StreamingResult as r, type SupportedPermissionInfo as s, erc7710BundlerActions as t, erc7710WalletActions as u, erc7715ProviderActions as v, getErc20PeriodTransferEnforcerAvailableAmount as w, getErc20StreamingEnforcerAvailableAmount as x, erc7715GetGrantedExecutionPermissionsAction as y, getMultiTokenPeriodEnforcerAvailableAmount as z };
@@ -1,8 +1,8 @@
1
1
  import { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
2
2
  import * as viem from 'viem';
3
3
  import { Client, Transport, Chain, Account, Address, Hex } from 'viem';
4
- import { p as DelegationStruct, E as ExecutionMode, e as ExecutionStruct } from './delegation-DIriDFkq.cjs';
5
- import { D as Delegation, P as PermissionContext } from './types-qdEHxd5Q.cjs';
4
+ import { m as DelegationStruct, E as ExecutionMode, d as ExecutionStruct } from './delegation-KbWHzRxV.cjs';
5
+ import { D as Delegation, P as PermissionContext } from './types-BWaH4KH1.cjs';
6
6
 
7
7
  declare const NAME$1 = "DelegationManager";
8
8
  declare const VERSION$1 = "1.3.0";
@@ -22134,4 +22134,4 @@ declare namespace index {
22134
22134
  export { index$j as DeleGatorCore, index$k as DelegationManager, index$i as EIP712, index$g as ERC20PeriodTransferEnforcer, index$f as ERC20StreamingEnforcer, index$e as ERC20TransferAmountEnforcer, index$h as EntryPoint, index$d as HybridDeleGator, index$c as IdEnforcer, type index_InitializedClient as InitializedClient, index$b as LimitedCallsEnforcer, index$a as MultiSigDeleGator, index$9 as MultiTokenPeriodEnforcer, index$8 as NativeTokenPeriodTransferEnforcer, index$7 as NativeTokenStreamingEnforcer, index$6 as NativeTokenTransferAmountEnforcer, index$5 as NonceEnforcer, index$4 as Ownable2Step, type index_P256Owner as P256Owner, index$3 as Pausable, index$2 as SimpleFactory, index$1 as SpecificActionERC20TransferBatchEnforcer, index_encodeProxyCreationCode as encodeProxyCreationCode, index_isContractDeployed as isContractDeployed, index_isImplementationExpected as isImplementationExpected };
22135
22135
  }
22136
22136
 
22137
- export { type InitializedClient as I, type P256Owner as P, index$k as a, index$j as b, index$i as c, index$h as d, index$d as e, index$c as f, index$b as g, index$a as h, index as i, index$5 as j, index$4 as k, index$3 as l, index$2 as m, index$1 as n, index$g as o, index$f as p, index$e as q, index$9 as r, index$8 as s, index$7 as t, index$6 as u, isContractDeployed as v, isImplementationExpected as w, encodeProxyCreationCode as x };
22137
+ export { type InitializedClient as I, type P256Owner as P, index$j as a, index$k as b, index$i as c, index$g as d, index$f as e, index$e as f, index$h as g, index$d as h, index as i, index$c as j, index$b as k, index$a as l, index$9 as m, index$8 as n, index$7 as o, index$6 as p, index$5 as q, index$4 as r, index$3 as s, index$2 as t, index$1 as u, encodeProxyCreationCode as v, isContractDeployed as w, isImplementationExpected as x };
@@ -1,7 +1,7 @@
1
1
  import { PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
2
- import { Address, Hex, Client, Transport, Chain, Account, RpcSchema, SendTransactionRequest, SendTransactionParameters, OneOf, PublicClient, WalletClient } from 'viem';
2
+ import { Address, Hex, Client, Transport, Chain, Account, RpcSchema, OneOf, PublicClient, SendTransactionRequest, SendTransactionParameters, WalletClient } from 'viem';
3
3
  import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
4
- import { P as PermissionContext, l as Call, S as SmartAccountsEnvironment, D as Delegation } from './types-qdEHxd5Q.cjs';
4
+ import { l as Call, P as PermissionContext, S as SmartAccountsEnvironment, D as Delegation } from './types-BWaH4KH1.cjs';
5
5
  import { U as UserOperationV07 } from './userOp-DKgjzz7B.cjs';
6
6
 
7
7
  type BasePermission = {
@@ -268,4 +268,4 @@ declare namespace index {
268
268
  export { type index_CaveatEnforcerParams as CaveatEnforcerParams, type index_DelegatedCall as DelegatedCall, type index_Erc20TokenPeriodicPermission as Erc20TokenPeriodicPermission, type index_Erc20TokenRevocationPermission as Erc20TokenRevocationPermission, type index_Erc20TokenStreamPermission as Erc20TokenStreamPermission, type index_Erc7715Client as Erc7715Client, type index_GetGrantedExecutionPermissionsResult as GetGrantedExecutionPermissionsResult, type index_GetSupportedExecutionPermissionsResult as GetSupportedExecutionPermissionsResult, type index_MetaMaskExtensionClient as MetaMaskExtensionClient, type index_MetaMaskExtensionSchema as MetaMaskExtensionSchema, type index_NativeTokenPeriodicPermission as NativeTokenPeriodicPermission, type index_NativeTokenStreamPermission as NativeTokenStreamPermission, type index_PeriodTransferResult as PeriodTransferResult, type index_PermissionRequestParameter as PermissionRequestParameter, type index_PermissionTypes as PermissionTypes, type index_RequestExecutionPermissionsParameters as RequestExecutionPermissionsParameters, type index_RequestExecutionPermissionsReturnType as RequestExecutionPermissionsReturnType, type index_RpcGetGrantedExecutionPermissionsResult as RpcGetGrantedExecutionPermissionsResult, type index_RpcGetSupportedExecutionPermissionsResult as RpcGetSupportedExecutionPermissionsResult, type index_RpcSupportedPermissionInfo as RpcSupportedPermissionInfo, type index_SignDelegationParameters as SignDelegationParameters, type index_SignDelegationReturnType as SignDelegationReturnType, type index_SignUserOperationParameters as SignUserOperationParameters, type index_SignUserOperationReturnType as SignUserOperationReturnType, type index_StreamingResult as StreamingResult, type index_SupportedPermissionInfo as SupportedPermissionInfo, index_caveatEnforcerActions as caveatEnforcerActions, index_erc7710BundlerActions as erc7710BundlerActions, index_erc7710WalletActions as erc7710WalletActions, index_erc7715ProviderActions as erc7715ProviderActions, index_getErc20PeriodTransferEnforcerAvailableAmount as getErc20PeriodTransferEnforcerAvailableAmount, index_getErc20StreamingEnforcerAvailableAmount as getErc20StreamingEnforcerAvailableAmount, erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions, index_getMultiTokenPeriodEnforcerAvailableAmount as getMultiTokenPeriodEnforcerAvailableAmount, index_getNativeTokenPeriodTransferEnforcerAvailableAmount as getNativeTokenPeriodTransferEnforcerAvailableAmount, index_getNativeTokenStreamingEnforcerAvailableAmount as getNativeTokenStreamingEnforcerAvailableAmount, erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions, index_isValid7702Implementation as isValid7702Implementation, erc7715RequestExecutionPermissionsAction as requestExecutionPermissions, index_signDelegation as signDelegation, index_signDelegationActions as signDelegationActions, index_signUserOperation as signUserOperation, index_signUserOperationActions as signUserOperationActions };
269
269
  }
270
270
 
271
- export { type SupportedPermissionInfo as A, type PermissionTypes as B, type CaveatEnforcerParams as C, type NativeTokenPeriodicPermission as D, type Erc7715Client as E, type Erc20TokenStreamPermission as F, type GetSupportedExecutionPermissionsResult as G, type Erc20TokenPeriodicPermission as H, type Erc20TokenRevocationPermission as I, type RpcGetSupportedExecutionPermissionsResult as J, type RpcGetGrantedExecutionPermissionsResult as K, type RpcSupportedPermissionInfo as L, type MetaMaskExtensionClient as M, type NativeTokenStreamPermission as N, type DelegatedCall as O, type PeriodTransferResult as P, type RequestExecutionPermissionsParameters as R, type StreamingResult as S, erc7710WalletActions as a, erc7710BundlerActions as b, caveatEnforcerActions as c, getErc20StreamingEnforcerAvailableAmount as d, erc7715ProviderActions as e, getMultiTokenPeriodEnforcerAvailableAmount as f, getErc20PeriodTransferEnforcerAvailableAmount as g, getNativeTokenPeriodTransferEnforcerAvailableAmount as h, index as i, getNativeTokenStreamingEnforcerAvailableAmount as j, isValid7702Implementation as k, signDelegationActions as l, type SignDelegationParameters as m, type SignDelegationReturnType as n, signUserOperation as o, signUserOperationActions as p, type SignUserOperationParameters as q, type SignUserOperationReturnType as r, signDelegation as s, erc7715RequestExecutionPermissionsAction as t, type MetaMaskExtensionSchema as u, type RequestExecutionPermissionsReturnType as v, type PermissionRequestParameter as w, erc7715GetSupportedExecutionPermissionsAction as x, erc7715GetGrantedExecutionPermissionsAction as y, type GetGrantedExecutionPermissionsResult as z };
271
+ export { getNativeTokenPeriodTransferEnforcerAvailableAmount as A, getNativeTokenStreamingEnforcerAvailableAmount as B, type CaveatEnforcerParams as C, type DelegatedCall as D, type Erc20TokenPeriodicPermission as E, erc7715GetSupportedExecutionPermissionsAction as F, type GetGrantedExecutionPermissionsResult as G, isValid7702Implementation as H, erc7715RequestExecutionPermissionsAction as I, signDelegation as J, signDelegationActions as K, signUserOperation as L, type MetaMaskExtensionClient as M, type NativeTokenPeriodicPermission as N, signUserOperationActions as O, type PeriodTransferResult as P, type RequestExecutionPermissionsParameters as R, type SignDelegationParameters as S, type Erc20TokenRevocationPermission as a, type Erc20TokenStreamPermission as b, caveatEnforcerActions as c, type Erc7715Client as d, type GetSupportedExecutionPermissionsResult as e, type MetaMaskExtensionSchema as f, type NativeTokenStreamPermission as g, type PermissionRequestParameter as h, index as i, type PermissionTypes as j, type RequestExecutionPermissionsReturnType as k, type RpcGetGrantedExecutionPermissionsResult as l, type RpcGetSupportedExecutionPermissionsResult as m, type RpcSupportedPermissionInfo as n, type SignDelegationReturnType as o, type SignUserOperationParameters as p, type SignUserOperationReturnType as q, type StreamingResult as r, type SupportedPermissionInfo as s, erc7710BundlerActions as t, erc7710WalletActions as u, erc7715ProviderActions as v, getErc20PeriodTransferEnforcerAvailableAmount as w, getErc20StreamingEnforcerAvailableAmount as x, erc7715GetGrantedExecutionPermissionsAction as y, getMultiTokenPeriodEnforcerAvailableAmount as z };
package/dist/index.cjs CHANGED
@@ -1,30 +1,30 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
4
 
5
- var _chunkQMRKCB7Tcjs = require('./chunk-QMRKCB7T.cjs');
5
+ var _chunkT4IAMAB2cjs = require('./chunk-T4IAMAB2.cjs');
6
6
 
7
7
 
8
+ var _chunkHFRQNSZEcjs = require('./chunk-HFRQNSZE.cjs');
9
+ require('./chunk-3SHZ7PV2.cjs');
8
10
 
9
- var _chunkXN36L4RXcjs = require('./chunk-XN36L4RX.cjs');
10
- require('./chunk-UUOH2WAW.cjs');
11
11
 
12
12
 
13
13
 
14
14
 
15
-
16
- var _chunkBYWRJGSKcjs = require('./chunk-BYWRJGSK.cjs');
15
+ var _chunkUB2FLPP3cjs = require('./chunk-UB2FLPP3.cjs');
17
16
 
18
17
 
19
18
 
20
19
 
21
20
 
22
21
  var _chunkSOFB2MXGcjs = require('./chunk-SOFB2MXG.cjs');
23
- require('./chunk-23YXLKTX.cjs');
22
+ require('./chunk-UZO5OYCD.cjs');
23
+
24
24
 
25
25
 
26
+ var _chunkMOHCTPYQcjs = require('./chunk-MOHCTPYQ.cjs');
26
27
 
27
- var _chunkVLKX4BR6cjs = require('./chunk-VLKX4BR6.cjs');
28
28
 
29
29
 
30
30
 
@@ -39,7 +39,7 @@ var _chunkVLKX4BR6cjs = require('./chunk-VLKX4BR6.cjs');
39
39
 
40
40
 
41
41
 
42
- var _chunkYDLLC6PPcjs = require('./chunk-YDLLC6PP.cjs');
42
+ var _chunk7BEEGBA2cjs = require('./chunk-7BEEGBA2.cjs');
43
43
 
44
44
  // src/toMetaMaskSmartAccount.ts
45
45
 
@@ -62,6 +62,9 @@ var signatureTypes = ["ECDSA"];
62
62
  var aggregateSignature = ({
63
63
  signatures
64
64
  }) => {
65
+ _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0, "aggregateSignature", {
66
+ signatureCount: signatures.length
67
+ });
65
68
  if (signatures.length === 0) {
66
69
  return "0x";
67
70
  }
@@ -115,7 +118,7 @@ var resolveHybridSigner = (config) => {
115
118
  if (webAuthnAccount.type !== "webAuthn") {
116
119
  throw new Error("Account is not a webAuthn account");
117
120
  }
118
- const encodeSignature = (result) => _chunkBYWRJGSKcjs.encodeDeleGatorSignature.call(void 0,
121
+ const encodeSignature = (result) => _chunkUB2FLPP3cjs.encodeDeleGatorSignature.call(void 0,
119
122
  keyId,
120
123
  result.signature,
121
124
  result.webauthn.clientDataJSON,
@@ -123,7 +126,7 @@ var resolveHybridSigner = (config) => {
123
126
  );
124
127
  const signMessage = async (args) => webAuthnAccount.signMessage(args).then(encodeSignature);
125
128
  const signTypedData = async (typedDataDefinition) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);
126
- const getStubSignature = async () => _chunkBYWRJGSKcjs.createDummyWebAuthnSignature.call(void 0, keyId);
129
+ const getStubSignature = async () => _chunkUB2FLPP3cjs.createDummyWebAuthnSignature.call(void 0, keyId);
127
130
  return {
128
131
  signMessage,
129
132
  signTypedData,
@@ -231,8 +234,15 @@ async function toMetaMaskSmartAccount(params) {
231
234
  const {
232
235
  client,
233
236
  client: { chain },
234
- implementation
237
+ implementation,
238
+ nonceKeyManager
235
239
  } = params;
240
+ _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0, "toMetaMaskSmartAccount", {
241
+ implementation,
242
+ hasAddress: params.address !== void 0,
243
+ hasEnvironment: params.environment !== void 0,
244
+ chainId: _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _ => _.id]), () => ( null))
245
+ });
236
246
  if (!chain) {
237
247
  throw new Error("Chain not specified");
238
248
  }
@@ -249,7 +259,7 @@ async function toMetaMaskSmartAccount(params) {
249
259
  if (implementation === "Stateless7702" /* Stateless7702 */) {
250
260
  throw new Error("Stateless7702 does not support counterfactual accounts");
251
261
  }
252
- const accountData = await _chunkBYWRJGSKcjs.getCounterfactualAccountData.call(void 0, {
262
+ const accountData = await _chunkUB2FLPP3cjs.getCounterfactualAccountData.call(void 0, {
253
263
  factory: environment.SimpleFactory,
254
264
  implementations: environment.implementations,
255
265
  implementation,
@@ -296,7 +306,7 @@ async function toMetaMaskSmartAccount(params) {
296
306
  );
297
307
  }
298
308
  const { delegation, chainId } = delegationParams;
299
- const delegationStruct = _chunkYDLLC6PPcjs.toDelegationStruct.call(void 0, {
309
+ const delegationStruct = _chunk7BEEGBA2cjs.toDelegationStruct.call(void 0, {
300
310
  ...delegation,
301
311
  signature: "0x"
302
312
  });
@@ -307,7 +317,7 @@ async function toMetaMaskSmartAccount(params) {
307
317
  version: "1",
308
318
  verifyingContract: environment.DelegationManager
309
319
  },
310
- types: _chunkYDLLC6PPcjs.SIGNABLE_DELEGATION_TYPED_DATA,
320
+ types: _chunk7BEEGBA2cjs.SIGNABLE_DELEGATION_TYPED_DATA,
311
321
  primaryType: "Delegation",
312
322
  message: delegationStruct
313
323
  });
@@ -339,13 +349,7 @@ async function toMetaMaskSmartAccount(params) {
339
349
  return signature;
340
350
  };
341
351
  const getAddress = async () => address;
342
- const getNonce = async () => _chunkXN36L4RXcjs.read.call(void 0, {
343
- client,
344
- entryPoint: environment.EntryPoint,
345
- contractAddress: address,
346
- key: 0n
347
- });
348
- const encodeCalls = async (calls) => _chunkBYWRJGSKcjs.encodeCallsForCaller.call(void 0, address, calls);
352
+ const encodeCalls = async (calls) => _chunkUB2FLPP3cjs.encodeCallsForCaller.call(void 0, address, calls);
349
353
  const signerMethods = _nullishCoalesce(signer, () => ( {
350
354
  signMessage: async () => {
351
355
  throw new Error(
@@ -371,15 +375,15 @@ async function toMetaMaskSmartAccount(params) {
371
375
  getAddress,
372
376
  getFactoryArgs,
373
377
  encodeCalls,
374
- getNonce,
375
378
  signUserOperation: signUserOperation2,
376
379
  signDelegation: signDelegation2,
380
+ nonceKeyManager,
377
381
  ...signerMethods
378
382
  });
379
383
  if (implementation === "Stateless7702" /* Stateless7702 */) {
380
384
  return {
381
385
  ...smartAccount,
382
- isDeployed: async () => _chunkQMRKCB7Tcjs.isValid7702Implementation.call(void 0, {
386
+ isDeployed: async () => _chunkT4IAMAB2cjs.isValid7702Implementation.call(void 0, {
383
387
  client,
384
388
  accountAddress: address,
385
389
  environment
@@ -394,7 +398,10 @@ function createCaveatEnforcerClient({
394
398
  client,
395
399
  environment
396
400
  }) {
397
- return client.extend(_chunkQMRKCB7Tcjs.caveatEnforcerActions.call(void 0, { environment }));
401
+ _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0, "createCaveatEnforcerClient", {
402
+ chainId: _nullishCoalesce(_optionalChain([client, 'access', _2 => _2.chain, 'optionalAccess', _3 => _3.id]), () => ( null))
403
+ });
404
+ return client.extend(_chunkT4IAMAB2cjs.caveatEnforcerActions.call(void 0, { environment }));
398
405
  }
399
406
 
400
407
  // src/actions/infuraBundlerClient.ts
@@ -422,6 +429,9 @@ var infuraBundlerActions = () => (client) => ({
422
429
  }
423
430
  });
424
431
  function createInfuraBundlerClient(config) {
432
+ _chunk7BEEGBA2cjs.trackSmartAccountsKitFunctionCall.call(void 0, "createInfuraBundlerClient", {
433
+ chainId: _nullishCoalesce(_optionalChain([config, 'access', _4 => _4.chain, 'optionalAccess', _5 => _5.id]), () => ( null))
434
+ });
425
435
  const baseBundlerClient = _accountabstraction.createBundlerClient.call(void 0, config);
426
436
  return baseBundlerClient.extend(
427
437
  infuraBundlerActions()
@@ -450,5 +460,5 @@ function createInfuraBundlerClient(config) {
450
460
 
451
461
 
452
462
 
453
- exports.ANY_BENEFICIARY = _chunkYDLLC6PPcjs.ANY_BENEFICIARY; exports.BalanceChangeType = _chunkYDLLC6PPcjs.BalanceChangeType; exports.CaveatType = _chunkYDLLC6PPcjs.CaveatType; exports.ExecutionMode = _chunkVLKX4BR6cjs.ExecutionMode; exports.Implementation = _chunkYDLLC6PPcjs.Implementation; exports.PREFERRED_VERSION = _chunkSOFB2MXGcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunkYDLLC6PPcjs.ROOT_AUTHORITY; exports.ScopeType = _chunkYDLLC6PPcjs.ScopeType; exports.TransferWindow = _chunkYDLLC6PPcjs.TransferWindow; exports.actions = _chunkQMRKCB7Tcjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunkXN36L4RXcjs.contracts_exports; exports.createCaveat = _chunkYDLLC6PPcjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunkYDLLC6PPcjs.createDelegation; exports.createExecution = _chunkVLKX4BR6cjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunkYDLLC6PPcjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunkSOFB2MXGcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunkYDLLC6PPcjs.signDelegation; exports.signUserOperation = _chunkSOFB2MXGcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
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;
454
464
  //# sourceMappingURL=index.cjs.map