@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,410 @@
1
+ import { EntryPointV06Abi, ExecutionErrors, RpcError, ValidationErrors, executionResultSchema, hexDataSchema, EntryPointV06SimulationsAbi, EntryPointV07SimulationsAbi, EntryPointV07Abi, targetCallResultSchema } from "../types/index.js";
2
+ import { deepHexlify, getUserOperationHash, isVersion06, toPackedUserOperation } from "../utils/index.js";
3
+ import { decodeErrorResult, encodeFunctionData, toHex, decodeAbiParameters, decodeFunctionResult, toFunctionSelector, toBytes, slice } from "viem";
4
+ import { z } from "zod";
5
+ import { ExecuteSimulatorDeployedBytecode } from "./ExecuteSimulator.js";
6
+ import { PimlicoEntryPointSimulationsAbi } from "../types/index.js";
7
+ function getStateOverrides({ userOperation, entryPoint, replacedEntryPoint, stateOverride = {} }) {
8
+ return replacedEntryPoint
9
+ ? {
10
+ ...stateOverride,
11
+ [userOperation.sender]: {
12
+ balance: toHex(100000000000000000000000n),
13
+ ...(stateOverride
14
+ ? deepHexlify(stateOverride?.[userOperation.sender])
15
+ : [])
16
+ },
17
+ [entryPoint]: {
18
+ code: ExecuteSimulatorDeployedBytecode
19
+ }
20
+ }
21
+ : {
22
+ ...stateOverride,
23
+ [userOperation.sender]: {
24
+ balance: toHex(100000000000000000000000n),
25
+ ...(stateOverride
26
+ ? deepHexlify(stateOverride?.[userOperation.sender])
27
+ : [])
28
+ }
29
+ };
30
+ }
31
+ export async function simulateHandleOpV06(userOperation, entryPoint, publicClient, targetAddress, targetCallData, finalParam = undefined, fixedGasLimitForEstimation) {
32
+ try {
33
+ await publicClient.request({
34
+ method: "eth_call",
35
+ params: [
36
+ {
37
+ to: entryPoint,
38
+ data: encodeFunctionData({
39
+ abi: EntryPointV06Abi,
40
+ functionName: "simulateHandleOp",
41
+ args: [userOperation, targetAddress, targetCallData]
42
+ }),
43
+ ...(fixedGasLimitForEstimation !== undefined && {
44
+ gas: `0x${fixedGasLimitForEstimation.toString(16)}`
45
+ }),
46
+ },
47
+ "latest",
48
+ // @ts-ignore
49
+ ...(finalParam ? [finalParam] : [])
50
+ ]
51
+ });
52
+ }
53
+ catch (e) {
54
+ const err = e;
55
+ if (/return data out of bounds.*|EVM error OutOfOffset.*/.test(err.details)) {
56
+ // out of bound (low level evm error) occurs when paymaster reverts with less than 32bytes
57
+ return {
58
+ result: "failed",
59
+ data: "AA50 postOp revert (paymaster revert data out of bounds)"
60
+ };
61
+ }
62
+ const causeParseResult = z
63
+ .union([
64
+ z.object({
65
+ code: z.literal(3),
66
+ message: z.string().regex(/execution reverted.*/),
67
+ data: hexDataSchema
68
+ }),
69
+ /* fuse rpcs return weird values, this accounts for that. */
70
+ z.object({
71
+ code: z.number(),
72
+ message: z.string().regex(/VM execution error.*/),
73
+ data: z
74
+ .string()
75
+ .transform((data) => data.replace("Reverted ", ""))
76
+ .pipe(hexDataSchema)
77
+ })
78
+ ])
79
+ .safeParse(err.cause);
80
+ if (!causeParseResult.success) {
81
+ throw new Error(JSON.stringify(err.cause));
82
+ }
83
+ const cause = causeParseResult.data;
84
+ if (cause.data === "0x") {
85
+ throw new RpcError("AA23 reverted: UserOperation called non-existant contract, or reverted with 0x", ValidationErrors.SimulateValidation);
86
+ }
87
+ const decodedError = decodeErrorResult({
88
+ abi: [...EntryPointV06Abi, ...EntryPointV06SimulationsAbi],
89
+ data: cause.data
90
+ });
91
+ if (decodedError &&
92
+ decodedError.errorName === "FailedOp" &&
93
+ decodedError.args) {
94
+ return {
95
+ result: "failed",
96
+ data: decodedError.args[1]
97
+ };
98
+ }
99
+ if (decodedError &&
100
+ decodedError.errorName === "Error" &&
101
+ decodedError.args) {
102
+ return {
103
+ result: "failed",
104
+ data: decodedError.args[0]
105
+ };
106
+ }
107
+ if (decodedError.errorName === "ExecutionResult") {
108
+ const parsedExecutionResult = executionResultSchema.parse(decodedError.args);
109
+ return {
110
+ result: "execution",
111
+ data: {
112
+ executionResult: parsedExecutionResult
113
+ }
114
+ };
115
+ }
116
+ }
117
+ throw new Error("Unexpected error");
118
+ }
119
+ async function callPimlicoEntryPointSimulations(publicClient, entryPoint, entryPointSimulationsCallData, entryPointSimulationsAddress, stateOverride, fixedGasLimitForEstimation) {
120
+ const callData = encodeFunctionData({
121
+ abi: PimlicoEntryPointSimulationsAbi,
122
+ functionName: "simulateEntryPoint",
123
+ args: [entryPoint, entryPointSimulationsCallData]
124
+ });
125
+ const result = (await publicClient.request({
126
+ method: "eth_call",
127
+ params: [
128
+ {
129
+ to: entryPointSimulationsAddress,
130
+ data: callData,
131
+ ...(fixedGasLimitForEstimation !== undefined && {
132
+ gas: `0x${fixedGasLimitForEstimation.toString(16)}`
133
+ })
134
+ },
135
+ "latest",
136
+ // @ts-ignore
137
+ ...(stateOverride ? [stateOverride] : [])
138
+ ]
139
+ }));
140
+ const returnBytes = decodeAbiParameters([{ name: "ret", type: "bytes[]" }], result);
141
+ return returnBytes[0].map((data) => {
142
+ const decodedDelegateAndError = decodeErrorResult({
143
+ abi: EntryPointV07Abi,
144
+ data: data
145
+ });
146
+ if (!decodedDelegateAndError?.args?.[1]) {
147
+ throw new Error("Unexpected error");
148
+ }
149
+ return decodedDelegateAndError.args[1];
150
+ });
151
+ }
152
+ const panicCodes = {
153
+ // from https://docs.soliditylang.org/en/v0.8.0/control-structures.html
154
+ 1: "assert(false)",
155
+ 17: "arithmetic overflow/underflow",
156
+ 18: "divide by zero",
157
+ 33: "invalid enum value",
158
+ 34: "storage byte array that is incorrectly encoded",
159
+ 49: ".pop() on an empty array.",
160
+ 50: "array sout-of-bounds or negative index",
161
+ 65: "memory overflow",
162
+ 81: "zero-initialized variable of internal function type"
163
+ };
164
+ export function parseFailedOpWithRevert(data) {
165
+ const methodSig = data.slice(0, 10);
166
+ const dataParams = `0x${data.slice(10)}`;
167
+ if (methodSig === "0x08c379a0") {
168
+ const [err] = decodeAbiParameters([
169
+ {
170
+ name: "err",
171
+ type: "string"
172
+ }
173
+ ], dataParams);
174
+ return err;
175
+ }
176
+ if (methodSig === "0x4e487b71") {
177
+ const [code] = decodeAbiParameters([
178
+ {
179
+ name: "err",
180
+ type: "uint256"
181
+ }
182
+ ], dataParams);
183
+ return panicCodes[Number(code)] ?? `${code}`;
184
+ }
185
+ return data;
186
+ }
187
+ function validateTargetCallDataResult(data) {
188
+ try {
189
+ const targetCallResult = decodeFunctionResult({
190
+ abi: EntryPointV07SimulationsAbi,
191
+ functionName: "simulateCallData",
192
+ data: data
193
+ });
194
+ const parsedTargetCallResult = targetCallResultSchema.parse(targetCallResult);
195
+ if (parsedTargetCallResult.success) {
196
+ return {
197
+ result: "success",
198
+ data: parsedTargetCallResult
199
+ };
200
+ }
201
+ return {
202
+ result: "failed",
203
+ data: parsedTargetCallResult.returnData,
204
+ code: ExecutionErrors.UserOperationReverted
205
+ };
206
+ }
207
+ catch (_e) {
208
+ // no error we go the result
209
+ return {
210
+ result: "failed",
211
+ data: "Unknown error, could not parse target call data result.",
212
+ code: ExecutionErrors.UserOperationReverted
213
+ };
214
+ }
215
+ }
216
+ function getSimulateHandleOpResult(data) {
217
+ try {
218
+ const decodedError = decodeErrorResult({
219
+ abi: EntryPointV07SimulationsAbi,
220
+ data: data
221
+ });
222
+ if (decodedError &&
223
+ decodedError.errorName === "FailedOp" &&
224
+ decodedError.args) {
225
+ return {
226
+ result: "failed",
227
+ data: decodedError.args[1],
228
+ code: ValidationErrors.SimulateValidation
229
+ };
230
+ }
231
+ if (decodedError &&
232
+ decodedError.errorName === "FailedOpWithRevert" &&
233
+ decodedError.args) {
234
+ return {
235
+ result: "failed",
236
+ data: parseFailedOpWithRevert(decodedError.args?.[2]),
237
+ code: ValidationErrors.SimulateValidation
238
+ };
239
+ }
240
+ }
241
+ catch {
242
+ // no error we go the result
243
+ const decodedResult = decodeFunctionResult({
244
+ abi: EntryPointV07SimulationsAbi,
245
+ functionName: "simulateHandleOp",
246
+ data
247
+ });
248
+ return {
249
+ result: "execution",
250
+ data: {
251
+ executionResult: decodedResult
252
+ }
253
+ };
254
+ }
255
+ throw new Error("Unexpected error");
256
+ }
257
+ export async function simulateHandleOpV07(userOperation, queuedUserOperations, entryPoint, publicClient, entryPointSimulationsAddress, chainId, finalParam = undefined, fixedGasLimitForEstimation) {
258
+ const userOperations = [...queuedUserOperations, userOperation];
259
+ const packedUserOperations = userOperations.map((uop) => ({
260
+ packedUserOperation: toPackedUserOperation(uop),
261
+ userOperation: uop,
262
+ userOperationHash: getUserOperationHash(uop, entryPoint, chainId)
263
+ }));
264
+ const entryPointSimulationsSimulateHandleOpCallData = encodeFunctionData({
265
+ abi: EntryPointV07SimulationsAbi,
266
+ functionName: "simulateHandleOpLast",
267
+ args: [packedUserOperations.map((uop) => uop.packedUserOperation)]
268
+ });
269
+ const entryPointSimulationsSimulateTargetCallData = encodeFunctionData({
270
+ abi: EntryPointV07SimulationsAbi,
271
+ functionName: "simulateCallDataLast",
272
+ args: [
273
+ packedUserOperations.map((uop) => uop.packedUserOperation),
274
+ packedUserOperations.map((packedUserOperation) => packedUserOperation.userOperation.sender),
275
+ packedUserOperations.map((packedUserOperation) => {
276
+ const executeUserOpAbi = [
277
+ {
278
+ inputs: [
279
+ {
280
+ components: [
281
+ {
282
+ internalType: "address",
283
+ name: "sender",
284
+ type: "address"
285
+ },
286
+ {
287
+ internalType: "uint256",
288
+ name: "nonce",
289
+ type: "uint256"
290
+ },
291
+ {
292
+ internalType: "bytes",
293
+ name: "initCode",
294
+ type: "bytes"
295
+ },
296
+ {
297
+ internalType: "bytes",
298
+ name: "callData",
299
+ type: "bytes"
300
+ },
301
+ {
302
+ internalType: "bytes32",
303
+ name: "accountGasLimits",
304
+ type: "bytes32"
305
+ },
306
+ {
307
+ internalType: "uint256",
308
+ name: "preVerificationGas",
309
+ type: "uint256"
310
+ },
311
+ {
312
+ internalType: "bytes32",
313
+ name: "gasFees",
314
+ type: "bytes32"
315
+ },
316
+ {
317
+ internalType: "bytes",
318
+ name: "paymasterAndData",
319
+ type: "bytes"
320
+ },
321
+ {
322
+ internalType: "bytes",
323
+ name: "signature",
324
+ type: "bytes"
325
+ }
326
+ ],
327
+ internalType: "struct PackedUserOperation",
328
+ name: "userOp",
329
+ type: "tuple"
330
+ },
331
+ {
332
+ internalType: "bytes32",
333
+ name: "userOpHash",
334
+ type: "bytes32"
335
+ }
336
+ ],
337
+ name: "executeUserOp",
338
+ outputs: [],
339
+ stateMutability: "nonpayable",
340
+ type: "function"
341
+ }
342
+ ];
343
+ const executeUserOpMethodSig = toFunctionSelector(executeUserOpAbi[0]);
344
+ const callDataMethodSig = toHex(slice(toBytes(packedUserOperation.userOperation.callData), 0, 4));
345
+ if (executeUserOpMethodSig === callDataMethodSig) {
346
+ return encodeFunctionData({
347
+ abi: executeUserOpAbi,
348
+ functionName: "executeUserOp",
349
+ args: [
350
+ packedUserOperation.packedUserOperation,
351
+ getUserOperationHash(packedUserOperation.userOperation, entryPoint, chainId)
352
+ ]
353
+ });
354
+ }
355
+ return packedUserOperation.userOperation.callData;
356
+ })
357
+ ]
358
+ });
359
+ const cause = await callPimlicoEntryPointSimulations(publicClient, entryPoint, [
360
+ entryPointSimulationsSimulateHandleOpCallData,
361
+ entryPointSimulationsSimulateTargetCallData
362
+ ], entryPointSimulationsAddress, finalParam, fixedGasLimitForEstimation);
363
+ try {
364
+ const executionResult = getSimulateHandleOpResult(cause[0]);
365
+ if (executionResult.result === "failed") {
366
+ return executionResult;
367
+ }
368
+ const targetCallValidationResult = validateTargetCallDataResult(cause[1]);
369
+ if (targetCallValidationResult.result === "failed") {
370
+ return targetCallValidationResult;
371
+ }
372
+ return {
373
+ result: "execution",
374
+ data: {
375
+ callDataResult: targetCallValidationResult.data,
376
+ executionResult: executionResult.data.executionResult
377
+ }
378
+ };
379
+ }
380
+ catch (e) {
381
+ return {
382
+ result: "failed",
383
+ data: "Unknown error, could not parse simulate handle op result.",
384
+ code: ValidationErrors.SimulateValidation
385
+ };
386
+ }
387
+ }
388
+ export function simulateHandleOp(userOperation, queuedUserOperations, entryPoint, publicClient, replacedEntryPoint, targetAddress, targetCallData, balanceOverrideEnabled, chainId, stateOverride = {}, entryPointSimulationsAddress, fixedGasLimitForEstimation) {
389
+ let finalStateOverride = undefined;
390
+ if (balanceOverrideEnabled) {
391
+ finalStateOverride = getStateOverrides({
392
+ userOperation,
393
+ entryPoint,
394
+ replacedEntryPoint,
395
+ stateOverride
396
+ });
397
+ }
398
+ if (isVersion06(userOperation)) {
399
+ return simulateHandleOpV06(userOperation, entryPoint, publicClient, targetAddress, targetCallData, finalStateOverride,
400
+ // Enable fixed gas limit for estimation only for Vanguard testnet and Vanar mainnet
401
+ chainId === 2040 || chainId === 78600 ? fixedGasLimitForEstimation : undefined);
402
+ }
403
+ if (!entryPointSimulationsAddress) {
404
+ throw new RpcError("entryPointSimulationsAddress must be provided for V07 UserOperation", ValidationErrors.InvalidFields);
405
+ }
406
+ return simulateHandleOpV07(userOperation, queuedUserOperations, entryPoint, publicClient, entryPointSimulationsAddress, chainId, finalStateOverride,
407
+ // Enable fixed gas limit for estimation only for Vanguard testnet and Vanar mainnet
408
+ chainId === 2040 || chainId === 78600 ? fixedGasLimitForEstimation : undefined);
409
+ }
410
+ //# sourceMappingURL=gasEstimation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gasEstimation.js","sourceRoot":"","sources":["../../rpc/gasEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,eAAe,EAEf,QAAQ,EAER,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,2BAA2B,EAC3B,2BAA2B,EAC3B,gBAAgB,EAChB,sBAAsB,EACzB,MAAM,aAAa,CAAA;AAOpB,OAAO,EACH,WAAW,EACX,oBAAoB,EACpB,WAAW,EACX,qBAAqB,EACxB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAGH,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,OAAO,EACP,KAAK,EACR,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAA;AAE7D,SAAS,iBAAiB,CAAC,EACvB,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,aAAa,GAAG,EAAE,EAMrB;IACG,OAA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YACjE,IAAI,EAAE,gBAAgB,CAAC,kBAAkB;SAC5C,CAAA;IACL,CAAC;AACL,CAAC;AAeD,MAAM,UAAU,gBAAgB,CAC5B,aAA4B,EAC5B,oBAAqC,EACrC,UAAmB,EACnB,YAA0B,EAC1B,kBAA2B,EAC3B,aAAsB,EACtB,cAAmB,EACnB,sBAA+B,EAC/B,OAAe,EACf,gBAAgC,EAAE,EAClC,4BAAsC,EACtC,0BAAmC;IAEnC,IAAI,kBAAkB,GAAG,SAAS,CAAA;IAElC,IAAI,sBAAsB,EAAE,CAAC;QACzB,kBAAkB,GAAG,iBAAiB,CAAC;YACnC,aAAa;YACb,UAAU;YACV,kBAAkB;YAClB,aAAa;SAChB,CAAC,CAAA;IACN,CAAC;IAED,IAAI,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC;QAC7B,OAAO,mBAAmB,CACtB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,aAAa,EACb,cAAc,EACd,kBAAkB;QAClB,oFAAoF;QACpF,OAAO,KAAK,IAAI,IAAI,OAAO,KAAI,KAAK,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,SAAS,CAChF,CAAA;IACL,CAAC;IAED,IAAI,CAAC,4BAA4B,EAAE,CAAC;QAChC,MAAM,IAAI,QAAQ,CACd,qEAAqE,EACrE,gBAAgB,CAAC,aAAa,CACjC,CAAA;IACL,CAAC;IAED,OAAO,mBAAmB,CACtB,aAAa,EACb,oBAA0C,EAC1C,UAAU,EACV,YAAY,EACZ,4BAA4B,EAC5B,OAAO,EACP,kBAAkB;IAClB,oFAAoF;IACpF,OAAO,KAAK,IAAI,IAAI,OAAO,KAAI,KAAK,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,SAAS,CAChF,CAAA;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./rpcHandler.js";
2
+ export * from "./server.js";
3
+ export * from "./validation/index.js";
4
+ export * from "./nonceQueuer.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ export * from "./rpcHandler.js";
2
+ export * from "./server.js";
3
+ export * from "./validation/index.js";
4
+ export * from "./nonceQueuer.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../rpc/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { type MempoolUserOperation } from "../types/index.js";
2
+ import type { Logger } from "../utils/index.js";
3
+ import { type Address, type Chain, type Hash, type PublicClient, type Transport } from "viem";
4
+ import type { MemoryMempool } from "../mempool/index.js";
5
+ type QueuedUserOperation = {
6
+ entryPoint: Address;
7
+ userOperationHash: Hash;
8
+ mempoolUserOperation: MempoolUserOperation;
9
+ nonceKey: bigint;
10
+ nonceValue: bigint;
11
+ addedAt: number;
12
+ };
13
+ export declare class NonceQueuer {
14
+ queuedUserOperations: QueuedUserOperation[];
15
+ mempool: MemoryMempool;
16
+ publicClient: PublicClient<Transport, Chain>;
17
+ logger: Logger;
18
+ constructor(mempool: MemoryMempool, publicClient: PublicClient<Transport, Chain>, logger: Logger);
19
+ process(): Promise<void>;
20
+ add(mempoolUserOperation: MempoolUserOperation, entryPoint: Address): void;
21
+ resubmitUserOperation(mempoolUserOperation: MempoolUserOperation, entryPoint: Address): void;
22
+ getAvailableUserOperations(publicClient: PublicClient): Promise<QueuedUserOperation[]>;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=nonceQueuer.d.ts.map
@@ -0,0 +1,135 @@
1
+ import { EntryPointV06Abi, deriveUserOperation, EntryPointV07Abi } from "../types/index.js";
2
+ import { getNonceKeyAndValue, getUserOperationHash, isVersion06 } from "../utils/index.js";
3
+ import { getContract } from "viem";
4
+ export class NonceQueuer {
5
+ queuedUserOperations = [];
6
+ mempool;
7
+ publicClient;
8
+ logger;
9
+ constructor(mempool, publicClient, logger) {
10
+ this.mempool = mempool;
11
+ this.publicClient = publicClient;
12
+ this.logger = logger;
13
+ setInterval(() => {
14
+ this.process();
15
+ }, 2000);
16
+ }
17
+ async process() {
18
+ // remove queued ops that have been in the queue for more than 15 minutes
19
+ this.queuedUserOperations = this.queuedUserOperations.filter((qop) => {
20
+ return qop.addedAt > Date.now() - 1000 * 60 * 15;
21
+ });
22
+ if (this.queuedUserOperations.length === 0) {
23
+ return;
24
+ }
25
+ const availableOps = await this.getAvailableUserOperations(this.publicClient);
26
+ if (availableOps.length === 0) {
27
+ return;
28
+ }
29
+ this.queuedUserOperations = this.queuedUserOperations.filter((qop) => {
30
+ return !availableOps.some((op) => {
31
+ return op.userOperationHash === qop.userOperationHash;
32
+ });
33
+ });
34
+ availableOps.map((op) => {
35
+ this.resubmitUserOperation(op.mempoolUserOperation, op.entryPoint);
36
+ });
37
+ this.logger.info({ availableOps: availableOps.map((qop) => qop.userOperationHash) }, "submitted user operations from nonce queue");
38
+ }
39
+ add(mempoolUserOperation, entryPoint) {
40
+ const userOperation = deriveUserOperation(mempoolUserOperation);
41
+ const [nonceKey, nonceValue] = getNonceKeyAndValue(userOperation.nonce);
42
+ this.queuedUserOperations.push({
43
+ entryPoint,
44
+ userOperationHash: getUserOperationHash(deriveUserOperation(mempoolUserOperation), entryPoint, this.publicClient.chain.id),
45
+ mempoolUserOperation: mempoolUserOperation,
46
+ nonceKey: nonceKey,
47
+ nonceValue: nonceValue,
48
+ addedAt: Date.now()
49
+ });
50
+ }
51
+ resubmitUserOperation(mempoolUserOperation, entryPoint) {
52
+ const userOperation = mempoolUserOperation;
53
+ this.logger.info({ userOperation: userOperation }, "submitting user operation from nonce queue");
54
+ const result = this.mempool.add(mempoolUserOperation, entryPoint);
55
+ if (result) {
56
+ this.logger.info({ userOperation: userOperation, result: result }, "added user operation");
57
+ }
58
+ else {
59
+ this.logger.error("error adding user operation");
60
+ }
61
+ }
62
+ async getAvailableUserOperations(publicClient) {
63
+ const queuedUserOperations = this.queuedUserOperations.slice();
64
+ let results;
65
+ try {
66
+ results = await publicClient.multicall({
67
+ contracts: queuedUserOperations.map((qop) => {
68
+ const userOperation = deriveUserOperation(qop.mempoolUserOperation);
69
+ const isUserOpV06 = isVersion06(userOperation);
70
+ return {
71
+ address: qop.entryPoint,
72
+ abi: isUserOpV06 ? EntryPointV06Abi : EntryPointV07Abi,
73
+ functionName: "getNonce",
74
+ args: [userOperation.sender, qop.nonceKey]
75
+ };
76
+ }),
77
+ blockTag: "latest"
78
+ });
79
+ }
80
+ catch (error) {
81
+ this.logger.error({ error: JSON.stringify(error) }, "error fetching with multiCall");
82
+ results = await Promise.all(queuedUserOperations.map(async (qop) => {
83
+ const userOperation = deriveUserOperation(qop.mempoolUserOperation);
84
+ try {
85
+ const isUserOpV06 = isVersion06(userOperation);
86
+ const entryPointContract = isUserOpV06
87
+ ? getContract({
88
+ abi: EntryPointV06Abi,
89
+ address: qop.entryPoint,
90
+ client: {
91
+ public: publicClient
92
+ }
93
+ })
94
+ : getContract({
95
+ abi: EntryPointV07Abi,
96
+ address: qop.entryPoint,
97
+ client: {
98
+ public: publicClient
99
+ }
100
+ });
101
+ const nonce = await entryPointContract.read.getNonce([userOperation.sender, qop.nonceKey], { blockTag: "latest" });
102
+ return {
103
+ result: nonce,
104
+ status: "success"
105
+ };
106
+ }
107
+ catch (e) {
108
+ return {
109
+ error: e,
110
+ status: "failure"
111
+ };
112
+ }
113
+ }));
114
+ }
115
+ if (results.length !== queuedUserOperations.length) {
116
+ this.logger.error("error fetching nonces");
117
+ return [];
118
+ }
119
+ const currentOutstandingOps = [];
120
+ for (let i = 0; i < queuedUserOperations.length; i++) {
121
+ const qop = queuedUserOperations[i];
122
+ const result = results[i];
123
+ if (result.status !== "success") {
124
+ this.logger.error({ error: result.error }, "error fetching nonce");
125
+ continue;
126
+ }
127
+ const onchainNonceValue = result.result;
128
+ if (onchainNonceValue === qop.nonceValue) {
129
+ currentOutstandingOps.push(qop);
130
+ }
131
+ }
132
+ return currentOutstandingOps;
133
+ }
134
+ }
135
+ //# sourceMappingURL=nonceQueuer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nonceQueuer.js","sourceRoot":"","sources":["../../rpc/nonceQueuer.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAEhB,mBAAmB,EACnB,gBAAgB,EACnB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACH,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACd,MAAM,aAAa,CAAA;AACpB,OAAO,EAOH,WAAW,EACd,MAAM,MAAM,CAAA;AAYb,MAAM,OAAO,WAAW;IACpB,oBAAoB,GAA0B,EAAE,CAAA;IAEhD,OAAO,CAAe;IACtB,YAAY,CAAgC;IAC5C,MAAM,CAAQ;IAEd,YACI,OAAsB,EACtB,YAA4C,EAC5C,MAAc;QAEd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,WAAW,CAAC,GAAG,EAAE;YACb,IAAI,CAAC,OAAO,EAAE,CAAA;QAClB,CAAC,EAAE,IAAI,CAAC,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,OAAO;QACT,yEAAyE;QACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;YACjE,OAAO,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAA;QACpD,CAAC,CAAC,CAAA;QAEF,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzC,OAAM;QACV,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,0BAA0B,CACtD,IAAI,CAAC,YAAY,CACpB,CAAA;QAED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