permissionless 0.3.6 → 0.3.7

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 (209) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/_cjs/accounts/biconomy/toBiconomySmartAccount.js +9 -5
  3. package/_cjs/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
  4. package/_cjs/accounts/kernel/toKernelSmartAccount.js +4 -0
  5. package/_cjs/accounts/kernel/toKernelSmartAccount.js.map +1 -1
  6. package/_cjs/accounts/light/toLightSmartAccount.js +9 -5
  7. package/_cjs/accounts/light/toLightSmartAccount.js.map +1 -1
  8. package/_cjs/accounts/safe/signUserOperation.js +3 -0
  9. package/_cjs/accounts/safe/signUserOperation.js.map +1 -1
  10. package/_cjs/accounts/safe/toSafeSmartAccount.js +4 -3
  11. package/_cjs/accounts/safe/toSafeSmartAccount.js.map +1 -1
  12. package/_cjs/accounts/simple/toSimpleSmartAccount.js +15 -10
  13. package/_cjs/accounts/simple/toSimpleSmartAccount.js.map +1 -1
  14. package/_cjs/accounts/thirdweb/utils/decodeCallData.js +7 -5
  15. package/_cjs/accounts/thirdweb/utils/decodeCallData.js.map +1 -1
  16. package/_cjs/accounts/trust/utils/decodeCallData.js +7 -5
  17. package/_cjs/accounts/trust/utils/decodeCallData.js.map +1 -1
  18. package/_cjs/actions/{erc7579.js → erc7579/index.js} +9 -9
  19. package/_cjs/actions/erc7579/index.js.map +1 -0
  20. package/_cjs/actions/{etherspot.js → etherspot/index.js} +2 -2
  21. package/_cjs/actions/etherspot/index.js.map +1 -0
  22. package/_cjs/actions/{passkeyServer.js → passkeyServer/index.js} +4 -4
  23. package/_cjs/actions/passkeyServer/index.js.map +1 -0
  24. package/_cjs/actions/pimlico/estimateErc20PaymasterCost.js +7 -3
  25. package/_cjs/actions/pimlico/estimateErc20PaymasterCost.js.map +1 -1
  26. package/_cjs/actions/{pimlico.js → pimlico/index.js} +8 -8
  27. package/_cjs/actions/pimlico/index.js.map +1 -0
  28. package/_cjs/actions/{smartAccount.js → smartAccount/index.js} +5 -5
  29. package/_cjs/actions/smartAccount/index.js.map +1 -0
  30. package/_cjs/clients/createSmartAccountClient.js.map +1 -1
  31. package/_cjs/clients/decorators/pimlico.js +4 -4
  32. package/_cjs/clients/decorators/pimlico.js.map +1 -1
  33. package/_cjs/clients/{passkeyServer.js → passkeyServer/index.js} +2 -2
  34. package/_cjs/clients/passkeyServer/index.js.map +1 -0
  35. package/_cjs/clients/{pimlico.js → pimlico/index.js} +2 -2
  36. package/_cjs/clients/pimlico/index.js.map +1 -0
  37. package/_cjs/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js +6 -5
  38. package/_cjs/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
  39. package/_esm/accounts/biconomy/toBiconomySmartAccount.js +9 -5
  40. package/_esm/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
  41. package/_esm/accounts/kernel/toKernelSmartAccount.js +4 -0
  42. package/_esm/accounts/kernel/toKernelSmartAccount.js.map +1 -1
  43. package/_esm/accounts/light/toLightSmartAccount.js +9 -5
  44. package/_esm/accounts/light/toLightSmartAccount.js.map +1 -1
  45. package/_esm/accounts/safe/signUserOperation.js +3 -0
  46. package/_esm/accounts/safe/signUserOperation.js.map +1 -1
  47. package/_esm/accounts/safe/toSafeSmartAccount.js +4 -3
  48. package/_esm/accounts/safe/toSafeSmartAccount.js.map +1 -1
  49. package/_esm/accounts/simple/toSimpleSmartAccount.js +15 -10
  50. package/_esm/accounts/simple/toSimpleSmartAccount.js.map +1 -1
  51. package/_esm/accounts/thirdweb/utils/decodeCallData.js +7 -5
  52. package/_esm/accounts/thirdweb/utils/decodeCallData.js.map +1 -1
  53. package/_esm/accounts/trust/utils/decodeCallData.js +7 -5
  54. package/_esm/accounts/trust/utils/decodeCallData.js.map +1 -1
  55. package/_esm/actions/{erc7579.js → erc7579/index.js} +9 -9
  56. package/_esm/actions/erc7579/index.js.map +1 -0
  57. package/_esm/actions/etherspot/index.js +2 -0
  58. package/_esm/actions/etherspot/index.js.map +1 -0
  59. package/_esm/actions/passkeyServer/index.js +4 -0
  60. package/_esm/actions/passkeyServer/index.js.map +1 -0
  61. package/_esm/actions/pimlico/estimateErc20PaymasterCost.js +7 -3
  62. package/_esm/actions/pimlico/estimateErc20PaymasterCost.js.map +1 -1
  63. package/_esm/actions/pimlico/index.js +8 -0
  64. package/_esm/actions/pimlico/index.js.map +1 -0
  65. package/_esm/actions/smartAccount/index.js +5 -0
  66. package/_esm/actions/smartAccount/index.js.map +1 -0
  67. package/_esm/clients/createSmartAccountClient.js.map +1 -1
  68. package/_esm/clients/decorators/pimlico.js +1 -1
  69. package/_esm/clients/decorators/pimlico.js.map +1 -1
  70. package/_esm/clients/{passkeyServer.js → passkeyServer/index.js} +2 -2
  71. package/_esm/clients/passkeyServer/index.js.map +1 -0
  72. package/_esm/clients/{pimlico.js → pimlico/index.js} +2 -2
  73. package/_esm/clients/pimlico/index.js.map +1 -0
  74. package/_esm/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js +5 -4
  75. package/_esm/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
  76. package/_types/accounts/biconomy/toBiconomySmartAccount.d.ts.map +1 -1
  77. package/_types/accounts/kernel/toKernelSmartAccount.d.ts.map +1 -1
  78. package/_types/accounts/light/toLightSmartAccount.d.ts.map +1 -1
  79. package/_types/accounts/safe/signUserOperation.d.ts.map +1 -1
  80. package/_types/accounts/safe/toSafeSmartAccount.d.ts.map +1 -1
  81. package/_types/accounts/simple/toSimpleSmartAccount.d.ts.map +1 -1
  82. package/_types/accounts/thirdweb/utils/decodeCallData.d.ts.map +1 -1
  83. package/_types/accounts/trust/utils/decodeCallData.d.ts.map +1 -1
  84. package/_types/actions/{erc7579.d.ts → erc7579/index.d.ts} +11 -11
  85. package/_types/actions/erc7579/index.d.ts.map +1 -0
  86. package/_types/actions/etherspot/index.d.ts +2 -0
  87. package/_types/actions/etherspot/index.d.ts.map +1 -0
  88. package/_types/actions/passkeyServer/index.d.ts +4 -0
  89. package/_types/actions/passkeyServer/index.d.ts.map +1 -0
  90. package/_types/actions/pimlico/estimateErc20PaymasterCost.d.ts.map +1 -1
  91. package/_types/actions/pimlico/index.d.ts +8 -0
  92. package/_types/actions/pimlico/index.d.ts.map +1 -0
  93. package/_types/actions/smartAccount/index.d.ts +5 -0
  94. package/_types/actions/smartAccount/index.d.ts.map +1 -0
  95. package/_types/clients/createSmartAccountClient.d.ts +9 -1
  96. package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
  97. package/_types/clients/decorators/pimlico.d.ts +1 -1
  98. package/_types/clients/decorators/pimlico.d.ts.map +1 -1
  99. package/_types/clients/{passkeyServer.d.ts → passkeyServer/index.d.ts} +8 -4
  100. package/_types/clients/passkeyServer/index.d.ts.map +1 -0
  101. package/_types/clients/pimlico/index.d.ts +21 -0
  102. package/_types/clients/pimlico/index.d.ts.map +1 -0
  103. package/_types/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.d.ts.map +1 -1
  104. package/accounts/biconomy/package.json +6 -0
  105. package/accounts/biconomy/toBiconomySmartAccount.ts +13 -5
  106. package/accounts/etherspot/package.json +6 -0
  107. package/accounts/kernel/package.json +6 -0
  108. package/accounts/kernel/toKernelSmartAccount.ts +7 -0
  109. package/accounts/light/package.json +6 -0
  110. package/accounts/light/toLightSmartAccount.ts +13 -5
  111. package/accounts/nexus/package.json +6 -0
  112. package/accounts/package.json +6 -0
  113. package/accounts/safe/package.json +6 -0
  114. package/accounts/safe/signUserOperation.ts +4 -0
  115. package/accounts/safe/toSafeSmartAccount.ts +5 -3
  116. package/accounts/simple/package.json +6 -0
  117. package/accounts/simple/toSimpleSmartAccount.ts +21 -10
  118. package/accounts/thirdweb/package.json +6 -0
  119. package/accounts/thirdweb/utils/decodeCallData.ts +9 -5
  120. package/accounts/trust/package.json +6 -0
  121. package/accounts/trust/utils/decodeCallData.ts +9 -5
  122. package/actions/{erc7579.ts → erc7579/index.ts} +10 -16
  123. package/actions/erc7579/package.json +6 -0
  124. package/actions/{etherspot.ts → etherspot/index.ts} +1 -1
  125. package/actions/etherspot/package.json +6 -0
  126. package/actions/{passkeyServer.ts → passkeyServer/index.ts} +3 -3
  127. package/actions/passkeyServer/package.json +6 -0
  128. package/actions/pimlico/estimateErc20PaymasterCost.ts +9 -3
  129. package/actions/{pimlico.ts → pimlico/index.ts} +7 -7
  130. package/actions/pimlico/package.json +6 -0
  131. package/actions/smartAccount/index.ts +7 -0
  132. package/actions/smartAccount/package.json +6 -0
  133. package/clients/createSmartAccountClient.ts +45 -20
  134. package/clients/decorators/pimlico.ts +10 -10
  135. package/clients/package.json +6 -0
  136. package/clients/{passkeyServer.ts → passkeyServer/index.ts} +15 -13
  137. package/clients/passkeyServer/package.json +6 -0
  138. package/clients/{pimlico.ts → pimlico/index.ts} +50 -23
  139. package/clients/pimlico/package.json +6 -0
  140. package/errors/package.json +6 -0
  141. package/experimental/pimlico/package.json +6 -0
  142. package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts +6 -4
  143. package/package.json +34 -29
  144. package/utils/package.json +6 -0
  145. package/_cjs/actions/erc7579.js.map +0 -1
  146. package/_cjs/actions/etherspot.js.map +0 -1
  147. package/_cjs/actions/passkeyServer.js.map +0 -1
  148. package/_cjs/actions/pimlico.js.map +0 -1
  149. package/_cjs/actions/smartAccount.js.map +0 -1
  150. package/_cjs/clients/passkeyServer.js.map +0 -1
  151. package/_cjs/clients/pimlico.js.map +0 -1
  152. package/_esm/actions/erc7579.js.map +0 -1
  153. package/_esm/actions/etherspot.js +0 -2
  154. package/_esm/actions/etherspot.js.map +0 -1
  155. package/_esm/actions/passkeyServer.js +0 -4
  156. package/_esm/actions/passkeyServer.js.map +0 -1
  157. package/_esm/actions/pimlico.js +0 -8
  158. package/_esm/actions/pimlico.js.map +0 -1
  159. package/_esm/actions/smartAccount.js +0 -5
  160. package/_esm/actions/smartAccount.js.map +0 -1
  161. package/_esm/clients/passkeyServer.js.map +0 -1
  162. package/_esm/clients/pimlico.js.map +0 -1
  163. package/_types/actions/erc7579.d.ts.map +0 -1
  164. package/_types/actions/etherspot.d.ts +0 -2
  165. package/_types/actions/etherspot.d.ts.map +0 -1
  166. package/_types/actions/passkeyServer.d.ts +0 -4
  167. package/_types/actions/passkeyServer.d.ts.map +0 -1
  168. package/_types/actions/pimlico.d.ts +0 -8
  169. package/_types/actions/pimlico.d.ts.map +0 -1
  170. package/_types/actions/smartAccount.d.ts +0 -5
  171. package/_types/actions/smartAccount.d.ts.map +0 -1
  172. package/_types/clients/passkeyServer.d.ts.map +0 -1
  173. package/_types/clients/pimlico.d.ts +0 -13
  174. package/_types/clients/pimlico.d.ts.map +0 -1
  175. package/accounts/decodeCalls.test.ts +0 -505
  176. package/accounts/safe/signUserOperation.test.ts +0 -275
  177. package/actions/erc7579/accountId.test.ts +0 -39
  178. package/actions/erc7579/installModule.test.ts +0 -214
  179. package/actions/erc7579/installModules.test.ts +0 -235
  180. package/actions/erc7579/isModuleInstalled.test.ts +0 -72
  181. package/actions/erc7579/supportsExecutionMode.test.ts +0 -108
  182. package/actions/erc7579/supportsModule.test.ts +0 -35
  183. package/actions/erc7579/uninstallModule.test.ts +0 -128
  184. package/actions/erc7579/uninstallModules.test.ts +0 -117
  185. package/actions/pimlico/getTokenQuotes.test.ts +0 -90
  186. package/actions/pimlico/getUserOperationGasPrice.test.ts +0 -82
  187. package/actions/pimlico/getUserOperationStatus.test.ts +0 -223
  188. package/actions/pimlico/sponsorUserOperation.test.ts +0 -236
  189. package/actions/pimlico/validateSponsorshipPolicies.test.ts +0 -153
  190. package/actions/public/getAccountNonce.test.ts +0 -96
  191. package/actions/public/getSenderAddress.test.ts +0 -154
  192. package/actions/smartAccount/getCallsStatus.test.ts +0 -253
  193. package/actions/smartAccount/sendCalls.test.ts +0 -569
  194. package/actions/smartAccount/sendTransaction.test.ts +0 -414
  195. package/actions/smartAccount/signMessage.test.ts +0 -217
  196. package/actions/smartAccount/signTypedData.test.ts +0 -226
  197. package/actions/smartAccount.ts +0 -7
  198. package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +0 -574
  199. package/types/package.json +0 -6
  200. package/utils/decodeNonce.test.ts +0 -40
  201. package/utils/deepHexlify.test.ts +0 -57
  202. package/utils/encode7579Calls.test.ts +0 -69
  203. package/utils/encodeNonce.test.ts +0 -38
  204. package/utils/erc20AllowanceOverride.test.ts +0 -59
  205. package/utils/erc20BalanceOverride.test.ts +0 -57
  206. package/utils/getAddressFromInitCodeOrPaymasterAndData.test.ts +0 -31
  207. package/utils/getPackedUserOperation.test.ts +0 -204
  208. package/utils/getRequiredPrefund.test.ts +0 -90
  209. package/vitest.config.ts +0 -41
