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,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
- })
@@ -1,38 +0,0 @@
1
- import { toHex } from "viem"
2
- import { describe, expect, test } from "vitest"
3
- import { encodeNonce } from "./index"
4
-
5
- describe("encodeNonce", () => {
6
- test("should encode key and sequence correctly", async () => {
7
- const key = 123456789012345678901234n
8
- const sequence = 9876543210n
9
- const expectedKey = BigInt(toHex(key, { size: 24 }))
10
- const expectedSequence = BigInt(toHex(sequence, { size: 8 }))
11
-
12
- const result = encodeNonce({ key, sequence })
13
-
14
- expect(result).toBe((expectedKey << BigInt(64)) + expectedSequence)
15
- })
16
-
17
- test("should handle zero values correctly", () => {
18
- const key = BigInt(0)
19
- const sequence = BigInt(0)
20
- const expectedKey = BigInt(toHex(key, { size: 24 }))
21
- const expectedSequence = BigInt(toHex(sequence, { size: 8 }))
22
-
23
- const result = encodeNonce({ key, sequence })
24
-
25
- expect(result).toBe((expectedKey << BigInt(64)) + expectedSequence)
26
- })
27
-
28
- test("should handle large values correctly", () => {
29
- const key = BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFF")
30
- const sequence = BigInt("0xFFFFFFFF")
31
- const expectedKey = BigInt(toHex(key, { size: 24 }))
32
- const expectedSequence = BigInt(toHex(sequence, { size: 8 }))
33
-
34
- const result = encodeNonce({ key, sequence })
35
-
36
- expect(result).toBe((expectedKey << BigInt(64)) + expectedSequence)
37
- })
38
- })
@@ -1,59 +0,0 @@
1
- import { toHex } from "viem"
2
- import { describe, expect, test } from "vitest"
3
- import {
4
- type Erc20AllowanceOverrideParameters,
5
- erc20AllowanceOverride
6
- } from "./erc20AllowanceOverride"
7
-
8
- describe("erc20AllowanceOverride", () => {
9
- test("should return the correct structure for valid inputs", () => {
10
- const params = {
11
- token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF",
12
- owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
13
- spender: "0xDDdDddDdDdddDDddDDddDDDDdDdDDdDDdDDDDDDd",
14
- slot: BigInt(1),
15
- amount: BigInt(100)
16
- } as const
17
-
18
- const result = erc20AllowanceOverride(params)
19
-
20
- expect(result).toEqual([
21
- {
22
- address: params.token,
23
- stateDiff: [
24
- {
25
- slot: expect.any(String), // Slot will be a keccak256 hash
26
- value: toHex(params.amount)
27
- }
28
- ]
29
- }
30
- ])
31
- })
32
-
33
- test("should use the default amount when none is provided", () => {
34
- const params: Erc20AllowanceOverrideParameters = {
35
- token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF",
36
- owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
37
- spender: "0xDDdDddDdDdddDDddDDddDDDDdDdDDdDDdDDDDDDd",
38
- slot: BigInt(1)
39
- }
40
-
41
- const result = erc20AllowanceOverride(params)
42
-
43
- const expectedDefaultAmount = BigInt(
44
- "0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
45
- )
46
-
47
- expect(result).toEqual([
48
- {
49
- address: params.token,
50
- stateDiff: [
51
- {
52
- slot: expect.any(String), // Slot will be a keccak256 hash
53
- value: toHex(expectedDefaultAmount)
54
- }
55
- ]
56
- }
57
- ])
58
- })
59
- })
@@ -1,57 +0,0 @@
1
- import { toHex } from "viem"
2
- import { describe, expect, test } from "vitest"
3
- import {
4
- type Erc20BalanceOverrideParameters,
5
- erc20BalanceOverride
6
- } from "./erc20BalanceOverride"
7
-
8
- describe("erc20BalanceOverride", () => {
9
- test("should return the correct structure for valid inputs", () => {
10
- const params = {
11
- token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF",
12
- owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
13
- slot: BigInt(1),
14
- balance: BigInt(1000)
15
- } as const
16
-
17
- const result = erc20BalanceOverride(params)
18
-
19
- expect(result).toEqual([
20
- {
21
- address: params.token,
22
- stateDiff: [
23
- {
24
- slot: expect.any(String), // Slot will be a keccak256 hash
25
- value: toHex(params.balance)
26
- }
27
- ]
28
- }
29
- ])
30
- })
31
-
32
- test("should use the default balance when none is provided", () => {
33
- const params: Erc20BalanceOverrideParameters = {
34
- token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF",
35
- owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
36
- slot: BigInt(1)
37
- }
38
-
39
- const result = erc20BalanceOverride(params)
40
-
41
- const expectedDefaultBalance = BigInt(
42
- "0x100000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
43
- )
44
-
45
- expect(result).toEqual([
46
- {
47
- address: params.token,
48
- stateDiff: [
49
- {
50
- slot: expect.any(String), // Slot will be a keccak256 hash
51
- value: toHex(expectedDefaultBalance)
52
- }
53
- ]
54
- }
55
- ])
56
- })
57
- })
@@ -1,31 +0,0 @@
1
- import { describe, expect, test } from "vitest"
2
- import { getAddressFromInitCodeOrPaymasterAndData } from "./getAddressFromInitCodeOrPaymasterAndData"
3
-
4
- describe("getAddressFromInitCodeOrPaymasterAndData", () => {
5
- test("should return undefined for undefined data", () => {
6
- expect(
7
- // @ts-expect-error
8
- getAddressFromInitCodeOrPaymasterAndData(undefined)
9
- ).toBeUndefined()
10
- })
11
-
12
- test("should return undefined for empty string data", () => {
13
- // @ts-expect-error
14
- expect(getAddressFromInitCodeOrPaymasterAndData("")).toBeUndefined()
15
- })
16
-
17
- test("should return undefined for data shorter than 42 characters", () => {
18
- const shortData = "0x123456789"
19
- expect(
20
- getAddressFromInitCodeOrPaymasterAndData(shortData)
21
- ).toBeUndefined()
22
- })
23
-
24
- test("should return the correct address for data exactly 42 characters", () => {
25
- const expectedAddress = "0x1234567890123456789012345678901234567890"
26
- const exactData = `${expectedAddress}_mocked_address_for`
27
- expect(getAddressFromInitCodeOrPaymasterAndData(exactData)).toBe(
28
- expectedAddress
29
- )
30
- })
31
- })
@@ -1,204 +0,0 @@
1
- import { describe, expect, test } from "vitest"
2
- import type { UserOperation } from "../types/userOperation"
3
- import {
4
- getAccountGasLimits,
5
- getGasLimits,
6
- getInitCode,
7
- getPackedUserOperation,
8
- getPaymasterAndData,
9
- unPackInitCode,
10
- unpackAccountGasLimits,
11
- unpackGasLimits,
12
- unpackPaymasterAndData
13
- } from "./getPackedUserOperation"
14
-
15
- describe("getPackedUserOperation", () => {
16
- describe("getInitCode", () => {
17
- test("should return concatenated factory and factoryData", () => {
18
- const userOperation = {
19
- factory: "0x60e04be163dBb94688952449bbD9755D1Cd63231",
20
- factoryData: "0xfedcba0987654321"
21
- }
22
- expect(getInitCode(userOperation as UserOperation<"v0.7">)).toBe(
23
- "0x60e04be163dBb94688952449bbD9755D1Cd63231fedcba0987654321"
24
- )
25
- })
26
-
27
- test("should return factory with default factoryData when factoryData is missing", () => {
28
- const userOperation = {
29
- factory: "0x1234567890abcdef"
30
- }
31
- expect(getInitCode(userOperation as UserOperation<"v0.7">)).toBe(
32
- "0x1234567890abcdef"
33
- )
34
- })
35
-
36
- test('should return "0x" when factory is missing', () => {
37
- const userOperation = {}
38
- expect(getInitCode(userOperation as UserOperation<"v0.7">)).toBe(
39
- "0x"
40
- )
41
- })
42
- })
43
-
44
- describe("unPackInitCode", () => {
45
- test('should return nulls for factory and factoryData when initCode is "0x"', () => {
46
- expect(unPackInitCode("0x")).toEqual({
47
- factory: null,
48
- factoryData: null
49
- })
50
- })
51
-
52
- test("should return sliced factory and factoryData from initCode", () => {
53
- const initCode =
54
- "0x60e04be163dBb94688952449bbD9755D1Cd63231fedcba0987654321"
55
- expect(unPackInitCode(initCode)).toEqual({
56
- factory: "0x60e04be163dBb94688952449bbD9755D1Cd63231",
57
- factoryData: "0xfedcba0987654321"
58
- })
59
- })
60
- })
61
-
62
- describe("getAccountGasLimits", () => {
63
- test("should return concatenated padded verificationGasLimit and callGasLimit", () => {
64
- const userOperation = {
65
- verificationGasLimit: BigInt(1000),
66
- callGasLimit: BigInt(2000)
67
- }
68
- expect(
69
- getAccountGasLimits(userOperation as UserOperation<"v0.7">)
70
- ).toBe(
71
- "0x000000000000000000000000000003e8000000000000000000000000000007d0"
72
- )
73
- })
74
- })
75
-
76
- describe("unpackAccountGasLimits", () => {
77
- test("should return verificationGasLimit and callGasLimit from sliced accountGasLimits", () => {
78
- const accountGasLimits =
79
- "0x000000000000000000000000000003e8000000000000000000000000000007d0"
80
- expect(unpackAccountGasLimits(accountGasLimits)).toEqual({
81
- verificationGasLimit: BigInt(1000),
82
- callGasLimit: BigInt(2000)
83
- })
84
- })
85
- })
86
-
87
- describe("getGasLimits", () => {
88
- test("should return concatenated padded maxPriorityFeePerGas and maxFeePerGas", () => {
89
- const userOperation = {
90
- maxPriorityFeePerGas: BigInt(1000),
91
- maxFeePerGas: BigInt(2000)
92
- }
93
- expect(getGasLimits(userOperation as UserOperation<"v0.7">)).toBe(
94
- "0x000000000000000000000000000003e8000000000000000000000000000007d0"
95
- )
96
- })
97
- })
98
-
99
- describe("unpackGasLimits", () => {
100
- test("should return maxPriorityFeePerGas and maxFeePerGas from sliced gasLimits", () => {
101
- const gasLimits =
102
- "0x000000000000000000000000000003e8000000000000000000000000000007d0"
103
- expect(unpackGasLimits(gasLimits)).toEqual({
104
- maxPriorityFeePerGas: BigInt(1000),
105
- maxFeePerGas: BigInt(2000)
106
- })
107
- })
108
- })
109
-
110
- describe("getPaymasterAndData", () => {
111
- test("should return concatenated paymaster, verificationGasLimit, postOpGasLimit and paymasterData", () => {
112
- const userOperation = {
113
- paymaster: "0x60e04be163dBb94688952449bbD9755D1Cd63231",
114
- paymasterVerificationGasLimit: BigInt(1000),
115
- paymasterPostOpGasLimit: BigInt(2000),
116
- paymasterData: "0xabcdef"
117
- }
118
- expect(
119
- getPaymasterAndData(userOperation as UserOperation<"v0.7">)
120
- ).toBe(
121
- "0x60e04be163dBb94688952449bbD9755D1Cd63231000000000000000000000000000003e8000000000000000000000000000007d0abcdef"
122
- )
123
- })
124
-
125
- test("should return concatenated paymaster with default values when some fields are missing", () => {
126
- const userOperation = {
127
- paymaster: "0x1234567890abcdef"
128
- }
129
- expect(
130
- getPaymasterAndData(userOperation as UserOperation<"v0.7">)
131
- ).toBe(
132
- "0x1234567890abcdef0000000000000000000000000000000000000000000000000000000000000000"
133
- )
134
- })
135
-
136
- test('should return "0x" when paymaster is missing', () => {
137
- const userOperation = {}
138
- expect(
139
- getPaymasterAndData(userOperation as UserOperation<"v0.7">)
140
- ).toBe("0x")
141
- })
142
- })
143
-
144
- describe("unpackPaymasterAndData", () => {
145
- test('should return nulls for all fields when paymasterAndData is "0x"', () => {
146
- expect(unpackPaymasterAndData("0x")).toEqual({
147
- paymaster: null,
148
- paymasterVerificationGasLimit: null,
149
- paymasterPostOpGasLimit: null,
150
- paymasterData: null
151
- })
152
- })
153
-
154
- test("should return sliced fields from paymasterAndData", () => {
155
- const paymasterAndData =
156
- "0x60e04be163dBb94688952449bbD9755D1Cd63231000000000000000000000000000003e8000000000000000000000000000007d0abcdef"
157
- expect(unpackPaymasterAndData(paymasterAndData)).toEqual({
158
- paymaster: "0x60e04be163dBb94688952449bbD9755D1Cd63231",
159
- paymasterVerificationGasLimit: BigInt(1000),
160
- paymasterPostOpGasLimit: BigInt(2000),
161
- paymasterData: "0xabcdef"
162
- })
163
- })
164
- })
165
-
166
- describe("getPackedUserOperation", () => {
167
- test("should return packed user operation", () => {
168
- const userOperation = {
169
- sender: "0xsender",
170
- nonce: BigInt(1),
171
- factory: "0xfactory",
172
- factoryData: "0xfactoryData",
173
- verificationGasLimit: BigInt(1000),
174
- callGasLimit: BigInt(2000),
175
- callData: "0xcallData",
176
- preVerificationGas: BigInt(500),
177
- maxPriorityFeePerGas: BigInt(3000),
178
- maxFeePerGas: BigInt(4000),
179
- paymaster: "0xpaymaster",
180
- paymasterVerificationGasLimit: BigInt(5000),
181
- paymasterPostOpGasLimit: BigInt(6000),
182
- paymasterData: "0xpaymasterData",
183
- signature: "0xsignature"
184
- }
185
- const packedUserOperation = getPackedUserOperation(
186
- userOperation as UserOperation<"v0.7">
187
- )
188
- expect(packedUserOperation).toEqual({
189
- sender: "0xsender",
190
- callData: "0xcallData",
191
- nonce: BigInt(1),
192
- initCode: "0xfactoryfactoryData",
193
- accountGasLimits:
194
- "0x000000000000000000000000000003e8000000000000000000000000000007d0",
195
- preVerificationGas: BigInt(500),
196
- gasFees:
197
- "0x00000000000000000000000000000bb800000000000000000000000000000fa0",
198
- paymasterAndData:
199
- "0xpaymaster0000000000000000000000000000138800000000000000000000000000001770paymasterData",
200
- signature: "0xsignature"
201
- })
202
- })
203
- })
204
- })
@@ -1,90 +0,0 @@
1
- import type { UserOperation } from "viem/account-abstraction"
2
- import { describe, expect, test } from "vitest"
3
- import { getRequiredPrefund } from "./getRequiredPrefund"
4
-
5
- describe("getRequiredPrefund", () => {
6
- describe("v0.6 UserOperation", () => {
7
- test("should calculate the required prefund without paymasterAndData", () => {
8
- const userOperation = {
9
- callGasLimit: BigInt(1000),
10
- verificationGasLimit: BigInt(2000),
11
- preVerificationGas: BigInt(500),
12
- maxFeePerGas: BigInt(10),
13
- paymasterAndData: "0x"
14
- }
15
- const result = getRequiredPrefund({
16
- userOperation: userOperation as UserOperation<"0.6">,
17
- entryPointVersion: "0.6"
18
- })
19
- const expectedGas =
20
- BigInt(1000) + BigInt(2000) * BigInt(1) + BigInt(500)
21
- const expectedResult = expectedGas * BigInt(10)
22
- expect(result).toBe(expectedResult)
23
- })
24
-
25
- test("should calculate the required prefund with paymasterAndData", () => {
26
- const userOperation = {
27
- callGasLimit: BigInt(1000),
28
- verificationGasLimit: BigInt(2000),
29
- preVerificationGas: BigInt(500),
30
- maxFeePerGas: BigInt(10),
31
- paymasterAndData: "0x1234"
32
- }
33
- const result = getRequiredPrefund({
34
- userOperation: userOperation as UserOperation<"0.6">,
35
- entryPointVersion: "0.6"
36
- })
37
- const multiplier = BigInt(3)
38
- const expectedGas =
39
- BigInt(1000) + BigInt(2000) * multiplier + BigInt(500)
40
- const expectedResult = expectedGas * BigInt(10)
41
- expect(result).toBe(expectedResult)
42
- })
43
- })
44
- describe("v0.7 UserOperation", () => {
45
- test("should calculate the required prefund without paymater gasLimits", () => {
46
- const userOperation = {
47
- callGasLimit: BigInt(1000),
48
- verificationGasLimit: BigInt(2000),
49
- preVerificationGas: BigInt(500),
50
- paymasterVerificationGasLimit: undefined,
51
- paymasterPostOpGasLimit: undefined,
52
- paymaster: undefined,
53
- paymasterData: undefined,
54
- maxFeePerGas: BigInt(10)
55
- }
56
- const result = getRequiredPrefund({
57
- userOperation: userOperation as UserOperation<"0.7">,
58
- entryPointVersion: "0.7"
59
- })
60
- const expectedGas =
61
- BigInt(1000) + BigInt(2000) * BigInt(1) + BigInt(500)
62
- const expectedResult = expectedGas * BigInt(10)
63
- expect(result).toBe(expectedResult)
64
- })
65
-
66
- test("should calculate the required prefund with paymaster gasLimits", () => {
67
- const userOperation = {
68
- callGasLimit: BigInt(1000),
69
- verificationGasLimit: BigInt(2000),
70
- preVerificationGas: BigInt(500),
71
- paymasterVerificationGasLimit: BigInt(20),
72
- paymasterPostOpGasLimit: BigInt(30),
73
- paymaster: "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
74
- maxFeePerGas: BigInt(10)
75
- }
76
- const result = getRequiredPrefund({
77
- userOperation: userOperation as UserOperation<"0.7">,
78
- entryPointVersion: "0.7"
79
- })
80
- const expectedGas =
81
- BigInt(1000) +
82
- BigInt(2000) +
83
- BigInt(500) +
84
- BigInt(20) +
85
- BigInt(30)
86
- const expectedResult = expectedGas * BigInt(10)
87
- expect(result).toBe(expectedResult)
88
- })
89
- })
90
- })
package/vitest.config.ts DELETED
@@ -1,41 +0,0 @@
1
- import { join } from "node:path"
2
- import { loadEnv } from "vite"
3
- import { defineConfig } from "vitest/config"
4
-
5
- export default defineConfig({
6
- resolve: {
7
- alias: {
8
- "@pimlico/mock-paymaster": join(
9
- __dirname,
10
- "../mock-paymaster/index.ts"
11
- )
12
- }
13
- },
14
- test: {
15
- coverage: {
16
- all: true,
17
- provider: "v8",
18
- reporter: process.env.CI ? ["lcov"] : ["text", "json", "html"],
19
- include: ["**/permissionless/**"],
20
- exclude: [
21
- "**/errors/utils.ts",
22
- "**/*.test.ts",
23
- "**/permissionless-test/**",
24
- "**/_cjs/**",
25
- "**/_esm/**",
26
- "**/_types/**",
27
- "**/permissionless/accounts/index.ts",
28
- "**/permissionless/accounts/*/index.ts"
29
- ]
30
- },
31
- sequence: {
32
- concurrent: false
33
- },
34
- fileParallelism: true,
35
- environment: "node",
36
- testTimeout: 60_000,
37
- hookTimeout: 45_000,
38
- include: [join(__dirname, "./**/*.test.ts")],
39
- env: loadEnv("test", process.cwd())
40
- }
41
- })