permissionless 0.3.6 → 0.4.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 (229) hide show
  1. package/CHANGELOG.md +13 -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/nexus/toNexusSmartAccount.js +3 -2
  9. package/_cjs/accounts/nexus/toNexusSmartAccount.js.map +1 -1
  10. package/_cjs/accounts/safe/signUserOperation.js +14 -1
  11. package/_cjs/accounts/safe/signUserOperation.js.map +1 -1
  12. package/_cjs/accounts/safe/toSafeSmartAccount.js +6 -4
  13. package/_cjs/accounts/safe/toSafeSmartAccount.js.map +1 -1
  14. package/_cjs/accounts/simple/toSimpleSmartAccount.js +15 -10
  15. package/_cjs/accounts/simple/toSimpleSmartAccount.js.map +1 -1
  16. package/_cjs/accounts/thirdweb/utils/decodeCallData.js +7 -5
  17. package/_cjs/accounts/thirdweb/utils/decodeCallData.js.map +1 -1
  18. package/_cjs/accounts/trust/utils/decodeCallData.js +7 -5
  19. package/_cjs/accounts/trust/utils/decodeCallData.js.map +1 -1
  20. package/_cjs/actions/{erc7579.js → erc7579/index.js} +9 -9
  21. package/_cjs/actions/erc7579/index.js.map +1 -0
  22. package/_cjs/actions/{etherspot.js → etherspot/index.js} +2 -2
  23. package/_cjs/actions/etherspot/index.js.map +1 -0
  24. package/_cjs/actions/{passkeyServer.js → passkeyServer/index.js} +4 -4
  25. package/_cjs/actions/passkeyServer/index.js.map +1 -0
  26. package/_cjs/actions/pimlico/estimateErc20PaymasterCost.js +7 -3
  27. package/_cjs/actions/pimlico/estimateErc20PaymasterCost.js.map +1 -1
  28. package/_cjs/actions/{pimlico.js → pimlico/index.js} +8 -8
  29. package/_cjs/actions/pimlico/index.js.map +1 -0
  30. package/_cjs/actions/{smartAccount.js → smartAccount/index.js} +5 -5
  31. package/_cjs/actions/smartAccount/index.js.map +1 -0
  32. package/_cjs/clients/createSmartAccountClient.js.map +1 -1
  33. package/_cjs/clients/decorators/pimlico.js +4 -4
  34. package/_cjs/clients/decorators/pimlico.js.map +1 -1
  35. package/_cjs/clients/{passkeyServer.js → passkeyServer/index.js} +2 -2
  36. package/_cjs/clients/passkeyServer/index.js.map +1 -0
  37. package/_cjs/clients/{pimlico.js → pimlico/index.js} +2 -2
  38. package/_cjs/clients/pimlico/index.js.map +1 -0
  39. package/_cjs/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js +6 -5
  40. package/_cjs/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
  41. package/_cjs/utils/index.js +3 -1
  42. package/_cjs/utils/index.js.map +1 -1
  43. package/_cjs/utils/sortAddresses.js +16 -0
  44. package/_cjs/utils/sortAddresses.js.map +1 -0
  45. package/_esm/accounts/biconomy/toBiconomySmartAccount.js +9 -5
  46. package/_esm/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
  47. package/_esm/accounts/kernel/toKernelSmartAccount.js +4 -0
  48. package/_esm/accounts/kernel/toKernelSmartAccount.js.map +1 -1
  49. package/_esm/accounts/light/toLightSmartAccount.js +9 -5
  50. package/_esm/accounts/light/toLightSmartAccount.js.map +1 -1
  51. package/_esm/accounts/nexus/toNexusSmartAccount.js +3 -2
  52. package/_esm/accounts/nexus/toNexusSmartAccount.js.map +1 -1
  53. package/_esm/accounts/safe/signUserOperation.js +14 -1
  54. package/_esm/accounts/safe/signUserOperation.js.map +1 -1
  55. package/_esm/accounts/safe/toSafeSmartAccount.js +6 -4
  56. package/_esm/accounts/safe/toSafeSmartAccount.js.map +1 -1
  57. package/_esm/accounts/simple/toSimpleSmartAccount.js +15 -10
  58. package/_esm/accounts/simple/toSimpleSmartAccount.js.map +1 -1
  59. package/_esm/accounts/thirdweb/utils/decodeCallData.js +7 -5
  60. package/_esm/accounts/thirdweb/utils/decodeCallData.js.map +1 -1
  61. package/_esm/accounts/trust/utils/decodeCallData.js +7 -5
  62. package/_esm/accounts/trust/utils/decodeCallData.js.map +1 -1
  63. package/_esm/actions/{erc7579.js → erc7579/index.js} +9 -9
  64. package/_esm/actions/erc7579/index.js.map +1 -0
  65. package/_esm/actions/etherspot/index.js +2 -0
  66. package/_esm/actions/etherspot/index.js.map +1 -0
  67. package/_esm/actions/passkeyServer/index.js +4 -0
  68. package/_esm/actions/passkeyServer/index.js.map +1 -0
  69. package/_esm/actions/pimlico/estimateErc20PaymasterCost.js +7 -3
  70. package/_esm/actions/pimlico/estimateErc20PaymasterCost.js.map +1 -1
  71. package/_esm/actions/pimlico/index.js +8 -0
  72. package/_esm/actions/pimlico/index.js.map +1 -0
  73. package/_esm/actions/smartAccount/index.js +5 -0
  74. package/_esm/actions/smartAccount/index.js.map +1 -0
  75. package/_esm/clients/createSmartAccountClient.js.map +1 -1
  76. package/_esm/clients/decorators/pimlico.js +1 -1
  77. package/_esm/clients/decorators/pimlico.js.map +1 -1
  78. package/_esm/clients/{passkeyServer.js → passkeyServer/index.js} +2 -2
  79. package/_esm/clients/passkeyServer/index.js.map +1 -0
  80. package/_esm/clients/{pimlico.js → pimlico/index.js} +2 -2
  81. package/_esm/clients/pimlico/index.js.map +1 -0
  82. package/_esm/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js +5 -4
  83. package/_esm/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
  84. package/_esm/utils/index.js +1 -0
  85. package/_esm/utils/index.js.map +1 -1
  86. package/_esm/utils/sortAddresses.js +19 -0
  87. package/_esm/utils/sortAddresses.js.map +1 -0
  88. package/_types/accounts/biconomy/toBiconomySmartAccount.d.ts.map +1 -1
  89. package/_types/accounts/kernel/toKernelSmartAccount.d.ts.map +1 -1
  90. package/_types/accounts/light/toLightSmartAccount.d.ts.map +1 -1
  91. package/_types/accounts/nexus/toNexusSmartAccount.d.ts.map +1 -1
  92. package/_types/accounts/safe/signUserOperation.d.ts.map +1 -1
  93. package/_types/accounts/safe/toSafeSmartAccount.d.ts.map +1 -1
  94. package/_types/accounts/simple/toSimpleSmartAccount.d.ts.map +1 -1
  95. package/_types/accounts/thirdweb/utils/decodeCallData.d.ts.map +1 -1
  96. package/_types/accounts/trust/utils/decodeCallData.d.ts.map +1 -1
  97. package/_types/actions/{erc7579.d.ts → erc7579/index.d.ts} +11 -11
  98. package/_types/actions/erc7579/index.d.ts.map +1 -0
  99. package/_types/actions/etherspot/index.d.ts +2 -0
  100. package/_types/actions/etherspot/index.d.ts.map +1 -0
  101. package/_types/actions/passkeyServer/index.d.ts +4 -0
  102. package/_types/actions/passkeyServer/index.d.ts.map +1 -0
  103. package/_types/actions/pimlico/estimateErc20PaymasterCost.d.ts.map +1 -1
  104. package/_types/actions/pimlico/index.d.ts +8 -0
  105. package/_types/actions/pimlico/index.d.ts.map +1 -0
  106. package/_types/actions/smartAccount/index.d.ts +5 -0
  107. package/_types/actions/smartAccount/index.d.ts.map +1 -0
  108. package/_types/clients/createSmartAccountClient.d.ts +9 -1
  109. package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
  110. package/_types/clients/decorators/pimlico.d.ts +1 -1
  111. package/_types/clients/decorators/pimlico.d.ts.map +1 -1
  112. package/_types/clients/{passkeyServer.d.ts → passkeyServer/index.d.ts} +8 -4
  113. package/_types/clients/passkeyServer/index.d.ts.map +1 -0
  114. package/_types/clients/pimlico/index.d.ts +21 -0
  115. package/_types/clients/pimlico/index.d.ts.map +1 -0
  116. package/_types/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.d.ts.map +1 -1
  117. package/_types/utils/index.d.ts +1 -0
  118. package/_types/utils/index.d.ts.map +1 -1
  119. package/_types/utils/sortAddresses.d.ts +9 -0
  120. package/_types/utils/sortAddresses.d.ts.map +1 -0
  121. package/accounts/biconomy/package.json +6 -0
  122. package/accounts/biconomy/toBiconomySmartAccount.ts +13 -5
  123. package/accounts/etherspot/package.json +6 -0
  124. package/accounts/kernel/package.json +6 -0
  125. package/accounts/kernel/toKernelSmartAccount.ts +7 -0
  126. package/accounts/light/package.json +6 -0
  127. package/accounts/light/toLightSmartAccount.ts +13 -5
  128. package/accounts/nexus/package.json +6 -0
  129. package/accounts/nexus/toNexusSmartAccount.ts +3 -6
  130. package/accounts/package.json +6 -0
  131. package/accounts/safe/package.json +6 -0
  132. package/accounts/safe/signUserOperation.ts +15 -3
  133. package/accounts/safe/toSafeSmartAccount.ts +7 -6
  134. package/accounts/simple/package.json +6 -0
  135. package/accounts/simple/toSimpleSmartAccount.ts +21 -10
  136. package/accounts/thirdweb/package.json +6 -0
  137. package/accounts/thirdweb/utils/decodeCallData.ts +9 -5
  138. package/accounts/trust/package.json +6 -0
  139. package/accounts/trust/utils/decodeCallData.ts +9 -5
  140. package/actions/{erc7579.ts → erc7579/index.ts} +10 -16
  141. package/actions/erc7579/package.json +6 -0
  142. package/actions/{etherspot.ts → etherspot/index.ts} +1 -1
  143. package/actions/etherspot/package.json +6 -0
  144. package/actions/{passkeyServer.ts → passkeyServer/index.ts} +3 -3
  145. package/actions/passkeyServer/package.json +6 -0
  146. package/actions/pimlico/estimateErc20PaymasterCost.ts +9 -3
  147. package/actions/{pimlico.ts → pimlico/index.ts} +7 -7
  148. package/actions/pimlico/package.json +6 -0
  149. package/actions/smartAccount/index.ts +7 -0
  150. package/actions/smartAccount/package.json +6 -0
  151. package/clients/createSmartAccountClient.ts +45 -20
  152. package/clients/decorators/pimlico.ts +10 -10
  153. package/clients/package.json +6 -0
  154. package/clients/{passkeyServer.ts → passkeyServer/index.ts} +15 -13
  155. package/clients/passkeyServer/package.json +6 -0
  156. package/clients/{pimlico.ts → pimlico/index.ts} +50 -23
  157. package/clients/pimlico/package.json +6 -0
  158. package/errors/package.json +6 -0
  159. package/experimental/pimlico/package.json +6 -0
  160. package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts +6 -4
  161. package/package.json +34 -29
  162. package/utils/index.ts +1 -0
  163. package/utils/package.json +6 -0
  164. package/utils/sortAddresses.ts +21 -0
  165. package/_cjs/actions/erc7579.js.map +0 -1
  166. package/_cjs/actions/etherspot.js.map +0 -1
  167. package/_cjs/actions/passkeyServer.js.map +0 -1
  168. package/_cjs/actions/pimlico.js.map +0 -1
  169. package/_cjs/actions/smartAccount.js.map +0 -1
  170. package/_cjs/clients/passkeyServer.js.map +0 -1
  171. package/_cjs/clients/pimlico.js.map +0 -1
  172. package/_esm/actions/erc7579.js.map +0 -1
  173. package/_esm/actions/etherspot.js +0 -2
  174. package/_esm/actions/etherspot.js.map +0 -1
  175. package/_esm/actions/passkeyServer.js +0 -4
  176. package/_esm/actions/passkeyServer.js.map +0 -1
  177. package/_esm/actions/pimlico.js +0 -8
  178. package/_esm/actions/pimlico.js.map +0 -1
  179. package/_esm/actions/smartAccount.js +0 -5
  180. package/_esm/actions/smartAccount.js.map +0 -1
  181. package/_esm/clients/passkeyServer.js.map +0 -1
  182. package/_esm/clients/pimlico.js.map +0 -1
  183. package/_types/actions/erc7579.d.ts.map +0 -1
  184. package/_types/actions/etherspot.d.ts +0 -2
  185. package/_types/actions/etherspot.d.ts.map +0 -1
  186. package/_types/actions/passkeyServer.d.ts +0 -4
  187. package/_types/actions/passkeyServer.d.ts.map +0 -1
  188. package/_types/actions/pimlico.d.ts +0 -8
  189. package/_types/actions/pimlico.d.ts.map +0 -1
  190. package/_types/actions/smartAccount.d.ts +0 -5
  191. package/_types/actions/smartAccount.d.ts.map +0 -1
  192. package/_types/clients/passkeyServer.d.ts.map +0 -1
  193. package/_types/clients/pimlico.d.ts +0 -13
  194. package/_types/clients/pimlico.d.ts.map +0 -1
  195. package/accounts/decodeCalls.test.ts +0 -505
  196. package/accounts/safe/signUserOperation.test.ts +0 -275
  197. package/actions/erc7579/accountId.test.ts +0 -39
  198. package/actions/erc7579/installModule.test.ts +0 -214
  199. package/actions/erc7579/installModules.test.ts +0 -235
  200. package/actions/erc7579/isModuleInstalled.test.ts +0 -72
  201. package/actions/erc7579/supportsExecutionMode.test.ts +0 -108
  202. package/actions/erc7579/supportsModule.test.ts +0 -35
  203. package/actions/erc7579/uninstallModule.test.ts +0 -128
  204. package/actions/erc7579/uninstallModules.test.ts +0 -117
  205. package/actions/pimlico/getTokenQuotes.test.ts +0 -90
  206. package/actions/pimlico/getUserOperationGasPrice.test.ts +0 -82
  207. package/actions/pimlico/getUserOperationStatus.test.ts +0 -223
  208. package/actions/pimlico/sponsorUserOperation.test.ts +0 -236
  209. package/actions/pimlico/validateSponsorshipPolicies.test.ts +0 -153
  210. package/actions/public/getAccountNonce.test.ts +0 -96
  211. package/actions/public/getSenderAddress.test.ts +0 -154
  212. package/actions/smartAccount/getCallsStatus.test.ts +0 -253
  213. package/actions/smartAccount/sendCalls.test.ts +0 -569
  214. package/actions/smartAccount/sendTransaction.test.ts +0 -414
  215. package/actions/smartAccount/signMessage.test.ts +0 -217
  216. package/actions/smartAccount/signTypedData.test.ts +0 -226
  217. package/actions/smartAccount.ts +0 -7
  218. package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +0 -574
  219. package/types/package.json +0 -6
  220. package/utils/decodeNonce.test.ts +0 -40
  221. package/utils/deepHexlify.test.ts +0 -57
  222. package/utils/encode7579Calls.test.ts +0 -69
  223. package/utils/encodeNonce.test.ts +0 -38
  224. package/utils/erc20AllowanceOverride.test.ts +0 -59
  225. package/utils/erc20BalanceOverride.test.ts +0 -57
  226. package/utils/getAddressFromInitCodeOrPaymasterAndData.test.ts +0 -31
  227. package/utils/getPackedUserOperation.test.ts +0 -204
  228. package/utils/getRequiredPrefund.test.ts +0 -90
  229. package/vitest.config.ts +0 -41
