@metamask/smart-accounts-kit 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/dist/actions/index.cjs +8 -4
  3. package/dist/actions/index.cjs.map +1 -1
  4. package/dist/actions/index.d.cts +4 -2
  5. package/dist/actions/index.d.ts +4 -2
  6. package/dist/actions/index.mjs +7 -3
  7. package/dist/{caveats-Cey0wm33.d.cts → caveats-CaSt_VHs.d.cts} +1 -1
  8. package/dist/{caveats-CQbtzOKm.d.ts → caveats-DQ6HoAHe.d.ts} +1 -1
  9. package/dist/{chunk-GZ7HHI2D.cjs → chunk-7FYDQNJ3.cjs} +12 -12
  10. package/dist/{chunk-GZ7HHI2D.cjs.map → chunk-7FYDQNJ3.cjs.map} +1 -1
  11. package/dist/{chunk-FKI4OME5.mjs → chunk-BGOSYTKV.mjs} +254 -60
  12. package/dist/chunk-BGOSYTKV.mjs.map +1 -0
  13. package/dist/{chunk-57I2FJY7.cjs → chunk-DN4O5VOP.cjs} +102 -102
  14. package/dist/{chunk-57I2FJY7.cjs.map → chunk-DN4O5VOP.cjs.map} +1 -1
  15. package/dist/{chunk-DLCTHNAE.cjs → chunk-FH6HZCHI.cjs} +11 -11
  16. package/dist/{chunk-DLCTHNAE.cjs.map → chunk-FH6HZCHI.cjs.map} +1 -1
  17. package/dist/{chunk-SZOX7K2V.cjs → chunk-IBZSNB7D.cjs} +81 -33
  18. package/dist/chunk-IBZSNB7D.cjs.map +1 -0
  19. package/dist/{chunk-Z4D7ZWVB.mjs → chunk-MV2KHN75.mjs} +84 -36
  20. package/dist/chunk-MV2KHN75.mjs.map +1 -0
  21. package/dist/{chunk-AC2BQSYP.mjs → chunk-N66VAWMO.mjs} +2 -2
  22. package/dist/{chunk-3PBVHNYP.cjs → chunk-SCS3CFRE.cjs} +10 -10
  23. package/dist/{chunk-3PBVHNYP.cjs.map → chunk-SCS3CFRE.cjs.map} +1 -1
  24. package/dist/{chunk-26PADMXR.mjs → chunk-TBHT26BV.mjs} +4 -4
  25. package/dist/{chunk-KBSFVKUB.mjs → chunk-W7O2UQL5.mjs} +2 -2
  26. package/dist/{chunk-AJWMPR7X.cjs → chunk-XEOE25DE.cjs} +298 -104
  27. package/dist/chunk-XEOE25DE.cjs.map +1 -0
  28. package/dist/{chunk-LQXOM3TA.mjs → chunk-YXHUT56Z.mjs} +3 -3
  29. package/dist/contracts/index.cjs +5 -5
  30. package/dist/contracts/index.d.cts +3 -2
  31. package/dist/contracts/index.d.ts +3 -2
  32. package/dist/contracts/index.mjs +4 -4
  33. package/dist/delegation-BKkEyxZY.d.cts +64 -0
  34. package/dist/delegation-DbPGWKfP.d.ts +64 -0
  35. package/dist/experimental/index.cjs +7 -7
  36. package/dist/experimental/index.mjs +1 -1
  37. package/dist/{index-D2THBlfm.d.ts → index-DXdlz7t4.d.ts} +2 -1
  38. package/dist/{index-BDC55AA9.d.cts → index-DfDAuvr5.d.cts} +58 -5
  39. package/dist/{index-DhG2lH80.d.ts → index-G78z6nwi.d.ts} +58 -5
  40. package/dist/{index-DE87r5KY.d.cts → index-yU3olCJV.d.cts} +2 -1
  41. package/dist/index.cjs +22 -20
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +7 -6
  44. package/dist/index.d.ts +7 -6
  45. package/dist/index.mjs +9 -7
  46. package/dist/index.mjs.map +1 -1
  47. package/dist/{delegation-Bx4FEAIU.d.ts → resolveCaveats-DiqGB-T5.d.cts} +4 -57
  48. package/dist/{delegation-KbWHzRxV.d.cts → resolveCaveats-s2snaFEo.d.ts} +4 -57
  49. package/dist/utils/index.cjs +4 -4
  50. package/dist/utils/index.d.cts +3 -2
  51. package/dist/utils/index.d.ts +3 -2
  52. package/dist/utils/index.mjs +3 -3
  53. package/package.json +4 -4
  54. package/dist/chunk-AJWMPR7X.cjs.map +0 -1
  55. package/dist/chunk-FKI4OME5.mjs.map +0 -1
  56. package/dist/chunk-SZOX7K2V.cjs.map +0 -1
  57. package/dist/chunk-Z4D7ZWVB.mjs.map +0 -1
  58. /package/dist/{chunk-AC2BQSYP.mjs.map → chunk-N66VAWMO.mjs.map} +0 -0
  59. /package/dist/{chunk-26PADMXR.mjs.map → chunk-TBHT26BV.mjs.map} +0 -0
  60. /package/dist/{chunk-KBSFVKUB.mjs.map → chunk-W7O2UQL5.mjs.map} +0 -0
  61. /package/dist/{chunk-LQXOM3TA.mjs.map → chunk-YXHUT56Z.mjs.map} +0 -0
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkGZ7HHI2Dcjs = require('./chunk-GZ7HHI2D.cjs');
7
+ var _chunk7FYDQNJ3cjs = require('./chunk-7FYDQNJ3.cjs');
8
8
 
9
9
 
10
10
 
@@ -21,11 +21,15 @@ var _chunkMOHCTPYQcjs = require('./chunk-MOHCTPYQ.cjs');
21
21
 
22
22
 
