@metamask/smart-accounts-kit 0.4.0-beta.0 → 0.4.0-beta.2

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 (79) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/dist/actions/index.cjs +5 -5
  3. package/dist/actions/index.d.cts +2 -2
  4. package/dist/actions/index.d.ts +2 -2
  5. package/dist/actions/index.mjs +4 -4
  6. package/dist/{chunk-S2Q5ZC64.cjs → chunk-23YXLKTX.cjs} +58 -59
  7. package/dist/chunk-23YXLKTX.cjs.map +1 -0
  8. package/dist/{chunk-W6ZI7GWI.mjs → chunk-33AMUJBJ.mjs} +49 -52
  9. package/dist/chunk-33AMUJBJ.mjs.map +1 -0
  10. package/dist/{chunk-TEH426Y4.mjs → chunk-C5ZEEH2Z.mjs} +283 -184
  11. package/dist/chunk-C5ZEEH2Z.mjs.map +1 -0
  12. package/dist/{chunk-NTZ57GNF.cjs → chunk-DLD377CN.cjs} +17 -33
  13. package/dist/chunk-DLD377CN.cjs.map +1 -0
  14. package/dist/{chunk-5BYJZGRI.mjs → chunk-NOCLGZGB.mjs} +174 -129
  15. package/dist/chunk-NOCLGZGB.mjs.map +1 -0
  16. package/dist/{chunk-EHIZB5U7.mjs → chunk-QCULIK3O.mjs} +211 -97
  17. package/dist/chunk-QCULIK3O.mjs.map +1 -0
  18. package/dist/{chunk-YWRHYLKB.cjs → chunk-QMRKCB7T.cjs} +204 -159
  19. package/dist/chunk-QMRKCB7T.cjs.map +1 -0
  20. package/dist/{chunk-TXN7GX6Y.cjs → chunk-SOFB2MXG.cjs} +207 -93
  21. package/dist/chunk-SOFB2MXG.cjs.map +1 -0
  22. package/dist/{chunk-RAXFJGCS.cjs → chunk-UUOH2WAW.cjs} +19 -19
  23. package/dist/chunk-UUOH2WAW.cjs.map +1 -0
  24. package/dist/{chunk-AUCZDOTJ.mjs → chunk-WPVSFOQM.mjs} +11 -27
  25. package/dist/chunk-WPVSFOQM.mjs.map +1 -0
  26. package/dist/{chunk-4A5RMDDC.mjs → chunk-WV2R7BXP.mjs} +49 -50
  27. package/dist/chunk-WV2R7BXP.mjs.map +1 -0
  28. package/dist/{chunk-YTGYVHDF.cjs → chunk-XN36L4RX.cjs} +144 -147
  29. package/dist/chunk-XN36L4RX.cjs.map +1 -0
  30. package/dist/{chunk-MIP7KJYH.cjs → chunk-YDLLC6PP.cjs} +252 -153
  31. package/dist/chunk-YDLLC6PP.cjs.map +1 -0
  32. package/dist/{chunk-DPWYECSV.mjs → chunk-YTELOQ4I.mjs} +9 -9
  33. package/dist/chunk-YTELOQ4I.mjs.map +1 -0
  34. package/dist/contracts/index.cjs +5 -5
  35. package/dist/contracts/index.d.cts +3 -3
  36. package/dist/contracts/index.d.ts +3 -3
  37. package/dist/contracts/index.mjs +4 -4
  38. package/dist/{delegation-DHjM_pVa.d.ts → delegation-DGUfyX-C.d.ts} +52 -26
  39. package/dist/{delegation-BnhAvKt4.d.cts → delegation-D_TY-tAq.d.cts} +52 -26
  40. package/dist/experimental/index.cjs +4 -4
  41. package/dist/experimental/index.cjs.map +1 -1
  42. package/dist/experimental/index.d.cts +1 -1
  43. package/dist/experimental/index.d.ts +1 -1
  44. package/dist/experimental/index.mjs +5 -5
  45. package/dist/experimental/index.mjs.map +1 -1
  46. package/dist/{index-CX3hrztI.d.cts → index-B9bsjGqI.d.ts} +240 -38
  47. package/dist/{index-D04LO0vH.d.cts → index-CZes99jV.d.cts} +95 -62
  48. package/dist/{index-i8cod4JY.d.ts → index-DvcKJcXi.d.cts} +240 -38
  49. package/dist/{index-BlgCQ80b.d.ts → index-FpCh2419.d.ts} +95 -62
  50. package/dist/index.cjs +26 -24
  51. package/dist/index.cjs.map +1 -1
  52. package/dist/index.d.cts +9 -11
  53. package/dist/index.d.ts +9 -11
  54. package/dist/index.mjs +17 -15
  55. package/dist/index.mjs.map +1 -1
  56. package/dist/{smartAccountsEnvironment-SVknZ_3f.d.cts → smartAccountsEnvironment-BU8kjlEv.d.cts} +1 -1
  57. package/dist/{smartAccountsEnvironment-BOhrxEnt.d.ts → smartAccountsEnvironment-egxuflDO.d.ts} +1 -1
  58. package/dist/{types-Bwksz_U6.d.ts → types-BLYWtcR3.d.cts} +49 -31
  59. package/dist/{types-Bwksz_U6.d.cts → types-BLYWtcR3.d.ts} +49 -31
  60. package/dist/utils/index.cjs +7 -5
  61. package/dist/utils/index.cjs.map +1 -1
  62. package/dist/utils/index.d.cts +3 -4
  63. package/dist/utils/index.d.ts +3 -4
  64. package/dist/utils/index.mjs +12 -10
  65. package/package.json +6 -11
  66. package/dist/chunk-4A5RMDDC.mjs.map +0 -1
  67. package/dist/chunk-5BYJZGRI.mjs.map +0 -1
  68. package/dist/chunk-AUCZDOTJ.mjs.map +0 -1
  69. package/dist/chunk-DPWYECSV.mjs.map +0 -1
  70. package/dist/chunk-EHIZB5U7.mjs.map +0 -1
  71. package/dist/chunk-MIP7KJYH.cjs.map +0 -1
  72. package/dist/chunk-NTZ57GNF.cjs.map +0 -1
  73. package/dist/chunk-RAXFJGCS.cjs.map +0 -1
  74. package/dist/chunk-S2Q5ZC64.cjs.map +0 -1
  75. package/dist/chunk-TEH426Y4.mjs.map +0 -1
  76. package/dist/chunk-TXN7GX6Y.cjs.map +0 -1
  77. package/dist/chunk-W6ZI7GWI.mjs.map +0 -1
  78. package/dist/chunk-YTGYVHDF.cjs.map +0 -1
  79. package/dist/chunk-YWRHYLKB.cjs.map +0 -1
@@ -4,22 +4,23 @@ import {
4
4
  read_exports3,
5
5
  read_exports4,
6
6
  read_exports5
7
- } from "./chunk-DPWYECSV.mjs";
7
+ } from "./chunk-YTELOQ4I.mjs";
8
8
  import {
9
9
  getSmartAccountsEnvironment,
10
10
  prepareSignUserOperationTypedData
11
- } from "./chunk-EHIZB5U7.mjs";
11
+ } from "./chunk-QCULIK3O.mjs";
12
12
  import {
13
13
  createExecution,
14
14
  encodeExecutionCalldatas
15
15
  } from "./chunk-TPBFVDVM.mjs";
16
16
  import {
17
17
  __export,
18
- getDelegationHashOffchain,
18
+ encodeDelegations,
19
+ hashDelegation,
19
20
  isDefined,
20
21
  prepareSignDelegationTypedData,
21
22
  toHexOrThrow
22
- } from "./chunk-TEH426Y4.mjs";
23
+ } from "./chunk-C5ZEEH2Z.mjs";
23
24
 
24
25
  // src/actions/index.ts
25
26
  var actions_exports = {};
@@ -52,6 +53,16 @@ async function sendTransactionWithDelegationAction(client, args) {
52
53
  "`to` is required. `sendTransactionWithDelegation` cannot be used to deploy contracts."
53
54
  );
54
55
  }