@@ -1,236 +0,0 @@
1
- import { isHash, zeroAddress } from "viem"
2
- import {
3
- type UserOperation,
4
- entryPoint06Address,
5
- entryPoint07Address,
6
- entryPoint08Address
7
- } from "viem/account-abstraction"
8
- import { describe, expect } from "vitest"
9
- import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
10
- import {
11
- getBundlerClient,
12
- getPimlicoClient,
13
- getSimpleAccountClient
14
- } from "../../../permissionless-test/src/utils"
15
- import { sponsorUserOperation } from "./sponsorUserOperation"
16
-
17
- describe("sponsorUserOperation", () => {
18
- testWithRpc("sponsorUserOperation_V06", async ({ rpc }) => {
19
- const { altoRpc, paymasterRpc } = rpc
20
-
21
- const bundlerClient = getPimlicoClient({
22
- entryPointVersion: "0.6",
23
- altoRpc: altoRpc
24
- })
25
-
26
- const simpleAccountClient = getBundlerClient({
27
- account: await getSimpleAccountClient({
28
- ...rpc,
29
- entryPoint: {
30
- version: "0.6"
31
- }
32
- }),
33
- entryPoint: {
34
- version: "0.6"
35
- },
36
- ...rpc
37
- })
38
-
39
- const preparedUserOp = await simpleAccountClient.prepareUserOperation({
40
- calls: [
41
- {
42
- to: zeroAddress,
43
- data: "0x",
44
- value: 0n
45
- }
46
- ]
47
- })
48
-
49
- const paymasterClient = getPimlicoClient({
50
- entryPointVersion: "0.6",
51
- altoRpc: paymasterRpc
52
- })
53
-
54
- const sponsorResult = await sponsorUserOperation(paymasterClient, {
55
- userOperation: preparedUserOp,
56
- entryPoint: {
57
- address: entryPoint06Address,
58
- version: "0.6"
59
- }
60
- })
61
-
62
- const finalUserOp = {
63
- ...preparedUserOp,
64
- ...sponsorResult
65
- }
66
- const account = simpleAccountClient.account
67
- finalUserOp.signature = await account.signUserOperation(finalUserOp)
68
-
69
- const opHash = await simpleAccountClient.sendUserOperation(finalUserOp)
70
-
71
- expect(isHash(opHash)).toBe(true)
72
-
73
- const userOperationReceipt =
74
- await bundlerClient.waitForUserOperationReceipt({
75
- hash: opHash,
76
- timeout: 100000
77
- })
78
- expect(userOperationReceipt).not.toBeNull()
79
- expect(userOperationReceipt?.userOpHash).toBe(opHash)
80
- expect(userOperationReceipt?.receipt.transactionHash).toBeTruthy()
81
-
82
- const receipt = await bundlerClient.getUserOperationReceipt({
83
- hash: opHash
84
- })
85
-
86
- expect(receipt?.receipt.transactionHash).toBe(
87
- userOperationReceipt?.receipt.transactionHash
88
- )
89
- })
90
-
91
- testWithRpc("sponsorUserOperation_V07", async ({ rpc }) => {
92
- const { altoRpc, paymasterRpc } = rpc
93
-
94
- const bundlerClient = getPimlicoClient({
95
- entryPointVersion: "0.7",
96
- altoRpc: altoRpc
97
- })
98
-
99
- const simpleAccountClient = getBundlerClient({
100
- account: await getSimpleAccountClient({
101
- ...rpc,
102
- entryPoint: {
103
- version: "0.7"
104
- }
105
- }),
106
- entryPoint: {
107
- version: "0.7"
108
- },
109
- ...rpc
110
- })
111
-
112
- const preparedUserOp = await simpleAccountClient.prepareUserOperation({
113
- calls: [
114
- {
115
- to: zeroAddress,
116
- data: "0x",
117
- value: 0n
118
- }
119
- ]
120
- })
121
-
122
- const paymasterClient = getPimlicoClient({
123
- entryPointVersion: "0.7",
124
- altoRpc: paymasterRpc
125
- })
126
-
127
- const sponsorResult = await sponsorUserOperation(paymasterClient, {
128
- userOperation: preparedUserOp,
129
- entryPoint: {
130
- address: entryPoint07Address,
131
- version: "0.7"
132
- }
133
- })
134
-
135
- const finalUserOp = {
136
- ...preparedUserOp,
137
- ...sponsorResult
138
- }
139
- const account = simpleAccountClient.account
140
- finalUserOp.signature = await account.signUserOperation(finalUserOp)
141
-
142
- const opHash = await simpleAccountClient.sendUserOperation(finalUserOp)
143
-
144
- expect(isHash(opHash)).toBe(true)
145
-
146
- const userOperationReceipt =
147
- await bundlerClient.waitForUserOperationReceipt({
148
- hash: opHash,
149
- timeout: 100000
150
- })
151
- expect(userOperationReceipt).not.toBeNull()
152
- expect(userOperationReceipt?.userOpHash).toBe(opHash)
153
- expect(userOperationReceipt?.receipt.transactionHash).toBeTruthy()
154
-
155
- const receipt = await bundlerClient.getUserOperationReceipt({
156
- hash: opHash
157
- })
158
-
159
- expect(receipt?.receipt.transactionHash).toBe(
160
- userOperationReceipt?.receipt.transactionHash
161
- )
162
- })
163
-
164
- testWithRpc("sponsorUserOperation_V08", async ({ rpc }) => {
165
- const { altoRpc, paymasterRpc } = rpc
166
-
167
- const bundlerClient = getPimlicoClient({
168
- entryPointVersion: "0.8",
169
- altoRpc: altoRpc
170
- })
171
-
172
- const simpleAccountClient = getBundlerClient({
173
- account: await getSimpleAccountClient({
174
- ...rpc,
175
- entryPoint: {
176
- version: "0.8"
177
- }
178
- }),
179
- entryPoint: {
180
- version: "0.8"
181
- },
182
- ...rpc
183
- })
184
-
185
- const preparedUserOp = (await simpleAccountClient.prepareUserOperation({
186
- calls: [
187
- {
188
- to: zeroAddress,
189
- data: "0x",
190
- value: 0n
191
- }
192
- ]
193
- })) as UserOperation<"0.8">
194
-
195
- const paymasterClient = getPimlicoClient({
196
- entryPointVersion: "0.8",
197
- altoRpc: paymasterRpc
198
- })
199
-
200
- const sponsorResult = await sponsorUserOperation(paymasterClient, {
201
- userOperation: preparedUserOp,
202
- entryPoint: {
203
- address: entryPoint08Address,
204
- version: "0.8"
205
- }
206
- })
207
-
208
- const finalUserOp = {
209
- ...preparedUserOp,
210
- ...sponsorResult
211
- }
212
- const account = simpleAccountClient.account
213
- finalUserOp.signature = await account.signUserOperation(finalUserOp)
214
-
215
- const opHash = await simpleAccountClient.sendUserOperation(finalUserOp)
216
-
217
- expect(isHash(opHash)).toBe(true)
218
-
219
- const userOperationReceipt =
220
- await bundlerClient.waitForUserOperationReceipt({
221
- hash: opHash,
222
- timeout: 100000
223
- })
224
- expect(userOperationReceipt).not.toBeNull()
225
- expect(userOperationReceipt?.userOpHash).toBe(opHash)
226
- expect(userOperationReceipt?.receipt.transactionHash).toBeTruthy()
227
-
228
- const receipt = await bundlerClient.getUserOperationReceipt({
229
- hash: opHash
230
- })
231
-
232
- expect(receipt?.receipt.transactionHash).toBe(
233
- userOperationReceipt?.receipt.transactionHash
234
- )
235
- })
236
- })
@@ -1,153 +0,0 @@
1
- import {
2
- entryPoint06Address,
3
- entryPoint07Address,
4
- entryPoint08Address
5
- } from "viem/account-abstraction"
6
- import { describe, expect } from "vitest"
7
- import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
8
- import {
9
- getBundlerClient,
10
- getPimlicoClient,
11
- getSimpleAccountClient
12
- } from "../../../permissionless-test/src/utils"
13
- import { validateSponsorshipPolicies } from "./validateSponsorshipPolicies"
14
-
15
- describe("validateSponsorshipPolicies", () => {
16
- testWithRpc("Validating sponsorship policies V06", async ({ rpc }) => {
17
- const { paymasterRpc } = rpc
18
-
19
- const simpleAccountClient = getBundlerClient({
20
- account: await getSimpleAccountClient({
21
- ...rpc,
22
- entryPoint: {
23
- version: "0.6"
24
- }
25
- }),
26
- entryPoint: {
27
- version: "0.6"
28
- },
29
- ...rpc
30
- })
31
-
32
- const userOperation = await simpleAccountClient.prepareUserOperation({
33
- calls: [
34
- {
35
- to: "0x5af0d9827e0c53e4799bb226655a1de152a425a5",
36
- data: "0x",
37
- value: 0n
38
- }
39
- ]
40
- })
41
-
42
- const pimlicoPaymasterClient = getPimlicoClient({
43
- entryPointVersion: "0.6",
44
- altoRpc: paymasterRpc
45
- })
46
-
47
- const policies = await validateSponsorshipPolicies(
48
- pimlicoPaymasterClient,
49
- {
50
- entryPointAddress: entryPoint06Address,
51
- userOperation: userOperation,
52
- sponsorshipPolicyIds: ["sp_crazy_kangaroo"]
53
- }
54
- )
55
-
56
- expect(policies).toBeTruthy()
57
- expect(policies.length).toBeGreaterThan(0)
58
- expect(Array.isArray(policies)).toBe(true)
59
- expect(policies.length).toBe(1)
60
- })
61
-
62
- testWithRpc("Validating sponsorship policies V07", async ({ rpc }) => {
63
- const { paymasterRpc } = rpc
64
-
65
- const simpleAccountClient = getBundlerClient({
66
- account: await getSimpleAccountClient({
67
- ...rpc,
68
- entryPoint: {
69
- version: "0.7"
70
- }
71
- }),
72
- entryPoint: {
73
- version: "0.7"
74
- },
75
- ...rpc
76
- })
77
-
78
- const userOperation = await simpleAccountClient.prepareUserOperation({
79
- calls: [
80
- {
81
- to: "0x5af0d9827e0c53e4799bb226655a1de152a425a5",
82
- data: "0x",
83
- value: 0n
84
- }
85
- ]
86
- })
87
-
88
- const pimlicoPaymasterClient = getPimlicoClient({
89
- entryPointVersion: "0.7",
90
- altoRpc: paymasterRpc
91
- })
92
-
93
- const policies = await validateSponsorshipPolicies(
94
- pimlicoPaymasterClient,
95
- {
96
- entryPointAddress: entryPoint07Address,
97
- userOperation: userOperation,
98
- sponsorshipPolicyIds: ["sp_crazy_kangaroo"]
99
- }
100
- )
101
-
102
- expect(policies).toBeTruthy()
103
- expect(policies.length).toBeGreaterThan(0)
104
- expect(Array.isArray(policies)).toBe(true)
105
- expect(policies.length).toBe(1)
106
- })
107
-
108
- testWithRpc("Validating sponsorship policies V08", async ({ rpc }) => {
109
- const { paymasterRpc } = rpc
110
-
111
- const simpleAccountClient = getBundlerClient({
112
- account: await getSimpleAccountClient({
113
- ...rpc,
114
- entryPoint: {
115
- version: "0.8"
116
- }
117
- }),
118
- entryPoint: {
119
- version: "0.8"
120
- },
121
- ...rpc
122
- })
123
-
124
- const userOperation = await simpleAccountClient.prepareUserOperation({
125
- calls: [
126
- {
127
- to: "0x5af0d9827e0c53e4799bb226655a1de152a425a5",
128
- data: "0x",
129
- value: 0n
130
- }
131
- ]
132
- })
133
-
134
- const pimlicoPaymasterClient = getPimlicoClient({
135
- entryPointVersion: "0.8",
136
- altoRpc: paymasterRpc
137
- })
138
-
139
- const policies = await validateSponsorshipPolicies(
140
- pimlicoPaymasterClient,
141
- {
142
- entryPointAddress: entryPoint08Address,
143
- userOperation: userOperation,
144
- sponsorshipPolicyIds: ["sp_crazy_kangaroo"]
145
- }
146
- )
147
-
148
- expect(policies).toBeTruthy()
149
- expect(policies.length).toBeGreaterThan(0)
150
- expect(Array.isArray(policies)).toBe(true)
151
- expect(policies.length).toBe(1)
152
- })
153
- })
@@ -1,96 +0,0 @@
1
- import { http, createPublicClient } from "viem"
2
- import {
3
- entryPoint06Address,
4
- entryPoint07Address
5
- } from "viem/account-abstraction"
6
- import { describe, expect } from "vitest"
7
- import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
8
- import {
9
- getBundlerClient,
10
- getSimpleAccountClient
11
- } from "../../../permissionless-test/src/utils"
12
- import { getAccountNonce } from "./getAccountNonce"
13
-
14
- describe("getAccountNonce", () => {
15
- testWithRpc("getAccountNonce_V06", async ({ rpc }) => {
16
- const { anvilRpc } = rpc
17
-
18
- const client = createPublicClient({
19
- transport: http(anvilRpc)
20
- })
21
-
22
- const simpleAccountClient = getBundlerClient({
23
- account: await getSimpleAccountClient({
24
- ...rpc,
25
- entryPoint: {
26
- version: "0.6"
27
- }
28
- }),
29
- entryPoint: {
30
- version: "0.6"
31
- },
32
- ...rpc
33
- })
34
-
35
- const nonce = await getAccountNonce(client, {
36
- entryPointAddress: entryPoint06Address,
37
- address: simpleAccountClient.account.address
38
- })
39
-
40
- expect(nonce).toBe(0n)
41
- })
42
- testWithRpc("getAccountNonce_V07", async ({ rpc }) => {
43
- const { anvilRpc } = rpc
44
-
45
- const client = createPublicClient({
46
- transport: http(anvilRpc)
47
- })
48
-
49
- const simpleAccountClient = getBundlerClient({
50
- account: await getSimpleAccountClient({
51
- ...rpc,
52
- entryPoint: {
53
- version: "0.7"
54
- }
55
- }),
56
- entryPoint: {
57
- version: "0.7"
58
- },
59
- ...rpc
60
- })
61
-
62
- const nonce = await getAccountNonce(client, {
63
- entryPointAddress: entryPoint07Address,
64
- address: simpleAccountClient.account.address
65
- })
66
-
67
- expect(nonce).toBe(0n)
68
- })
69
- testWithRpc("getAccountNonce_V08", async ({ rpc }) => {
70
- const { anvilRpc } = rpc
71
-
72
- const client = createPublicClient({
73
- transport: http(anvilRpc)
74
- })
75
-
76
- const simpleAccountClient = getBundlerClient({
77
- account: await getSimpleAccountClient({
78
- ...rpc,
79
- entryPoint: {
80
- version: "0.8"
81
- }
82
- }),
83
- entryPoint: {
84
- version: "0.8"
85
- },
86
- ...rpc
87
- })
88
-
89
- const nonce = await getAccountNonce(client, {
90
- entryPointAddress: entryPoint07Address,
91
- address: simpleAccountClient.account.address
92
- })
93
-
94
- expect(nonce).toBe(0n)
95
- })
96
- })
@@ -1,154 +0,0 @@
1
- import { http, concatHex, createPublicClient } from "viem"
2
- import {
3
- entryPoint06Address,
4
- entryPoint07Address,
5
- entryPoint08Address
6
- } from "viem/account-abstraction"
7
- import { describe, expect } from "vitest"
8
- import { testWithRpc } from "../../../permissionless-test/src/testWithRpc"
9
- import {
10
- getBundlerClient,
11
- getSimpleAccountClient
12
- } from "../../../permissionless-test/src/utils"
13
- import { getSenderAddress } from "./getSenderAddress"
14
-
15
- describe("getSenderAddress", () => {
16
- testWithRpc("getSenderAddress_V06", async ({ rpc }) => {
17
- const { anvilRpc } = rpc
18
-
19
- const client = createPublicClient({
20
- transport: http(anvilRpc)
21
- })
22
-
23
- const simpleAccountClient = getBundlerClient({
24
- account: await getSimpleAccountClient({
25
- ...rpc,
26
- entryPoint: {
27
- version: "0.6"
28
- }
29
- }),
30
- entryPoint: {
31
- version: "0.6"
32
- },
33
- ...rpc
34
- })
35
-
36
- const { factory, factoryData } =
37
- await simpleAccountClient.account.getFactoryArgs()
38
-
39
- if (!factory || !factoryData) {
40
- throw new Error("Init code not found")
41
- }
42
-
43
- const address = await getSenderAddress(client, {
44
- entryPointAddress: entryPoint06Address,
45
- initCode: concatHex([factory, factoryData])
46
- })
47
-
48
- expect(address).toBe(simpleAccountClient.account.address)
49
- })
50
- testWithRpc("getSenderAddress_V06_error", async ({ rpc }) => {
51
- const { anvilRpc } = rpc
52
-
53
- const client = createPublicClient({
54
- transport: http(anvilRpc)
55
- })
56
-
57
- const simpleAccountClient = getBundlerClient({
58
- account: await getSimpleAccountClient({
59
- ...rpc,
60
- entryPoint: {
61
- version: "0.6"
62
- }
63
- }),
64
- entryPoint: {
65
- version: "0.6"
66
- },
67
- ...rpc
68
- })
69
-
70
- const { factory, factoryData } =
71
- await simpleAccountClient.account.getFactoryArgs()
72
-
73
- if (!factory || !factoryData) {
74
- throw new Error("Init code not found")
75
- }
76
-
77
- await expect(async () =>
78
- getSenderAddress(client, {
79
- entryPointAddress: "0x0000000000000000000000000000000000000000",
80
- initCode: concatHex([factory, factoryData])
81
- })
82
- ).rejects.toThrowError()
83
- })
84
- testWithRpc("getSenderAddress_V07", async ({ rpc }) => {
85
- const { anvilRpc } = rpc
86
-
87
- const client = createPublicClient({
88
- transport: http(anvilRpc)
89
- })
90
-
91
- const simpleAccountClient = getBundlerClient({
92
- account: await getSimpleAccountClient({
93
- ...rpc,
94
- entryPoint: {
95
- version: "0.7"
96
- }
97
- }),
98
- entryPoint: {
99
- version: "0.7"
100
- },
101
- ...rpc
102
- })
103
-
104
- const { factory, factoryData } =
105
- await simpleAccountClient.account.getFactoryArgs()
106
-
107
- if (!factory || !factoryData) {
108
- throw new Error("Factory or factoryData not found")
109
- }
110
-
111
- const address = await getSenderAddress(client, {
112
- entryPointAddress: entryPoint07Address,
113
- factory,
114
- factoryData
115
- })
116
-
117
- expect(address).toBe(simpleAccountClient.account.address)
118
- })
119
- testWithRpc("getSenderAddress_V08", async ({ rpc }) => {
120
- const { anvilRpc } = rpc
121
-
122
- const client = createPublicClient({
123
- transport: http(anvilRpc)
124
- })
125
-
126
- const simpleAccountClient = getBundlerClient({
127
- account: await getSimpleAccountClient({
128
- ...rpc,
129
- entryPoint: {
130
- version: "0.8"
131
- }
132
- }),
133
- entryPoint: {
134
- version: "0.8"
135
- },
136
- ...rpc
137
- })
138
-
139
- const { factory, factoryData } =
140
- await simpleAccountClient.account.getFactoryArgs()
141
-
142
- if (!factory || !factoryData) {
143
- throw new Error("Factory or factoryData not found")
144
- }
145
-
146
- const address = await getSenderAddress(client, {
147
- entryPointAddress: entryPoint08Address,
148
- factory,
149
- factoryData
150
- })
151
-
152
- expect(address).toBe(simpleAccountClient.account.address)
153
- })
154
- })