@@ -1,275 +0,0 @@
1
- import {
2
- entryPoint06Address,
3
- entryPoint07Address
4
- } from "viem/account-abstraction"
5
- import {
6
- generatePrivateKey,
7
- privateKeyToAccount,
8
- toAccount
9
- } from "viem/accounts"
10
- import { foundry } from "viem/chains"
11
- import { describe, expect } from "vitest"
12
- import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
13
- import {
14
- getBundlerClient,
15
- getSafeClient
16
- } from "../../../permissionless-test/src/utils"
17
- import { signUserOperation } from "./signUserOperation"
18
-
19
- describe("signUserOperation", () => {
20
- testWithRpc("signUserOperation_V06", async ({ rpc }) => {
21
- const owners = [
22
- privateKeyToAccount(generatePrivateKey()),
23
- privateKeyToAccount(generatePrivateKey()),
24
- privateKeyToAccount(generatePrivateKey())
25
- ]
26
-
27
- const safeAccountClient = getBundlerClient({
28
- account: await getSafeClient({
29
- ...rpc,
30
- entryPoint: {
31
- version: "0.6"
32
- },
33
- owners: owners.map((owner) => toAccount(owner.address))
34
- }),
35
- entryPoint: {
36
- version: "0.6"
37
- },
38
- ...rpc
39
- })
40
-
41
- const unSignedUserOperation =
42
- await safeAccountClient.prepareUserOperation({
43
- calls: [
44
- {
45
- to: safeAccountClient.account.address,
46
- data: "0x"
47
- }
48
- ]
49
- })
50
-
51
- let partialSignatures = await signUserOperation({
52
- version: "1.4.1",
53
- entryPoint: {
54
- address: entryPoint06Address,
55
- version: "0.6"
56
- },
57
- chainId: foundry.id,
58
- owners: owners.map((owner) => toAccount(owner.address)),
59
- account: owners[0],
60
- ...unSignedUserOperation
61
- })
62
-
63
- partialSignatures = await signUserOperation({
64
- version: "1.4.1",
65
- entryPoint: {
66
- address: entryPoint06Address,
67
- version: "0.6"
68
- },
69
- chainId: foundry.id,
70
- owners: owners.map((owner) => toAccount(owner.address)),
71
- account: owners[1],
72
- signatures: partialSignatures,
73
- ...unSignedUserOperation
74
- })
75
-
76
- const finalSignature = await signUserOperation({
77
- version: "1.4.1",
78
- entryPoint: {
79
- address: entryPoint06Address,
80
- version: "0.6"
81
- },
82
- chainId: foundry.id,
83
- owners: owners.map((owner) => toAccount(owner.address)),
84
- account: owners[2],
85
- signatures: partialSignatures,
86
- ...unSignedUserOperation
87
- })
88
-
89
- const userOpHash = safeAccountClient.sendUserOperation({
90
- ...unSignedUserOperation,
91
- signature: finalSignature
92
- })
93
-
94
- expect(userOpHash).toBeTruthy()
95
-
96
- const receipt = await safeAccountClient.waitForUserOperationReceipt({
97
- hash: await userOpHash
98
- })
99
-
100
- expect(receipt).toBeTruthy()
101
- expect(receipt.success).toBeTruthy()
102
- })
103
-
104
- testWithRpc("signUserOperation_V07", async ({ rpc }) => {
105
- const owners = [
106
- privateKeyToAccount(generatePrivateKey()),
107
- privateKeyToAccount(generatePrivateKey()),
108
- privateKeyToAccount(generatePrivateKey())
109
- ]
110
-
111
- const safeAccountClient = getBundlerClient({
112
- account: await getSafeClient({
113
- ...rpc,
114
- entryPoint: {
115
- version: "0.7"
116
- },
117
- owners: owners.map((owner) => toAccount(owner.address))
118
- }),
119
- entryPoint: {
120
- version: "0.7"
121
- },
122
- ...rpc
123
- })
124
-
125
- const unSignedUserOperation =
126
- await safeAccountClient.prepareUserOperation({
127
- calls: [
128
- {
129
- to: safeAccountClient.account.address,
130
- data: "0x"
131
- }
132
- ]
133
- })
134
-
135
- let partialSignatures = await signUserOperation({
136
- version: "1.4.1",
137
- entryPoint: {
138
- address: entryPoint07Address,
139
- version: "0.7"
140
- },
141
- chainId: foundry.id,
142
- owners: owners.map((owner) => toAccount(owner.address)),
143
- account: owners[0],
144
- ...unSignedUserOperation
145
- })
146
-
147
- partialSignatures = await signUserOperation({
148
- version: "1.4.1",
149
- entryPoint: {
150
- address: entryPoint07Address,
151
- version: "0.7"
152
- },
153
- chainId: foundry.id,
154
- owners: owners.map((owner) => toAccount(owner.address)),
155
- account: owners[1],
156
- signatures: partialSignatures,
157
- ...unSignedUserOperation
158
- })
159
-
160
- const finalSignature = await signUserOperation({
161
- version: "1.4.1",
162
- entryPoint: {
163
- address: entryPoint07Address,
164
- version: "0.7"
165
- },
166
- chainId: foundry.id,
167
- owners: owners.map((owner) => toAccount(owner.address)),
168
- account: owners[2],
169
- signatures: partialSignatures,
170
- ...unSignedUserOperation
171
- })
172
-
173
- const userOpHash = safeAccountClient.sendUserOperation({
174
- ...unSignedUserOperation,
175
- signature: finalSignature
176
- })
177
-
178
- expect(userOpHash).toBeTruthy()
179
-
180
- const receipt = await safeAccountClient.waitForUserOperationReceipt({
181
- hash: await userOpHash
182
- })
183
-
184
- expect(receipt).toBeTruthy()
185
- expect(receipt.success).toBeTruthy()
186
- })
187
-
188
- testWithRpc("signUserOperation_V07 7579", async ({ rpc }) => {
189
- const owners = [
190
- privateKeyToAccount(generatePrivateKey()),
191
- privateKeyToAccount(generatePrivateKey()),
192
- privateKeyToAccount(generatePrivateKey())
193
- ]
194
-
195
- const safeAccountClient = getBundlerClient({
196
- account: await getSafeClient({
197
- ...rpc,
198
- entryPoint: {
199
- version: "0.7"
200
- },
201
- owners: owners.map((owner) => toAccount(owner.address)),
202
- erc7579: true
203
- }),
204
- entryPoint: {
205
- version: "0.7"
206
- },
207
- ...rpc
208
- })
209
-
210
- const unSignedUserOperation =
211
- await safeAccountClient.prepareUserOperation({
212
- calls: [
213
- {
214
- to: safeAccountClient.account.address,
215
- data: "0x"
216
- }
217
- ]
218
- })
219
-
220
- let partialSignatures = await signUserOperation({
221
- version: "1.4.1",
222
- entryPoint: {
223
- address: entryPoint07Address,
224
- version: "0.7"
225
- },
226
- chainId: foundry.id,
227
- owners: owners.map((owner) => toAccount(owner.address)),
228
- account: owners[0],
229
- safe4337ModuleAddress: "0x7579EE8307284F293B1927136486880611F20002",
230
- ...unSignedUserOperation
231
- })
232
-
233
- partialSignatures = await signUserOperation({
234
- version: "1.4.1",
235
- entryPoint: {
236
- address: entryPoint07Address,
237
- version: "0.7"
238
- },
239
- chainId: foundry.id,
240
- owners: owners.map((owner) => toAccount(owner.address)),
241
- account: owners[1],
242
- signatures: partialSignatures,
243
- safe4337ModuleAddress: "0x7579EE8307284F293B1927136486880611F20002",
244
- ...unSignedUserOperation
245
- })
246
-
247
- const finalSignature = await signUserOperation({
248
- version: "1.4.1",
249
- entryPoint: {
250
- address: entryPoint07Address,
251
- version: "0.7"
252
- },
253
- chainId: foundry.id,
254
- owners: owners.map((owner) => toAccount(owner.address)),
255
- account: owners[2],
256
- signatures: partialSignatures,
257
- safe4337ModuleAddress: "0x7579EE8307284F293B1927136486880611F20002",
258
- ...unSignedUserOperation
259
- })
260
-
261
- const userOpHash = safeAccountClient.sendUserOperation({
262
- ...unSignedUserOperation,
263
- signature: finalSignature
264
- })
265
-
266
- expect(userOpHash).toBeTruthy()
267
-
268
- const receipt = await safeAccountClient.waitForUserOperationReceipt({
269
- hash: await userOpHash
270
- })
271
-
272
- expect(receipt).toBeTruthy()
273
- expect(receipt.success).toBeTruthy()
274
- })
275
- })
@@ -1,39 +0,0 @@
1
- import { zeroAddress } from "viem"
2
- import { describe, expect } from "vitest"
3
- import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
4
- import { getCoreSmartAccounts } from "../../../permissionless-test/src/utils"
5
- import { accountId } from "./accountId"
6
-
7
- describe.each(getCoreSmartAccounts())(
8
- "accountId $name",
9
- ({ getErc7579SmartAccountClient }) => {
10
- testWithRpc.skipIf(!getErc7579SmartAccountClient)(
11
- "accountId",
12
- async ({ rpc }) => {
13
- if (!getErc7579SmartAccountClient) {
14
- throw new Error("getErc7579SmartAccountClient not defined")
15
- }
16
-
17
- const smartClient = await getErc7579SmartAccountClient({
18
- entryPoint: {
19
- version: "0.7"
20
- },
21
- ...rpc
22
- })
23
-
24
- const accountIdBeforeDeploy = await accountId(smartClient)
25
-
26
- // deploy account
27
- await smartClient.sendTransaction({
28
- to: zeroAddress,
29
- value: 0n,
30
- data: "0x"
31
- })
32
-
33
- const postDeployAccountId = await accountId(smartClient)
34
-
35
- expect(accountIdBeforeDeploy).toBe(postDeployAccountId)
36
- }
37
- )
38
- }
39
- )
@@ -1,214 +0,0 @@
1
- import { encodeAbiParameters, encodePacked, isHash, zeroAddress } from "viem"
2
- import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"
3
- import { describe, expect } from "vitest"
4
- import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
5
- import {
6
- getCoreSmartAccounts,
7
- getPublicClient
8
- } from "../../../permissionless-test/src/utils"
9
- import { erc7579Actions } from "../erc7579"
10
- import { installModule } from "./installModule"
11
-
12
- describe.each(getCoreSmartAccounts())(
13
- "installModule $name",
14
- ({ getErc7579SmartAccountClient, name, isEip7702Compliant }) => {
15
- testWithRpc.skipIf(!getErc7579SmartAccountClient)(
16
- "installModule",
17
- async ({ rpc }) => {
18
- if (!getErc7579SmartAccountClient) {
19
- throw new Error("getErc7579SmartAccountClient not defined")
20
- }
21
-
22
- const privateKey = generatePrivateKey()
23
-
24
- const privateKeyAccount = privateKeyToAccount(privateKey)
25
-
26
- const smartClientWithoutExtend =
27
- await getErc7579SmartAccountClient({
28
- entryPoint: {
29
- version: "0.7"
30
- },
31
- privateKey,
32
- ...rpc
33
- })
34
-
35
- const publicClient = getPublicClient(rpc.anvilRpc)
36
-
37
- const smartClient = smartClientWithoutExtend.extend(
38
- erc7579Actions()
39
- )
40
-
41
- const moduleData = encodePacked(
42
- ["address"],
43
- [smartClient.account.address]
44
- )
45
-
46
- const opHash = await installModule(smartClient, {
47
- account: smartClient.account,
48
- type: "executor",
49
- address: "0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
50
- initData: name.startsWith("Kernel 7579")
51
- ? encodePacked(
52
- ["address", "bytes"],
53
- [
54
- zeroAddress,
55
- encodeAbiParameters(
56
- [{ type: "bytes" }, { type: "bytes" }],
57
- [moduleData, "0x"]
58
- )
59
- ]
60
- )
61
- : moduleData,
62
- authorization: isEip7702Compliant
63
- ? await privateKeyAccount.signAuthorization({
64
- address: (smartClient.account as any)
65
- .implementation,
66
- chainId: smartClient.chain.id,
67
- nonce: await publicClient.getTransactionCount({
68
- address: smartClient.account.address
69
- })
70
- })
71
- : undefined
72
- })
73
-
74
- expect(isHash(opHash)).toBe(true)
75
-
76
- const userOperationReceipt =
77
- await smartClient.waitForUserOperationReceipt({
78
- hash: opHash,
79
- timeout: 100000
80
- })
81
-
82
- expect(userOperationReceipt).not.toBeNull()
83
- expect(userOperationReceipt?.userOpHash).toBe(opHash)
84
- expect(
85
- userOperationReceipt?.receipt.transactionHash
86
- ).toBeTruthy()
87
-
88
- const receipt = await smartClient.getUserOperationReceipt({
89
- hash: opHash
90
- })
91
-
92
- expect(receipt?.receipt.transactionHash).toBe(
93
- userOperationReceipt?.receipt.transactionHash
94
- )
95
-
96
- const isModuleInstalled = await smartClient.isModuleInstalled({
97
- type: "executor",
98
- address: "0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
99
- context: "0x"
100
- })
101
-
102
- expect(isModuleInstalled).toBe(true)
103
- }
104
- )
105
- testWithRpc.skipIf(!getErc7579SmartAccountClient)(
106
- "installModule post deployment",
107
- async ({ rpc }) => {
108
- if (!getErc7579SmartAccountClient) {
109
- throw new Error("getErc7579SmartAccountClient not defined")
110
- }
111
-
112
- const privateKey = generatePrivateKey()
113
-
114
- const privateKeyAccount = privateKeyToAccount(privateKey)
115
-
116
- const smartClientWithoutExtend =
117
- await getErc7579SmartAccountClient({
118
- entryPoint: {
119
- version: "0.7"
120
- },
121
- privateKey,
122
- ...rpc
123
- })
124
-
125
- const publicClient = getPublicClient(rpc.anvilRpc)
126
-
127
- const smartClient = smartClientWithoutExtend.extend(
128
- erc7579Actions()
129
- )
130
-
131
- const userOpHash = await smartClient.sendUserOperation({
132
- calls: [
133
- {
134
- to: smartClient.account.address,
135
- value: 0n,
136
- data: "0x"
137
- },
138
- {
139
- to: smartClient.account.address,
140
- value: 0n,
141
- data: "0x"
142
- }
143
- ],
144
- authorization: isEip7702Compliant
145
- ? await privateKeyAccount.signAuthorization({
146
- address: (smartClient.account as any)
147
- .implementation,
148
- chainId: smartClient.chain.id,
149
- nonce: await publicClient.getTransactionCount({
150
- address: smartClient.account.address
151
- })
152
- })
153
- : undefined
154
- })
155
-
156
- await smartClient.waitForUserOperationReceipt({
157
- hash: userOpHash
158
- })
159
-
160
- const moduleData = encodePacked(
161
- ["address"],
162
- [smartClient.account.address]
163
- )
164
-
165
- const opHash = await installModule(smartClient, {
166
- account: smartClient.account,
167
- type: "executor",
168
- address: "0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
169
- context: name.startsWith("Kernel 7579")
170
- ? encodePacked(
171
- ["address", "bytes"],
172
- [
173
- zeroAddress,
174
- encodeAbiParameters(
175
- [{ type: "bytes" }, { type: "bytes" }],
176
- [moduleData, "0x"]
177
- )
178
- ]
179
- )
180
- : moduleData
181
- })
182
-
183
- expect(isHash(opHash)).toBe(true)
184
-
185
- const userOperationReceipt =
186
- await smartClient.waitForUserOperationReceipt({
187
- hash: opHash,
188
- timeout: 100000
189
- })
190
- expect(userOperationReceipt).not.toBeNull()
191
- expect(userOperationReceipt?.userOpHash).toBe(opHash)
192
- expect(
193
- userOperationReceipt?.receipt.transactionHash
194
- ).toBeTruthy()
195
-
196
- const receipt = await smartClient.getUserOperationReceipt({
197
- hash: opHash
198
- })
199
-
200
- expect(receipt?.receipt.transactionHash).toBe(
201
- userOperationReceipt?.receipt.transactionHash
202
- )
203
-
204
- const isModuleInstalled = await smartClient.isModuleInstalled({
205
- type: "executor",
206
- address: "0x4Fd8d57b94966982B62e9588C27B4171B55E8354",
207
- context: "0x"
208
- })
209
-
210
- expect(isModuleInstalled).toBe(true)
211
- }
212
- )
213
- }
214
- )