@pimlico/alto 0.0.0-staging.20240606T101741 → 0.0.0-staging.20240606T103333

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 (220) hide show
  1. package/esm/cli/alto.d.ts +6 -0
  2. package/esm/cli/alto.js +92 -0
  3. package/esm/cli/alto.js.map +1 -0
  4. package/esm/cli/config/bundler.d.ts +391 -0
  5. package/esm/cli/config/bundler.js +132 -0
  6. package/esm/cli/config/bundler.js.map +1 -0
  7. package/esm/cli/config/index.d.ts +3 -0
  8. package/esm/cli/config/index.js +3 -0
  9. package/esm/cli/config/index.js.map +1 -0
  10. package/esm/cli/config/options.d.ts +11 -0
  11. package/esm/cli/config/options.js +336 -0
  12. package/esm/cli/config/options.js.map +1 -0
  13. package/esm/cli/customTransport.d.ts +14 -0
  14. package/esm/cli/customTransport.js +53 -0
  15. package/esm/cli/customTransport.js.map +1 -0
  16. package/esm/cli/handler.d.ts +3 -0
  17. package/esm/cli/handler.js +116 -0
  18. package/esm/cli/handler.js.map +1 -0
  19. package/esm/cli/index.d.ts +4 -0
  20. package/esm/cli/index.js +4 -0
  21. package/esm/cli/index.js.map +1 -0
  22. package/esm/cli/instrumentation.d.ts +2 -0
  23. package/esm/cli/instrumentation.js +39 -0
  24. package/esm/cli/instrumentation.js.map +1 -0
  25. package/esm/cli/setupServer.d.ts +17 -0
  26. package/esm/cli/setupServer.js +155 -0
  27. package/esm/cli/setupServer.js.map +1 -0
  28. package/esm/cli/util.d.ts +22 -0
  29. package/esm/cli/util.js +30 -0
  30. package/esm/cli/util.js.map +1 -0
  31. package/esm/executor/executor.d.ts +54 -0
  32. package/esm/executor/executor.js +637 -0
  33. package/esm/executor/executor.js.map +1 -0
  34. package/esm/executor/executorManager.d.ts +34 -0
  35. package/esm/executor/executorManager.js +401 -0
  36. package/esm/executor/executorManager.js.map +1 -0
  37. package/esm/executor/index.d.ts +5 -0
  38. package/esm/executor/index.js +5 -0
  39. package/esm/executor/index.js.map +1 -0
  40. package/esm/executor/senderManager.d.ts +17 -0
  41. package/esm/executor/senderManager.js +160 -0
  42. package/esm/executor/senderManager.js.map +1 -0
  43. package/esm/executor/test/utils.d.ts +13 -0
  44. package/esm/executor/test/utils.js +75 -0
  45. package/esm/executor/test/utils.js.map +1 -0
  46. package/esm/executor/utils.d.ts +32 -0
  47. package/esm/executor/utils.js +239 -0
  48. package/esm/executor/utils.js.map +1 -0
  49. package/esm/index.d.ts +2 -0
  50. package/esm/index.js +2 -0
  51. package/esm/index.js.map +1 -0
  52. package/esm/mempool/index.d.ts +5 -0
  53. package/esm/mempool/index.js +5 -0
  54. package/esm/mempool/index.js.map +1 -0
  55. package/esm/mempool/mempool.d.ts +64 -0
  56. package/esm/mempool/mempool.js +489 -0
  57. package/esm/mempool/mempool.js.map +1 -0
  58. package/esm/mempool/monitoring.d.ts +10 -0
  59. package/esm/mempool/monitoring.js +34 -0
  60. package/esm/mempool/monitoring.js.map +1 -0
  61. package/esm/mempool/nullMempool.d.ts +15 -0
  62. package/esm/mempool/nullMempool.js +36 -0
  63. package/esm/mempool/nullMempool.js.map +1 -0
  64. package/esm/mempool/reputationManager.d.ts +115 -0
  65. package/esm/mempool/reputationManager.js +397 -0
  66. package/esm/mempool/reputationManager.js.map +1 -0
  67. package/esm/mempool/store.d.ts +22 -0
  68. package/esm/mempool/store.js +123 -0
  69. package/esm/mempool/store.js.map +1 -0
  70. package/esm/rpc/EntryPointSimulationsV07.d.ts +58 -0
  71. package/esm/rpc/EntryPointSimulationsV07.js +407 -0
  72. package/esm/rpc/EntryPointSimulationsV07.js.map +1 -0
  73. package/esm/rpc/ExecuteSimulator.d.ts +37 -0
  74. package/esm/rpc/ExecuteSimulator.js +48 -0
  75. package/esm/rpc/ExecuteSimulator.js.map +1 -0
  76. package/esm/rpc/gasEstimation.d.ts +17 -0
  77. package/esm/rpc/gasEstimation.js +410 -0
  78. package/esm/rpc/gasEstimation.js.map +1 -0
  79. package/esm/rpc/index.d.ts +5 -0
  80. package/esm/rpc/index.js +5 -0
  81. package/esm/rpc/index.js.map +1 -0
  82. package/esm/rpc/nonceQueuer.d.ts +25 -0
  83. package/esm/rpc/nonceQueuer.js +135 -0
  84. package/esm/rpc/nonceQueuer.js.map +1 -0
  85. package/esm/rpc/rpcHandler.d.ts +64 -0
  86. package/esm/rpc/rpcHandler.js +727 -0
  87. package/esm/rpc/rpcHandler.js.map +1 -0
  88. package/esm/rpc/server.d.ts +31 -0
  89. package/esm/rpc/server.js +238 -0
  90. package/esm/rpc/server.js.map +1 -0
  91. package/esm/rpc/validation/BundlerCollectorTracerV06.d.ts +102 -0
  92. package/esm/rpc/validation/BundlerCollectorTracerV06.js +255 -0
  93. package/esm/rpc/validation/BundlerCollectorTracerV06.js.map +1 -0
  94. package/esm/rpc/validation/BundlerCollectorTracerV07.d.ts +102 -0
  95. package/esm/rpc/validation/BundlerCollectorTracerV07.js +254 -0
  96. package/esm/rpc/validation/BundlerCollectorTracerV07.js.map +1 -0
  97. package/esm/rpc/validation/SafeValidator.d.ts +35 -0
  98. package/esm/rpc/validation/SafeValidator.js +487 -0
  99. package/esm/rpc/validation/SafeValidator.js.map +1 -0
  100. package/esm/rpc/validation/TracerResultParserV06.d.ts +13 -0
  101. package/esm/rpc/validation/TracerResultParserV06.js +578 -0
  102. package/esm/rpc/validation/TracerResultParserV06.js.map +1 -0
  103. package/esm/rpc/validation/TracerResultParserV07.d.ts +33 -0
  104. package/esm/rpc/validation/TracerResultParserV07.js +557 -0
  105. package/esm/rpc/validation/TracerResultParserV07.js.map +1 -0
  106. package/esm/rpc/validation/UnsafeValidator.d.ts +63 -0
  107. package/esm/rpc/validation/UnsafeValidator.js +257 -0
  108. package/esm/rpc/validation/UnsafeValidator.js.map +1 -0
  109. package/esm/rpc/validation/index.d.ts +3 -0
  110. package/esm/rpc/validation/index.js +3 -0
  111. package/esm/rpc/validation/index.js.map +1 -0
  112. package/esm/rpc/validation/tracer.d.ts +122 -0
  113. package/esm/rpc/validation/tracer.js +82 -0
  114. package/esm/rpc/validation/tracer.js.map +1 -0
  115. package/esm/types/contracts/BundleBulker.d.ts +120 -0
  116. package/esm/types/contracts/BundleBulker.js +157 -0
  117. package/esm/types/contracts/BundleBulker.js.map +1 -0
  118. package/esm/types/contracts/CallEngine.d.ts +28 -0
  119. package/esm/types/contracts/CallEngine.js +37 -0
  120. package/esm/types/contracts/CallEngine.js.map +1 -0
  121. package/esm/types/contracts/CodeHashGetter.d.ts +37 -0
  122. package/esm/types/contracts/CodeHashGetter.js +45 -0
  123. package/esm/types/contracts/CodeHashGetter.js.map +1 -0
  124. package/esm/types/contracts/EntryPoint.d.ts +1789 -0
  125. package/esm/types/contracts/EntryPoint.js +2304 -0
  126. package/esm/types/contracts/EntryPoint.js.map +1 -0
  127. package/esm/types/contracts/EntryPointSimulations.d.ts +153 -0
  128. package/esm/types/contracts/EntryPointSimulations.js +15 -0
  129. package/esm/types/contracts/EntryPointSimulations.js.map +1 -0
  130. package/esm/types/contracts/IOpInflator.d.ts +61 -0
  131. package/esm/types/contracts/IOpInflator.js +80 -0
  132. package/esm/types/contracts/IOpInflator.js.map +1 -0
  133. package/esm/types/contracts/IPaymaster.d.ts +3 -0
  134. package/esm/types/contracts/IPaymaster.js +117 -0
  135. package/esm/types/contracts/IPaymaster.js.map +1 -0
  136. package/esm/types/contracts/Inflator.d.ts +65 -0
  137. package/esm/types/contracts/Inflator.js +84 -0
  138. package/esm/types/contracts/Inflator.js.map +1 -0
  139. package/esm/types/contracts/PerOpInflator.d.ts +176 -0
  140. package/esm/types/contracts/PerOpInflator.js +229 -0
  141. package/esm/types/contracts/PerOpInflator.js.map +1 -0
  142. package/esm/types/contracts/PimlicoEntryPointSimulations.d.ts +23 -0
  143. package/esm/types/contracts/PimlicoEntryPointSimulations.js +33 -0
  144. package/esm/types/contracts/PimlicoEntryPointSimulations.js.map +1 -0
  145. package/esm/types/contracts/SenderCreator.d.ts +4 -0
  146. package/esm/types/contracts/SenderCreator.js +23 -0
  147. package/esm/types/contracts/SenderCreator.js.map +1 -0
  148. package/esm/types/contracts/SimpleAccountFactory.d.ts +57 -0
  149. package/esm/types/contracts/SimpleAccountFactory.js +76 -0
  150. package/esm/types/contracts/SimpleAccountFactory.js.map +1 -0
  151. package/esm/types/contracts/TestOpcodesAccount.d.ts +4 -0
  152. package/esm/types/contracts/TestOpcodesAccount.js +281 -0
  153. package/esm/types/contracts/TestOpcodesAccount.js.map +1 -0
  154. package/esm/types/contracts/TestOpcodesAccountFactory.d.ts +4 -0
  155. package/esm/types/contracts/TestOpcodesAccountFactory.js +23 -0
  156. package/esm/types/contracts/TestOpcodesAccountFactory.js.map +1 -0
  157. package/esm/types/contracts/TestStorageAccount.d.ts +4 -0
  158. package/esm/types/contracts/TestStorageAccount.js +313 -0
  159. package/esm/types/contracts/TestStorageAccount.js.map +1 -0
  160. package/esm/types/contracts/index.d.ts +17 -0
  161. package/esm/types/contracts/index.js +17 -0
  162. package/esm/types/contracts/index.js.map +1 -0
  163. package/esm/types/gasPrice.d.ts +110 -0
  164. package/esm/types/gasPrice.js +52 -0
  165. package/esm/types/gasPrice.js.map +1 -0
  166. package/esm/types/index.d.ts +11 -0
  167. package/esm/types/index.js +11 -0
  168. package/esm/types/index.js.map +1 -0
  169. package/esm/types/interfaces.d.ts +26 -0
  170. package/esm/types/interfaces.js +2 -0
  171. package/esm/types/interfaces.js.map +1 -0
  172. package/esm/types/mempool.d.ts +78 -0
  173. package/esm/types/mempool.js +16 -0
  174. package/esm/types/mempool.js.map +1 -0
  175. package/esm/types/schemas.d.ts +4791 -0
  176. package/esm/types/schemas.js +497 -0
  177. package/esm/types/schemas.js.map +1 -0
  178. package/esm/types/test/validationTestErrors.d.ts +3 -0
  179. package/esm/types/test/validationTestErrors.js +229 -0
  180. package/esm/types/test/validationTestErrors.js.map +1 -0
  181. package/esm/types/utils.d.ts +24 -0
  182. package/esm/types/utils.js +30 -0
  183. package/esm/types/utils.js.map +1 -0
  184. package/esm/types/validation.d.ts +14327 -0
  185. package/esm/types/validation.js +304 -0
  186. package/esm/types/validation.js.map +1 -0
  187. package/esm/utils/bigInt.d.ts +3 -0
  188. package/esm/utils/bigInt.js +9 -0
  189. package/esm/utils/bigInt.js.map +1 -0
  190. package/esm/utils/compressionHandler.d.ts +11 -0
  191. package/esm/utils/compressionHandler.js +39 -0
  192. package/esm/utils/compressionHandler.js.map +1 -0
  193. package/esm/utils/gasPriceManager.d.ts +34 -0
  194. package/esm/utils/gasPriceManager.js +338 -0
  195. package/esm/utils/gasPriceManager.js.map +1 -0
  196. package/esm/utils/helpers.d.ts +4 -0
  197. package/esm/utils/helpers.js +13 -0
  198. package/esm/utils/helpers.js.map +1 -0
  199. package/esm/utils/index.d.ts +11 -0
  200. package/esm/utils/index.js +10 -0
  201. package/esm/utils/index.js.map +1 -0
  202. package/esm/utils/logger.d.ts +6 -0
  203. package/esm/utils/logger.js +76 -0
  204. package/esm/utils/logger.js.map +1 -0
  205. package/esm/utils/metrics.d.ts +22 -0
  206. package/esm/utils/metrics.js +150 -0
  207. package/esm/utils/metrics.js.map +1 -0
  208. package/esm/utils/rpc-reply.d.ts +17 -0
  209. package/esm/utils/rpc-reply.js +41 -0
  210. package/esm/utils/rpc-reply.js.map +1 -0
  211. package/esm/utils/test.d.ts +17 -0
  212. package/esm/utils/test.js +130 -0
  213. package/esm/utils/test.js.map +1 -0
  214. package/esm/utils/userop.d.ts +49 -0
  215. package/esm/utils/userop.js +408 -0
  216. package/esm/utils/userop.js.map +1 -0
  217. package/esm/utils/validation.d.ts +65 -0
  218. package/esm/utils/validation.js +461 -0
  219. package/esm/utils/validation.js.map +1 -0
  220. package/package.json +70 -66
