permissionless 0.3.5 → 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 (286) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/_cjs/accounts/biconomy/index.js +8 -0
  3. package/_cjs/accounts/biconomy/index.js.map +1 -0
  4. package/_cjs/accounts/biconomy/toBiconomySmartAccount.js +9 -5
  5. package/_cjs/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
  6. package/_cjs/accounts/etherspot/index.js +8 -0
  7. package/_cjs/accounts/etherspot/index.js.map +1 -0
  8. package/_cjs/accounts/kernel/index.js +18 -0
  9. package/_cjs/accounts/kernel/index.js.map +1 -0
  10. package/_cjs/accounts/kernel/toKernelSmartAccount.js +10 -6
  11. package/_cjs/accounts/kernel/toKernelSmartAccount.js.map +1 -1
  12. package/_cjs/accounts/kernel/utils/signMessage.js +9 -7
  13. package/_cjs/accounts/kernel/utils/signMessage.js.map +1 -1
  14. package/_cjs/accounts/kernel/utils/signTypedData.js +7 -6
  15. package/_cjs/accounts/kernel/utils/signTypedData.js.map +1 -1
  16. package/_cjs/accounts/kernel/utils/wrapMessageHash.js +3 -3
  17. package/_cjs/accounts/kernel/utils/wrapMessageHash.js.map +1 -1
  18. package/_cjs/accounts/light/index.js +8 -0
  19. package/_cjs/accounts/light/index.js.map +1 -0
  20. package/_cjs/accounts/light/toLightSmartAccount.js +9 -5
  21. package/_cjs/accounts/light/toLightSmartAccount.js.map +1 -1
  22. package/_cjs/accounts/nexus/index.js +8 -0
  23. package/_cjs/accounts/nexus/index.js.map +1 -0
  24. package/_cjs/accounts/safe/signUserOperation.js +3 -0
  25. package/_cjs/accounts/safe/signUserOperation.js.map +1 -1
  26. package/_cjs/accounts/safe/toSafeSmartAccount.js +4 -3
  27. package/_cjs/accounts/safe/toSafeSmartAccount.js.map +1 -1
  28. package/_cjs/accounts/simple/index.js +10 -0
  29. package/_cjs/accounts/simple/index.js.map +1 -0
  30. package/_cjs/accounts/simple/toSimpleSmartAccount.js +15 -10
  31. package/_cjs/accounts/simple/toSimpleSmartAccount.js.map +1 -1
  32. package/_cjs/accounts/thirdweb/index.js +8 -0
  33. package/_cjs/accounts/thirdweb/index.js.map +1 -0
  34. package/_cjs/accounts/thirdweb/utils/decodeCallData.js +7 -5
  35. package/_cjs/accounts/thirdweb/utils/decodeCallData.js.map +1 -1
  36. package/_cjs/accounts/trust/index.js +8 -0
  37. package/_cjs/accounts/trust/index.js.map +1 -0
  38. package/_cjs/accounts/trust/utils/decodeCallData.js +7 -5
  39. package/_cjs/accounts/trust/utils/decodeCallData.js.map +1 -1
  40. package/_cjs/actions/{erc7579.js → erc7579/index.js} +9 -9
  41. package/_cjs/actions/erc7579/index.js.map +1 -0
  42. package/_cjs/actions/{etherspot.js → etherspot/index.js} +2 -2
  43. package/_cjs/actions/etherspot/index.js.map +1 -0
  44. package/_cjs/actions/{passkeyServer.js → passkeyServer/index.js} +4 -4
  45. package/_cjs/actions/passkeyServer/index.js.map +1 -0
  46. package/_cjs/actions/pimlico/estimateErc20PaymasterCost.js +7 -3
  47. package/_cjs/actions/pimlico/estimateErc20PaymasterCost.js.map +1 -1
  48. package/_cjs/actions/{pimlico.js → pimlico/index.js} +8 -8
  49. package/_cjs/actions/pimlico/index.js.map +1 -0
  50. package/_cjs/actions/{smartAccount.js → smartAccount/index.js} +5 -5
  51. package/_cjs/actions/smartAccount/index.js.map +1 -0
  52. package/_cjs/clients/createSmartAccountClient.js.map +1 -1
  53. package/_cjs/clients/decorators/pimlico.js +4 -4
  54. package/_cjs/clients/decorators/pimlico.js.map +1 -1
  55. package/_cjs/clients/{passkeyServer.js → passkeyServer/index.js} +2 -2
  56. package/_cjs/clients/passkeyServer/index.js.map +1 -0
  57. package/_cjs/clients/{pimlico.js → pimlico/index.js} +2 -2
  58. package/_cjs/clients/pimlico/index.js.map +1 -0
  59. package/_cjs/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js +6 -5
  60. package/_cjs/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
  61. package/_esm/accounts/biconomy/index.js +5 -0
  62. package/_esm/accounts/biconomy/index.js.map +1 -0
  63. package/_esm/accounts/biconomy/toBiconomySmartAccount.js +9 -5
  64. package/_esm/accounts/biconomy/toBiconomySmartAccount.js.map +1 -1
  65. package/_esm/accounts/etherspot/index.js +5 -0
  66. package/_esm/accounts/etherspot/index.js.map +1 -0
  67. package/_esm/accounts/kernel/index.js +15 -0
  68. package/_esm/accounts/kernel/index.js.map +1 -0
  69. package/_esm/accounts/kernel/toKernelSmartAccount.js +10 -6
  70. package/_esm/accounts/kernel/toKernelSmartAccount.js.map +1 -1
  71. package/_esm/accounts/kernel/utils/signMessage.js +9 -7
  72. package/_esm/accounts/kernel/utils/signMessage.js.map +1 -1
  73. package/_esm/accounts/kernel/utils/signTypedData.js +7 -6
  74. package/_esm/accounts/kernel/utils/signTypedData.js.map +1 -1
  75. package/_esm/accounts/kernel/utils/wrapMessageHash.js +3 -3
  76. package/_esm/accounts/kernel/utils/wrapMessageHash.js.map +1 -1
  77. package/_esm/accounts/light/index.js +5 -0
  78. package/_esm/accounts/light/index.js.map +1 -0
  79. package/_esm/accounts/light/toLightSmartAccount.js +9 -5
  80. package/_esm/accounts/light/toLightSmartAccount.js.map +1 -1
  81. package/_esm/accounts/nexus/index.js +5 -0
  82. package/_esm/accounts/nexus/index.js.map +1 -0
  83. package/_esm/accounts/safe/signUserOperation.js +3 -0
  84. package/_esm/accounts/safe/signUserOperation.js.map +1 -1
  85. package/_esm/accounts/safe/toSafeSmartAccount.js +4 -3
  86. package/_esm/accounts/safe/toSafeSmartAccount.js.map +1 -1
  87. package/_esm/accounts/simple/index.js +7 -0
  88. package/_esm/accounts/simple/index.js.map +1 -0
  89. package/_esm/accounts/simple/toSimpleSmartAccount.js +15 -10
  90. package/_esm/accounts/simple/toSimpleSmartAccount.js.map +1 -1
  91. package/_esm/accounts/thirdweb/index.js +5 -0
  92. package/_esm/accounts/thirdweb/index.js.map +1 -0
  93. package/_esm/accounts/thirdweb/utils/decodeCallData.js +7 -5
  94. package/_esm/accounts/thirdweb/utils/decodeCallData.js.map +1 -1
  95. package/_esm/accounts/trust/index.js +5 -0
  96. package/_esm/accounts/trust/index.js.map +1 -0
  97. package/_esm/accounts/trust/utils/decodeCallData.js +7 -5
  98. package/_esm/accounts/trust/utils/decodeCallData.js.map +1 -1
  99. package/_esm/actions/{erc7579.js → erc7579/index.js} +9 -9
  100. package/_esm/actions/erc7579/index.js.map +1 -0
  101. package/_esm/actions/etherspot/index.js +2 -0
  102. package/_esm/actions/etherspot/index.js.map +1 -0
  103. package/_esm/actions/passkeyServer/index.js +4 -0
  104. package/_esm/actions/passkeyServer/index.js.map +1 -0
  105. package/_esm/actions/pimlico/estimateErc20PaymasterCost.js +7 -3
  106. package/_esm/actions/pimlico/estimateErc20PaymasterCost.js.map +1 -1
  107. package/_esm/actions/pimlico/index.js +8 -0
  108. package/_esm/actions/pimlico/index.js.map +1 -0
  109. package/_esm/actions/smartAccount/index.js +5 -0
  110. package/_esm/actions/smartAccount/index.js.map +1 -0
  111. package/_esm/clients/createSmartAccountClient.js.map +1 -1
  112. package/_esm/clients/decorators/pimlico.js +1 -1
  113. package/_esm/clients/decorators/pimlico.js.map +1 -1
  114. package/_esm/clients/{passkeyServer.js → passkeyServer/index.js} +2 -2
  115. package/_esm/clients/passkeyServer/index.js.map +1 -0
  116. package/_esm/clients/{pimlico.js → pimlico/index.js} +2 -2
  117. package/_esm/clients/pimlico/index.js.map +1 -0
  118. package/_esm/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js +5 -4
  119. package/_esm/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.js.map +1 -1
  120. package/_types/accounts/biconomy/index.d.ts +6 -0
  121. package/_types/accounts/biconomy/index.d.ts.map +1 -0
  122. package/_types/accounts/biconomy/toBiconomySmartAccount.d.ts.map +1 -1
  123. package/_types/accounts/etherspot/index.d.ts +6 -0
  124. package/_types/accounts/etherspot/index.d.ts.map +1 -0
  125. package/_types/accounts/kernel/index.d.ts +22 -0
  126. package/_types/accounts/kernel/index.d.ts.map +1 -0
  127. package/_types/accounts/kernel/toKernelSmartAccount.d.ts.map +1 -1
  128. package/_types/accounts/kernel/utils/signMessage.d.ts +4 -5
  129. package/_types/accounts/kernel/utils/signMessage.d.ts.map +1 -1
  130. package/_types/accounts/kernel/utils/signTypedData.d.ts +4 -4
  131. package/_types/accounts/kernel/utils/signTypedData.d.ts.map +1 -1
  132. package/_types/accounts/kernel/utils/wrapMessageHash.d.ts +8 -3
  133. package/_types/accounts/kernel/utils/wrapMessageHash.d.ts.map +1 -1
  134. package/_types/accounts/light/index.d.ts +6 -0
  135. package/_types/accounts/light/index.d.ts.map +1 -0
  136. package/_types/accounts/light/toLightSmartAccount.d.ts.map +1 -1
  137. package/_types/accounts/nexus/index.d.ts +6 -0
  138. package/_types/accounts/nexus/index.d.ts.map +1 -0
  139. package/_types/accounts/safe/signUserOperation.d.ts.map +1 -1
  140. package/_types/accounts/safe/toSafeSmartAccount.d.ts.map +1 -1
  141. package/_types/accounts/simple/index.d.ts +9 -0
  142. package/_types/accounts/simple/index.d.ts.map +1 -0
  143. package/_types/accounts/simple/toSimpleSmartAccount.d.ts.map +1 -1
  144. package/_types/accounts/thirdweb/index.d.ts +6 -0
  145. package/_types/accounts/thirdweb/index.d.ts.map +1 -0
  146. package/_types/accounts/thirdweb/utils/decodeCallData.d.ts.map +1 -1
  147. package/_types/accounts/trust/index.d.ts +6 -0
  148. package/_types/accounts/trust/index.d.ts.map +1 -0
  149. package/_types/accounts/trust/utils/decodeCallData.d.ts.map +1 -1
  150. package/_types/actions/{erc7579.d.ts → erc7579/index.d.ts} +11 -11
  151. package/_types/actions/erc7579/index.d.ts.map +1 -0
  152. package/_types/actions/etherspot/index.d.ts +2 -0
  153. package/_types/actions/etherspot/index.d.ts.map +1 -0
  154. package/_types/actions/passkeyServer/index.d.ts +4 -0
  155. package/_types/actions/passkeyServer/index.d.ts.map +1 -0
  156. package/_types/actions/pimlico/estimateErc20PaymasterCost.d.ts.map +1 -1
  157. package/_types/actions/pimlico/index.d.ts +8 -0
  158. package/_types/actions/pimlico/index.d.ts.map +1 -0
  159. package/_types/actions/smartAccount/index.d.ts +5 -0
  160. package/_types/actions/smartAccount/index.d.ts.map +1 -0
  161. package/_types/clients/createSmartAccountClient.d.ts +9 -1
  162. package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
  163. package/_types/clients/decorators/pimlico.d.ts +1 -1
  164. package/_types/clients/decorators/pimlico.d.ts.map +1 -1
  165. package/_types/clients/{passkeyServer.d.ts → passkeyServer/index.d.ts} +8 -4
  166. package/_types/clients/passkeyServer/index.d.ts.map +1 -0
  167. package/_types/clients/pimlico/index.d.ts +21 -0
  168. package/_types/clients/pimlico/index.d.ts.map +1 -0
  169. package/_types/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.d.ts.map +1 -1
  170. package/accounts/biconomy/index.ts +11 -0
  171. package/accounts/biconomy/package.json +6 -0
  172. package/accounts/biconomy/toBiconomySmartAccount.ts +13 -5
  173. package/accounts/etherspot/index.ts +11 -0
  174. package/accounts/etherspot/package.json +6 -0
  175. package/accounts/kernel/index.ts +33 -0
  176. package/accounts/kernel/package.json +6 -0
  177. package/accounts/kernel/toKernelSmartAccount.ts +13 -6
  178. package/accounts/kernel/utils/signMessage.ts +19 -15
  179. package/accounts/kernel/utils/signTypedData.ts +14 -11
  180. package/accounts/kernel/utils/wrapMessageHash.ts +11 -8
  181. package/accounts/light/index.ts +12 -0
  182. package/accounts/light/package.json +6 -0
  183. package/accounts/light/toLightSmartAccount.ts +13 -5
  184. package/accounts/nexus/index.ts +11 -0
  185. package/accounts/nexus/package.json +6 -0
  186. package/accounts/package.json +6 -0
  187. package/accounts/safe/package.json +6 -0
  188. package/accounts/safe/signUserOperation.ts +4 -0
  189. package/accounts/safe/toSafeSmartAccount.ts +5 -3
  190. package/accounts/simple/index.ts +18 -0
  191. package/accounts/simple/package.json +6 -0
  192. package/accounts/simple/toSimpleSmartAccount.ts +21 -10
  193. package/accounts/thirdweb/index.ts +11 -0
  194. package/accounts/thirdweb/package.json +6 -0
  195. package/accounts/thirdweb/utils/decodeCallData.ts +9 -5
  196. package/accounts/trust/index.ts +11 -0
  197. package/accounts/trust/package.json +6 -0
  198. package/accounts/trust/utils/decodeCallData.ts +9 -5
  199. package/actions/{erc7579.ts → erc7579/index.ts} +10 -16
  200. package/actions/erc7579/package.json +6 -0
  201. package/actions/{etherspot.ts → etherspot/index.ts} +1 -1
  202. package/actions/etherspot/package.json +6 -0
  203. package/actions/{passkeyServer.ts → passkeyServer/index.ts} +3 -3
  204. package/actions/passkeyServer/package.json +6 -0
  205. package/actions/pimlico/estimateErc20PaymasterCost.ts +9 -3
  206. package/actions/{pimlico.ts → pimlico/index.ts} +7 -7
  207. package/actions/pimlico/package.json +6 -0
  208. package/actions/smartAccount/index.ts +7 -0
  209. package/actions/smartAccount/package.json +6 -0
  210. package/clients/createSmartAccountClient.ts +45 -20
  211. package/clients/decorators/pimlico.ts +10 -10
  212. package/clients/package.json +6 -0
  213. package/clients/{passkeyServer.ts → passkeyServer/index.ts} +15 -13
  214. package/clients/passkeyServer/package.json +6 -0
  215. package/clients/{pimlico.ts → pimlico/index.ts} +50 -23
  216. package/clients/pimlico/package.json +6 -0
  217. package/errors/package.json +6 -0
  218. package/experimental/pimlico/package.json +6 -0
  219. package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts +6 -4
  220. package/package.json +74 -29
  221. package/utils/package.json +6 -0
  222. package/_cjs/actions/erc7579.js.map +0 -1
  223. package/_cjs/actions/etherspot.js.map +0 -1
  224. package/_cjs/actions/passkeyServer.js.map +0 -1
  225. package/_cjs/actions/pimlico.js.map +0 -1
  226. package/_cjs/actions/smartAccount.js.map +0 -1
  227. package/_cjs/clients/passkeyServer.js.map +0 -1
  228. package/_cjs/clients/pimlico.js.map +0 -1
  229. package/_esm/actions/erc7579.js.map +0 -1
  230. package/_esm/actions/etherspot.js +0 -2
  231. package/_esm/actions/etherspot.js.map +0 -1
  232. package/_esm/actions/passkeyServer.js +0 -4
  233. package/_esm/actions/passkeyServer.js.map +0 -1
  234. package/_esm/actions/pimlico.js +0 -8
  235. package/_esm/actions/pimlico.js.map +0 -1
  236. package/_esm/actions/smartAccount.js +0 -5
  237. package/_esm/actions/smartAccount.js.map +0 -1
  238. package/_esm/clients/passkeyServer.js.map +0 -1
  239. package/_esm/clients/pimlico.js.map +0 -1
  240. package/_types/actions/erc7579.d.ts.map +0 -1
  241. package/_types/actions/etherspot.d.ts +0 -2
  242. package/_types/actions/etherspot.d.ts.map +0 -1
  243. package/_types/actions/passkeyServer.d.ts +0 -4
  244. package/_types/actions/passkeyServer.d.ts.map +0 -1
  245. package/_types/actions/pimlico.d.ts +0 -8
  246. package/_types/actions/pimlico.d.ts.map +0 -1
  247. package/_types/actions/smartAccount.d.ts +0 -5
  248. package/_types/actions/smartAccount.d.ts.map +0 -1
  249. package/_types/clients/passkeyServer.d.ts.map +0 -1
  250. package/_types/clients/pimlico.d.ts +0 -13
  251. package/_types/clients/pimlico.d.ts.map +0 -1
  252. package/accounts/decodeCalls.test.ts +0 -505
  253. package/accounts/safe/signUserOperation.test.ts +0 -275
  254. package/actions/erc7579/accountId.test.ts +0 -39
  255. package/actions/erc7579/installModule.test.ts +0 -216
  256. package/actions/erc7579/installModules.test.ts +0 -237
  257. package/actions/erc7579/isModuleInstalled.test.ts +0 -72
  258. package/actions/erc7579/supportsExecutionMode.test.ts +0 -108
  259. package/actions/erc7579/supportsModule.test.ts +0 -35
  260. package/actions/erc7579/uninstallModule.test.ts +0 -129
  261. package/actions/erc7579/uninstallModules.test.ts +0 -117
  262. package/actions/pimlico/getTokenQuotes.test.ts +0 -90
  263. package/actions/pimlico/getUserOperationGasPrice.test.ts +0 -82
  264. package/actions/pimlico/getUserOperationStatus.test.ts +0 -199
  265. package/actions/pimlico/sponsorUserOperation.test.ts +0 -236
  266. package/actions/pimlico/validateSponsorshipPolicies.test.ts +0 -153
  267. package/actions/public/getAccountNonce.test.ts +0 -96
  268. package/actions/public/getSenderAddress.test.ts +0 -154
  269. package/actions/smartAccount/getCallsStatus.test.ts +0 -255
  270. package/actions/smartAccount/sendCalls.test.ts +0 -571
  271. package/actions/smartAccount/sendTransaction.test.ts +0 -416
  272. package/actions/smartAccount/signMessage.test.ts +0 -219
  273. package/actions/smartAccount/signTypedData.test.ts +0 -228
  274. package/actions/smartAccount.ts +0 -7
  275. package/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +0 -523
  276. package/types/package.json +0 -6
  277. package/utils/decodeNonce.test.ts +0 -40
  278. package/utils/deepHexlify.test.ts +0 -57
  279. package/utils/encode7579Calls.test.ts +0 -69
  280. package/utils/encodeNonce.test.ts +0 -38
  281. package/utils/erc20AllowanceOverride.test.ts +0 -59
  282. package/utils/erc20BalanceOverride.test.ts +0 -57
  283. package/utils/getAddressFromInitCodeOrPaymasterAndData.test.ts +0 -31
  284. package/utils/getPackedUserOperation.test.ts +0 -204
  285. package/utils/getRequiredPrefund.test.ts +0 -90
  286. package/vitest.config.ts +0 -31
