@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
@@ -1,16 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkMIP7KJYHcjs = require('./chunk-MIP7KJYH.cjs');
3
+ var _chunkYDLLC6PPcjs = require('./chunk-YDLLC6PP.cjs');
4
4
 
5
5
  // src/DelegationFramework/ERC20PeriodTransferEnforcer/index.ts
6
6
  var ERC20PeriodTransferEnforcer_exports = {};
7
- _chunkMIP7KJYHcjs.__export.call(void 0, ERC20PeriodTransferEnforcer_exports, {
7
+ _chunkYDLLC6PPcjs.__export.call(void 0, ERC20PeriodTransferEnforcer_exports, {
8
8
  read: () => read_exports
9
9
  });
10
10
 
11
11
  // src/DelegationFramework/ERC20PeriodTransferEnforcer/read.ts
12
12
  var read_exports = {};
13
- _chunkMIP7KJYHcjs.__export.call(void 0, read_exports, {
13
+ _chunkYDLLC6PPcjs.__export.call(void 0, read_exports, {
14
14
  getAvailableAmount: () => read
15
15
  });
16
16
 
@@ -28,7 +28,7 @@ var read = async ({
28
28
  client,
29
29
  {
30
30
  address: contractAddress,
31
- abi: _delegationabis.ERC20PeriodTransferEnforcer.abi,
31
+ abi: _delegationabis.ERC20PeriodTransferEnforcer,
32
32
  functionName: "getAvailableAmount",
33
33
  args: [delegationHash, delegationManager, terms]
34
34
  }
@@ -42,13 +42,13 @@ var read = async ({
42
42
 
43
43
  // src/DelegationFramework/ERC20StreamingEnforcer/index.ts
44
44
  var ERC20StreamingEnforcer_exports = {};
45
- _chunkMIP7KJYHcjs.__export.call(void 0, ERC20StreamingEnforcer_exports, {
45
+ _chunkYDLLC6PPcjs.__export.call(void 0, ERC20StreamingEnforcer_exports, {
46
46
  read: () => read_exports2
47
47
  });
48
48
 
49
49
  // src/DelegationFramework/ERC20StreamingEnforcer/read.ts
50
50
  var read_exports2 = {};
51
- _chunkMIP7KJYHcjs.__export.call(void 0, read_exports2, {
51
+ _chunkYDLLC6PPcjs.__export.call(void 0, read_exports2, {
52
52
  getAvailableAmount: () => read2
53
53
  });
54
54
 
@@ -66,7 +66,7 @@ var read2 = async ({
66
66
  const currentTimestamp = currentBlock.timestamp;
67
67
  const allowanceState = await _actions.readContract.call(void 0, client, {
68
68
  address: contractAddress,
69
- abi: _delegationabis.ERC20StreamingEnforcer.abi,
69
+ abi: _delegationabis.ERC20StreamingEnforcer,
70
70
  functionName: "streamingAllowances",
71
71
  args: [delegationManager, delegationHash]
72
72
  });
@@ -86,7 +86,7 @@ var read2 = async ({
86
86
  }
87
87
  const decodedTerms = await _actions.readContract.call(void 0, client, {
88
88
  address: contractAddress,
89
- abi: _delegationabis.ERC20StreamingEnforcer.abi,
89
+ abi: _delegationabis.ERC20StreamingEnforcer,
90
90
  functionName: "getTermsInfo",
91
91
  args: [terms]
92
92
  });
@@ -126,13 +126,13 @@ function getAvailableAmount(allowance) {
126
126
 
127
127
  // src/DelegationFramework/MultiTokenPeriodEnforcer/index.ts
128
128
  var MultiTokenPeriodEnforcer_exports = {};
129
- _chunkMIP7KJYHcjs.__export.call(void 0, MultiTokenPeriodEnforcer_exports, {
129
+ _chunkYDLLC6PPcjs.__export.call(void 0, MultiTokenPeriodEnforcer_exports, {
130
130
  read: () => read_exports3
131
131
  });
132
132
 
133
133
  // src/DelegationFramework/MultiTokenPeriodEnforcer/read.ts
134
134
  var read_exports3 = {};
135
- _chunkMIP7KJYHcjs.__export.call(void 0, read_exports3, {
135
+ _chunkYDLLC6PPcjs.__export.call(void 0, read_exports3, {
136
136
  getAvailableAmount: () => read3
137
137
  });
138
138
 
@@ -151,7 +151,7 @@ var read3 = async ({
151
151
  client,
152
152
  {
153
153
  address: contractAddress,
154
- abi: _delegationabis.MultiTokenPeriodEnforcer.abi,
154
+ abi: _delegationabis.MultiTokenPeriodEnforcer,
155
155
  functionName: "getAvailableAmount",
156
156
  args: [delegationHash, delegationManager, terms, args]
157
157
  }
@@ -165,13 +165,13 @@ var read3 = async ({
165
165
 
166
166
  // src/DelegationFramework/NativeTokenPeriodTransferEnforcer/index.ts
167
167
  var NativeTokenPeriodTransferEnforcer_exports = {};
168
- _chunkMIP7KJYHcjs.__export.call(void 0, NativeTokenPeriodTransferEnforcer_exports, {
168
+ _chunkYDLLC6PPcjs.__export.call(void 0, NativeTokenPeriodTransferEnforcer_exports, {
169
169
  read: () => read_exports4
170
170
  });
171
171
 
172
172
  // src/DelegationFramework/NativeTokenPeriodTransferEnforcer/read.ts
173
173
  var read_exports4 = {};
174
- _chunkMIP7KJYHcjs.__export.call(void 0, read_exports4, {
174
+ _chunkYDLLC6PPcjs.__export.call(void 0, read_exports4, {
175
175
  getAvailableAmount: () => read4
176
176
  });
177
177
 
@@ -189,7 +189,7 @@ var read4 = async ({
189
189
  client,
190
190
  {
191
191
  address: contractAddress,
192
- abi: _delegationabis.NativeTokenPeriodTransferEnforcer.abi,
192
+ abi: _delegationabis.NativeTokenPeriodTransferEnforcer,
193
193
  functionName: "getAvailableAmount",
194
194
  args: [delegationHash, delegationManager, terms]
195
195
  }
@@ -203,13 +203,13 @@ var read4 = async ({
203
203
 
204
204
  // src/DelegationFramework/NativeTokenStreamingEnforcer/index.ts
205
205
  var NativeTokenStreamingEnforcer_exports = {};
206
- _chunkMIP7KJYHcjs.__export.call(void 0, NativeTokenStreamingEnforcer_exports, {
206
+ _chunkYDLLC6PPcjs.__export.call(void 0, NativeTokenStreamingEnforcer_exports, {
207
207
  read: () => read_exports5
208
208
  });
209
209
 
210
210
  // src/DelegationFramework/NativeTokenStreamingEnforcer/read.ts
211
211
  var read_exports5 = {};
212
- _chunkMIP7KJYHcjs.__export.call(void 0, read_exports5, {
212
+ _chunkYDLLC6PPcjs.__export.call(void 0, read_exports5, {
213
213
  getAvailableAmount: () => read5
214
214
  });
215
215
 
@@ -227,7 +227,7 @@ var read5 = async ({
227
227
  const currentTimestamp = currentBlock.timestamp;
228
228
  const allowanceState = await _actions.readContract.call(void 0, client, {
229
229
  address: contractAddress,
230
- abi: _delegationabis.NativeTokenStreamingEnforcer.abi,
230
+ abi: _delegationabis.NativeTokenStreamingEnforcer,
231
231
  functionName: "streamingAllowances",
232
232
  args: [delegationManager, delegationHash]
233
233
  });
@@ -247,7 +247,7 @@ var read5 = async ({
247
247
  }
248
248
  const decodedTerms = await _actions.readContract.call(void 0, client, {
249
249
  address: contractAddress,
250
- abi: _delegationabis.NativeTokenStreamingEnforcer.abi,
250
+ abi: _delegationabis.NativeTokenStreamingEnforcer,
251
251
  functionName: "getTermsInfo",
252
252
  args: [terms]
253
253
  });
@@ -296,4 +296,4 @@ function getAvailableAmount2(allowance) {
296
296
 
297
297
 
298
298
  exports.read_exports = read_exports; exports.ERC20PeriodTransferEnforcer_exports = ERC20PeriodTransferEnforcer_exports; exports.read_exports2 = read_exports2; exports.ERC20StreamingEnforcer_exports = ERC20StreamingEnforcer_exports; exports.read_exports3 = read_exports3; exports.MultiTokenPeriodEnforcer_exports = MultiTokenPeriodEnforcer_exports; exports.read_exports4 = read_exports4; exports.NativeTokenPeriodTransferEnforcer_exports = NativeTokenPeriodTransferEnforcer_exports; exports.read_exports5 = read_exports5; exports.NativeTokenStreamingEnforcer_exports = NativeTokenStreamingEnforcer_exports;
299
- //# sourceMappingURL=chunk-RAXFJGCS.cjs.map
299
+ //# sourceMappingURL=chunk-UUOH2WAW.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/chunk-UUOH2WAW.cjs","../src/DelegationFramework/ERC20PeriodTransferEnforcer/index.ts","../src/DelegationFramework/ERC20PeriodTransferEnforcer/read.ts","../src/DelegationFramework/ERC20PeriodTransferEnforcer/methods/getAvailableAmount.ts","../src/DelegationFramework/ERC20StreamingEnforcer/index.ts","../src/DelegationFramework/ERC20StreamingEnforcer/read.ts","../src/DelegationFramework/ERC20StreamingEnforcer/methods/getAvailableAmount.ts","../src/DelegationFramework/MultiTokenPeriodEnforcer/index.ts","../src/DelegationFramework/MultiTokenPeriodEnforcer/read.ts","../src/DelegationFramework/MultiTokenPeriodEnforcer/methods/getAvailableAmount.ts","../src/DelegationFramework/NativeTokenPeriodTransferEnforcer/index.ts","../src/DelegationFramework/NativeTokenPeriodTransferEnforcer/read.ts","../src/DelegationFramework/NativeTokenPeriodTransferEnforcer/methods/getAvailableAmount.ts","../src/DelegationFramework/NativeTokenStreamingEnforcer/index.ts","../src/DelegationFramework/NativeTokenStreamingEnforcer/read.ts","../src/DelegationFramework/NativeTokenStreamingEnforcer/methods/getAvailableAmount.ts"],"names":["read_exports","read","readContract","availableAmount","getBl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smart-accounts-kit/packages/smart-accounts-kit/dist/chunk-UUOH2WAW.cjs","sourcesContent":[null,"import * as read from './read';\n\nexport { read };\n","import { read as getAvailableAmount } from './methods/getAvailableAmount';\n\nexport { getAvailableAmount };\n","import { ERC20PeriodTransferEnforcer } from '@metamask/delegation-abis';\nimport type { Address, Client, Hex } from 'viem';\nimport { readContract } from 'viem/actions';\n\nexport type ReadGetAvailableAmountParameters = {\n client: Client;\n contractAddress: Address;\n delegationHash: Hex;\n delegationManager: Address;\n terms: Hex;\n};\n\nexport const read = async ({\n client,\n contractAddress,\n delegationHash,\n delegationManager,\n terms,\n}: ReadGetAvailableAmountParameters) => {\n const [availableAmount, isNewPeriod, currentPeriod] = await readContract(\n client,\n {\n address: contractAddress,\n abi: ERC20PeriodTransferEnforcer,\n functionName: 'getAvailableAmount',\n args: [delegationHash, delegationManager, terms],\n },\n );\n\n return {\n availableAmount,\n isNewPeriod,\n currentPeriod,\n };\n};\n","import * as read from './read';\n\nexport { read };\n","import { read as getAvailableAmount } from './methods/getAvailableAmount';\n\nexport { getAvailableAmount };\n","import { ERC20StreamingEnforcer } from '@metamask/delegation-abis';\nimport type { Address, Client, Hex } from 'viem';\nimport { readContract, getBlock } from 'viem/actions';\n\nexport type ReadGetAvailableAmountParameters = {\n client: Client;\n contractAddress: Address;\n delegationManager: Address;\n delegationHash: Hex;\n terms: Hex;\n};\n\nexport const read = async ({\n client,\n contractAddress,\n delegationManager,\n delegationHash,\n terms,\n}: ReadGetAvailableAmountParameters) => {\n // Get current block timestamp from blockchain\n const currentBlock = await getBlock(client);\n const currentTimestamp = currentBlock.timestamp;\n\n // First, get the current state from the contract\n const allowanceState = await readContract(client, {\n address: contractAddress,\n abi: ERC20StreamingEnforcer,\n functionName: 'streamingAllowances',\n args: [delegationManager, delegationHash],\n });\n\n const [initialAmount, maxAmount, amountPerSecond, startTime, spent] =\n allowanceState;\n\n // Check if state exists (startTime != 0)\n if (startTime !== 0n) {\n // State exists, calculate available amount using the stored state\n const availableAmount = getAvailableAmount({\n initialAmount,\n maxAmount,\n amountPerSecond,\n startTime,\n spent,\n currentTimestamp,\n });\n\n return {\n availableAmount,\n };\n }\n\n // State doesn't exist, decode terms and simulate with spent = 0\n const decodedTerms = await readContract(client, {\n address: contractAddress,\n abi: ERC20StreamingEnforcer,\n functionName: 'getTermsInfo',\n args: [terms],\n });\n\n const [\n ,\n decodedInitialAmount,\n decodedMaxAmount,\n decodedAmountPerSecond,\n decodedStartTime,\n ] = decodedTerms;\n\n // Simulate using decoded terms with spent = 0\n const availableAmount = getAvailableAmount({\n initialAmount: decodedInitialAmount,\n maxAmount: decodedMaxAmount,\n amountPerSecond: decodedAmountPerSecond,\n startTime: decodedStartTime,\n spent: 0n,\n currentTimestamp,\n });\n\n return {\n availableAmount,\n };\n};\n\n/**\n * Replicates the internal _getAvailableAmount logic from the smart contract.\n *\n * @param allowance - The allowance object containing all parameters.\n * @param allowance.initialAmount - The initial amount available.\n * @param allowance.maxAmount - The maximum amount allowed.\n * @param allowance.amountPerSecond - The amount streamed per second.\n * @param allowance.startTime - The start time of the streaming.\n * @param allowance.spent - The amount already spent.\n * @param allowance.currentTimestamp - The current timestamp.\n * @returns The available amount that can be spent.\n */\nfunction getAvailableAmount(allowance: {\n initialAmount: bigint;\n maxAmount: bigint;\n amountPerSecond: bigint;\n startTime: bigint;\n spent: bigint;\n currentTimestamp: bigint;\n}): bigint {\n // If current time is before start time, nothing is available\n if (allowance.currentTimestamp < allowance.startTime) {\n return 0n;\n }\n\n // Calculate elapsed time since start\n const elapsed = allowance.currentTimestamp - allowance.startTime;\n\n // Calculate total unlocked amount\n let unlocked = allowance.initialAmount + allowance.amountPerSecond * elapsed;\n\n // Cap by max amount\n if (unlocked > allowance.maxAmount) {\n unlocked = allowance.maxAmount;\n }\n\n // If spent >= unlocked, nothing available\n if (allowance.spent >= unlocked) {\n return 0n;\n }\n\n // Return available amount\n return unlocked - allowance.spent;\n}\n","import * as read from './read';\n\nexport { read };\n","import { read as getAvailableAmount } from './methods/getAvailableAmount';\n\nexport { getAvailableAmount };\n","import { MultiTokenPeriodEnforcer } from '@metamask/delegation-abis';\nimport type { Address, Client, Hex } from 'viem';\nimport { readContract } from 'viem/actions';\n\nexport type ReadGetAvailableAmountParameters = {\n client: Client;\n contractAddress: Address;\n delegationHash: Hex;\n delegationManager: Address;\n terms: Hex;\n args: Hex;\n};\n\nexport const read = async ({\n client,\n contractAddress,\n delegationHash,\n delegationManager,\n terms,\n args,\n}: ReadGetAvailableAmountParameters) => {\n const [availableAmount, isNewPeriod, currentPeriod] = await readContract(\n client,\n {\n address: contractAddress,\n abi: MultiTokenPeriodEnforcer,\n functionName: 'getAvailableAmount',\n args: [delegationHash, delegationManager, terms, args],\n },\n );\n\n return {\n availableAmount,\n isNewPeriod,\n currentPeriod,\n };\n};\n","import * as read from './read';\n\nexport { read };\n","import { read as getAvailableAmount } from './methods/getAvailableAmount';\n\nexport { getAvailableAmount };\n","import { NativeTokenPeriodTransferEnforcer } from '@metamask/delegation-abis';\nimport type { Address, Client, Hex } from 'viem';\nimport { readContract } from 'viem/actions';\n\nexport type ReadGetAvailableAmountParameters = {\n client: Client;\n contractAddress: Address;\n delegationHash: Hex;\n delegationManager: Address;\n terms: Hex;\n};\n\nexport const read = async ({\n client,\n contractAddress,\n delegationHash,\n delegationManager,\n terms,\n}: ReadGetAvailableAmountParameters) => {\n const [availableAmount, isNewPeriod, currentPeriod] = await readContract(\n client,\n {\n address: contractAddress,\n abi: NativeTokenPeriodTransferEnforcer,\n functionName: 'getAvailableAmount',\n args: [delegationHash, delegationManager, terms],\n },\n );\n\n return {\n availableAmount,\n isNewPeriod,\n currentPeriod,\n };\n};\n","import * as read from './read';\n\nexport { read };\n","import { read as getAvailableAmount } from './methods/getAvailableAmount';\n\nexport { getAvailableAmount };\n","import { NativeTokenStreamingEnforcer } from '@metamask/delegation-abis';\nimport type { Address, Client, Hex } from 'viem';\nimport { readContract, getBlock } from 'viem/actions';\n\nexport type ReadGetAvailableAmountParameters = {\n client: Client;\n contractAddress: Address;\n delegationManager: Address;\n delegationHash: Hex;\n terms: Hex;\n};\n\nexport const read = async ({\n client,\n contractAddress,\n delegationManager,\n delegationHash,\n terms,\n}: ReadGetAvailableAmountParameters) => {\n // Get current block timestamp from blockchain\n const currentBlock = await getBlock(client);\n const currentTimestamp = currentBlock.timestamp;\n\n // First, get the current state from the contract\n const allowanceState = await readContract(client, {\n address: contractAddress,\n abi: NativeTokenStreamingEnforcer,\n functionName: 'streamingAllowances',\n args: [delegationManager, delegationHash],\n });\n\n const [initialAmount, maxAmount, amountPerSecond, startTime, spent] =\n allowanceState;\n\n // Check if state exists (startTime != 0)\n if (startTime !== 0n) {\n // State exists, calculate available amount using the stored state\n const availableAmount = getAvailableAmount({\n initialAmount,\n maxAmount,\n amountPerSecond,\n startTime,\n spent,\n currentTimestamp,\n });\n\n return {\n availableAmount,\n };\n }\n\n // State doesn't exist, decode terms and simulate with spent = 0\n const decodedTerms = await readContract(client, {\n address: contractAddress,\n abi: NativeTokenStreamingEnforcer,\n functionName: 'getTermsInfo',\n args: [terms],\n });\n\n const [\n decodedInitialAmount,\n decodedMaxAmount,\n decodedAmountPerSecond,\n decodedStartTime,\n ] = decodedTerms;\n\n // Simulate using decoded terms with spent = 0\n const availableAmount = getAvailableAmount({\n initialAmount: decodedInitialAmount,\n maxAmount: decodedMaxAmount,\n amountPerSecond: decodedAmountPerSecond,\n startTime: decodedStartTime,\n spent: 0n,\n currentTimestamp,\n });\n\n return {\n availableAmount,\n };\n};\n\n/**\n * Replicates the internal _getAvailableAmount logic from the smart contract.\n *\n * @param allowance - The allowance object containing all parameters.\n * @param allowance.initialAmount - The initial amount available.\n * @param allowance.maxAmount - The maximum amount allowed.\n * @param allowance.amountPerSecond - The amount streamed per second.\n * @param allowance.startTime - The start time of the streaming.\n * @param allowance.spent - The amount already spent.\n * @param allowance.currentTimestamp - The current timestamp.\n * @returns The available amount that can be spent.\n */\nfunction getAvailableAmount(allowance: {\n initialAmount: bigint;\n maxAmount: bigint;\n amountPerSecond: bigint;\n startTime: bigint;\n spent: bigint;\n currentTimestamp: bigint;\n}): bigint {\n // If current time is before start time, nothing is available\n if (allowance.currentTimestamp < allowance.startTime) {\n return 0n;\n }\n\n // Calculate elapsed time since start\n const elapsed = allowance.currentTimestamp - allowance.startTime;\n\n // Calculate total unlocked amount\n let unlocked = allowance.initialAmount + allowance.amountPerSecond * elapsed;\n\n // Cap by max amount\n if (unlocked > allowance.maxAmount) {\n unlocked = allowance.maxAmount;\n }\n\n // If spent >= unlocked, nothing available\n if (allowance.spent >= unlocked) {\n return 0n;\n }\n\n // Return available amount\n return unlocked - allowance.spent;\n}\n"]}
@@ -5,29 +5,14 @@ import {
5
5
  encode4,
6
6
  encode5,
7
7
  encodeProxyCreationCode
8
- } from "./chunk-4A5RMDDC.mjs";
8
+ } from "./chunk-WV2R7BXP.mjs";
9
9
  import {
10
10
  createExecution,
11
11
  encodeExecutionCalldatas
12
12
  } from "./chunk-TPBFVDVM.mjs";
13
-
14
- // src/constants.ts
15
- var Implementation = /* @__PURE__ */ ((Implementation2) => {
16
- Implementation2["MultiSig"] = "MultiSig";
17
- Implementation2["Hybrid"] = "Hybrid";
18
- Implementation2["Stateless7702"] = "Stateless7702";
19
- return Implementation2;
20
- })(Implementation || {});
21
- var TransferWindow = /* @__PURE__ */ ((TransferWindow2) => {
22
- TransferWindow2[TransferWindow2["Hourly"] = 3600] = "Hourly";
23
- TransferWindow2[TransferWindow2["Daily"] = 86400] = "Daily";
24
- TransferWindow2[TransferWindow2["Weekly"] = 604800] = "Weekly";
25
- TransferWindow2[TransferWindow2["BiWeekly"] = 1209600] = "BiWeekly";
26
- TransferWindow2[TransferWindow2["Monthly"] = 2592e3] = "Monthly";
27
- TransferWindow2[TransferWindow2["Quarterly"] = 7776e3] = "Quarterly";
28
- TransferWindow2[TransferWindow2["Yearly"] = 31536e3] = "Yearly";
29
- return TransferWindow2;
30
- })(TransferWindow || {});
13
+ import {
14
+ encodeDelegations
15
+ } from "./chunk-C5ZEEH2Z.mjs";
31
16
 
32
17
  // src/counterfactualAccountData.ts
33
18
  import { getContractAddress, pad } from "viem";
@@ -103,25 +88,26 @@ var getCounterfactualAccountData = async ({
103
88
  import { DelegationManager } from "@metamask/delegation-abis";
104
89
  import { encodeFunctionData } from "viem";
105
90
  var isDelegatedCall = (call) => {
106
- return "permissionsContext" in call && "delegationManager" in call;
91
+ return "permissionContext" in call && "delegationManager" in call;
107
92
  };
108
93
  var processDelegatedCall = (call) => {
109
94
  const {
110
- permissionsContext,
95
+ permissionContext,
111
96
  delegationManager,
112
97
  to: target,
113
98
  value,
114
99
  data: callData
115
100
  } = call;
116
101
  const callAsExecution = createExecution({ target, value, callData });
117
- if (!permissionsContext) {
102
+ if (!permissionContext) {
118
103
  return callAsExecution;
119
104
  }
105
+ const encodedPermissionsContext = encodeDelegations(permissionContext);
120
106
  const redeemCalldata = encodeFunctionData({
121
- abi: DelegationManager.abi,
107
+ abi: DelegationManager,
122
108
  functionName: "redeemDelegations",
123
109
  args: [
124
- [permissionsContext],
110
+ [encodedPermissionsContext],
125
111
  ["0x0000000000000000000000000000000000000000000000000000000000000000" /* SingleDefault */],
126
112
  encodeExecutionCalldatas([[callAsExecution]])
127
113
  ]
@@ -263,8 +249,6 @@ var createDummyWebAuthnSignature = (keyId) => {
263
249
  };
264
250
 
265
251
  export {
266
- Implementation,
267
- TransferWindow,
268
252
  getCounterfactualAccountData,
269
253
  encodeCalls,
270
254
  encodeCallsForCaller,
@@ -272,4 +256,4 @@ export {
272
256
  encodeDeleGatorSignature,
273
257
  createDummyWebAuthnSignature
274
258
  };
275
- //# sourceMappingURL=chunk-AUCZDOTJ.mjs.map
259
+ //# sourceMappingURL=chunk-WPVSFOQM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/counterfactualAccountData.ts","../src/encodeCalls.ts","../src/webAuthn.ts"],"sourcesContent":["import type { Address, Hex } from 'viem';\nimport { getContractAddress, pad } from 'viem';\n\nimport { Implementation } from './constants';\nimport { initializeHybridDeleGator } from './DelegationFramework/HybridDeleGator/encode';\nimport { initializeMultiSigDeleGator } from './DelegationFramework/MultiSigDeleGator/encode';\nimport { create2Deploy as encodeCreate2Deploy } from './DelegationFramework/SimpleFactory/encode';\nimport { encodeProxyCreationCode } from './DelegationFramework/utils';\nimport type {\n SmartAccountsEnvironment,\n HybridDeleGatorDeployParams,\n MultiSigDeleGatorDeployParams,\n DeployParams,\n} from './types';\n\n/**\n * Infers counterfactual account data for a DeleGator smart account.\n *\n * @template TImplementation - The type of implementation, extending Implementation.\n * @template TDeployParams - The type of deployment parameters, defaults to DeployParams<Implementation>.\n * @param options - The options for generating counterfactual account data.\n * @param options.factory - The address of the SimpleFactory contract.\n * @param options.implementations - The DeleGator implementation contracts.\n * @param options.implementation - The implementation type to use.\n * @param options.deployParams - The deployment parameters for the specified implementation.\n * @param options.deploySalt - The salt to use for CREATE2 address computation.\n * @returns An object containing the counterfactual address and factory calldata.\n * @description This function calculates the address a DeleGator contract would have if deployed,\n * and provides the calldata needed to deploy it.\n */\nexport const getCounterfactualAccountData = async <\n TImplementation extends Implementation,\n>({\n factory,\n implementations,\n implementation,\n deployParams,\n deploySalt,\n}: {\n factory: Address;\n implementations: SmartAccountsEnvironment['implementations'];\n implementation: TImplementation;\n deployParams: DeployParams<TImplementation>;\n deploySalt: Hex;\n}): Promise<{ factoryData: Hex; address: Address }> => {\n let implementationAddress: Address;\n let initcode: Hex;\n\n switch (implementation) {\n case Implementation.Hybrid: {\n const [owner, keyIds, xValues, yValues] =\n deployParams as HybridDeleGatorDeployParams;\n\n if (!implementations.HybridDeleGatorImpl) {\n throw new Error(\n 'HybridDeleGatorImpl address not provided in environment',\n );\n }\n\n implementationAddress = implementations.HybridDeleGatorImpl;\n\n const p256Owners = keyIds.map((keyId, index) => {\n const xValue = xValues[index];\n const yValue = yValues[index];\n\n if (!xValue || !yValue) {\n throw new Error(\n `Missing X or Y value for keyId ${keyId} at index ${index}`,\n );\n }\n\n return {\n keyId,\n x: xValue,\n y: yValue,\n };\n });\n\n initcode = initializeHybridDeleGator({ eoaOwner: owner, p256Owners });\n break;\n }\n case Implementation.MultiSig: {\n const [owners, threshold] = deployParams as MultiSigDeleGatorDeployParams;\n\n if (!implementations.MultiSigDeleGatorImpl) {\n throw new Error(\n 'MultiSigDeleGatorImpl address not provided in environment',\n );\n }\n\n implementationAddress = implementations.MultiSigDeleGatorImpl;\n initcode = initializeMultiSigDeleGator({ owners, threshold });\n break;\n }\n case Implementation.Stateless7702:\n default:\n throw new Error(`Implementation type '${implementation}' not supported`);\n }\n\n const salt = pad(deploySalt, { dir: 'left', size: 32 });\n\n const proxyCreationCode = encodeProxyCreationCode({\n implementationAddress,\n initcode,\n });\n\n const address = getContractAddress({\n bytecode: proxyCreationCode,\n from: factory,\n opcode: 'CREATE2',\n salt,\n });\n\n const factoryData = encodeCreate2Deploy(proxyCreationCode, salt);\n\n return {\n factoryData,\n address,\n };\n};\n","import { DelegationManager } from '@metamask/delegation-abis';\nimport { encodeFunctionData } from 'viem';\nimport type { Address, Hex } from 'viem';\n\nimport type { DelegatedCall } from './actions/erc7710RedeemDelegationAction';\nimport { encodeDelegations } from './delegation';\nimport {\n execute,\n executeWithMode,\n} from './DelegationFramework/DeleGatorCore/encode';\nimport {\n ExecutionMode,\n createExecution,\n encodeExecutionCalldatas,\n} from './executions';\nimport type { Call } from './types';\n\n/**\n * Checks if a call is a delegated call by checking for the presence of permissionContext and delegationManager.\n *\n * @param call - The call to check.\n * @returns True if the call is a delegated call, false otherwise.\n */\nconst isDelegatedCall = (call: Call): call is DelegatedCall => {\n return 'permissionContext' in call && 'delegationManager' in call;\n};\n\n/**\n * If there's a single call with permissionContext and delegationManager,\n * processes it as a delegated call.\n *\n * @param call - The call to process.\n * @returns The execution object for the delegated call.\n * @description\n * This function creates an execution that calls redeemDelegations on the delegation manager.\n */\nconst processDelegatedCall = (call: DelegatedCall) => {\n const {\n permissionContext,\n delegationManager,\n to: target,\n value,\n data: callData,\n } = call;\n\n const callAsExecution = createExecution({ target, value, callData });\n\n if (!permissionContext) {\n return callAsExecution;\n }\n\n const encodedPermissionsContext = encodeDelegations(permissionContext);\n\n const redeemCalldata = encodeFunctionData({\n abi: DelegationManager,\n functionName: 'redeemDelegations',\n args: [\n [encodedPermissionsContext],\n [ExecutionMode.SingleDefault],\n encodeExecutionCalldatas([[callAsExecution]]),\n ],\n });\n\n return createExecution({\n target: delegationManager,\n callData: redeemCalldata,\n });\n};\n\n/**\n * If there's a single call, encode the shorthand `execute` function. Otherwise, encode the `executeWithMode` function. Execution type will always be \"default\".\n *\n * @param calls - The calls to execute.\n * @returns The encoded calldata for the DeleGator to execute the calls.\n * @description\n * This function supports both single and batch execution modes.\n * For single calls, it uses the gas-efficient execute function.\n */\nexport const encodeCalls = (calls: readonly Call[]) => {\n if (calls.length === 1) {\n const call = calls[0];\n if (call && !isDelegatedCall(call)) {\n const { to: target, value, data: callData } = call;\n const execution = createExecution({ target, value, callData });\n return execute({ execution });\n }\n }\n\n const executions = calls.map((call) => {\n if (isDelegatedCall(call)) {\n return processDelegatedCall(call);\n }\n const { to: target, value, data: callData } = call;\n return createExecution({ target, value, callData });\n });\n\n const mode =\n calls.length === 1\n ? ExecutionMode.SingleDefault\n : ExecutionMode.BatchDefault;\n return executeWithMode({ mode, executions });\n};\n\n/**\n * Encodes calls for execution by a DeleGator smart contract.\n *\n * @param caller - The address of the DeleGator contract.\n * @param calls - An array of Call objects, each containing 'to', optional 'data', and optional 'value'.\n * @returns A promise that resolves to the encoded function data as a hexadecimal string.\n * @description\n * - If there's a single call directly to the delegator, it returns the call data directly.\n * - For multiple calls or calls to other addresses, it creates executions and encodes them for the DeleGator's execute function.\n * - The execution mode is set to ExecutionMode.SingleDefault for a single call, or ExecutionMode.BatchDefault for multiple calls.\n *\n * todo: This doesn't fully expose the flexibility of the DeleGator's execute function, but it's a start.\n * maybe we add a mechanism where individual calls passed to this function can be encoded batches.\n */\nexport const encodeCallsForCaller = async (\n caller: Address,\n calls: readonly Call[],\n): Promise<Hex> => {\n if (calls.length === 1) {\n const call = calls[0];\n if (call?.to === caller && !isDelegatedCall(call)) {\n // if there's a single call, and it's to the delegator, we can just return the calldata directly.\n return call.data ?? '0x';\n }\n }\n return encodeCalls(calls);\n};\n","import {\n parseAbiParameters,\n encodeAbiParameters,\n type Hex,\n encodePacked,\n keccak256,\n concat,\n hexToBytes,\n} from 'viem';\nimport { parseSignature } from 'webauthn-p256';\n\nexport const FIELD_MODULUS =\n 115792089210356248762697446949407573529996955224135760342422259061068512044369n;\nexport const MALLEABILITY_THRESHOLD = FIELD_MODULUS / 2n;\n\nexport const SIGNATURE_ABI_PARAMS = parseAbiParameters(\n 'bytes32, uint256, uint256, bytes, bool, string, string, uint256',\n);\n\n/**\n * This function is used to convert the client data returned from the\n * credentials API into a format that can be consumed by the DeleGator\n * contracts. We need the flattend JSON strings before and after the\n * userOpHash/challenge. This function provides those two client data string\n * slices.\n *\n * @param clientDataJson - The client data JSON string.\n * @returns Returns [clientDataJSONPrefix and clientDataJSONSuffix]\n * ClientDataJSONPrefix contains the client data till the challengeHash\n * ClientDataJSONSuffix contains the client data after the challengeHash.\n */\nexport const splitOnChallenge = (\n clientDataJson: string,\n): [clientDataJSONPrefix: string, clientDataJSONSuffix: string] => {\n /*\n CientData looks like this:\n {\n \"type\": \"webauthn.create\" | \"webauthn.get\",\n \"challenge\": \"{userOpHash}\",\n \"origin\": \"{Domain}\",\n \"crossOrigin\": boolean\n }\n */\n try {\n const { challenge } = JSON.parse(clientDataJson);\n if (challenge === undefined) {\n throw new Error('No \"challenge\" found in the input string');\n }\n return clientDataJson.split(challenge) as [string, string];\n } catch (error) {\n throw new Error('No \"challenge\" found in the input string', {\n cause: error,\n });\n }\n};\n\n/**\n * Returns the index of '\"type\":' in the ClientData.\n *\n * @param clientDataJson - Stringified ClientDataJSON.\n * @returns The index of '\"type\":' in the ClientData.\n */\nexport const getResponseTypeLocation = (clientDataJson: string): bigint => {\n try {\n // Find the index of the `\"type\":` key in the JSON string directly\n const typeIndex = clientDataJson.indexOf('\"type\":');\n\n if (typeIndex === -1) {\n throw new Error('No \"type\" found in the input string');\n }\n // Return the index of the `\"type\":` key\n return BigInt(typeIndex);\n } catch (error) {\n // Handle any errors that occur during the search\n throw new Error('No \"type\" found in the input string', {\n cause: error,\n });\n }\n};\n\n/**\n * Encodes a signature to a hexadecimal signature that will be accepted\n * by the DeleGator contracts.\n *\n * @param keyId - The key used for the signature, represented as a hexadecimal string.\n * @param signature - The signature to convert, as Hex.\n * @param clientDataJSON - The client data used in the creation of the signature.\n * @param authenticatorData - The authenticator data used in the creation of the signature.\n * @returns The signature as a valid DeleGator signature encoded as Hexadecimal string.\n */\nexport function encodeDeleGatorSignature(\n keyId: string,\n signature: Hex,\n clientDataJSON: string,\n authenticatorData: Hex,\n): Hex {\n const keyIdHash = keccak256(encodePacked(['string'], [keyId]));\n\n const parsedSignature = parseSignature(signature);\n\n let { s } = parsedSignature;\n\n while (s > MALLEABILITY_THRESHOLD) {\n s = FIELD_MODULUS - s;\n }\n\n const { r } = parsedSignature;\n\n const [clientDataComponent1, clientDataComponent2] =\n splitOnChallenge(clientDataJSON);\n\n const { userVerified } = parseAuthenticatorFlags(authenticatorData);\n\n const responseTypeLocation = getResponseTypeLocation(clientDataJSON);\n\n const encodedSignature = encodeAbiParameters(SIGNATURE_ABI_PARAMS, [\n keyIdHash,\n r,\n s,\n authenticatorData,\n userVerified,\n clientDataComponent1,\n clientDataComponent2,\n responseTypeLocation,\n ]);\n return encodedSignature;\n}\n\nconst AUTHENTICATOR_DATA_FLAGS_OFFSET = 32;\n// We have all of the flag bits defined here for completeness, even though we only extract the userVerified flag.\nenum AuthenticatorDataFlagBitIndex {\n UserPresence = 0,\n UserVerified = 2,\n BackupEligibility = 3,\n BackupState = 4,\n AttestedCredentialData = 6,\n ExtensionData = 7,\n}\n\nexport type AuthenticatorFlags = {\n userVerified: boolean;\n};\n\n/**\n * Parses the authenticator data and returns an authenticator flags object with the `userVerified` flag.\n * See https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data.\n *\n * @param authenticatorData - The authenticator data to parse.\n * @returns An object representing the parsed authenticator flags.\n */\nexport function parseAuthenticatorFlags(\n authenticatorData: Hex,\n): AuthenticatorFlags {\n const authenticatorDataBuffer = hexToBytes(authenticatorData);\n const dataBufferUint8 = new Uint8Array(authenticatorDataBuffer);\n const flags = dataBufferUint8[AUTHENTICATOR_DATA_FLAGS_OFFSET];\n if (flags === undefined) {\n throw new Error('Authenticator flags not found in authenticator data');\n }\n\n // Bit 0 is the least significant bit in the flags byte, so we left shift 0b1 by the bit index\n // eslint-disable-next-line no-bitwise\n const bitMask = 0b1 << AuthenticatorDataFlagBitIndex.UserVerified;\n\n return {\n // eslint-disable-next-line no-bitwise\n userVerified: (flags & bitMask) !== 0x0,\n };\n}\n\n/**\n * Creates a dummy signature.\n * This must meet all early-failure conditions of the real signature, but does not need to be a valid signature.\n *\n * @param keyId - The key ID to use for the dummy signature.\n * @returns The encoded signature.\n */\nexport const createDummyWebAuthnSignature = (keyId: Hex) => {\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API/Authenticator_data#data_structure\n const rpIdHash = keccak256(encodePacked(['string'], ['AuthenticatorData']));\n const flags = '0x05';\n const signCount = '0x00000000';\n const authenticatorData = concat([rpIdHash, flags, signCount]);\n\n const keyIdHash = keccak256(encodePacked(['string'], [keyId]));\n const rs =\n 57896044605178124381348723474703786764998477612067880171211129530534256022184n;\n const userVerification = true;\n const clientDataPrefix = '{\"type\":\"webauthn.get\",\"challenge\":\"';\n const clientDataSuffix = '\",\"origin\":\"passkey-domain\",\"crossOrigin\":false}';\n const responseTypeLocation = 1n;\n\n const encodedSignature = encodeAbiParameters(SIGNATURE_ABI_PARAMS, [\n keyIdHash,\n rs,\n rs,\n authenticatorData,\n userVerification,\n clientDataPrefix,\n clientDataSuffix,\n responseTypeLocation,\n ]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