23
23
 
24
- var _chunkSZOX7K2Vcjs = require('./chunk-SZOX7K2V.cjs');
24
+
25
+
26
+
27
+
28
+ var _chunkIBZSNB7Dcjs = require('./chunk-IBZSNB7D.cjs');
25
29
 
26
30
  // src/actions/index.ts
27
31
  var actions_exports = {};
28
- _chunkSZOX7K2Vcjs.__export.call(void 0, actions_exports, {
32
+ _chunkIBZSNB7Dcjs.__export.call(void 0, actions_exports, {
29
33
  caveatEnforcerActions: () => caveatEnforcerActions,
30
34
  erc7710BundlerActions: () => erc7710BundlerActions,
31
35
  erc7710WalletActions: () => erc7710WalletActions,
@@ -38,6 +42,8 @@ _chunkSZOX7K2Vcjs.__export.call(void 0, actions_exports, {
38
42
  getNativeTokenStreamingEnforcerAvailableAmount: () => getNativeTokenStreamingEnforcerAvailableAmount,
39
43
  getSupportedExecutionPermissions: () => erc7715GetSupportedExecutionPermissionsAction,
40
44
  isValid7702Implementation: () => isValid7702Implementation,
45
+ redelegatePermissionContextAction: () => redelegatePermissionContextAction,
46
+ redelegatePermissionContextOpenAction: () => redelegatePermissionContextOpenAction,
41
47
  requestExecutionPermissions: () => erc7715RequestExecutionPermissionsAction,
42
48
  signDelegation: () => signDelegation,
43
49
  signDelegationActions: () => signDelegationActions,
@@ -49,7 +55,7 @@ _chunkSZOX7K2Vcjs.__export.call(void 0, actions_exports, {
49
55
  var _delegationabis = require('@metamask/delegation-abis');
50
56
  var _viem = require('viem');
51
57
  async function sendTransactionWithDelegationAction(client, args) {
52
- _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0, "sendTransactionWithDelegationAction", {
58
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0, "sendTransactionWithDelegationAction", {
53
59
  chainId: _nullishCoalesce(_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]), () => ( null))
54
60
  });
55
61
  if (!args.to) {
@@ -78,7 +84,7 @@ async function sendTransactionWithDelegationAction(client, args) {
78
84
  abi: _delegationabis.DelegationManager,
79
85
  functionName: "redeemDelegations",
80
86
  args: [
81
- [_chunkSZOX7K2Vcjs.encodeDelegations.call(void 0, args.permissionContext)],
87
+ [_chunkIBZSNB7Dcjs.encodeDelegations.call(void 0, args.permissionContext)],
82
88
  ["0x0000000000000000000000000000000000000000000000000000000000000000" /* SingleDefault */],
83
89
  _chunkMOHCTPYQcjs.encodeExecutionCalldatas.call(void 0, [executions])
84
90
  ]
@@ -97,7 +103,7 @@ async function sendTransactionWithDelegationAction(client, args) {
97
103
  return hash;
98
104
  }
99
105
  async function sendUserOperationWithDelegationAction(client, parameters) {
100
- _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0, "sendUserOperationWithDelegationAction", {
106
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0, "sendUserOperationWithDelegationAction", {
101
107
  chainId: _nullishCoalesce(_optionalChain([client, 'access', _5 => _5.chain, 'optionalAccess', _6 => _6.id]), () => ( null)),
102
108
  callCount: parameters.calls.length,
103
109
  hasDependencies: parameters.dependencies !== void 0
@@ -152,7 +158,7 @@ async function sendUserOperationWithDelegationAction(client, parameters) {
152
158
  }
153
159
  return {
154
160
  ...call,
155
- permissionContext: _chunkSZOX7K2Vcjs.encodeDelegations.call(void 0, permissionContext)
161
+ permissionContext: _chunkIBZSNB7Dcjs.encodeDelegations.call(void 0, permissionContext)
156
162
  };
157
163
  });
158
164
  return client.sendUserOperation(
@@ -163,12 +169,12 @@ async function sendUserOperationWithDelegationAction(client, parameters) {
163
169
  // src/actions/erc7715Mapping.ts
164
170
 
165
171
  function permissionRequestToRpc(parameters) {
166
- const { chainId, from, expiry, redeemer } = parameters;
172
+ const { chainId, from, expiry, redeemer, payee } = parameters;
167
173
  const converter = getPermissionRequestToRpcConverter(
168
174
  parameters.permission.type
169
175
  );
170
176
  const rules = [];
171
- if (_chunkSZOX7K2Vcjs.isDefined.call(void 0, expiry)) {
177
+ if (_chunkIBZSNB7Dcjs.isDefined.call(void 0, expiry)) {
172
178
  rules.push({
173
179
  type: "expiry",
174
180
  data: {
@@ -176,7 +182,7 @@ function permissionRequestToRpc(parameters) {
176
182
  }
177
183
  });
178
184
  }
179
- if (_chunkSZOX7K2Vcjs.isDefined.call(void 0, redeemer)) {
185
+ if (_chunkIBZSNB7Dcjs.isDefined.call(void 0, redeemer)) {
180
186
  if (redeemer.length === 0) {
181
187
  throw new Error(
182
188
  "Invalid redeemers: must specify at least one redeemer address"
@@ -194,6 +200,24 @@ function permissionRequestToRpc(parameters) {
194
200
  data: { addresses }
195
201
  });
196
202
  }
203
+ if (_chunkIBZSNB7Dcjs.isDefined.call(void 0, payee)) {
204
+ if (payee.length === 0) {
205
+ throw new Error(
206
+ "Invalid payees: must specify at least one payee address"
207
+ );
208
+ }
209
+ const payeeAddresses = [];
210
+ for (const addr of payee) {
211
+ if (!_viem.isAddress.call(void 0, addr)) {
212
+ throw new Error("Invalid payees: must be a valid address");
213
+ }
214
+ payeeAddresses.push(_viem.getAddress.call(void 0, addr));
215
+ }
216
+ rules.push({
217
+ type: "payee",
218
+ data: { addresses: payeeAddresses }
219
+ });
220
+ }
197
221
  const optionalFields = {
198
222
  ...from ? { from } : {}
199
223
  };
@@ -219,10 +243,18 @@ function getPermissionRequestToRpcConverter(permissionType) {
219
243
  return (permission) => nativeTokenPeriodicPermissionToRpc(
220
244
  permission
221
245
  );
246
+ case "native-token-allowance":
247
+ return (permission) => nativeTokenAllowancePermissionToRpc(
248
+ permission
249
+ );
222
250
  case "erc20-token-periodic":
223
251
  return (permission) => erc20TokenPeriodicPermissionToRpc(
224
252
  permission
225
253
  );
254
+ case "erc20-token-allowance":
255
+ return (permission) => erc20TokenAllowancePermissionToRpc(
256
+ permission
257
+ );
226
258
  case "erc20-token-revocation":
227
259
  return (permission) => erc20TokenRevocationPermissionToRpc(
228
260
  permission
@@ -243,13 +275,13 @@ function nativeTokenStreamPermissionToRpc(permission) {
243
275
  isAdjustmentAllowed
244
276
  } = permission;
245
277
  const optionalFields = {
246
- ..._chunkSZOX7K2Vcjs.isDefined.call(void 0, initialAmount) && {
247
- initialAmount: _chunkSZOX7K2Vcjs.toHexOrThrow.call(void 0, initialAmount, "initialAmount")
278
+ ..._chunkIBZSNB7Dcjs.isDefined.call(void 0, initialAmount) && {
279
+ initialAmount: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, initialAmount, "initialAmount")
248
280
  },
249
- ..._chunkSZOX7K2Vcjs.isDefined.call(void 0, maxAmount) && {
250
- maxAmount: _chunkSZOX7K2Vcjs.toHexOrThrow.call(void 0, maxAmount, "maxAmount")
281
+ ..._chunkIBZSNB7Dcjs.isDefined.call(void 0, maxAmount) && {
282
+ maxAmount: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, maxAmount, "maxAmount")
251
283
  },
252
- ..._chunkSZOX7K2Vcjs.isDefined.call(void 0, startTime) && {
284
+ ..._chunkIBZSNB7Dcjs.isDefined.call(void 0, startTime) && {
253
285
  startTime: Number(startTime)
254
286
  },
255
287
  ...justification ? { justification } : {}
@@ -257,7 +289,7 @@ function nativeTokenStreamPermissionToRpc(permission) {
257
289
  return {
258
290
  type: "native-token-stream",
259
291
  data: {
260
- amountPerSecond: _chunkSZOX7K2Vcjs.toHexOrThrow.call(void 0, amountPerSecond, "amountPerSecond"),
292
+ amountPerSecond: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, amountPerSecond, "amountPerSecond"),
261
293
  ...optionalFields
262
294
  },
263
295
  isAdjustmentAllowed
@@ -276,13 +308,13 @@ function erc20TokenStreamPermissionToRpc(permission) {
276
308
  isAdjustmentAllowed
277
309
  } = permission;
278
310
  const optionalFields = {
279
- ..._chunkSZOX7K2Vcjs.isDefined.call(void 0, initialAmount) && {
280
- initialAmount: _chunkSZOX7K2Vcjs.toHexOrThrow.call(void 0, initialAmount, "initialAmount")
311
+ ..._chunkIBZSNB7Dcjs.isDefined.call(void 0, initialAmount) && {
312
+ initialAmount: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, initialAmount, "initialAmount")
281
313
  },
282
- ..._chunkSZOX7K2Vcjs.isDefined.call(void 0, maxAmount) && {
283
- maxAmount: _chunkSZOX7K2Vcjs.toHexOrThrow.call(void 0, maxAmount, "maxAmount")
314
+ ..._chunkIBZSNB7Dcjs.isDefined.call(void 0, maxAmount) && {
315
+ maxAmount: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, maxAmount, "maxAmount")
284
316
  },
285
- ..._chunkSZOX7K2Vcjs.isDefined.call(void 0, startTime) && {
317
+ ..._chunkIBZSNB7Dcjs.isDefined.call(void 0, startTime) && {
286
318
  startTime: Number(startTime)
287
319
  },
288
320
  ...justification ? { justification } : {}
@@ -290,8 +322,8 @@ function erc20TokenStreamPermissionToRpc(permission) {
290
322
  return {
291
323
  type: "erc20-token-stream",
292
324
  data: {
293
- tokenAddress: _chunkSZOX7K2Vcjs.toHexOrThrow.call(void 0, tokenAddress, "tokenAddress"),
294
- amountPerSecond: _chunkSZOX7K2Vcjs.toHexOrThrow.call(void 0, amountPerSecond, "amountPerSecond"),
325
+ tokenAddress: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, tokenAddress, "tokenAddress"),
326
+ amountPerSecond: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, amountPerSecond, "amountPerSecond"),
295
327
  ...optionalFields
296
328
  },
297
329
  isAdjustmentAllowed
@@ -303,7 +335,7 @@ function nativeTokenPeriodicPermissionToRpc(permission) {
303
335
  isAdjustmentAllowed
304
336
  } = permission;
305
337
  const optionalFields = {
306
- ..._chunkSZOX7K2Vcjs.isDefined.call(void 0, startTime) && {
338
+ ..._chunkIBZSNB7Dcjs.isDefined.call(void 0, startTime) && {
307
339
  startTime: Number(startTime)
308
340
  },
309
341
  ...justification ? { justification } : {}
@@ -311,7 +343,7 @@ function nativeTokenPeriodicPermissionToRpc(permission) {
311
343
  return {
312
344
  type: "native-token-periodic",
313
345
  data: {
314
- periodAmount: _chunkSZOX7K2Vcjs.toHexOrThrow.call(void 0, periodAmount, "periodAmount"),
346
+ periodAmount: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, periodAmount, "periodAmount"),
315
347
  periodDuration: Number(periodDuration),
316
348
  ...optionalFields
317
349
  },
@@ -330,7 +362,7 @@ function erc20TokenPeriodicPermissionToRpc(permission) {
330
362
  isAdjustmentAllowed
331
363
  } = permission;
332
364
  const optionalFields = {
333
- ..._chunkSZOX7K2Vcjs.isDefined.call(void 0, startTime) && {
365
+ ..._chunkIBZSNB7Dcjs.isDefined.call(void 0, startTime) && {
334
366
  startTime: Number(startTime)
335
367
  },
336
368
  ...justification ? { justification } : {}
@@ -338,14 +370,55 @@ function erc20TokenPeriodicPermissionToRpc(permission) {
338
370
  return {
339
371
  type: "erc20-token-periodic",
340
372
  data: {
341
- tokenAddress: _chunkSZOX7K2Vcjs.toHexOrThrow.call(void 0, tokenAddress, "tokenAddress"),
342
- periodAmount: _chunkSZOX7K2Vcjs.toHexOrThrow.call(void 0, periodAmount, "periodAmount"),
373
+ tokenAddress: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, tokenAddress, "tokenAddress"),
374
+ periodAmount: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, periodAmount, "periodAmount"),
343
375
  periodDuration: Number(periodDuration),
344
376
  ...optionalFields
345
377
  },
346
378
  isAdjustmentAllowed
347
379
  };
348
380
  }
381
+ function nativeTokenAllowancePermissionToRpc(permission) {
382
+ const {
383
+ data: { allowanceAmount, startTime, justification },
384
+ isAdjustmentAllowed
385
+ } = permission;
386
+ const optionalFields = {
387
+ ..._chunkIBZSNB7Dcjs.isDefined.call(void 0, startTime) && {
388
+ startTime: Number(startTime)
389
+ },
390
+ ...justification ? { justification } : {}
391
+ };
392
+ return {
393
+ type: "native-token-allowance",
394
+ data: {
395
+ allowanceAmount: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, allowanceAmount, "allowanceAmount"),
396
+ ...optionalFields
397
+ },
398
+ isAdjustmentAllowed
399
+ };
400
+ }
401
+ function erc20TokenAllowancePermissionToRpc(permission) {
402
+ const {
403
+ data: { tokenAddress, allowanceAmount, startTime, justification },
404
+ isAdjustmentAllowed
405
+ } = permission;
406
+ const optionalFields = {
407
+ ..._chunkIBZSNB7Dcjs.isDefined.call(void 0, startTime) && {
408
+ startTime: Number(startTime)
409
+ },
410
+ ...justification ? { justification } : {}
411
+ };
412
+ return {
413
+ type: "erc20-token-allowance",
414
+ data: {
415
+ tokenAddress: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, tokenAddress, "tokenAddress"),
416
+ allowanceAmount: _chunkIBZSNB7Dcjs.toHexOrThrow.call(void 0, allowanceAmount, "allowanceAmount"),
417
+ ...optionalFields
418
+ },
419
+ isAdjustmentAllowed
420
+ };
421
+ }
349
422
  function erc20TokenRevocationPermissionToRpc(permission) {
350
423
  const {
351
424
  data: { justification },
@@ -373,7 +446,7 @@ function normalizeRulesFromRpc(rules) {
373
446
  return rules;
374
447
  }
375
448
  return rules.map((rule) => {
376
- if (rule.type !== "redeemer") {
449
+ if (rule.type !== "redeemer" && rule.type !== "payee") {
377
450
  return rule;
378
451
  }
379
452
  const rawAddresses = _optionalChain([rule, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.addresses]);
@@ -381,7 +454,7 @@ function normalizeRulesFromRpc(rules) {
381
454
  return rule;
382
455
  }
383
456
  return {
384
- type: "redeemer",
457
+ type: rule.type,
385
458
  data: {
386
459
  addresses: rawAddresses.map((addr) => _viem.getAddress.call(void 0, addr))
387
460
  }
@@ -408,6 +481,11 @@ function permissionTypeFromRpc(permission) {
408
481
  if ("maxAmount" in convertedData && convertedData.maxAmount) {
409
482
  convertedData.maxAmount = BigInt(convertedData.maxAmount);
410
483
  }
484
+ if ("allowanceAmount" in convertedData && convertedData.allowanceAmount) {
485
+ convertedData.allowanceAmount = BigInt(
486
+ convertedData.allowanceAmount
487
+ );
488
+ }
411
489
  return {
412
490
  ...permission,
413
491
  data: convertedData
@@ -426,7 +504,7 @@ function rpcSupportedPermissionsToDeveloper(result) {
426
504
 
427
505
  // src/actions/erc7715GetGrantedExecutionPermissionsAction.ts
428
506
  async function erc7715GetGrantedExecutionPermissionsAction(client) {
429
- _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
507
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
430
508
  "erc7715GetGrantedExecutionPermissionsAction",
431
509
  {
432
510
  chainId: _nullishCoalesce(_optionalChain([client, 'access', _11 => _11.chain, 'optionalAccess', _12 => _12.id]), () => ( null))
@@ -447,7 +525,7 @@ async function erc7715GetGrantedExecutionPermissionsAction(client) {
447
525
 
448
526
  // src/actions/erc7715GetSupportedExecutionPermissionsAction.ts
449
527
  async function erc7715GetSupportedExecutionPermissionsAction(client) {
450
- _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
528
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
451
529
  "erc7715GetSupportedExecutionPermissionsAction",
452
530
  {
453
531
  chainId: _nullishCoalesce(_optionalChain([client, 'access', _13 => _13.chain, 'optionalAccess', _14 => _14.id]), () => ( null))
@@ -468,7 +546,7 @@ async function erc7715GetSupportedExecutionPermissionsAction(client) {
468
546
 
469
547
  // src/actions/erc7715RequestExecutionPermissionsAction.ts
470
548
  async function erc7715RequestExecutionPermissionsAction(client, parameters) {
471
- _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
549
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
472
550
  "erc7715RequestExecutionPermissionsAction",
473
551
  {
474
552
  chainId: _nullishCoalesce(_optionalChain([client, 'access', _15 => _15.chain, 'optionalAccess', _16 => _16.id]), () => ( null)),
@@ -489,6 +567,164 @@ async function erc7715RequestExecutionPermissionsAction(client, parameters) {
489
567
  return permissionResponsesFromRpc(result);
490
568
  }
491
569
 
570
+ // src/actions/redelegatePermissionContext.ts
571
+
572
+ var _accounts = require('viem/accounts');
573
+
574
+ // src/actions/signDelegation.ts
575
+
576
+
577
+ async function signDelegation(client, parameters) {
578
+ const {
579
+ account: accountParam = client.account,
580
+ delegation,
581
+ delegationManager,
582
+ chainId,
583
+ name = "DelegationManager",
584
+ version = "1",
585
+ allowInsecureUnrestrictedDelegation = false
586
+ } = parameters;
587
+ if (!accountParam) {
588
+ throw new (0, _viem.BaseError)("Account not found. Please provide an account.");
589
+ }
590
+ const account = _accounts.parseAccount.call(void 0, accountParam);
591
+ const typedData = _chunkIBZSNB7Dcjs.prepareSignDelegationTypedData.call(void 0, {
592
+ delegation,
593
+ delegationManager,
594
+ chainId,
595
+ name,
596
+ version,
597
+ allowInsecureUnrestrictedDelegation
598
+ });
599
+ return client.signTypedData({
600
+ account,
601
+ ...typedData
602
+ });
603
+ }
604
+ function signDelegationActions() {
605
+ return (client) => ({
606
+ signDelegation: async (parameters) => signDelegation(client, {
607
+ chainId: _nullishCoalesce(parameters.chainId, () => ( (() => {
608
+ if (!_optionalChain([client, 'access', _17 => _17.chain, 'optionalAccess', _18 => _18.id])) {
609
+ throw new (0, _viem.BaseError)(
610
+ "Chain ID is required. Either provide it in parameters or configure the client with a chain."
611
+ );
612
+ }
613
+ return client.chain.id;
614
+ })())),
615
+ ...parameters
616
+ })
617
+ });
618
+ }
619
+
620
+ // src/actions/redelegatePermissionContext.ts
621
+ async function signAndPrependRedelegation(client, options) {
622
+ const { account, environment, delegations, unsignedDelegation, chainId } = options;
623
+ const signature = await signDelegation(client, {
624
+ account,
625
+ delegation: unsignedDelegation,
626
+ delegationManager: environment.DelegationManager,
627
+ chainId,
628
+ // Redelegations always inherit from a parent delegation (enforced by
629
+ // `resolveRedelegationArgs`), so the parent's caveats provide the
630
+ // restriction even when the redelegation itself adds no extra caveats.
631
+ // This mirrors `resolveCaveats`, which also allows empty caveats in this
632
+ // case.
633
+ allowInsecureUnrestrictedDelegation: true
634
+ });
635
+ const signedDelegation = {
636
+ ...unsignedDelegation,
637
+ signature
638
+ };
639
+ const newPermissionContext = _chunkIBZSNB7Dcjs.encodeDelegations.call(void 0, [
640
+ signedDelegation,
641
+ ...delegations
642
+ ]);
643
+ return {
644
+ delegation: signedDelegation,
645
+ permissionContext: newPermissionContext
646
+ };
647
+ }
648
+ function resolveRedelegationArgs(client, parameters) {
649
+ const { account: accountParam = client.account, permissionContext } = parameters;
650
+ if (!accountParam) {
651
+ throw new (0, _viem.BaseError)("Account not found. Please provide an account.");
652
+ }
653
+ const account = _accounts.parseAccount.call(void 0, accountParam);
654
+ const delegations = _chunkIBZSNB7Dcjs.decodeDelegations.call(void 0, permissionContext);
655
+ const parentDelegation = delegations[0];
656
+ if (!parentDelegation) {
657
+ throw new (0, _viem.BaseError)(
658
+ "Permission context must contain at least one delegation"
659
+ );
660
+ }
661
+ const isParentOpenDelegation = parentDelegation.delegate.toLowerCase() === _chunkIBZSNB7Dcjs.ANY_BENEFICIARY.toLowerCase();
662
+ const from = isParentOpenDelegation ? account.address : parentDelegation.delegate;
663
+ return { account, delegations, parentDelegation, from };
664
+ }
665
+ async function redelegatePermissionContextAction(client, parameters) {
666
+ const { environment, scope, caveats, salt, to } = parameters;
667
+ const chainId = resolveChainId(client, parameters.chainId);
668
+ const { account, delegations, parentDelegation, from } = resolveRedelegationArgs(client, parameters);
669
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0, "redelegatePermissionContext", {
670
+ chainId,
671
+ hasScope: scope !== void 0,
672
+ hasCaveats: caveats !== void 0
673
+ });
674
+ const unsignedDelegation = _chunkIBZSNB7Dcjs.createDelegation.call(void 0, {
675
+ environment,
676
+ from,
677
+ to,
678
+ scope,
679
+ caveats,
680
+ parentDelegation,
681
+ salt
682
+ });
683
+ return signAndPrependRedelegation(client, {
684
+ account,
685
+ environment,
686
+ delegations,
687
+ unsignedDelegation,
688
+ chainId
689
+ });
690
+ }
691
+ async function redelegatePermissionContextOpenAction(client, parameters) {
692
+ const { environment, scope, caveats, salt } = parameters;
693
+ const chainId = resolveChainId(client, parameters.chainId);
694
+ const { account, delegations, parentDelegation, from } = resolveRedelegationArgs(client, parameters);
695
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0, "redelegatePermissionContextOpen", {
696
+ chainId,
697
+ hasScope: scope !== void 0,
698
+ hasCaveats: caveats !== void 0
699
+ });
700
+ const unsignedDelegation = _chunkIBZSNB7Dcjs.createOpenDelegation.call(void 0, {
701
+ environment,
702
+ from,
703
+ scope,
704
+ caveats,
705
+ parentDelegation,
706
+ salt
707
+ });
708
+ return signAndPrependRedelegation(client, {
709
+ account,
710
+ environment,
711
+ delegations,
712
+ unsignedDelegation,
713
+ chainId
714
+ });
715
+ }
716
+ function resolveChainId(client, chainId) {
717
+ if (chainId !== void 0) {
718
+ return chainId;
719
+ }
720
+ if (!_optionalChain([client, 'access', _19 => _19.chain, 'optionalAccess', _20 => _20.id])) {
721
+ throw new (0, _viem.BaseError)(
722
+ "Chain ID is required. Either provide it in parameters or configure the client with a chain."
723
+ );
724
+ }
725
+ return client.chain.id;
726
+ }
727
+
492
728
  // src/actions/getCaveatAvailableAmount.ts
493
729
  function findMatchingCaveat({
494
730
  delegation,
@@ -529,10 +765,10 @@ function getEnforcerAddress({
529
765
  return enforcerAddress;
530
766
  }
531
767
  async function getErc20PeriodTransferEnforcerAvailableAmount(client, environment, params) {
532
- _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
768
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
533
769
  "getErc20PeriodTransferEnforcerAvailableAmount",
534
770
  {
535
- chainId: _nullishCoalesce(_optionalChain([client, 'access', _17 => _17.chain, 'optionalAccess', _18 => _18.id]), () => ( null))
771
+ chainId: _nullishCoalesce(_optionalChain([client, 'access', _21 => _21.chain, 'optionalAccess', _22 => _22.id]), () => ( null))
536
772
  }
537
773
  );
538
774
  const enforcerName = "ERC20PeriodTransferEnforcer";
@@ -541,13 +777,13 @@ async function getErc20PeriodTransferEnforcerAvailableAmount(client, environment
541
777
  enforcerName,
542
778
  environment
543
779
  });
544
- const delegationHash = _chunkSZOX7K2Vcjs.hashDelegation.call(void 0, params.delegation);
780
+ const delegationHash = _chunkIBZSNB7Dcjs.hashDelegation.call(void 0, params.delegation);
545
781
  const { terms } = findMatchingCaveat({
546
782
  delegation: params.delegation,
547
783
  enforcerAddress,
548
784
  enforcerName
549
785
  });
550
- return _chunkGZ7HHI2Dcjs.read_exports.getAvailableAmount({
786
+ return _chunk7FYDQNJ3cjs.read_exports.getAvailableAmount({
551
787
  client,
552
788
  contractAddress: enforcerAddress,
553
789
  delegationHash,
@@ -556,10 +792,10 @@ async function getErc20PeriodTransferEnforcerAvailableAmount(client, environment
556
792
  });
557
793
  }
558
794
  async function getErc20StreamingEnforcerAvailableAmount(client, environment, params) {
559
- _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
795
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
560
796
  "getErc20StreamingEnforcerAvailableAmount",
561
797
  {
562
- chainId: _nullishCoalesce(_optionalChain([client, 'access', _19 => _19.chain, 'optionalAccess', _20 => _20.id]), () => ( null))
798
+ chainId: _nullishCoalesce(_optionalChain([client, 'access', _23 => _23.chain, 'optionalAccess', _24 => _24.id]), () => ( null))
563
799
  }
564
800
  );
565
801
  const enforcerName = "ERC20StreamingEnforcer";
@@ -568,13 +804,13 @@ async function getErc20StreamingEnforcerAvailableAmount(client, environment, par
568
804
  enforcerName,
569
805
  environment
570
806
  });
571
- const delegationHash = _chunkSZOX7K2Vcjs.hashDelegation.call(void 0, params.delegation);
807
+ const delegationHash = _chunkIBZSNB7Dcjs.hashDelegation.call(void 0, params.delegation);
572
808
  const { terms } = findMatchingCaveat({
573
809
  delegation: params.delegation,
574
810
  enforcerAddress,
575
811
  enforcerName
576
812
  });
577
- return _chunkGZ7HHI2Dcjs.read_exports2.getAvailableAmount({
813
+ return _chunk7FYDQNJ3cjs.read_exports2.getAvailableAmount({
578
814
  client,
579
815
  contractAddress: enforcerAddress,
580
816
  delegationManager,
@@ -583,10 +819,10 @@ async function getErc20StreamingEnforcerAvailableAmount(client, environment, par
583
819
  });
584
820
  }
585
821
  async function getMultiTokenPeriodEnforcerAvailableAmount(client, environment, params) {
586
- _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
822
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
587
823
  "getMultiTokenPeriodEnforcerAvailableAmount",
588
824
  {
589
- chainId: _nullishCoalesce(_optionalChain([client, 'access', _21 => _21.chain, 'optionalAccess', _22 => _22.id]), () => ( null))
825
+ chainId: _nullishCoalesce(_optionalChain([client, 'access', _25 => _25.chain, 'optionalAccess', _26 => _26.id]), () => ( null))
590
826
  }
591
827
  );
592
828
  const enforcerName = "MultiTokenPeriodEnforcer";
@@ -595,13 +831,13 @@ async function getMultiTokenPeriodEnforcerAvailableAmount(client, environment, p
595
831
  enforcerName,
596
832
  environment
597
833
  });
598
- const delegationHash = _chunkSZOX7K2Vcjs.hashDelegation.call(void 0, params.delegation);
834
+ const delegationHash = _chunkIBZSNB7Dcjs.hashDelegation.call(void 0, params.delegation);
599
835
  const { terms, args } = findMatchingCaveat({
600
836
  delegation: params.delegation,
601
837
  enforcerAddress,
602
838
  enforcerName
603
839
  });
604
- return _chunkGZ7HHI2Dcjs.read_exports3.getAvailableAmount({
840
+ return _chunk7FYDQNJ3cjs.read_exports3.getAvailableAmount({
605
841
  client,
606
842
  contractAddress: enforcerAddress,
607
843
  delegationHash,
@@ -611,10 +847,10 @@ async function getMultiTokenPeriodEnforcerAvailableAmount(client, environment, p
611
847
  });
612
848
  }
613
849
  async function getNativeTokenPeriodTransferEnforcerAvailableAmount(client, environment, params) {
614
- _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
850
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
615
851
  "getNativeTokenPeriodTransferEnforcerAvailableAmount",
616
852
  {
617
- chainId: _nullishCoalesce(_optionalChain([client, 'access', _23 => _23.chain, 'optionalAccess', _24 => _24.id]), () => ( null))
853
+ chainId: _nullishCoalesce(_optionalChain([client, 'access', _27 => _27.chain, 'optionalAccess', _28 => _28.id]), () => ( null))
618
854
  }
619
855
  );
620
856
  const enforcerName = "NativeTokenPeriodTransferEnforcer";
@@ -623,13 +859,13 @@ async function getNativeTokenPeriodTransferEnforcerAvailableAmount(client, envir
623
859
  enforcerName,
624
860
  environment
625
861
  });
626
- const delegationHash = _chunkSZOX7K2Vcjs.hashDelegation.call(void 0, params.delegation);
862
+ const delegationHash = _chunkIBZSNB7Dcjs.hashDelegation.call(void 0, params.delegation);
627
863
  const { terms } = findMatchingCaveat({
628
864
  delegation: params.delegation,
629
865
  enforcerAddress,
630
866
  enforcerName
631
867
  });
632
- return _chunkGZ7HHI2Dcjs.read_exports4.getAvailableAmount({
868
+ return _chunk7FYDQNJ3cjs.read_exports4.getAvailableAmount({
633
869
  client,
634
870
  contractAddress: enforcerAddress,
635
871
  delegationHash,
@@ -638,10 +874,10 @@ async function getNativeTokenPeriodTransferEnforcerAvailableAmount(client, envir
638
874
  });
639
875
  }
640
876
  async function getNativeTokenStreamingEnforcerAvailableAmount(client, environment, params) {
641
- _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
877
+ _chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0,
642
878
  "getNativeTokenStreamingEnforcerAvailableAmount",
643
879
  {
644
- chainId: _nullishCoalesce(_optionalChain([client, 'access', _25 => _25.chain, 'optionalAccess', _26 => _26.id]), () => ( null))
880
+ chainId: _nullishCoalesce(_optionalChain([client, 'access', _29 => _29.chain, 'optionalAccess', _30 => _30.id]), () => ( null))
645
881
  }
646
882
  );
647
883
  const enforcerName = "NativeTokenStreamingEnforcer";
@@ -650,13 +886,13 @@ async function getNativeTokenStreamingEnforcerAvailableAmount(client, environmen
650
886
  enforcerName,
651
887
  environment
652
888
  });
653
- const delegationHash = _chunkSZOX7K2Vcjs.hashDelegation.call(void 0, params.delegation);
889
+ const delegationHash = _chunkIBZSNB7Dcjs.hashDelegation.call(void 0, params.delegation);
654
890
  const { terms } = findMatchingCaveat({
655
891
  delegation: params.delegation,
656
892
  enforcerAddress,
657
893
  enforcerName
658
894
  });
659
- return _chunkGZ7HHI2Dcjs.read_exports5.getAvailableAmount({
895
+ return _chunk7FYDQNJ3cjs.read_exports5.getAvailableAmount({
660
896
  client,
661
897
  contractAddress: enforcerAddress,
662
898
  delegationManager,
@@ -737,7 +973,7 @@ var caveatEnforcerActions = ({ environment }) => (client) => ({
737
973
  var _actions = require('viem/actions');
738
974
  var DELEGATION_PREFIX = "0xef0100";
739
975
  function extractDelegatedAddress(code) {
740
- if (_optionalChain([code, 'optionalAccess', _27 => _27.length]) !== 48) {
976
+ if (_optionalChain([code, 'optionalAccess', _31 => _31.length]) !== 48) {
741
977
  return null;
742
978
  }
743
979
  if (!code.toLowerCase().startsWith(DELEGATION_PREFIX.toLowerCase())) {
@@ -769,52 +1005,6 @@ async function isValid7702Implementation({
769
1005
  }
770
1006
  }
771
1007
 
772
- // src/actions/signDelegation.ts
773
-
774
- var _accounts = require('viem/accounts');
775
- async function signDelegation(client, parameters) {
776
- const {
777
- account: accountParam = client.account,
778
- delegation,
779
- delegationManager,
780
- chainId,
781
- name = "DelegationManager",
782
- version = "1",
783
- allowInsecureUnrestrictedDelegation = false
784
- } = parameters;
785
- if (!accountParam) {
786
- throw new (0, _viem.BaseError)("Account not found. Please provide an account.");
787
- }
788
- const account = _accounts.parseAccount.call(void 0, accountParam);
789
- const typedData = _chunkSZOX7K2Vcjs.prepareSignDelegationTypedData.call(void 0, {
790
- delegation,
791
- delegationManager,
792
- chainId,
793
- name,
794
- version,
795
- allowInsecureUnrestrictedDelegation
796
- });
797
- return client.signTypedData({
798
- account,
799
- ...typedData
800
- });
801
- }
802
- function signDelegationActions() {
803
- return (client) => ({
804
- signDelegation: async (parameters) => signDelegation(client, {
805
- chainId: _nullishCoalesce(parameters.chainId, () => ( (() => {
806
- if (!_optionalChain([client, 'access', _28 => _28.chain, 'optionalAccess', _29 => _29.id])) {
807
- throw new (0, _viem.BaseError)(
808
- "Chain ID is required. Either provide it in parameters or configure the client with a chain."
809
- );
810
- }
811
- return client.chain.id;
812
- })())),
813
- ...parameters
814
- })
815
- });
816
- }
817
-
818
1008
  // src/actions/signUserOperation.ts
819
1009
 
820
1010
 
@@ -849,7 +1039,7 @@ function signUserOperationActions() {
849
1039
  return (client) => ({
850
1040
  signUserOperation: async (parameters) => signUserOperation(client, {
851
1041
  chainId: _nullishCoalesce(parameters.chainId, () => ( (() => {
852
- if (!_optionalChain([client, 'access', _30 => _30.chain, 'optionalAccess', _31 => _31.id])) {
1042
+ if (!_optionalChain([client, 'access', _32 => _32.chain, 'optionalAccess', _33 => _33.id])) {
853
1043
  throw new (0, _viem.BaseError)(
854
1044
  "Chain ID is required. Either provide it in parameters or configure the client with a chain."
855
1045
  );
@@ -881,7 +1071,9 @@ var erc7715ProviderActions = () => (client) => ({
881
1071
  }
882
1072
  });
883
1073
  var erc7710WalletActions = () => (client) => ({
884
- sendTransactionWithDelegation: async (args) => sendTransactionWithDelegationAction(client, args)
1074
+ sendTransactionWithDelegation: async (args) => sendTransactionWithDelegationAction(client, args),
1075
+ redelegatePermissionContext: async (parameters) => redelegatePermissionContextAction(client, parameters),
1076
+ redelegatePermissionContextOpen: async (parameters) => redelegatePermissionContextOpenAction(client, parameters)
885
1077
  });
886
1078
  var erc7710BundlerActions = () => (client) => ({
887
1079
  sendUserOperationWithDelegation: async (args) => sendUserOperationWithDelegationAction(client, args)
@@ -906,5 +1098,7 @@ var erc7710BundlerActions = () => (client) => ({
906
1098
 
907
1099
 
908
1100
 
909
- exports.isValid7702Implementation = isValid7702Implementation; exports.erc7715GetGrantedExecutionPermissionsAction = erc7715GetGrantedExecutionPermissionsAction; exports.erc7715GetSupportedExecutionPermissionsAction = erc7715GetSupportedExecutionPermissionsAction; exports.erc7715RequestExecutionPermissionsAction = erc7715RequestExecutionPermissionsAction; exports.getErc20PeriodTransferEnforcerAvailableAmount = getErc20PeriodTransferEnforcerAvailableAmount; exports.getErc20StreamingEnforcerAvailableAmount = getErc20StreamingEnforcerAvailableAmount; exports.getMultiTokenPeriodEnforcerAvailableAmount = getMultiTokenPeriodEnforcerAvailableAmount; exports.getNativeTokenPeriodTransferEnforcerAvailableAmount = getNativeTokenPeriodTransferEnforcerAvailableAmount; exports.getNativeTokenStreamingEnforcerAvailableAmount = getNativeTokenStreamingEnforcerAvailableAmount; exports.caveatEnforcerActions = caveatEnforcerActions; exports.signDelegation = signDelegation; exports.signDelegationActions = signDelegationActions; exports.signUserOperation = signUserOperation; exports.signUserOperationActions = signUserOperationActions; exports.erc7715ProviderActions = erc7715ProviderActions; exports.erc7710WalletActions = erc7710WalletActions; exports.erc7710BundlerActions = erc7710BundlerActions; exports.actions_exports = actions_exports;
910
- //# sourceMappingURL=chunk-AJWMPR7X.cjs.map
1101
+
1102
+
1103
+ exports.isValid7702Implementation = isValid7702Implementation; exports.erc7715GetGrantedExecutionPermissionsAction = erc7715GetGrantedExecutionPermissionsAction; exports.erc7715GetSupportedExecutionPermissionsAction = erc7715GetSupportedExecutionPermissionsAction; exports.erc7715RequestExecutionPermissionsAction = erc7715RequestExecutionPermissionsAction; exports.signDelegation = signDelegation; exports.signDelegationActions = signDelegationActions; exports.redelegatePermissionContextAction = redelegatePermissionContextAction; exports.redelegatePermissionContextOpenAction = redelegatePermissionContextOpenAction; exports.getErc20PeriodTransferEnforcerAvailableAmount = getErc20PeriodTransferEnforcerAvailableAmount; exports.getErc20StreamingEnforcerAvailableAmount = getErc20StreamingEnforcerAvailableAmount; exports.getMultiTokenPeriodEnforcerAvailableAmount = getMultiTokenPeriodEnforcerAvailableAmount; exports.getNativeTokenPeriodTransferEnforcerAvailableAmount = getNativeTokenPeriodTransferEnforcerAvailableAmount; exports.getNativeTokenStreamingEnforcerAvailableAmount = getNativeTokenStreamingEnforcerAvailableAmount; exports.caveatEnforcerActions = caveatEnforcerActions; exports.signUserOperation = signUserOperation; exports.signUserOperationActions = signUserOperationActions; exports.erc7715ProviderActions = erc7715ProviderActions; exports.erc7710WalletActions = erc7710WalletActions; exports.erc7710BundlerActions = erc7710BundlerActions; exports.actions_exports = actions_exports;
1104
+ //# sourceMappingURL=chunk-XEOE25DE.cjs.map