56
+ const chainId = client.chain?.id;
57
+ if (!chainId) {
58
+ throw new Error("Chain ID is not set");
59
+ }
60
+ const { DelegationManager: expectedDelegationManager } = getSmartAccountsEnvironment(chainId);
61
+ if (!isAddressEqual(args.delegationManager, expectedDelegationManager)) {
62
+ throw new Error(
63
+ `Invalid DelegationManager: expected ${expectedDelegationManager} for chain ${chainId}, but got ${args.delegationManager}`
64
+ );
65
+ }
55
66
  const executions = [
56
67
  createExecution({
57
68
  target: args.to,
@@ -60,17 +71,17 @@ async function sendTransactionWithDelegationAction(client, args) {
60
71
  })
61
72
  ];
62
73
  const calldata = encodeFunctionData({
63
- abi: DelegationManager.abi,
74
+ abi: DelegationManager,
64
75
  functionName: "redeemDelegations",
65
76
  args: [
66
- [args.permissionsContext],
77
+ [encodeDelegations(args.permissionContext)],
67
78
  ["0x0000000000000000000000000000000000000000000000000000000000000000" /* SingleDefault */],
68
79
  encodeExecutionCalldatas([executions])
69
80
  ]
70
81
  });
71
82
  const {
72
83
  value: _value,
73
- permissionsContext: _permissionsContext,
84
+ permissionContext: _permissionContext,
74
85
  delegationManager: _delegationManager,
75
86
  ...rest
76
87
  } = args;
@@ -82,7 +93,7 @@ async function sendTransactionWithDelegationAction(client, args) {
82
93
  return hash;
83
94
  }
84
95
  async function sendUserOperationWithDelegationAction(client, parameters) {
85
- if (parameters.accountMetadata) {
96
+ if (parameters.dependencies) {
86
97
  const { publicClient } = parameters;
87
98
  const includedAccountKeys = {};
88
99
  const chainId = publicClient.chain?.id;
@@ -90,24 +101,19 @@ async function sendUserOperationWithDelegationAction(client, parameters) {
90
101
  throw new Error("Chain ID is not set");
91
102
  }
92
103
  const { SimpleFactory } = getSmartAccountsEnvironment(chainId);
93
- const uniqueAccountMetadatas = parameters.accountMetadata.filter(
94
- (accountMetadata) => {
95
- if (!isAddressEqual(accountMetadata.factory, SimpleFactory)) {
96
- throw new Error(
97
- `Invalid accountMetadata: ${accountMetadata.factory} is not allowed.`
98
- );
99
- }
100
- const accountKey = concat([
101
- accountMetadata.factory,
102
- accountMetadata.factoryData
103
- ]);
104
- const isDuplicate = includedAccountKeys[accountKey];
105
- includedAccountKeys[accountKey] = true;
106
- return !isDuplicate;
104
+ const uniqueDependencies = parameters.dependencies.filter((dependency) => {
105
+ if (!isAddressEqual(dependency.factory, SimpleFactory)) {
106
+ throw new Error(
107
+ `Invalid dependency: ${dependency.factory} is not allowed.`
108
+ );
107
109
  }
108
- );
110
+ const accountKey = concat([dependency.factory, dependency.factoryData]);
111
+ const isDuplicate = includedAccountKeys[accountKey];
112
+ includedAccountKeys[accountKey] = true;
113
+ return !isDuplicate;
114
+ });
109
115
  const factoryCalls = (await Promise.all(
110
- uniqueAccountMetadatas.map(async ({ factory, factoryData }) => {
116
+ uniqueDependencies.map(async ({ factory, factoryData }) => {
111
117
  const isDeployed = await publicClient.call({
112
118
  to: factory,
113
119
  data: factoryData
@@ -127,60 +133,29 @@ async function sendUserOperationWithDelegationAction(client, parameters) {
127
133
  ...parameters.calls
128
134
  ];
129
135
  }
136
+ parameters.calls = parameters.calls.map((call) => {
137
+ if (!("permissionContext" in call)) {
138
+ return call;
139
+ }
140
+ const { permissionContext } = call;
141
+ if (!permissionContext) {
142
+ return call;
143
+ }
144
+ return {
145
+ ...call,
146
+ permissionContext: encodeDelegations(permissionContext)
147
+ };
148
+ });
130
149
  return client.sendUserOperation(
131
150
  parameters
132
151
  );
133
152
  }
134
153
 
135
- // src/actions/erc7715GetGrantedExecutionPermissionsAction.ts
136
- async function erc7715GetGrantedExecutionPermissionsAction(client) {
137
- const result = await client.request(
138
- {
139
- method: "wallet_getGrantedExecutionPermissions",
140
- params: []
141
- },
142
- { retryCount: 0 }
143
- );
144
- if (!result) {
145
- throw new Error("Failed to get granted execution permissions");
146
- }
147
- return result;
148
- }
149
-
150
- // src/actions/erc7715GetSupportedExecutionPermissionsAction.ts
151
- async function erc7715GetSupportedExecutionPermissionsAction(client) {
152
- const result = await client.request(
153
- {
154
- method: "wallet_getSupportedExecutionPermissions",
155
- params: []
156
- },
157
- { retryCount: 0 }
158
- );
159
- if (!result) {
160
- throw new Error("Failed to get supported execution permissions");
161
- }
162
- return result;
163
- }
164
-
165
- // src/actions/erc7715RequestExecutionPermissionsAction.ts
166
- import { toHex } from "viem";
167
- async function erc7715RequestExecutionPermissionsAction(client, parameters) {
168
- const formattedPermissionRequest = parameters.map(formatPermissionsRequest);
169
- const result = await client.request(
170
- {
171
- method: "wallet_requestExecutionPermissions",
172
- params: formattedPermissionRequest
173
- },
174
- { retryCount: 0 }
175
- );
176
- if (!result) {
177
- throw new Error("Failed to grant permissions");
178
- }
179
- return result;
180
- }
181
- function formatPermissionsRequest(parameters) {
182
- const { chainId, from, expiry, isAdjustmentAllowed } = parameters;
183
- const permissionFormatter = getPermissionFormatter(
154
+ // src/actions/erc7715Mapping.ts
155
+ import { hexToNumber, toHex } from "viem";
156
+ function permissionRequestToRpc(parameters) {
157
+ const { chainId, from, expiry } = parameters;
158
+ const converter = getPermissionRequestToRpcConverter(
184
159
  parameters.permission.type
185
160
  );
186
161
  const rules = isDefined(expiry) ? [
@@ -197,49 +172,38 @@ function formatPermissionsRequest(parameters) {
197
172
  return {
198
173
  ...optionalFields,
199
174
  chainId: toHex(chainId),
200
- permission: permissionFormatter({
201
- permission: parameters.permission,
202
- isAdjustmentAllowed
203
- }),
175
+ permission: converter(parameters.permission),
204
176
  to: parameters.to,
205
177
  rules
206
178
  };
207
179
  }
208
- function getPermissionFormatter(permissionType) {
180
+ function getPermissionRequestToRpcConverter(permissionType) {
209
181
  switch (permissionType) {
210
182
  case "native-token-stream":
211
- return ({ permission, isAdjustmentAllowed }) => formatNativeTokenStreamPermission({
212
- permission,
213
- isAdjustmentAllowed
214
- });
183
+ return (permission) => nativeTokenStreamPermissionToRpc(
184
+ permission
185
+ );
215
186
  case "erc20-token-stream":
216
- return ({ permission, isAdjustmentAllowed }) => formatErc20TokenStreamPermission({
217
- permission,
218
- isAdjustmentAllowed
219
- });
187
+ return (permission) => erc20TokenStreamPermissionToRpc(
188
+ permission
189
+ );
220
190
  case "native-token-periodic":
221
- return ({ permission, isAdjustmentAllowed }) => formatNativeTokenPeriodicPermission({
222
- permission,
223
- isAdjustmentAllowed
224
- });
191
+ return (permission) => nativeTokenPeriodicPermissionToRpc(
192
+ permission
193
+ );
225
194
  case "erc20-token-periodic":
226
- return ({ permission, isAdjustmentAllowed }) => formatErc20TokenPeriodicPermission({
227
- permission,
228
- isAdjustmentAllowed
229
- });
195
+ return (permission) => erc20TokenPeriodicPermissionToRpc(
196
+ permission
197
+ );
230
198
  case "erc20-token-revocation":
231
- return ({ permission, isAdjustmentAllowed }) => formatErc20TokenRevocationPermission({
232
- permission,
233
- isAdjustmentAllowed
234
- });
199
+ return (permission) => erc20TokenRevocationPermissionToRpc(
200
+ permission
201
+ );
235
202
  default:
236
203
  throw new Error(`Unsupported permission type: ${permissionType}`);
237
204
  }
238
205
  }
239
- function formatNativeTokenStreamPermission({
240
- permission,
241
- isAdjustmentAllowed
242
- }) {
206
+ function nativeTokenStreamPermissionToRpc(permission) {
243
207
  const {
244
208
  data: {
245
209
  initialAmount,
@@ -247,7 +211,8 @@ function formatNativeTokenStreamPermission({
247
211
  maxAmount,
248
212
  startTime,
249
213
  amountPerSecond
250
- }
214
+ },
215
+ isAdjustmentAllowed
251
216
  } = permission;
252
217
  const optionalFields = {
253
218
  ...isDefined(initialAmount) && {
@@ -270,10 +235,7 @@ function formatNativeTokenStreamPermission({
270
235
  isAdjustmentAllowed
271
236
  };
272
237
  }
273
- function formatErc20TokenStreamPermission({
274
- permission,
275
- isAdjustmentAllowed
276
- }) {
238
+ function erc20TokenStreamPermissionToRpc(permission) {
277
239
  const {
278
240
  data: {
279
241
  tokenAddress,
@@ -282,7 +244,8 @@ function formatErc20TokenStreamPermission({
282
244
  startTime,
283
245
  maxAmount,
284
246
  justification
285
- }
247
+ },
248
+ isAdjustmentAllowed
286
249
  } = permission;
287
250
  const optionalFields = {
288
251
  ...isDefined(initialAmount) && {
@@ -306,12 +269,10 @@ function formatErc20TokenStreamPermission({
306
269
  isAdjustmentAllowed
307
270
  };
308
271
  }
309
- function formatNativeTokenPeriodicPermission({
310
- permission,
311
- isAdjustmentAllowed
312
- }) {
272
+ function nativeTokenPeriodicPermissionToRpc(permission) {
313
273
  const {
314
- data: { periodAmount, periodDuration, startTime, justification }
274
+ data: { periodAmount, periodDuration, startTime, justification },
275
+ isAdjustmentAllowed
315
276
  } = permission;
316
277
  const optionalFields = {
317
278
  ...isDefined(startTime) && {
@@ -329,10 +290,7 @@ function formatNativeTokenPeriodicPermission({
329
290
  isAdjustmentAllowed
330
291
  };
331
292
  }
332
- function formatErc20TokenPeriodicPermission({
333
- permission,
334
- isAdjustmentAllowed
335
- }) {
293
+ function erc20TokenPeriodicPermissionToRpc(permission) {
336
294
  const {
337
295
  data: {
338
296
  tokenAddress,
@@ -340,7 +298,8 @@ function formatErc20TokenPeriodicPermission({
340
298
  periodDuration,
341
299
  startTime,
342
300
  justification
343
- }
301
+ },
302
+ isAdjustmentAllowed
344
303
  } = permission;
345
304
  const optionalFields = {
346
305
  ...isDefined(startTime) && {
@@ -359,12 +318,10 @@ function formatErc20TokenPeriodicPermission({
359
318
  isAdjustmentAllowed
360
319
  };
361
320
  }
362
- function formatErc20TokenRevocationPermission({
363
- permission,
364
- isAdjustmentAllowed
365
- }) {
321
+ function erc20TokenRevocationPermissionToRpc(permission) {
366
322
  const {
367
- data: { justification }
323
+ data: { justification },
324
+ isAdjustmentAllowed
368
325
  } = permission;
369
326
  const data = {
370
327
  ...justification ? { justification } : {}
@@ -375,6 +332,94 @@ function formatErc20TokenRevocationPermission({
375
332
  isAdjustmentAllowed
376
333
  };
377
334
  }
335
+ function permissionResponsesFromRpc(result) {
336
+ return result.map((permission) => ({
337
+ ...permission,
338
+ chainId: hexToNumber(permission.chainId),
339
+ permission: permissionTypeFromRpc(permission.permission)
340
+ }));
341
+ }
342
+ function permissionTypeFromRpc(permission) {
343
+ const convertedData = { ...permission.data };
344
+ if ("amountPerSecond" in convertedData && convertedData.amountPerSecond) {
345
+ convertedData.amountPerSecond = BigInt(
346
+ convertedData.amountPerSecond
347
+ );
348
+ }
349
+ if ("periodAmount" in convertedData && convertedData.periodAmount) {
350
+ convertedData.periodAmount = BigInt(
351
+ convertedData.periodAmount
352
+ );
353
+ }
354
+ if ("initialAmount" in convertedData && convertedData.initialAmount) {
355
+ convertedData.initialAmount = BigInt(
356
+ convertedData.initialAmount
357
+ );
358
+ }
359
+ if ("maxAmount" in convertedData && convertedData.maxAmount) {
360
+ convertedData.maxAmount = BigInt(convertedData.maxAmount);
361
+ }
362
+ return {
363
+ ...permission,
364
+ data: convertedData
365
+ };
366
+ }
367
+ function rpcSupportedPermissionsToDeveloper(result) {
368
+ const converted = {};
369
+ for (const [permissionType, permissionInfo] of Object.entries(result)) {
370
+ converted[permissionType] = {
371
+ chainIds: permissionInfo.chainIds.map((chainId) => hexToNumber(chainId)),
372
+ ruleTypes: permissionInfo.ruleTypes
373
+ };
374
+ }
375
+ return converted;
376
+ }
377
+
378
+ // src/actions/erc7715GetGrantedExecutionPermissionsAction.ts
379
+ async function erc7715GetGrantedExecutionPermissionsAction(client) {
380
+ const result = await client.request(
381
+ {
382
+ method: "wallet_getGrantedExecutionPermissions",
383
+ params: []
384
+ },
385
+ { retryCount: 0 }
386
+ );
387
+ if (!result) {
388
+ throw new Error("Failed to get granted execution permissions");
389
+ }
390
+ return permissionResponsesFromRpc(result);
391
+ }
392
+
393
+ // src/actions/erc7715GetSupportedExecutionPermissionsAction.ts
394
+ async function erc7715GetSupportedExecutionPermissionsAction(client) {
395
+ const result = await client.request(
396
+ {
397
+ method: "wallet_getSupportedExecutionPermissions",
398
+ params: []
399
+ },
400
+ { retryCount: 0 }
401
+ );
402
+ if (!result) {
403
+ throw new Error("Failed to get supported execution permissions");
404
+ }
405
+ return rpcSupportedPermissionsToDeveloper(result);
406
+ }
407
+
408
+ // src/actions/erc7715RequestExecutionPermissionsAction.ts
409
+ async function erc7715RequestExecutionPermissionsAction(client, parameters) {
410
+ const formattedPermissionRequest = parameters.map(permissionRequestToRpc);
411
+ const result = await client.request(
412
+ {
413
+ method: "wallet_requestExecutionPermissions",
414
+ params: formattedPermissionRequest
415
+ },
416
+ { retryCount: 0 }
417
+ );
418
+ if (!result) {
419
+ throw new Error("Failed to grant permissions");
420
+ }
421
+ return permissionResponsesFromRpc(result);
422
+ }
378
423
 
379
424
  // src/actions/getCaveatAvailableAmount.ts
380
425
  function findMatchingCaveat({
@@ -422,7 +467,7 @@ async function getErc20PeriodTransferEnforcerAvailableAmount(client, environment
422
467
  enforcerName,
423
468
  environment
424
469
  });
425
- const delegationHash = getDelegationHashOffchain(params.delegation);
470
+ const delegationHash = hashDelegation(params.delegation);
426
471
  const { terms } = findMatchingCaveat({
427
472
  delegation: params.delegation,
428
473
  enforcerAddress,
@@ -443,7 +488,7 @@ async function getErc20StreamingEnforcerAvailableAmount(client, environment, par
443
488
  enforcerName,
444
489
  environment
445
490
  });
446
- const delegationHash = getDelegationHashOffchain(params.delegation);
491
+ const delegationHash = hashDelegation(params.delegation);
447
492
  const { terms } = findMatchingCaveat({
448
493
  delegation: params.delegation,
449
494
  enforcerAddress,
@@ -464,7 +509,7 @@ async function getMultiTokenPeriodEnforcerAvailableAmount(client, environment, p
464
509
  enforcerName,
465
510
  environment
466
511
  });
467
- const delegationHash = getDelegationHashOffchain(params.delegation);
512
+ const delegationHash = hashDelegation(params.delegation);
468
513
  const { terms, args } = findMatchingCaveat({
469
514
  delegation: params.delegation,
470
515
  enforcerAddress,
@@ -486,7 +531,7 @@ async function getNativeTokenPeriodTransferEnforcerAvailableAmount(client, envir
486
531
  enforcerName,
487
532
  environment
488
533
  });
489
- const delegationHash = getDelegationHashOffchain(params.delegation);
534
+ const delegationHash = hashDelegation(params.delegation);
490
535
  const { terms } = findMatchingCaveat({
491
536
  delegation: params.delegation,
492
537
  enforcerAddress,
@@ -507,7 +552,7 @@ async function getNativeTokenStreamingEnforcerAvailableAmount(client, environmen
507
552
  enforcerName,
508
553
  environment
509
554
  });
510
- const delegationHash = getDelegationHashOffchain(params.delegation);
555
+ const delegationHash = hashDelegation(params.delegation);
511
556
  const { terms } = findMatchingCaveat({
512
557
  delegation: params.delegation,
513
558
  enforcerAddress,
@@ -764,4 +809,4 @@ export {
764
809
  erc7710BundlerActions,
765
810
  actions_exports
766
811
  };
767
- //# sourceMappingURL=chunk-5BYJZGRI.mjs.map
812
+ //# sourceMappingURL=chunk-NOCLGZGB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/actions/index.ts","../src/actions/erc7710RedeemDelegationAction.ts","../src/actions/erc7715Mapping.ts","../src/actions/erc7715GetGrantedExecutionPermissionsAction.ts","../src/actions/erc7715GetSupportedExecutionPermissionsAction.ts","../src/actions/erc7715RequestExecutionPermissionsAction.ts","../src/actions/getCaveatAvailableAmount.ts","../src/actions/isValid7702Implementation.ts","../src/actions/signDelegation.ts","../src/actions/signUserOperation.ts"],"sourcesContent":["import type { Client, WalletClient } from 'viem';\nimport type { BundlerClient } from 'viem/account-abstraction';\n\nimport type {\n SendTransactionWithDelegationParameters,\n SendUserOperationWithDelegationParameters,\n} from './erc7710RedeemDelegationAction';\nimport {\n sendTransactionWithDelegationAction,\n sendUserOperationWithDelegationAction,\n} from './erc7710RedeemDelegationAction';\nimport { erc7715GetGrantedExecutionPermissionsAction } from './erc7715GetGrantedExecutionPermissionsAction';\nimport { erc7715GetSupportedExecutionPermissionsAction } from './erc7715GetSupportedExecutionPermissionsAction';\nimport { erc7715RequestExecutionPermissionsAction } from './erc7715RequestExecutionPermissionsAction';\nimport type {\n MetaMaskExtensionClient,\n RequestExecutionPermissionsParameters,\n} from './erc7715RequestExecutionPermissionsAction';\n\nexport {\n // Individual action functions\n getErc20PeriodTransferEnforcerAvailableAmount,\n getErc20StreamingEnforcerAvailableAmount,\n getMultiTokenPeriodEnforcerAvailableAmount,\n getNativeTokenPeriodTransferEnforcerAvailableAmount,\n getNativeTokenStreamingEnforcerAvailableAmount,\n // Action builder\n caveatEnforcerActions,\n // Parameter types\n type CaveatEnforcerParams,\n // Result types\n type PeriodTransferResult,\n type StreamingResult,\n} from './getCaveatAvailableAmount';\n\nexport { isValid7702Implementation } from './isValid7702Implementation';\n\n// Signing actions\nexport {\n signDelegation,\n signDelegationActions,\n type SignDelegationParameters,\n type SignDelegationReturnType,\n} from './signDelegation';\n\nexport {\n signUserOperation,\n signUserOperationActions,\n type SignUserOperationParameters,\n type SignUserOperationReturnType,\n} from './signUserOperation';\n\nexport {\n erc7715RequestExecutionPermissionsAction as requestExecutionPermissions,\n type MetaMaskExtensionClient,\n type MetaMaskExtensionSchema,\n type RequestExecutionPermissionsParameters,\n type RequestExecutionPermissionsReturnType,\n} from './erc7715RequestExecutionPermissionsAction';\n\nexport type { PermissionRequestParameter } from './erc7715Types';\n\nexport { erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions } from './erc7715GetSupportedExecutionPermissionsAction';\n\nexport { erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions } from './erc7715GetGrantedExecutionPermissionsAction';\n\nexport {\n type GetSupportedExecutionPermissionsResult,\n type GetGrantedExecutionPermissionsResult,\n type SupportedPermissionInfo,\n type PermissionTypes,\n type NativeTokenStreamPermission,\n type NativeTokenPeriodicPermission,\n type Erc20TokenStreamPermission,\n type Erc20TokenPeriodicPermission,\n type Erc20TokenRevocationPermission,\n type RpcGetSupportedExecutionPermissionsResult,\n type RpcGetGrantedExecutionPermissionsResult,\n type RpcSupportedPermissionInfo,\n} from './erc7715Types';\n\nexport type { DelegatedCall } from './erc7710RedeemDelegationAction';\n\nexport const erc7715ProviderActions = () => (client: Client) => ({\n requestExecutionPermissions: async (\n parameters: RequestExecutionPermissionsParameters,\n ) => {\n return erc7715RequestExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n parameters,\n );\n },\n getSupportedExecutionPermissions: async () => {\n return erc7715GetSupportedExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n );\n },\n getGrantedExecutionPermissions: async () => {\n return erc7715GetGrantedExecutionPermissionsAction(\n client as MetaMaskExtensionClient,\n );\n },\n});\n\n/**\n * Type for a viem Client extended with ERC-7715 provider actions.\n * Use this to type variables that will be assigned an extended client later.\n *\n * @example\n * ```typescript\n * let client: Erc7715Client | null = null;\n *\n * function setupClient() {\n * client = createWalletClient({\n * chain: sepolia,\n * transport: custom(window.ethereum),\n * }).extend(erc7715ProviderActions());\n * }\n * ```\n */\nexport type Erc7715Client = Client &\n ReturnType<ReturnType<typeof erc7715ProviderActions>>;\n\nexport const erc7710WalletActions = () => (client: WalletClient) => ({\n sendTransactionWithDelegation: async (\n args: SendTransactionWithDelegationParameters,\n ) => sendTransactionWithDelegationAction(client, args),\n});\n\nexport const erc7710BundlerActions = () => (client: Client) => ({\n sendUserOperationWithDelegation: async (\n args: SendUserOperationWithDelegationParameters,\n ) => sendUserOperationWithDelegationAction(client as BundlerClient, args),\n});\n","import { DelegationManager } from '@metamask/delegation-abis';\nimport type {\n Account,\n Chain,\n Hex,\n OneOf,\n PublicClient,\n SendTransactionParameters,\n SendTransactionRequest,\n Transport,\n WalletClient,\n} from 'viem';\nimport { concat, encodeFunctionData, isAddressEqual } from 'viem';\nimport type {\n BundlerClient,\n SendUserOperationParameters,\n SmartAccount,\n} from 'viem/account-abstraction';\n\nimport { encodeDelegations } from '../delegation';\nimport {\n createExecution,\n encodeExecutionCalldatas,\n ExecutionMode,\n} from '../executions';\nimport { getSmartAccountsEnvironment } from '../smartAccountsEnvironment';\nimport type { Call, PermissionContext } from '../types';\n\nexport type DelegatedCall = Call &\n OneOf<\n { permissionContext: PermissionContext; delegationManager: Hex } | object\n >;\n\nexport type SendTransactionWithDelegationParameters<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TRequest extends SendTransactionRequest<TChain, TChainOverride> =\n SendTransactionRequest<TChain, TChainOverride>,\n> = SendTransactionParameters<TChain, TAccount, TChainOverride, TRequest> & {\n permissionContext: PermissionContext;\n delegationManager: Hex;\n};\n\n/**\n * Sends a transaction using delegation to execute operations on behalf of another account.\n *\n * @param client - The wallet client to use for sending the transaction.\n * @param args - Transaction parameters with delegation details.\n * @returns Transaction hash of the executed transaction.\n */\nexport async function sendTransactionWithDelegationAction<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: WalletClient<Transport, TChain, TAccount>,\n args: SendTransactionWithDelegationParameters<TChain, TAccount>,\n) {\n if (!args.to) {\n throw new Error(\n '`to` is required. `sendTransactionWithDelegation` cannot be used to deploy contracts.',\n );\n }\n\n // Validate DelegationManager address\n const chainId = client.chain?.id;\n if (!chainId) {\n throw new Error('Chain ID is not set');\n }\n\n const { DelegationManager: expectedDelegationManager } =\n getSmartAccountsEnvironment(chainId);\n if (!isAddressEqual(args.delegationManager, expectedDelegationManager)) {\n throw new Error(\n `Invalid DelegationManager: expected ${expectedDelegationManager} for chain ${chainId}, but got ${args.delegationManager}`,\n );\n }\n\n const executions = [\n createExecution({\n target: args.to,\n value: args.value,\n callData: args.data,\n }),\n ];\n\n const calldata = encodeFunctionData({\n abi: DelegationManager,\n functionName: 'redeemDelegations',\n args: [\n [encodeDelegations(args.permissionContext)],\n [ExecutionMode.SingleDefault],\n encodeExecutionCalldatas([executions]),\n ],\n });\n\n const {\n value: _value,\n permissionContext: _permissionContext,\n delegationManager: _delegationManager,\n ...rest\n } = args;\n\n const hash = await client.sendTransaction({\n ...rest,\n to: args.delegationManager,\n data: calldata,\n } as unknown as SendTransactionParameters);\n\n return hash;\n}\n\nexport type SendUserOperationWithDelegationParameters<\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n TAccountOverride extends SmartAccount | undefined = SmartAccount | undefined,\n> = SendUserOperationParameters<TAccount, TAccountOverride, DelegatedCall[]> & {\n dependencies?: { factory: Hex; factoryData: Hex }[];\n calls: DelegatedCall[];\n publicClient: PublicClient<Transport, Chain>;\n};\n\n/**\n * Broadcasts a User Operation with delegation to the Bundler.\n *\n * @param client - Client to use for sending the user operation.\n * @param parameters - Parameters for the user operation with delegation.\n * @returns The User Operation hash of the broadcasted operation.\n * @example\n * import { createBundlerClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const bundlerClient = createBundlerClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const userOpHash = await sendUserOperationWithDelegationAction(bundlerClient, {\n * account: bobSmartAccount,\n * calls: [\n * {\n * to: aliceCounterContractAddress,\n * data: encodeFunctionData({\n * abi: CounterMetadata.abi,\n * functionName: 'increment',\n * }),\n * value: 0n,\n * permissionContext: '0x...',\n * delegationManager: '0x...',\n * },\n * ],\n * dependencies: [{ factory: '0x...', factoryData: '0x...' }], // Optional: for deploying accounts\n * })\n */\nexport async function sendUserOperationWithDelegationAction<\n TAccount extends SmartAccount | undefined,\n TAccountOverride extends SmartAccount | undefined = undefined,\n>(\n client: BundlerClient<Transport, Chain | undefined, TAccount>,\n parameters: SendUserOperationWithDelegationParameters<\n TAccount,\n TAccountOverride\n >,\n) {\n if (parameters.dependencies) {\n const { publicClient } = parameters;\n\n const includedAccountKeys: Record<Hex, boolean> = {};\n\n const chainId = publicClient.chain?.id;\n\n if (!chainId) {\n throw new Error('Chain ID is not set');\n }\n\n const { SimpleFactory } = getSmartAccountsEnvironment(chainId);\n\n const uniqueDependencies = parameters.dependencies.filter((dependency) => {\n if (!isAddressEqual(dependency.factory, SimpleFactory)) {\n throw new Error(\n `Invalid dependency: ${dependency.factory} is not allowed.`,\n );\n }\n\n // ensure that factory calls are not duplicated\n const accountKey = concat([dependency.factory, dependency.factoryData]);\n const isDuplicate = includedAccountKeys[accountKey];\n\n includedAccountKeys[accountKey] = true;\n return !isDuplicate;\n });\n\n const factoryCalls = (\n await Promise.all(\n uniqueDependencies.map(async ({ factory, factoryData }) => {\n const isDeployed = await publicClient\n .call({\n to: factory,\n data: factoryData,\n })\n .then(() => false)\n .catch(() => true);\n\n if (isDeployed) {\n return undefined;\n }\n return {\n to: factory,\n value: 0n,\n data: factoryData,\n };\n }),\n )\n ).filter((call: Call | undefined) => call !== undefined) as Call[];\n\n parameters.calls = [\n ...(factoryCalls as DelegatedCall[]),\n ...parameters.calls,\n ];\n }\n\n parameters.calls = parameters.calls.map((call) => {\n if (!('permissionContext' in call)) {\n return call;\n }\n\n const { permissionContext } = call;\n if (!permissionContext) {\n return call;\n }\n\n return {\n ...call,\n permissionContext: encodeDelegations(permissionContext),\n };\n });\n\n return client.sendUserOperation(\n parameters as unknown as SendUserOperationParameters,\n );\n}\n","import type {\n Erc20TokenPeriodicPermission as RpcErc20TokenPeriodicPermission,\n Erc20TokenStreamPermission as RpcErc20TokenStreamPermission,\n Erc20TokenRevocationPermission as RpcErc20TokenRevocationPermission,\n NativeTokenPeriodicPermission as RpcNativeTokenPeriodicPermission,\n NativeTokenStreamPermission as RpcNativeTokenStreamPermission,\n PermissionRequest,\n PermissionTypes as RpcPermissionTypes,\n Rule,\n} from '@metamask/7715-permission-types';\nimport { hexToNumber, toHex } from 'viem';\n\nimport { isDefined, toHexOrThrow } from '../utils';\nimport type {\n Erc20TokenPeriodicPermission,\n Erc20TokenRevocationPermission,\n Erc20TokenStreamPermission,\n GetGrantedExecutionPermissionsResult,\n GetSupportedExecutionPermissionsResult,\n NativeTokenPeriodicPermission,\n NativeTokenStreamPermission,\n PermissionRequestParameter,\n PermissionTypes as DeveloperPermissionTypes,\n RpcGetGrantedExecutionPermissionsResult,\n RpcGetSupportedExecutionPermissionsResult,\n} from './erc7715Types';\n\n// =============================================================================\n// Developer → RPC (request formatting)\n// =============================================================================\n\n/**\n * Converts a developer permission request to RPC format for wallet submission.\n *\n * @param parameters the permission request parameters\n * @returns the permission request in RPC format\n */\nexport function permissionRequestToRpc(\n parameters: PermissionRequestParameter,\n): PermissionRequest<RpcPermissionTypes> {\n const { chainId, from, expiry } = parameters;\n\n const converter = getPermissionRequestToRpcConverter(\n parameters.permission.type,\n );\n\n const rules: Rule[] = isDefined(expiry)\n ? [\n {\n type: 'expiry',\n data: {\n timestamp: expiry,\n },\n },\n ]\n : [];\n\n const optionalFields = {\n ...(from ? { from } : {}),\n };\n\n return {\n ...optionalFields,\n chainId: toHex(chainId),\n permission: converter(parameters.permission),\n to: parameters.to,\n rules,\n };\n}\n\ntype PermissionRequestToRpcConverter = (\n permission: DeveloperPermissionTypes,\n) => RpcPermissionTypes;\n\n/**\n * Get the permission request to RPC converter for the given permission type.\n *\n * @param permissionType the permission type\n * @returns the permission request to RPC converter for the given permission type\n */\nfunction getPermissionRequestToRpcConverter(\n permissionType: string,\n): PermissionRequestToRpcConverter {\n switch (permissionType) {\n case 'native-token-stream':\n return (permission) =>\n nativeTokenStreamPermissionToRpc(\n permission as NativeTokenStreamPermission,\n );\n case 'erc20-token-stream':\n return (permission) =>\n erc20TokenStreamPermissionToRpc(\n permission as Erc20TokenStreamPermission,\n );\n case 'native-token-periodic':\n return (permission) =>\n nativeTokenPeriodicPermissionToRpc(\n permission as NativeTokenPeriodicPermission,\n );\n case 'erc20-token-periodic':\n return (permission) =>\n erc20TokenPeriodicPermissionToRpc(\n permission as Erc20TokenPeriodicPermission,\n );\n case 'erc20-token-revocation':\n return (permission) =>\n erc20TokenRevocationPermissionToRpc(\n permission as Erc20TokenRevocationPermission,\n );\n default:\n throw new Error(`Unsupported permission type: ${permissionType}`);\n }\n}\n\n/**\n * Convert native token stream permission to RPC format.\n *\n * @param permission the native token stream permission\n * @returns the native token stream permission in RPC format\n */\nfunction nativeTokenStreamPermissionToRpc(\n permission: NativeTokenStreamPermission,\n): RpcNativeTokenStreamPermission {\n const {\n data: {\n initialAmount,\n justification,\n maxAmount,\n startTime,\n amountPerSecond,\n },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(initialAmount) && {\n initialAmount: toHexOrThrow(initialAmount, 'initialAmount'),\n }),\n ...(isDefined(maxAmount) && {\n maxAmount: toHexOrThrow(maxAmount, 'maxAmount'),\n }),\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'native-token-stream',\n data: {\n amountPerSecond: toHexOrThrow(amountPerSecond, 'amountPerSecond'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC20 token stream permission to RPC format.\n *\n * @param permission the erc20 token stream permission\n * @returns the erc20 token stream permission in RPC format\n */\nfunction erc20TokenStreamPermissionToRpc(\n permission: Erc20TokenStreamPermission,\n): RpcErc20TokenStreamPermission {\n const {\n data: {\n tokenAddress,\n amountPerSecond,\n initialAmount,\n startTime,\n maxAmount,\n justification,\n },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(initialAmount) && {\n initialAmount: toHexOrThrow(initialAmount, 'initialAmount'),\n }),\n ...(isDefined(maxAmount) && {\n maxAmount: toHexOrThrow(maxAmount, 'maxAmount'),\n }),\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'erc20-token-stream',\n data: {\n tokenAddress: toHexOrThrow(tokenAddress, 'tokenAddress'),\n amountPerSecond: toHexOrThrow(amountPerSecond, 'amountPerSecond'),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert native token periodic permission to RPC format.\n *\n * @param permission the native token periodic permission\n * @returns the native token periodic permission in RPC format\n */\nfunction nativeTokenPeriodicPermissionToRpc(\n permission: NativeTokenPeriodicPermission,\n): RpcNativeTokenPeriodicPermission {\n const {\n data: { periodAmount, periodDuration, startTime, justification },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'native-token-periodic',\n data: {\n periodAmount: toHexOrThrow(periodAmount, 'periodAmount'),\n periodDuration: Number(periodDuration),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC20 token periodic permission to RPC format.\n *\n * @param permission the erc20 token periodic permission\n * @returns the erc20 token periodic permission in RPC format\n */\nfunction erc20TokenPeriodicPermissionToRpc(\n permission: Erc20TokenPeriodicPermission,\n): RpcErc20TokenPeriodicPermission {\n const {\n data: {\n tokenAddress,\n periodAmount,\n periodDuration,\n startTime,\n justification,\n },\n isAdjustmentAllowed,\n } = permission;\n\n const optionalFields = {\n ...(isDefined(startTime) && {\n startTime: Number(startTime),\n }),\n ...(justification ? { justification } : {}),\n };\n\n return {\n type: 'erc20-token-periodic',\n data: {\n tokenAddress: toHexOrThrow(tokenAddress, 'tokenAddress'),\n periodAmount: toHexOrThrow(periodAmount, 'periodAmount'),\n periodDuration: Number(periodDuration),\n ...optionalFields,\n },\n isAdjustmentAllowed,\n };\n}\n\n/**\n * Convert ERC20 token revocation permission to RPC format.\n *\n * @param permission the erc20 token revocation permission\n * @returns the erc20 token revocation permission in RPC format\n */\nfunction erc20TokenRevocationPermissionToRpc(\n permission: Erc20TokenRevocationPermission,\n): RpcErc20TokenRevocationPermission {\n const {\n data: { justification },\n isAdjustmentAllowed,\n } = permission;\n\n const data = {\n ...(justification ? { justification } : {}),\n };\n return {\n type: 'erc20-token-revocation',\n data,\n isAdjustmentAllowed,\n };\n}\n\n// =============================================================================\n// RPC → Developer friendly types (response conversion)\n// =============================================================================\n\n/**\n * Converts RPC permission responses to developer-friendly types.\n * Converts chainId from hex to number, and token amounts from hex to bigint.\n *\n * @param result the RPC permission responses\n * @returns the developer-friendly permission responses\n */\nexport function permissionResponsesFromRpc(\n result: RpcGetGrantedExecutionPermissionsResult,\n): GetGrantedExecutionPermissionsResult {\n return result.map((permission) => ({\n ...permission,\n chainId: hexToNumber(permission.chainId),\n permission: permissionTypeFromRpc(permission.permission),\n }));\n}\n\n/**\n * Converts RPC permission type data to developer-friendly types.\n * Converts hex amount fields to bigint.\n *\n * @param permission the RPC permission\n * @returns the developer-friendly permission\n */\nexport function permissionTypeFromRpc(\n permission: RpcPermissionTypes,\n): DeveloperPermissionTypes {\n const convertedData: Record<string, unknown> = { ...permission.data };\n\n if ('amountPerSecond' in convertedData && convertedData.amountPerSecond) {\n convertedData.amountPerSecond = BigInt(\n convertedData.amountPerSecond as `0x${string}`,\n );\n }\n\n if ('periodAmount' in convertedData && convertedData.periodAmount) {\n convertedData.periodAmount = BigInt(\n convertedData.periodAmount as `0x${string}`,\n );\n }\n\n if ('initialAmount' in convertedData && convertedData.initialAmount) {\n convertedData.initialAmount = BigInt(\n convertedData.initialAmount as `0x${string}`,\n );\n }\n\n if ('maxAmount' in convertedData && convertedData.maxAmount) {\n convertedData.maxAmount = BigInt(convertedData.maxAmount as `0x${string}`);\n }\n\n return {\n ...permission,\n data: convertedData,\n } as DeveloperPermissionTypes;\n}\n\n/**\n * Converts RPC supported permissions result to developer-friendly types.\n * Converts chain IDs from hex to numbers.\n *\n * @param result the RPC supported permissions result\n * @returns the developer-friendly supported permissions result\n */\nexport function rpcSupportedPermissionsToDeveloper(\n result: RpcGetSupportedExecutionPermissionsResult,\n): GetSupportedExecutionPermissionsResult {\n const converted: GetSupportedExecutionPermissionsResult = {};\n\n for (const [permissionType, permissionInfo] of Object.entries(result)) {\n converted[permissionType] = {\n chainIds: permissionInfo.chainIds.map((chainId) => hexToNumber(chainId)),\n ruleTypes: permissionInfo.ruleTypes,\n };\n }\n\n return converted;\n}\n","import { permissionResponsesFromRpc } from './erc7715Mapping';\nimport type {\n GetGrantedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n} from './erc7715Types';\n\nexport type { GetGrantedExecutionPermissionsResult } from './erc7715Types';\n\n/**\n * Retrieves all previously granted execution permissions from the wallet according to EIP-7715 specification.\n *\n * @param client - The client to use for the request.\n * @returns A promise that resolves to an array of granted permission responses.\n * @description\n * This function queries the wallet for all granted permissions that are not yet revoked.\n * Each permission response includes the chain ID, address, signer, permission details,\n * context, and dependency information.\n * @example\n * ```typescript\n * const grantedPermissions = await erc7715GetGrantedExecutionPermissionsAction(client);\n * // Returns an array of PermissionResponse objects with user-friendly types\n * ```\n */\nexport async function erc7715GetGrantedExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n): Promise<GetGrantedExecutionPermissionsResult> {\n const result = await client.request(\n {\n method: 'wallet_getGrantedExecutionPermissions',\n params: [],\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to get granted execution permissions');\n }\n\n return permissionResponsesFromRpc(result);\n}\n","import { rpcSupportedPermissionsToDeveloper } from './erc7715Mapping';\nimport type {\n GetSupportedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n} from './erc7715Types';\n\nexport type { GetSupportedExecutionPermissionsResult } from './erc7715Types';\n\n/**\n * Retrieves the supported execution permission types from the wallet according to EIP-7715 specification.\n *\n * @param client - The client to use for the request.\n * @returns A promise that resolves to a record of supported permission types with their chain IDs and rule types.\n * @description\n * This function queries the wallet for the permission types it supports.\n * The result is keyed by permission type and includes the supported chain IDs and rule types.\n * @example\n * ```typescript\n * const supported = await erc7715GetSupportedExecutionPermissionsAction(client);\n * // Returns:\n * // {\n * // \"native-token-allowance\": {\n * // \"chainIds\": [1, 137],\n * // \"ruleTypes\": [\"expiry\"]\n * // },\n * // \"erc20-token-allowance\": {\n * // \"chainIds\": [1],\n * // \"ruleTypes\": []\n * // }\n * // }\n * ```\n */\nexport async function erc7715GetSupportedExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n): Promise<GetSupportedExecutionPermissionsResult> {\n const result = await client.request(\n {\n method: 'wallet_getSupportedExecutionPermissions',\n params: [],\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to get supported execution permissions');\n }\n\n return rpcSupportedPermissionsToDeveloper(result);\n}\n","import {\n permissionRequestToRpc,\n permissionResponsesFromRpc,\n} from './erc7715Mapping';\nimport type {\n GetGrantedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n PermissionRequestParameter,\n} from './erc7715Types';\n\nexport type {\n GetGrantedExecutionPermissionsResult,\n GetSupportedExecutionPermissionsResult,\n MetaMaskExtensionClient,\n MetaMaskExtensionSchema,\n SupportedPermissionInfo,\n PermissionTypes,\n PermissionRequestParameter,\n} from './erc7715Types';\n\n/**\n * Parameters for the RequestExecutionPermissions action.\n *\n * @template Signer - The type of the signer, either an Address or Account.\n */\nexport type RequestExecutionPermissionsParameters =\n PermissionRequestParameter[];\n\n/**\n * Return type for the request execution permissions action.\n */\nexport type RequestExecutionPermissionsReturnType =\n GetGrantedExecutionPermissionsResult;\n\n/**\n * Grants permissions according to EIP-7715 specification.\n *\n * @template Signer - The type of the signer, either an Address or Account.\n * @param client - The client to use for the request.\n * @param parameters - The permissions requests to grant.\n * @returns A promise that resolves to the permission responses.\n * @description\n * This function formats the permissions requests and invokes the wallet method to grant permissions.\n * It will throw an error if the permissions could not be granted.\n */\nexport async function erc7715RequestExecutionPermissionsAction(\n client: MetaMaskExtensionClient,\n parameters: RequestExecutionPermissionsParameters,\n): Promise<RequestExecutionPermissionsReturnType> {\n const formattedPermissionRequest = parameters.map(permissionRequestToRpc);\n\n const result = await client.request(\n {\n method: 'wallet_requestExecutionPermissions',\n params: formattedPermissionRequest,\n },\n { retryCount: 0 },\n );\n\n if (!result) {\n throw new Error('Failed to grant permissions');\n }\n\n return permissionResponsesFromRpc(result);\n}\n","import type { Address, Hex, Client } from 'viem';\n\nimport { hashDelegation } from '../delegation';\nimport * as ERC20PeriodTransferEnforcer from '../DelegationFramework/ERC20PeriodTransferEnforcer';\nimport * as ERC20StreamingEnforcer from '../DelegationFramework/ERC20StreamingEnforcer';\nimport * as MultiTokenPeriodEnforcer from '../DelegationFramework/MultiTokenPeriodEnforcer';\nimport * as NativeTokenPeriodTransferEnforcer from '../DelegationFramework/NativeTokenPeriodTransferEnforcer';\nimport * as NativeTokenStreamingEnforcer from '../DelegationFramework/NativeTokenStreamingEnforcer';\nimport type { SmartAccountsEnvironment, Delegation } from '../types';\n\n/**\n * Parameters for all caveat enforcer actions.\n */\nexport type CaveatEnforcerParams = {\n delegation: Delegation;\n};\n\n/**\n * Return type for period-based transfer enforcers\n */\nexport type PeriodTransferResult = {\n availableAmount: bigint;\n isNewPeriod: boolean;\n currentPeriod: bigint;\n};\n\n/**\n * Return type for streaming enforcers\n */\nexport type StreamingResult = {\n availableAmount: bigint;\n};\n\n/**\n * Finds a caveat that matches the specified enforcer address.\n *\n * @param config - The configuration object.\n * @param config.delegation - The delegation to search.\n * @param config.enforcerAddress - The enforcer address to match.\n * @param config.enforcerName - The name of the enforcer.\n * @returns The matching caveat.\n * @throws Error if no matching caveat is found.\n * @throws Error if multiple matching caveats are found.\n */\nfunction findMatchingCaveat({\n delegation,\n enforcerAddress,\n enforcerName,\n}: {\n delegation: Delegation;\n enforcerAddress: Address;\n enforcerName: keyof SmartAccountsEnvironment['caveatEnforcers'];\n}): { terms: Hex; args: Hex } {\n const matchingCaveats = delegation.caveats.filter(\n (caveat) => caveat.enforcer.toLowerCase() === enforcerAddress.toLowerCase(),\n );\n\n if (matchingCaveats.length === 0) {\n throw new Error(`No caveat found with enforcer matching ${enforcerName}`);\n }\n\n if (matchingCaveats.length > 1) {\n throw new Error(\n `Multiple caveats found with enforcer matching ${enforcerName}`,\n );\n }\n\n const [{ terms, args }] = matchingCaveats as unknown as [\n { terms: Hex; args: Hex },\n ];\n\n return {\n terms,\n args,\n };\n}\n\n/**\n * Gets the delegation manager address from environment.\n *\n * @param environment - The SmartAccountsEnvironment.\n * @returns The delegation manager address.\n */\nfunction getDelegationManager(environment: SmartAccountsEnvironment): Address {\n if (!environment.DelegationManager) {\n throw new Error('Delegation manager address not found');\n }\n\n return environment.DelegationManager;\n}\n\n/**\n * Gets the enforcer address from environment.\n *\n * @param config - The configuration object.\n * @param config.enforcerName - The name of the enforcer.\n * @param config.environment - The SmartAccountsEnvironment.\n * @returns The enforcer address.\n */\nfunction getEnforcerAddress({\n enforcerName,\n environment,\n}: {\n enforcerName: keyof SmartAccountsEnvironment['caveatEnforcers'];\n environment: SmartAccountsEnvironment;\n}): Address {\n const enforcerAddress = environment.caveatEnforcers[enforcerName];\n if (!enforcerAddress) {\n throw new Error(`${enforcerName} not found in environment`);\n }\n\n return enforcerAddress;\n}\n\n/**\n * Get available amount for ERC20 period transfer enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the ERC20 period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getErc20PeriodTransferEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n const enforcerName = 'ERC20PeriodTransferEnforcer';\n\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return ERC20PeriodTransferEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n });\n}\n\n/**\n * Get available amount for ERC20 streaming enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the ERC20 streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\nexport async function getErc20StreamingEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<StreamingResult> {\n const enforcerName = 'ERC20StreamingEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return ERC20StreamingEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationManager,\n delegationHash,\n terms,\n });\n}\n\n/**\n * Get available amount for multi-token period enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the multi-token period enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getMultiTokenPeriodEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n const enforcerName = 'MultiTokenPeriodEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms, args } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return MultiTokenPeriodEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n args,\n });\n}\n\n/**\n * Get available amount for native token period transfer enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the native token period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\nexport async function getNativeTokenPeriodTransferEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<PeriodTransferResult> {\n const enforcerName = 'NativeTokenPeriodTransferEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return NativeTokenPeriodTransferEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationHash,\n delegationManager,\n terms,\n });\n}\n\n/**\n * Get available amount for native token streaming enforcer.\n *\n * @param client - The viem client.\n * @param environment - The SmartAccountsEnvironment.\n * @param params - The parameters for the native token streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\nexport async function getNativeTokenStreamingEnforcerAvailableAmount(\n client: Client,\n environment: SmartAccountsEnvironment,\n params: CaveatEnforcerParams,\n): Promise<StreamingResult> {\n const enforcerName = 'NativeTokenStreamingEnforcer';\n const delegationManager = getDelegationManager(environment);\n const enforcerAddress = getEnforcerAddress({\n enforcerName,\n environment,\n });\n\n const delegationHash = hashDelegation(params.delegation);\n const { terms } = findMatchingCaveat({\n delegation: params.delegation,\n enforcerAddress,\n enforcerName,\n });\n\n return NativeTokenStreamingEnforcer.read.getAvailableAmount({\n client,\n contractAddress: enforcerAddress,\n delegationManager,\n delegationHash,\n terms,\n });\n}\n\n/**\n * Caveat enforcer actions for extending viem clients.\n *\n * @param params - The parameters object.\n * @param params.environment - The SmartAccountsEnvironment.\n * @returns A function that takes a client and returns the client extension with caveat enforcer actions.\n */\nexport const caveatEnforcerActions =\n ({ environment }: { environment: SmartAccountsEnvironment }) =>\n (client: Client) => ({\n /**\n * Get available amount for ERC20 period transfer enforcer.\n *\n * @param params - The parameters for the ERC20 period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getErc20PeriodTransferEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getErc20PeriodTransferEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for ERC20 streaming enforcer.\n *\n * @param params - The parameters for the ERC20 streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\n getErc20StreamingEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<StreamingResult> => {\n return getErc20StreamingEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for multi-token period enforcer.\n *\n * @param params - The parameters for the multi-token period enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getMultiTokenPeriodEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getMultiTokenPeriodEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for native token period transfer enforcer.\n *\n * @param params - The parameters for the native token period transfer enforcer.\n * @returns Promise resolving to the period transfer result.\n */\n getNativeTokenPeriodTransferEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<PeriodTransferResult> => {\n return getNativeTokenPeriodTransferEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n\n /**\n * Get available amount for native token streaming enforcer.\n *\n * @param params - The parameters for the native token streaming enforcer.\n * @returns Promise resolving to the streaming result.\n */\n getNativeTokenStreamingEnforcerAvailableAmount: async (\n params: CaveatEnforcerParams,\n ): Promise<StreamingResult> => {\n return getNativeTokenStreamingEnforcerAvailableAmount(\n client,\n environment,\n params,\n );\n },\n });\n","import type { Client, Address, Hex } from 'viem';\nimport { isAddressEqual } from 'viem';\nimport { getCode } from 'viem/actions';\n\nimport type { SmartAccountsEnvironment } from '../types';\n\n// EIP-7702 delegation prefix (0xef0100)\nconst DELEGATION_PREFIX = '0xef0100' as const;\n\n/**\n * Parameters for checking if an account is delegated to the EIP-7702 implementation.\n */\nexport type IsValid7702ImplementationParameters = {\n /** The client to use for the query. */\n client: Client;\n /** The address to check for proper delegation. */\n accountAddress: Address;\n /** The SmartAccountsEnvironment containing contract addresses. */\n environment: SmartAccountsEnvironment;\n};\n\n/**\n * Extracts the delegated contract address from EIP-7702 delegation code.\n *\n * @param code - The code returned from getCode for a delegated account.\n * @returns The delegated contract address or null if not a valid delegation.\n */\nfunction extractDelegatedAddress(code: Hex | undefined): Address | null {\n if (code?.length !== 48) {\n // 0x (2 chars) + ef0100 (6 chars) + address (40 chars) = 48 chars\n return null;\n }\n\n if (!code.toLowerCase().startsWith(DELEGATION_PREFIX.toLowerCase())) {\n return null;\n }\n\n // Extract the 20-byte address after the delegation prefix\n const addressHex = code.slice(8); // Remove '0xef0100' prefix (8 chars)\n return `0x${addressHex}`;\n}\n\n/**\n * Checks if an account is properly delegated to the EIP-7702 implementation.\n *\n * This function validates EIP-7702 delegations by checking if the EOA has a 7702\n * contract assigned to it and comparing the delegated address against the 7702\n * implementation found in the environment.\n *\n * @param params - The parameters for checking the delegation.\n * @param params.client - The client to use for the query.\n * @param params.accountAddress - The address to check for proper delegation.\n * @param params.environment - The SmartAccountsEnvironment containing contract addresses.\n * @returns A promise that resolves to true if the account is properly delegated to the 7702 implementation, false otherwise.\n * @example\n * ```typescript\n * const isValid = await isValid7702Implementation({\n * client: publicClient,\n * accountAddress: '0x...',\n * environment: smartAccountEnvironment,\n * });\n *\n * if (isValid) {\n * console.log('Account is properly delegated to EIP-7702 implementation');\n * } else {\n * console.log('Account is not properly delegated');\n * }\n * ```\n */\nexport async function isValid7702Implementation({\n client,\n accountAddress,\n environment,\n}: IsValid7702ImplementationParameters): Promise<boolean> {\n try {\n // Get the code at the account address\n const code = await getCode(client, {\n address: accountAddress,\n });\n\n // Extract the delegated contract address from the EIP-7702 delegation code\n const delegatedAddress = extractDelegatedAddress(code);\n\n // If no valid delegation found, return false\n if (!delegatedAddress) {\n return false;\n }\n\n // Compare the delegated address with the 7702 implementation in the environment\n const expectedImplementation =\n environment.implementations.EIP7702StatelessDeleGatorImpl;\n if (!expectedImplementation) {\n return false;\n }\n\n return isAddressEqual(delegatedAddress, expectedImplementation);\n } catch {\n // If the call fails (e.g., no code at address, network error),\n // then it's not properly delegated to our implementation\n return false;\n }\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n Transport,\n WalletClient,\n} from 'viem';\nimport { BaseError } from 'viem';\nimport { parseAccount } from 'viem/accounts';\n\nimport { prepareSignDelegationTypedData } from '../delegation';\nimport type { Delegation } from '../types';\n\nexport type SignDelegationParameters = {\n /** Account to sign with */\n account?: Account | Address;\n /** The delegation to sign */\n delegation: Omit<Delegation, 'signature'>;\n /** The address of the delegation manager contract */\n delegationManager: Address;\n /** The chain ID for the signature */\n chainId: number;\n /** The name of the contract */\n name?: string;\n /** The version of the contract */\n version?: string;\n /** Whether to allow insecure unrestricted delegation */\n allowInsecureUnrestrictedDelegation?: boolean;\n};\n\nexport type SignDelegationReturnType = Hex;\n\n/**\n * Signs a delegation using a wallet client.\n *\n * @param client - The wallet client to use for signing.\n * @param parameters - The parameters for signing the delegation.\n * @returns The signature of the delegation.\n * @example\n * ```ts\n * const signature = await signDelegation(walletClient, {\n * delegation: {\n * delegate: '0x...',\n * delegator: '0x...',\n * authority: '0x...',\n * caveats: [],\n * salt: '0x'\n * },\n * delegationManager: '0x...',\n * chainId: 1\n * });\n * ```\n */\nexport async function signDelegation<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n parameters: SignDelegationParameters,\n): Promise<SignDelegationReturnType> {\n const {\n account: accountParam = client.account,\n delegation,\n delegationManager,\n chainId,\n name = 'DelegationManager',\n version = '1',\n allowInsecureUnrestrictedDelegation = false,\n } = parameters;\n\n if (!accountParam) {\n throw new BaseError('Account not found. Please provide an account.');\n }\n\n const account = parseAccount(accountParam);\n\n const typedData = prepareSignDelegationTypedData({\n delegation,\n delegationManager,\n chainId,\n name,\n version,\n allowInsecureUnrestrictedDelegation,\n });\n\n return client.signTypedData({\n account,\n ...typedData,\n });\n}\n\n/**\n * Creates a sign delegation action that can be used to extend a wallet client.\n *\n * @returns A function that can be used with wallet client extend method.\n * @example\n * ```ts\n * const walletClient = createWalletClient({\n * chain: mainnet,\n * transport: http()\n * }).extend(signDelegationActions());\n * ```\n */\nexport function signDelegationActions() {\n return <\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n >(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n ) => ({\n signDelegation: async (\n parameters: Omit<SignDelegationParameters, 'chainId'> & {\n chainId?: number;\n },\n ) =>\n signDelegation(client, {\n chainId:\n parameters.chainId ??\n (() => {\n if (!client.chain?.id) {\n throw new BaseError(\n 'Chain ID is required. Either provide it in parameters or configure the client with a chain.',\n );\n }\n return client.chain.id;\n })(),\n ...parameters,\n }),\n });\n}\n","import type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n Transport,\n WalletClient,\n} from 'viem';\nimport { BaseError } from 'viem';\nimport { parseAccount } from 'viem/accounts';\n\nimport { prepareSignUserOperationTypedData } from '../userOp';\nimport type { UserOperationV07 } from '../userOp';\n\nexport type SignUserOperationParameters = {\n /** Account to sign with */\n account?: Account | Address;\n /** The user operation to sign */\n userOperation: Omit<UserOperationV07, 'signature'>;\n /** The entry point contract address */\n entryPoint: { address: Address };\n /** The chain ID that the entry point is deployed on */\n chainId: number;\n /** The address of the smart account */\n address: Address;\n /** The name of the domain of the implementation contract */\n name: 'HybridDeleGator' | 'MultiSigDeleGator';\n /** The version of the domain of the implementation contract */\n version?: string;\n};\n\nexport type SignUserOperationReturnType = Hex;\n\n/**\n * Signs a user operation using a wallet client.\n *\n * @param client - The wallet client to use for signing.\n * @param parameters - The parameters for signing the user operation.\n * @returns The signature of the user operation.\n * @example\n * ```ts\n * const signature = await signUserOperation(walletClient, {\n * userOperation: {\n * sender: '0x...',\n * nonce: 0n,\n * callData: '0x',\n * callGasLimit: 1000000n,\n * verificationGasLimit: 1000000n,\n * preVerificationGas: 21000n,\n * maxFeePerGas: 1000000000n,\n * maxPriorityFeePerGas: 1000000000n\n * },\n * entryPoint: { address: '0x...' },\n * chainId: 1,\n * address: '0x...',\n * name: 'HybridDeleGator'\n * });\n * ```\n */\nexport async function signUserOperation<\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n>(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n parameters: SignUserOperationParameters,\n): Promise<SignUserOperationReturnType> {\n const {\n account: accountParam = client.account,\n userOperation,\n entryPoint,\n chainId,\n name,\n address,\n version = '1',\n } = parameters;\n\n if (!accountParam) {\n throw new BaseError('Account not found. Please provide an account.');\n }\n\n const account = parseAccount(accountParam);\n\n const typedData = prepareSignUserOperationTypedData({\n userOperation,\n entryPoint,\n chainId,\n name,\n address,\n version,\n });\n\n return client.signTypedData({\n account,\n ...typedData,\n });\n}\n\n/**\n * Creates a sign user operation action that can be used to extend a wallet client.\n *\n * @returns A function that can be used with wallet client extend method.\n * @example\n * ```ts\n * const walletClient = createWalletClient({\n * chain: mainnet,\n * transport: http()\n * }).extend(signUserOperationActions());\n * ```\n */\nexport function signUserOperationActions() {\n return <\n TChain extends Chain | undefined,\n TAccount extends Account | undefined,\n >(\n client: Client<Transport, TChain, TAccount> & {\n signTypedData: WalletClient['signTypedData'];\n },\n ) => ({\n signUserOperation: async (\n parameters: Omit<SignUserOperationParameters, 'chainId'> & {\n chainId?: number;\n },\n ) =>\n signUserOperation(client, {\n chainId:\n parameters.chainId ??\n (() => {\n if (!client.chain?.id) {\n throw new BaseError(\n 'Chain ID is required. Either provide it in parameters or configure the client with a chain.',\n );\n }\n return client.chain.id;\n })(),\n ...parameters,\n }),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,SAAS,yBAAyB;AAYlC,SAAS,QAAQ,oBAAoB,sBAAsB;AAuC3D,eAAsB,oCAIpB,QACA,MACA;AACA,MAAI,CAAC,KAAK,IAAI;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAGA,QAAM,UAAU,OAAO,OAAO;AAC9B,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI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AAC,YAAoB;AAAA,EAC/D,6BAA6B,OAC3B,eACG;AACH,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EACA,kCAAkC,YAAY;AAC5C,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EACA,gCAAgC,YAAY;AAC1C,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;AAqBO,IAAM,uBAAuB,MAAM,CAAC,YAA0B;AAAA,EACnE,+BAA+B,OAC7B,SACG,oCAAoC,QAAQ,IAAI;AACvD;AAEO,IAAM,wBAAwB,MAAM,CAAC,YAAoB;AAAA,EAC9D,iCAAiC,OAC/B,SACG,sCAAsC,QAAyB,IAAI;AAC1E;","names":["read_exports","isAddressEqual","BaseError","parseAccount","BaseError","parseAccount"]}