@@ -1,523 +0,0 @@
1
- import { http, parseEther, zeroAddress } from "viem"
2
- import {
3
- entryPoint06Address,
4
- entryPoint07Address,
5
- entryPoint08Address
6
- } from "viem/account-abstraction"
7
- import { privateKeyToAccount } from "viem/accounts"
8
- import { foundry } from "viem/chains"
9
- import { describe, expect } from "vitest"
10
- import {
11
- erc20Address,
12
- sudoMintTokens,
13
- tokenBalanceOf
14
- } from "../../../../mock-paymaster/helpers/erc20-utils"
15
- import { testWithRpc } from "../../../../permissionless-test/src/testWithRpc"
16
- import {
17
- getCoreSmartAccounts,
18
- getPublicClient
19
- } from "../../../../permissionless-test/src/utils"
20
- import { createSmartAccountClient } from "../../../clients/createSmartAccountClient"
21
- import { createPimlicoClient } from "../../../clients/pimlico"
22
- import { prepareUserOperationForErc20Paymaster } from "./prepareUserOperationForErc20Paymaster"
23
-
24
- const privateKey =
25
- "0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356"
26
-
27
- describe.each(getCoreSmartAccounts())(
28
- "prepareUserOperationForErc20Paymaster $name",
29
- ({
30
- getSmartAccountClient,
31
- supportsEntryPointV06,
32
- supportsEntryPointV07,
33
- supportsEntryPointV08,
34
- isEip7702Compliant,
35
- name
36
- }) => {
37
- testWithRpc.skipIf(!supportsEntryPointV06 || name === "Kernel 0.2.1")(
38
- "prepareUserOperationForErc20Paymaster_v06",
39
- async ({ rpc }) => {
40
- const { anvilRpc } = rpc
41
-
42
- const account = (
43
- await getSmartAccountClient({
44
- entryPoint: {
45
- version: "0.6"
46
- },
47
- privateKey,
48
- ...rpc
49
- })
50
- ).account
51
-
52
- const pimlicoClient = createPimlicoClient({
53
- transport: http(rpc.paymasterRpc),
54
- entryPoint: {
55
- address: entryPoint06Address,
56
- version: "0.6"
57
- }
58
- })
59
-
60
- const publicClient = getPublicClient(anvilRpc)
61
-
62
- const smartAccountClient = createSmartAccountClient({
63
- // @ts-ignore
64
- client: getPublicClient(anvilRpc),
65
- account,
66
- paymaster: pimlicoClient,
67
- chain: foundry,
68
- userOperation: {
69
- prepareUserOperation:
70
- prepareUserOperationForErc20Paymaster(pimlicoClient)
71
- },
72
- bundlerTransport: http(rpc.altoRpc)
73
- })
74
-
75
- const INITIAL_TOKEN_BALANCE = parseEther("100")
76
- const INTIAL_ETH_BALANCE = await publicClient.getBalance({
77
- address: smartAccountClient.account.address
78
- })
79
-
80
- sudoMintTokens({
81
- amount: INITIAL_TOKEN_BALANCE,
82
- to: smartAccountClient.account.address,
83
- anvilRpc
84
- })
85
-
86
- const opHash = await smartAccountClient.sendUserOperation({
87
- calls: [
88
- {
89
- to: zeroAddress,
90
- data: "0x",
91
- value: 0n
92
- }
93
- ],
94
- paymasterContext: {
95
- token: erc20Address
96
- }
97
- })
98
-
99
- const receipt =
100
- await smartAccountClient.waitForUserOperationReceipt({
101
- hash: opHash
102
- })
103
-
104
- expect(receipt).toBeTruthy()
105
- expect(receipt).toBeTruthy()
106
-
107
- expect(receipt.success).toBeTruthy()
108
- const FINAL_TOKEN_BALANCE = await tokenBalanceOf(
109
- smartAccountClient.account.address,
110
- rpc.anvilRpc
111
- )
112
- const FINAL_ETH_BALANCE = await publicClient.getBalance({
113
- address: smartAccountClient.account.address
114
- })
115
-
116
- expect(FINAL_TOKEN_BALANCE).toBeLessThan(INITIAL_TOKEN_BALANCE) // Token balance should be deducted
117
- expect(FINAL_ETH_BALANCE).toEqual(INTIAL_ETH_BALANCE) // There should be no ETH balance change
118
- }
119
- )
120
-
121
- testWithRpc.skipIf(!supportsEntryPointV07)(
122
- "prepareUserOperationForErc20Paymaster_v07",
123
- async ({ rpc }) => {
124
- const { anvilRpc } = rpc
125
-
126
- const privateKeyAccount = privateKeyToAccount(privateKey)
127
-
128
- const account = (
129
- await getSmartAccountClient({
130
- entryPoint: {
131
- version: "0.7"
132
- },
133
- privateKey,
134
- ...rpc
135
- })
136
- ).account
137
-
138
- const publicClient = getPublicClient(anvilRpc)
139
-
140
- const pimlicoClient = createPimlicoClient({
141
- transport: http(rpc.paymasterRpc),
142
- entryPoint: {
143
- address: entryPoint07Address,
144
- version: "0.7"
145
- }
146
- })
147
-
148
- const smartAccountClient = createSmartAccountClient({
149
- // @ts-ignore
150
- client: getPublicClient(anvilRpc),
151
- account,
152
- paymaster: pimlicoClient,
153
- chain: foundry,
154
- userOperation: {
155
- prepareUserOperation:
156
- prepareUserOperationForErc20Paymaster(pimlicoClient)
157
- },
158
- bundlerTransport: http(rpc.altoRpc)
159
- })
160
-
161
- const INITIAL_TOKEN_BALANCE = parseEther("100")
162
- const INTIAL_ETH_BALANCE = await publicClient.getBalance({
163
- address: smartAccountClient.account.address
164
- })
165
-
166
- sudoMintTokens({
167
- amount: INITIAL_TOKEN_BALANCE,
168
- to: smartAccountClient.account.address,
169
- anvilRpc
170
- })
171
-
172
- const authorization = isEip7702Compliant
173
- ? await privateKeyAccount.signAuthorization({
174
- address: (smartAccountClient.account as any)
175
- .implementation,
176
- chainId: smartAccountClient.chain.id,
177
- nonce: await publicClient.getTransactionCount({
178
- address: smartAccountClient.account.address
179
- })
180
- })
181
- : undefined
182
-
183
- const opHash = await smartAccountClient.sendUserOperation({
184
- calls: [
185
- {
186
- to: zeroAddress,
187
- data: "0x",
188
- value: 0n
189
- }
190
- ],
191
- paymasterContext: {
192
- token: erc20Address
193
- },
194
- authorization
195
- })
196
-
197
- const receipt =
198
- await smartAccountClient.waitForUserOperationReceipt({
199
- hash: opHash
200
- })
201
-
202
- expect(receipt).toBeTruthy()
203
- expect(receipt).toBeTruthy()
204
- expect(receipt.success).toBeTruthy()
205
-
206
- const FINAL_TOKEN_BALANCE = await tokenBalanceOf(
207
- smartAccountClient.account.address,
208
- rpc.anvilRpc
209
- )
210
- const FINAL_ETH_BALANCE = await publicClient.getBalance({
211
- address: smartAccountClient.account.address
212
- })
213
-
214
- expect(FINAL_TOKEN_BALANCE).toBeLessThan(INITIAL_TOKEN_BALANCE) // Token balance should be deducted
215
- expect(FINAL_ETH_BALANCE).toEqual(INTIAL_ETH_BALANCE) // There should be no ETH balance change
216
- }
217
- )
218
-
219
- testWithRpc.skipIf(!supportsEntryPointV08)(
220
- "prepareUserOperationForErc20Paymaster_v08",
221
- async ({ rpc }) => {
222
- const { anvilRpc } = rpc
223
-
224
- const privateKeyAccount = privateKeyToAccount(privateKey)
225
-
226
- const account = (
227
- await getSmartAccountClient({
228
- entryPoint: {
229
- version: "0.8"
230
- },
231
- privateKey,
232
- ...rpc
233
- })
234
- ).account
235
-
236
- const publicClient = getPublicClient(anvilRpc)
237
-
238
- const pimlicoClient = createPimlicoClient({
239
- transport: http(rpc.paymasterRpc),
240
- entryPoint: {
241
- address: entryPoint08Address,
242
- version: "0.8"
243
- }
244
- })
245
-
246
- const smartAccountClient = createSmartAccountClient({
247
- // @ts-ignore
248
- client: getPublicClient(anvilRpc),
249
- account,
250
- paymaster: pimlicoClient,
251
- chain: foundry,
252
- userOperation: {
253
- prepareUserOperation:
254
- prepareUserOperationForErc20Paymaster(pimlicoClient)
255
- },
256
- bundlerTransport: http(rpc.altoRpc)
257
- })
258
-
259
- const INITIAL_TOKEN_BALANCE = parseEther("100")
260
- const INTIAL_ETH_BALANCE = await publicClient.getBalance({
261
- address: smartAccountClient.account.address
262
- })
263
-
264
- sudoMintTokens({
265
- amount: INITIAL_TOKEN_BALANCE,
266
- to: smartAccountClient.account.address,
267
- anvilRpc
268
- })
269
-
270
- const authorization = isEip7702Compliant
271
- ? await privateKeyAccount.signAuthorization({
272
- address: (smartAccountClient.account as any)
273
- .implementation,
274
- chainId: smartAccountClient.chain.id,
275
- nonce: await publicClient.getTransactionCount({
276
- address: smartAccountClient.account.address
277
- })
278
- })
279
- : undefined
280
-
281
- const opHash = await smartAccountClient.sendUserOperation({
282
- calls: [
283
- {
284
- to: zeroAddress,
285
- data: "0x",
286
- value: 0n
287
- }
288
- ],
289
- paymasterContext: {
290
- token: erc20Address
291
- },
292
- authorization
293
- })
294
-
295
- const receipt =
296
- await smartAccountClient.waitForUserOperationReceipt({
297
- hash: opHash
298
- })
299
-
300
- expect(receipt).toBeTruthy()
301
- expect(receipt).toBeTruthy()
302
- expect(receipt.success).toBeTruthy()
303
-
304
- const FINAL_TOKEN_BALANCE = await tokenBalanceOf(
305
- smartAccountClient.account.address,
306
- rpc.anvilRpc
307
- )
308
- const FINAL_ETH_BALANCE = await publicClient.getBalance({
309
- address: smartAccountClient.account.address
310
- })
311
-
312
- expect(FINAL_TOKEN_BALANCE).toBeLessThan(INITIAL_TOKEN_BALANCE) // Token balance should be deducted
313
- expect(FINAL_ETH_BALANCE).toEqual(INTIAL_ETH_BALANCE) // There should be no ETH balance change
314
- }
315
- )
316
-
317
- testWithRpc.skipIf(!supportsEntryPointV07)(
318
- "prepareUserOperationForErc20Paymaster_v07 (balanceOverride enabled)",
319
- async ({ rpc }) => {
320
- const { anvilRpc } = rpc
321
-
322
- const privateKeyAccount = privateKeyToAccount(privateKey)
323
-
324
- const account = (
325
- await getSmartAccountClient({
326
- entryPoint: {
327
- version: "0.7"
328
- },
329
- privateKey,
330
- ...rpc
331
- })
332
- ).account
333
-
334
- const publicClient = getPublicClient(anvilRpc)
335
-
336
- const pimlicoClient = createPimlicoClient({
337
- transport: http(rpc.paymasterRpc),
338
- entryPoint: {
339
- address: entryPoint07Address,
340
- version: "0.7"
341
- }
342
- })
343
-
344
- const smartAccountClient = createSmartAccountClient({
345
- // @ts-ignore
346
- client: getPublicClient(anvilRpc),
347
- account,
348
- paymaster: pimlicoClient,
349
- chain: foundry,
350
- userOperation: {
351
- prepareUserOperation:
352
- prepareUserOperationForErc20Paymaster(
353
- pimlicoClient,
354
- {
355
- balanceOverride: true
356
- }
357
- )
358
- },
359
- bundlerTransport: http(rpc.altoRpc)
360
- })
361
-
362
- const INITIAL_TOKEN_BALANCE = parseEther("100")
363
- const INTIAL_ETH_BALANCE = await publicClient.getBalance({
364
- address: smartAccountClient.account.address
365
- })
366
-
367
- sudoMintTokens({
368
- amount: INITIAL_TOKEN_BALANCE,
369
- to: smartAccountClient.account.address,
370
- anvilRpc
371
- })
372
-
373
- const authorization = isEip7702Compliant
374
- ? await privateKeyAccount.signAuthorization({
375
- address: (smartAccountClient.account as any)
376
- .implementation,
377
- chainId: smartAccountClient.chain.id,
378
- nonce: await publicClient.getTransactionCount({
379
- address: smartAccountClient.account.address
380
- })
381
- })
382
- : undefined
383
-
384
- const opHash = await smartAccountClient.sendUserOperation({
385
- calls: [
386
- {
387
- to: zeroAddress,
388
- data: "0x",
389
- value: 0n
390
- }
391
- ],
392
- paymasterContext: {
393
- token: erc20Address
394
- },
395
- authorization
396
- })
397
-
398
- const receipt =
399
- await smartAccountClient.waitForUserOperationReceipt({
400
- hash: opHash
401
- })
402
-
403
- expect(receipt).toBeTruthy()
404
- expect(receipt).toBeTruthy()
405
- expect(receipt.success).toBeTruthy()
406
-
407
- const FINAL_TOKEN_BALANCE = await tokenBalanceOf(
408
- smartAccountClient.account.address,
409
- rpc.anvilRpc
410
- )
411
- const FINAL_ETH_BALANCE = await publicClient.getBalance({
412
- address: smartAccountClient.account.address
413
- })
414
-
415
- expect(FINAL_TOKEN_BALANCE).toBeLessThan(INITIAL_TOKEN_BALANCE) // Token balance should be deducted
416
- expect(FINAL_ETH_BALANCE).toEqual(INTIAL_ETH_BALANCE) // There should be no ETH balance change
417
- }
418
- )
419
-
420
- testWithRpc.skipIf(!supportsEntryPointV08)(
421
- "prepareUserOperationForErc20Paymaster_v08 (balanceOverride enabled)",
422
- async ({ rpc }) => {
423
- const { anvilRpc } = rpc
424
-
425
- const privateKeyAccount = privateKeyToAccount(privateKey)
426
-
427
- const account = (
428
- await getSmartAccountClient({
429
- entryPoint: {
430
- version: "0.8"
431
- },
432
- privateKey,
433
- ...rpc
434
- })
435
- ).account
436
-
437
- const publicClient = getPublicClient(anvilRpc)
438
-
439
- const pimlicoClient = createPimlicoClient({
440
- transport: http(rpc.paymasterRpc),
441
- entryPoint: {
442
- address: entryPoint08Address,
443
- version: "0.8"
444
- }
445
- })
446
-
447
- const smartAccountClient = createSmartAccountClient({
448
- // @ts-ignore
449
- client: getPublicClient(anvilRpc),
450
- account,
451
- paymaster: pimlicoClient,
452
- chain: foundry,
453
- userOperation: {
454
- prepareUserOperation:
455
- prepareUserOperationForErc20Paymaster(
456
- pimlicoClient,
457
- {
458
- balanceOverride: true
459
- }
460
- )
461
- },
462
- bundlerTransport: http(rpc.altoRpc)
463
- })
464
-
465
- const INITIAL_TOKEN_BALANCE = parseEther("100")
466
- const INTIAL_ETH_BALANCE = await publicClient.getBalance({
467
- address: smartAccountClient.account.address
468
- })
469
-
470
- sudoMintTokens({
471
- amount: INITIAL_TOKEN_BALANCE,
472
- to: smartAccountClient.account.address,
473
- anvilRpc
474
- })
475
-
476
- const authorization = isEip7702Compliant
477
- ? await privateKeyAccount.signAuthorization({
478
- address: (smartAccountClient.account as any)
479
- .implementation,
480
- chainId: smartAccountClient.chain.id,
481
- nonce: await publicClient.getTransactionCount({
482
- address: smartAccountClient.account.address
483
- })
484
- })
485
- : undefined
486
-
487
- const opHash = await smartAccountClient.sendUserOperation({
488
- calls: [
489
- {
490
- to: zeroAddress,
491
- data: "0x",
492
- value: 0n
493
- }
494
- ],
495
- paymasterContext: {
496
- token: erc20Address
497
- },
498
- authorization
499
- })
500
-
501
- const receipt =
502
- await smartAccountClient.waitForUserOperationReceipt({
503
- hash: opHash
504
- })
505
-
506
- expect(receipt).toBeTruthy()
507
- expect(receipt).toBeTruthy()
508
- expect(receipt.success).toBeTruthy()
509
-
510
- const FINAL_TOKEN_BALANCE = await tokenBalanceOf(
511
- smartAccountClient.account.address,
512
- rpc.anvilRpc
513
- )
514
- const FINAL_ETH_BALANCE = await publicClient.getBalance({
515
- address: smartAccountClient.account.address
516
- })
517
-
518
- expect(FINAL_TOKEN_BALANCE).toBeLessThan(INITIAL_TOKEN_BALANCE) // Token balance should be deducted
519
- expect(FINAL_ETH_BALANCE).toEqual(INTIAL_ETH_BALANCE) // There should be no ETH balance change
520
- }
521
- )
522
- }
523
- )
@@ -1,6 +0,0 @@
1
- {
2
- "type": "module",
3
- "types": "../_types/types/index.d.ts",
4
- "module": "../_esm/types/index.js",
5
- "main": "../_cjs/types/index.js"
6
- }
@@ -1,40 +0,0 @@
1
- import { describe, expect, test } from "vitest"
2
- import { decodeNonce, encodeNonce } from "./index"
3
-
4
- describe("decodeNonce", () => {
5
- test("should encode key and sequence correctly", async () => {
6
- const key = 123456789012345678901234n
7
- const sequence = 9876543210n
8
-
9
- const result = encodeNonce({ key, sequence })
10
-
11
- const decodedNonce = decodeNonce(result)
12
-
13
- expect(decodedNonce.key).toBe(key)
14
- expect(decodedNonce.sequence).toBe(sequence)
15
- })
16
-
17
- test("should handle zero values correctly", () => {
18
- const key = BigInt(0)
19
- const sequence = BigInt(0)
20
-
21
- const result = encodeNonce({ key, sequence })
22
-
23
- const decodedNonce = decodeNonce(result)
24
-
25
- expect(decodedNonce.key).toBe(key)
26
- expect(decodedNonce.sequence).toBe(sequence)
27
- })
28
-
29
- test("should handle large values correctly", () => {
30
- const key = BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFF")
31
- const sequence = BigInt("0xFFFFFFFF")
32
-
33
- const result = encodeNonce({ key, sequence })
34
-
35
- const decodedNonce = decodeNonce(result)
36
-
37
- expect(decodedNonce.key).toBe(key)
38
- expect(decodedNonce.sequence).toBe(sequence)
39
- })
40
- })
@@ -1,57 +0,0 @@
1
- import { toHex } from "viem"
2
- import { describe, expect, test } from "vitest"
3
- import { deepHexlify } from "../utils"
4
-
5
- describe("deepHexlify", () => {
6
- test("should return undefined for function input", async () => {
7
- const func = () => {}
8
- expect(deepHexlify(func)).toBeUndefined()
9
- })
10
-
11
- test("should return null for null input", () => {
12
- expect(deepHexlify(null)).toBeNull()
13
- })
14
-
15
- test("should return the same string for string input", () => {
16
- const str = "test"
17
- expect(deepHexlify(str)).toBe(str)
18
- })
19
-
20
- test("should return the same boolean for boolean input", () => {
21
- const bool = true
22
- expect(deepHexlify(bool)).toBe(bool)
23
- })
24
-
25
- test("should return hex string for bigint input", () => {
26
- const bigint = BigInt(12345)
27
- expect(deepHexlify(bigint)).toBe(toHex(bigint))
28
- })
29
-
30
- test("should return hex string for number input", () => {
31
- const number = 12345
32
- expect(deepHexlify(number)).toBe(toHex(number).replace(/^0x0/, "0x"))
33
- })
34
-
35
- test("should return array with hex values for array input", () => {
36
- const array = [12345, BigInt(67890)]
37
- expect(deepHexlify(array)).toEqual([
38
- toHex(12345).replace(/^0x0/, "0x"),
39
- toHex(BigInt(67890))
40
- ])
41
- })
42
-
43
- test("should return object with hex values for object input", () => {
44
- const obj = {
45
- a: 12345,
46
- b: BigInt(67890),
47
- c: "string",
48
- d: true
49
- }
50
- expect(deepHexlify(obj)).toEqual({
51
- a: toHex(12345).replace(/^0x0/, "0x"),
52
- b: toHex(BigInt(67890)),
53
- c: "string",
54
- d: true
55
- })
56
- })
57
- })
@@ -1,69 +0,0 @@
1
- import { describe, expect, test } from "vitest"
2
- import { encode7579Calls } from "./encode7579Calls"
3
-
4
- describe("encode7579Calls", () => {
5
- test("single call", async () => {
6
- const callData = encode7579Calls({
7
- mode: {
8
- type: "call"
9
- },
10
- callData: [
11
- {
12
- to: "0x1234567890123456789012345678901234567890",
13
- value: BigInt(12345),
14
- data: "0x1234567890123456789012345678901234567890"
15
- }
16
- ]
17
- })
18
-
19
- expect(callData).toBe(
20
- "0xe9ae5c53000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000048123456789012345678901234567890123456789000000000000000000000000000000000000000000000000000000000000030391234567890123456789012345678901234567890000000000000000000000000000000000000000000000000"
21
- )
22
- })
23
-
24
- test("batch call", async () => {
25
- const callData = encode7579Calls({
26
- mode: {
27
- type: "batchcall"
28
- },
29
- callData: [
30
- {
31
- to: "0x1234567890123456789012345678901234567890",
32
- value: BigInt(12345),
33
- data: "0x1234567890123456789012345678901234567890"
34
- },
35
- {
36
- to: "0x1234567890123456789012345678901234567890",
37
- value: BigInt(12345),
38
- data: "0x1234567890123456789012345678901234567890"
39
- }
40
- ]
41
- })
42
-
43
- expect(callData).toBe(
44
- "0xe9ae5c530100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000001234567890123456789012345678901234567890000000000000000000000000000000000000000000000000000000000000303900000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000014123456789012345678901234567890123456789000000000000000000000000000000000000000000000000012345678901234567890123456789012345678900000000000000000000000000000000000000000000000000000000000003039000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000141234567890123456789012345678901234567890000000000000000000000000"
45
- )
46
- })
47
-
48
- test("should throw error for batch call with different mode", async () => {
49
- expect(() => {
50
- encode7579Calls({
51
- mode: {
52
- type: "call"
53
- },
54
- callData: [
55
- {
56
- to: "0x1234567890123456789012345678901234567890",
57
- value: BigInt(12345),
58
- data: "0x1234567890123456789012345678901234567890"
59
- },
60
- {
61
- to: "0x1234567890123456789012345678901234567890",
62
- value: BigInt(12345),
63
- data: "0x1234567890123456789012345678901234567890"
64
- }
65
- ]
66
- })
67
- }).toThrowError("batchcall calldata")
68
- })
69
- })