@@ -0,0 +1,408 @@
1
+ import { EntryPointV06Abi, EntryPointV07Abi } from "../types/index.js";
2
+ import * as sentry from "@sentry/node";
3
+ import { decodeEventLog, encodeAbiParameters, getAddress, keccak256, toHex, concat, slice, pad } from "viem";
4
+ import { areAddressesEqual } from "./helpers.js";
5
+ // Type predicate check if the UserOperation is V06.
6
+ export function isVersion06(operation) {
7
+ return "initCode" in operation && "paymasterAndData" in operation;
8
+ }
9
+ // Type predicate to check if the UserOperation is V07.
10
+ export function isVersion07(operation) {
11
+ return "factory" in operation && "paymaster" in operation;
12
+ }
13
+ export function getInitCode(unpackedUserOperation) {
14
+ return unpackedUserOperation.factory
15
+ ? concat([
16
+ unpackedUserOperation.factory,
17
+ unpackedUserOperation.factoryData || "0x"
18
+ ])
19
+ : "0x";
20
+ }
21
+ export function unPackInitCode(initCode) {
22
+ if (initCode === "0x") {
23
+ return {
24
+ factory: null,
25
+ factoryData: null
26
+ };
27
+ }
28
+ return {
29
+ factory: getAddress(slice(initCode, 0, 20)),
30
+ factoryData: slice(initCode, 20)
31
+ };
32
+ }
33
+ export function getAccountGasLimits(unpackedUserOperation) {
34
+ return concat([
35
+ pad(toHex(unpackedUserOperation.verificationGasLimit), {
36
+ size: 16
37
+ }),
38
+ pad(toHex(unpackedUserOperation.callGasLimit), { size: 16 })
39
+ ]);
40
+ }
41
+ export function unpackAccountGasLimits(accountGasLimits) {
42
+ return {
43
+ verificationGasLimit: BigInt(slice(accountGasLimits, 0, 16)),
44
+ callGasLimit: BigInt(slice(accountGasLimits, 16))
45
+ };
46
+ }
47
+ export function getGasLimits(unpackedUserOperation) {
48
+ return concat([
49
+ pad(toHex(unpackedUserOperation.maxPriorityFeePerGas), {
50
+ size: 16
51
+ }),
52
+ pad(toHex(unpackedUserOperation.maxFeePerGas), { size: 16 })
53
+ ]);
54
+ }
55
+ export function unpackGasLimits(gasLimits) {
56
+ return {
57
+ maxPriorityFeePerGas: BigInt(slice(gasLimits, 0, 16)),
58
+ maxFeePerGas: BigInt(slice(gasLimits, 16))
59
+ };
60
+ }
61
+ export function getPaymasterAndData(unpackedUserOperation) {
62
+ return unpackedUserOperation.paymaster
63
+ ? concat([
64
+ unpackedUserOperation.paymaster,
65
+ pad(toHex(unpackedUserOperation.paymasterVerificationGasLimit || 0n), {
66
+ size: 16
67
+ }),
68
+ pad(toHex(unpackedUserOperation.paymasterPostOpGasLimit || 0n), {
69
+ size: 16
70
+ }),
71
+ unpackedUserOperation.paymasterData || "0x"
72
+ ])
73
+ : "0x";
74
+ }
75
+ export function unpackPaymasterAndData(paymasterAndData) {
76
+ if (paymasterAndData === "0x") {
77
+ return {
78
+ paymaster: null,
79
+ paymasterVerificationGasLimit: null,
80
+ paymasterPostOpGasLimit: null,
81
+ paymasterData: null
82
+ };
83
+ }
84
+ return {
85
+ paymaster: getAddress(slice(paymasterAndData, 0, 20)),
86
+ paymasterVerificationGasLimit: BigInt(slice(paymasterAndData, 20, 36)),
87
+ paymasterPostOpGasLimit: BigInt(slice(paymasterAndData, 36, 52)),
88
+ paymasterData: slice(paymasterAndData, 52)
89
+ };
90
+ }
91
+ export function toPackedUserOperation(unpackedUserOperation) {
92
+ return {
93
+ sender: unpackedUserOperation.sender,
94
+ nonce: unpackedUserOperation.nonce,
95
+ initCode: getInitCode(unpackedUserOperation),
96
+ callData: unpackedUserOperation.callData,
97
+ accountGasLimits: getAccountGasLimits(unpackedUserOperation),
98
+ preVerificationGas: unpackedUserOperation.preVerificationGas,
99
+ gasFees: getGasLimits(unpackedUserOperation),
100
+ paymasterAndData: getPaymasterAndData(unpackedUserOperation),
101
+ signature: unpackedUserOperation.signature
102
+ };
103
+ }
104
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
105
+ export function deepHexlify(obj) {
106
+ if (typeof obj === "function") {
107
+ return undefined;
108
+ }
109
+ if (obj == null || typeof obj === "string" || typeof obj === "boolean") {
110
+ return obj;
111
+ }
112
+ if (typeof obj === "bigint") {
113
+ return toHex(obj);
114
+ }
115
+ if (obj._isBigNumber != null || typeof obj !== "object") {
116
+ return toHex(obj).replace(/^0x0/, "0x");
117
+ }
118
+ if (Array.isArray(obj)) {
119
+ return obj.map((member) => deepHexlify(member));
120
+ }
121
+ return Object.keys(obj).reduce(
122
+ // biome-ignore lint/suspicious/noExplicitAny: it's a recursive function, so it's hard to type
123
+ (set, key) => {
124
+ set[key] = deepHexlify(obj[key]);
125
+ return set;
126
+ }, {});
127
+ }
128
+ export function getAddressFromInitCodeOrPaymasterAndData(data) {
129
+ if (!data) {
130
+ return null;
131
+ }
132
+ if (data.length >= 42) {
133
+ return getAddress(data.slice(0, 42));
134
+ }
135
+ return null;
136
+ }
137
+ export const transactionIncluded = async (isVersion06, txHash, publicClient, entryPoint) => {
138
+ try {
139
+ const rcp = await publicClient.getTransactionReceipt({ hash: txHash });
140
+ if (rcp.status === "success") {
141
+ // find if any logs are UserOperationEvent or AccountDeployed
142
+ const r = rcp.logs
143
+ .map((l) => {
144
+ if (areAddressesEqual(l.address, entryPoint)) {
145
+ try {
146
+ const log = decodeEventLog({
147
+ abi: isVersion06
148
+ ? EntryPointV06Abi
149
+ : EntryPointV07Abi,
150
+ data: l.data,
151
+ topics: l.topics
152
+ });
153
+ if (log.eventName === "AccountDeployed") {
154
+ return {
155
+ userOperationHash: log.args.userOpHash,
156
+ success: !!log.args.factory,
157
+ accountDeployed: true
158
+ };
159
+ }
160
+ if (log.eventName === "UserOperationEvent") {
161
+ return {
162
+ userOperationHash: log.args.userOpHash,
163
+ success: !!log.args.success,
164
+ accountDeployed: false
165
+ };
166
+ }
167
+ return undefined;
168
+ }
169
+ catch (_e) {
170
+ sentry.captureException(_e);
171
+ return undefined;
172
+ }
173
+ }
174
+ return undefined;
175
+ })
176
+ .reduce((result, log) => {
177
+ if (log) {
178
+ result[log.userOperationHash] = {
179
+ userOperationHash: log.userOperationHash,
180
+ accountDeployed: log.accountDeployed ||
181
+ result[log.userOperationHash]
182
+ ?.accountDeployed,
183
+ success: log.success ||
184
+ result[log.userOperationHash]?.success
185
+ };
186
+ return result;
187
+ }
188
+ return result;
189
+ }, {});
190
+ const success = Object.values(r).reduce((x, v) => x || v.success, false);
191
+ if (success) {
192
+ return {
193
+ status: "included",
194
+ ...r
195
+ };
196
+ }
197
+ return {
198
+ status: "reverted"
199
+ };
200
+ }
201
+ return {
202
+ status: "failed"
203
+ };
204
+ }
205
+ catch (_e) {
206
+ return {
207
+ status: "not_found"
208
+ };
209
+ }
210
+ };
211
+ export const getUserOperationHashV06 = (userOperation, entryPointAddress, chainId) => {
212
+ const hash = keccak256(encodeAbiParameters([
213
+ {
214
+ name: "sender",
215
+ type: "address"
216
+ },
217
+ {
218
+ name: "nonce",
219
+ type: "uint256"
220
+ },
221
+ {
222
+ name: "initCodeHash",
223
+ type: "bytes32"
224
+ },
225
+ {
226
+ name: "callDataHash",
227
+ type: "bytes32"
228
+ },
229
+ {
230
+ name: "callGasLimit",
231
+ type: "uint256"
232
+ },
233
+ {
234
+ name: "verificationGasLimit",
235
+ type: "uint256"
236
+ },
237
+ {
238
+ name: "preVerificationGas",
239
+ type: "uint256"
240
+ },
241
+ {
242
+ name: "maxFeePerGas",
243
+ type: "uint256"
244
+ },
245
+ {
246
+ name: "maxPriorityFeePerGas",
247
+ type: "uint256"
248
+ },
249
+ {
250
+ name: "paymasterAndDataHash",
251
+ type: "bytes32"
252
+ }
253
+ ], [
254
+ userOperation.sender,
255
+ userOperation.nonce,
256
+ keccak256(userOperation.initCode),
257
+ keccak256(userOperation.callData),
258
+ userOperation.callGasLimit,
259
+ userOperation.verificationGasLimit,
260
+ userOperation.preVerificationGas,
261
+ userOperation.maxFeePerGas,
262
+ userOperation.maxPriorityFeePerGas,
263
+ keccak256(userOperation.paymasterAndData)
264
+ ]));
265
+ return keccak256(encodeAbiParameters([
266
+ {
267
+ name: "userOpHash",
268
+ type: "bytes32"
269
+ },
270
+ {
271
+ name: "entryPointAddress",
272
+ type: "address"
273
+ },
274
+ {
275
+ name: "chainId",
276
+ type: "uint256"
277
+ }
278
+ ], [hash, entryPointAddress, BigInt(chainId)]));
279
+ };
280
+ export const getUserOperationHashV07 = (userOperation, entryPointAddress, chainId) => {
281
+ const hash = keccak256(encodeAbiParameters([
282
+ {
283
+ name: "sender",
284
+ type: "address"
285
+ },
286
+ {
287
+ name: "nonce",
288
+ type: "uint256"
289
+ },
290
+ {
291
+ name: "initCodeHash",
292
+ type: "bytes32"
293
+ },
294
+ {
295
+ name: "callDataHash",
296
+ type: "bytes32"
297
+ },
298
+ {
299
+ name: "accountGasLimits",
300
+ type: "bytes32"
301
+ },
302
+ {
303
+ name: "preVerificationGas",
304
+ type: "uint256"
305
+ },
306
+ {
307
+ name: "gasFees",
308
+ type: "bytes32"
309
+ },
310
+ {
311
+ name: "paymasterAndDataHash",
312
+ type: "bytes32"
313
+ }
314
+ ], [
315
+ userOperation.sender,
316
+ userOperation.nonce,
317
+ keccak256(userOperation.initCode),
318
+ keccak256(userOperation.callData),
319
+ userOperation.accountGasLimits,
320
+ userOperation.preVerificationGas,
321
+ userOperation.gasFees,
322
+ keccak256(userOperation.paymasterAndData)
323
+ ]));
324
+ return keccak256(encodeAbiParameters([
325
+ {
326
+ name: "userOpHash",
327
+ type: "bytes32"
328
+ },
329
+ {
330
+ name: "entryPointAddress",
331
+ type: "address"
332
+ },
333
+ {
334
+ name: "chainId",
335
+ type: "uint256"
336
+ }
337
+ ], [hash, entryPointAddress, BigInt(chainId)]));
338
+ };
339
+ export const getUserOperationHash = (userOperation, entryPointAddress, chainId) => {
340
+ if (isVersion06(userOperation)) {
341
+ return getUserOperationHashV06(userOperation, entryPointAddress, chainId);
342
+ }
343
+ return getUserOperationHashV07(toPackedUserOperation(userOperation), entryPointAddress, chainId);
344
+ };
345
+ export const getNonceKeyAndValue = (nonce) => {
346
+ const nonceKey = nonce >> 64n; // first 192 bits of nonce
347
+ const userOperationNonceValue = nonce & 0xffffffffffffffffn; // last 64 bits of nonce
348
+ return [nonceKey, userOperationNonceValue];
349
+ };
350
+ export function toUnpackedUserOperation(packedUserOperation) {
351
+ const { factory, factoryData } = unPackInitCode(packedUserOperation.initCode);
352
+ const { callGasLimit, verificationGasLimit } = unpackAccountGasLimits(packedUserOperation.accountGasLimits);
353
+ const { maxFeePerGas, maxPriorityFeePerGas } = unpackGasLimits(packedUserOperation.gasFees);
354
+ const { paymaster, paymasterVerificationGasLimit, paymasterPostOpGasLimit, paymasterData } = unpackPaymasterAndData(packedUserOperation.paymasterAndData);
355
+ return {
356
+ sender: packedUserOperation.sender,
357
+ nonce: packedUserOperation.nonce,
358
+ factory: factory,
359
+ factoryData: factoryData,
360
+ callData: packedUserOperation.callData,
361
+ callGasLimit: callGasLimit,
362
+ verificationGasLimit: verificationGasLimit,
363
+ preVerificationGas: packedUserOperation.preVerificationGas,
364
+ maxFeePerGas: maxFeePerGas,
365
+ maxPriorityFeePerGas: maxPriorityFeePerGas,
366
+ paymaster: paymaster,
367
+ paymasterVerificationGasLimit: paymasterVerificationGasLimit,
368
+ paymasterPostOpGasLimit: paymasterPostOpGasLimit,
369
+ paymasterData: paymasterData,
370
+ signature: packedUserOperation.signature
371
+ };
372
+ }
373
+ /*
374
+ function pack(
375
+ UserOperation calldata userOp
376
+ ) internal pure returns (bytes memory ret) {
377
+ address sender = getSender(userOp);
378
+ uint256 nonce = userOp.nonce;
379
+ bytes32 hashInitCode = calldataKeccak(userOp.initCode);
380
+ bytes32 hashCallData = calldataKeccak(userOp.callData);
381
+ uint256 callGasLimit = userOp.callGasLimit;
382
+ uint256 verificationGasLimit = userOp.verificationGasLimit;
383
+ uint256 preVerificationGas = userOp.preVerificationGas;
384
+ uint256 maxFeePerGas = userOp.maxFeePerGas;
385
+ uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;
386
+ bytes32 hashPaymasterAndData = calldataKeccak(userOp.paymasterAndData);
387
+
388
+ return abi.encode(
389
+ sender, nonce,
390
+ hashInitCode, hashCallData,
391
+ callGasLimit, verificationGasLimit, preVerificationGas,
392
+ maxFeePerGas, maxPriorityFeePerGas,
393
+ hashPaymasterAndData
394
+ );
395
+ }
396
+
397
+
398
+ const encodedData = encodeAbiParameters(
399
+ [
400
+ { name: 'x', type: 'string' },
401
+ { name: 'y', type: 'uint' },
402
+ { name: 'z', type: 'bool' }
403
+ ],
404
+ ['wagmi', 420n, true]
405
+ )
406
+
407
+ */
408
+ //# sourceMappingURL=userop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userop.js","sourceRoot":"","sources":["../../utils/userop.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAMhB,gBAAgB,EACnB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAIH,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,KAAK,EACL,MAAM,EACN,KAAK,EACL,GAAG,EACN,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE7C,oDAAoD;AACpD,MAAM,UAAU,WAAW,CACvB,SAAwB;IAExB,OAAO,UAAU,IAAI,SAAS,IAAI,kBAAkB,IAAI,SAAS,CAAA;AACrE,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,WAAW,CACvB,SAAwB;IAExB,OAAO,SAAS,IAAI,SAAS,IAAI,WAAW,IAAI,SAAS,CAAA;AAC7D,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,qBAAuC;IAC/D,OAAO,qBAAqB,CAAC,OAAO;QAChC,CAAC,CAAC,MAAM,CAAC;YACH,qBAAqB,CAAC,OAAO;YAC7B,qBAAqB,CAAC,WAAW,IAAK,IAAY;SACrD,CAAC;QACJ,CAAC,CAAC,IAAI,CAAA;AACd,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAa;IACxC,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO;YACH,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,IAAI;SACpB,CAAA;IACL,CAAC;IACD,OAAO;QACH,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,WAAW,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;KACnC,CAAA;AACL,CAAC;AAED,MAAM,UAAU,m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AM;QAClC,KAAK,EAAE,mBAAmB,CAAC,KAAK;QAChC,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,WAAW;QACxB,QAAQ,EAAE,mBAAmB,CAAC,QAAQ;QACtC,YAAY,EAAE,YAAY;QAC1B,oBAAoB,EAAE,oBAAoB;QAC1C,kBAAkB,EAAE,mBAAmB,CAAC,kBAAkB;QAC1D,YAAY,EAAE,YAAY;QAC1B,oBAAoB,EAAE,oBAAoB;QAC1C,SAAS,EAAE,SAAS;QACpB,6BAA6B,EAAE,6BAA6B;QAC5D,uBAAuB,EAAE,uBAAuB;QAChD,aAAa,EAAE,aAAa;QAC5B,SAAS,EAAE,mBAAmB,CAAC,SAAS;KAC3C,CAAA;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCE"}
@@ -0,0 +1,65 @@
1
+ import { type Address, type ChainType, type PackedUserOperation, type UserOperation, type UserOperationV06 } from "../types/index.js";
2
+ import { type Chain, ContractFunctionRevertedError, EstimateGasExecutionError, FeeCapTooLowError, InsufficientFundsError, IntrinsicGasTooLowError, NonceTooLowError, type PublicClient, type Transport } from "viem";
3
+ import type { GasPriceManager } from "./gasPriceManager.js";
4
+ export interface GasOverheads {
5
+ /**
6
+ * fixed overhead for entire handleOp bundle.
7
+ */
8
+ fixed: number;
9
+ /**
10
+ * per userOp overhead, added on top of the above fixed per-bundle.
11
+ */
12
+ perUserOp: number;
13
+ /**
14
+ * overhead for userOp word (32 bytes) block
15
+ */
16
+ perUserOpWord: number;
17
+ /**
18
+ * zero byte cost, for calldata gas cost calculations
19
+ */
20
+ zeroByte: number;
21
+ /**
22
+ * non-zero byte cost, for calldata gas cost calculations
23
+ */
24
+ nonZeroByte: number;
25
+ /**
26
+ * expected bundle size, to split per-bundle overhead between all ops.
27
+ */
28
+ bundleSize: number;
29
+ /**
30
+ * expected length of the userOp signature.
31
+ */
32
+ sigSize: number;
33
+ }
34
+ export declare const DefaultGasOverheads: GasOverheads;
35
+ /**
36
+ * pack the userOperation
37
+ * @param op
38
+ * "false" to pack entire UserOp, for calculating the calldata cost of putting it on-chain.
39
+ */
40
+ export declare function packUserOpV06(op: UserOperationV06): `0x${string}`;
41
+ export declare function removeZeroBytesFromUserOp<T extends UserOperation>(userOpearation: T): T extends UserOperationV06 ? UserOperationV06 : PackedUserOperation;
42
+ export declare function packUserOpV07(op: PackedUserOperation): `0x${string}`;
43
+ export declare function calcPreVerificationGas(publicClient: PublicClient<Transport, Chain>, userOperation: UserOperation, entryPoint: Address, chainId: number, chainType: ChainType, gasPriceManager: GasPriceManager, validate: boolean, // when calculating preVerificationGas for validation
44
+ overheads?: GasOverheads): Promise<bigint>;
45
+ export declare function calcVerificationGasAndCallGasLimit(userOperation: UserOperation, executionResult: {
46
+ preOpGas: bigint;
47
+ paid: bigint;
48
+ }, chainId: number, callDataResult?: {
49
+ gasUsed: bigint;
50
+ }): {
51
+ verificationGasLimit: bigint;
52
+ callGasLimit: bigint;
53
+ };
54
+ /**
55
+ * calculate the preVerificationGas of the given UserOperation
56
+ * preVerificationGas (by definition) is the cost overhead that can't be calculated on-chain.
57
+ * it is based on parameters that are defined by the Ethereum protocol for external transactions.
58
+ * @param userOp filled userOp to calculate. The only possible missing fields can be the signature and preVerificationGas itself
59
+ * @param overheads gas overheads to use, to override the default values
60
+ */
61
+ export declare function calcDefaultPreVerificationGas(userOperation: UserOperation, overheads?: Partial<GasOverheads>): bigint;
62
+ export declare function calcOptimismPreVerificationGas(publicClient: PublicClient<Transport, Chain>, op: UserOperation, entryPoint: Address, staticFee: bigint, gasPriceManager: GasPriceManager, verify?: boolean): Promise<bigint>;
63
+ export declare function calcArbitrumPreVerificationGas(publicClient: PublicClient<Transport, Chain | undefined>, op: UserOperation, entryPoint: Address, staticFee: bigint): Promise<bigint>;
64
+ export declare function parseViemError(err: unknown): NonceTooLowError | FeeCapTooLowError | InsufficientFundsError | IntrinsicGasTooLowError | ContractFunctionRevertedError | EstimateGasExecutionError | undefined;
65
+ //# sourceMappingURL=validation.d.ts.map