@pimlico/alto 0.0.6 → 0.0.8

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 (292) hide show
  1. package/esm/cli/alto.js +3 -1
  2. package/esm/cli/alto.js.map +1 -1
  3. package/esm/cli/config/bundler.d.ts +348 -306
  4. package/esm/cli/config/bundler.js +26 -7
  5. package/esm/cli/config/bundler.js.map +1 -1
  6. package/esm/cli/config/options.d.ts +2 -1
  7. package/esm/cli/config/options.js +46 -8
  8. package/esm/cli/config/options.js.map +1 -1
  9. package/esm/cli/customTransport.js +40 -7
  10. package/esm/cli/customTransport.js.map +1 -1
  11. package/esm/cli/deploySimulationsContract.d.ts +8 -0
  12. package/esm/cli/deploySimulationsContract.js +26 -0
  13. package/esm/cli/deploySimulationsContract.js.map +1 -0
  14. package/esm/cli/handler.d.ts +2 -2
  15. package/esm/cli/handler.js +67 -89
  16. package/esm/cli/handler.js.map +1 -1
  17. package/esm/cli/instrumentation.js +4 -2
  18. package/esm/cli/instrumentation.js.map +1 -1
  19. package/esm/cli/parseArgs.d.ts +8 -0
  20. package/esm/cli/parseArgs.js +21 -0
  21. package/esm/cli/parseArgs.js.map +1 -0
  22. package/esm/cli/setupServer.d.ts +4 -9
  23. package/esm/cli/setupServer.js +98 -82
  24. package/esm/cli/setupServer.js.map +1 -1
  25. package/esm/createConfig.d.ts +15 -0
  26. package/esm/createConfig.js +8 -0
  27. package/esm/createConfig.js.map +1 -0
  28. package/esm/executor/executor.d.ts +29 -13
  29. package/esm/executor/executor.js +110 -72
  30. package/esm/executor/executor.js.map +1 -1
  31. package/esm/executor/executorManager.d.ts +14 -10
  32. package/esm/executor/executorManager.js +42 -42
  33. package/esm/executor/executorManager.js.map +1 -1
  34. package/esm/executor/senderManager.d.ts +11 -6
  35. package/esm/executor/senderManager.js +25 -32
  36. package/esm/executor/senderManager.js.map +1 -1
  37. package/esm/executor/utilityWalletMonitor.d.ts +9 -5
  38. package/esm/executor/utilityWalletMonitor.js +8 -8
  39. package/esm/executor/utilityWalletMonitor.js.map +1 -1
  40. package/esm/executor/utils.d.ts +2 -1
  41. package/esm/executor/utils.js +7 -2
  42. package/esm/executor/utils.js.map +1 -1
  43. package/esm/handlers/arbitrumGasPriceManager.d.ts +11 -0
  44. package/esm/handlers/arbitrumGasPriceManager.js +29 -0
  45. package/esm/handlers/arbitrumGasPriceManager.js.map +1 -0
  46. package/esm/handlers/eventManager.d.ts +7 -3
  47. package/esm/handlers/eventManager.js +24 -16
  48. package/esm/handlers/eventManager.js.map +1 -1
  49. package/esm/handlers/gasPriceManager.d.ts +14 -27
  50. package/esm/handlers/gasPriceManager.js +81 -135
  51. package/esm/handlers/gasPriceManager.js.map +1 -1
  52. package/esm/handlers/mantleGasPriceManager.d.ts +20 -0
  53. package/esm/handlers/mantleGasPriceManager.js +28 -0
  54. package/esm/handlers/mantleGasPriceManager.js.map +1 -0
  55. package/esm/mempool/mempool.d.ts +13 -10
  56. package/esm/mempool/mempool.js +29 -26
  57. package/esm/mempool/mempool.js.map +1 -1
  58. package/esm/mempool/reputationManager.d.ts +4 -6
  59. package/esm/mempool/reputationManager.js +25 -29
  60. package/esm/mempool/reputationManager.js.map +1 -1
  61. package/esm/mempool/store.d.ts +1 -1
  62. package/esm/rpc/estimation/gasEstimationHandler.d.ts +24 -0
  63. package/esm/rpc/estimation/gasEstimationHandler.js +48 -0
  64. package/esm/rpc/estimation/gasEstimationHandler.js.map +1 -0
  65. package/esm/rpc/estimation/gasEstimationsV06.d.ts +19 -0
  66. package/esm/rpc/estimation/gasEstimationsV06.js +146 -0
  67. package/esm/rpc/estimation/gasEstimationsV06.js.map +1 -0
  68. package/esm/rpc/estimation/gasEstimationsV07.d.ts +88 -0
  69. package/esm/rpc/estimation/gasEstimationsV07.js +429 -0
  70. package/esm/rpc/estimation/gasEstimationsV07.js.map +1 -0
  71. package/esm/rpc/estimation/types.d.ts +113 -0
  72. package/esm/rpc/estimation/types.js +122 -0
  73. package/esm/rpc/estimation/types.js.map +1 -0
  74. package/esm/rpc/nonceQueuer.d.ts +10 -6
  75. package/esm/rpc/nonceQueuer.js +10 -10
  76. package/esm/rpc/nonceQueuer.js.map +1 -1
  77. package/esm/rpc/rpcHandler.d.ts +19 -16
  78. package/esm/rpc/rpcHandler.js +83 -72
  79. package/esm/rpc/rpcHandler.js.map +1 -1
  80. package/esm/rpc/server.d.ts +9 -7
  81. package/esm/rpc/server.js +27 -26
  82. package/esm/rpc/server.js.map +1 -1
  83. package/esm/rpc/validation/SafeValidator.d.ts +11 -6
  84. package/esm/rpc/validation/SafeValidator.js +16 -14
  85. package/esm/rpc/validation/SafeValidator.js.map +1 -1
  86. package/esm/rpc/validation/TracerResultParserV06.d.ts +1 -1
  87. package/esm/rpc/validation/TracerResultParserV06.js.map +1 -1
  88. package/esm/rpc/validation/TracerResultParserV07.d.ts +1 -1
  89. package/esm/rpc/validation/TracerResultParserV07.js +1 -1
  90. package/esm/rpc/validation/TracerResultParserV07.js.map +1 -1
  91. package/esm/rpc/validation/UnsafeValidator.d.ts +14 -17
  92. package/esm/rpc/validation/UnsafeValidator.js +49 -42
  93. package/esm/rpc/validation/UnsafeValidator.js.map +1 -1
  94. package/esm/types/contracts/ArbitrumL1FeeAbi.d.ts +32 -0
  95. package/esm/types/contracts/ArbitrumL1FeeAbi.js +42 -0
  96. package/esm/types/contracts/ArbitrumL1FeeAbi.js.map +1 -0
  97. package/esm/types/contracts/EntryPointSimulationsV6.d.ts +34 -0
  98. package/esm/types/contracts/EntryPointSimulationsV6.js +48 -0
  99. package/esm/types/contracts/EntryPointSimulationsV6.js.map +1 -0
  100. package/esm/types/contracts/EntryPointSimulationsV7.d.ts +1370 -0
  101. package/esm/types/contracts/{EntryPointSimulations.js → EntryPointSimulationsV7.js} +197 -385
  102. package/esm/types/contracts/EntryPointSimulationsV7.js.map +1 -0
  103. package/esm/types/contracts/IAccountExecute.d.ts +53 -0
  104. package/esm/types/contracts/IAccountExecute.js +68 -0
  105. package/esm/types/contracts/IAccountExecute.js.map +1 -0
  106. package/esm/types/contracts/MantleBvmGasPriceOracle.d.ts +219 -0
  107. package/esm/types/contracts/MantleBvmGasPriceOracle.js +177 -0
  108. package/esm/types/contracts/MantleBvmGasPriceOracle.js.map +1 -0
  109. package/esm/types/contracts/OpL1FeeAbi.d.ts +26 -0
  110. package/esm/types/contracts/OpL1FeeAbi.js +29 -0
  111. package/esm/types/contracts/OpL1FeeAbi.js.map +1 -0
  112. package/esm/types/contracts/PimlicoEntryPointSimulations.d.ts +1 -1
  113. package/esm/types/contracts/PimlicoEntryPointSimulations.js +1 -1
  114. package/esm/types/contracts/PimlicoEntryPointSimulations.js.map +1 -1
  115. package/esm/types/contracts/index.d.ts +5 -1
  116. package/esm/types/contracts/index.js +5 -1
  117. package/esm/types/contracts/index.js.map +1 -1
  118. package/esm/types/interfaces.d.ts +2 -2
  119. package/esm/types/schemas.d.ts +94 -94
  120. package/esm/types/schemas.js +3 -3
  121. package/esm/types/schemas.js.map +1 -1
  122. package/esm/types/utils.d.ts +1 -1
  123. package/esm/utils/bigInt.js +2 -2
  124. package/esm/utils/bigInt.js.map +1 -1
  125. package/esm/utils/helpers.js +1 -1
  126. package/esm/utils/helpers.js.map +1 -1
  127. package/esm/utils/rpc-reply.d.ts +1 -1
  128. package/esm/utils/timedQueue.d.ts +12 -0
  129. package/esm/utils/timedQueue.js +51 -0
  130. package/esm/utils/timedQueue.js.map +1 -0
  131. package/esm/utils/userop.d.ts +2 -2
  132. package/esm/utils/userop.js +2 -2
  133. package/esm/utils/userop.js.map +1 -1
  134. package/esm/utils/validation.d.ts +14 -6
  135. package/esm/utils/validation.js +115 -132
  136. package/esm/utils/validation.js.map +1 -1
  137. package/lib/cli/alto.js +2 -0
  138. package/lib/cli/alto.js.map +1 -1
  139. package/lib/cli/config/bundler.d.ts +348 -306
  140. package/lib/cli/config/bundler.js +26 -7
  141. package/lib/cli/config/bundler.js.map +1 -1
  142. package/lib/cli/config/options.d.ts +2 -1
  143. package/lib/cli/config/options.js +47 -9
  144. package/lib/cli/config/options.js.map +1 -1
  145. package/lib/cli/customTransport.js +38 -5
  146. package/lib/cli/customTransport.js.map +1 -1
  147. package/lib/cli/deploySimulationsContract.d.ts +8 -0
  148. package/lib/cli/deploySimulationsContract.js +30 -0
  149. package/lib/cli/deploySimulationsContract.js.map +1 -0
  150. package/lib/cli/handler.d.ts +2 -2
  151. package/lib/cli/handler.js +66 -88
  152. package/lib/cli/handler.js.map +1 -1
  153. package/lib/cli/instrumentation.js +4 -2
  154. package/lib/cli/instrumentation.js.map +1 -1
  155. package/lib/cli/parseArgs.d.ts +8 -0
  156. package/lib/cli/parseArgs.js +25 -0
  157. package/lib/cli/parseArgs.js.map +1 -0
  158. package/lib/cli/setupServer.d.ts +4 -9
  159. package/lib/cli/setupServer.js +98 -82
  160. package/lib/cli/setupServer.js.map +1 -1
  161. package/lib/createConfig.d.ts +15 -0
  162. package/lib/createConfig.js +12 -0
  163. package/lib/createConfig.js.map +1 -0
  164. package/lib/executor/executor.d.ts +29 -13
  165. package/lib/executor/executor.js +106 -68
  166. package/lib/executor/executor.js.map +1 -1
  167. package/lib/executor/executorManager.d.ts +14 -10
  168. package/lib/executor/executorManager.js +40 -40
  169. package/lib/executor/executorManager.js.map +1 -1
  170. package/lib/executor/senderManager.d.ts +11 -6
  171. package/lib/executor/senderManager.js +25 -32
  172. package/lib/executor/senderManager.js.map +1 -1
  173. package/lib/executor/utilityWalletMonitor.d.ts +9 -5
  174. package/lib/executor/utilityWalletMonitor.js +8 -8
  175. package/lib/executor/utilityWalletMonitor.js.map +1 -1
  176. package/lib/executor/utils.d.ts +2 -1
  177. package/lib/executor/utils.js +9 -3
  178. package/lib/executor/utils.js.map +1 -1
  179. package/lib/handlers/arbitrumGasPriceManager.d.ts +11 -0
  180. package/lib/handlers/arbitrumGasPriceManager.js +33 -0
  181. package/lib/handlers/arbitrumGasPriceManager.js.map +1 -0
  182. package/lib/handlers/eventManager.d.ts +7 -3
  183. package/lib/handlers/eventManager.js +24 -16
  184. package/lib/handlers/eventManager.js.map +1 -1
  185. package/lib/handlers/gasPriceManager.d.ts +14 -27
  186. package/lib/handlers/gasPriceManager.js +80 -134
  187. package/lib/handlers/gasPriceManager.js.map +1 -1
  188. package/lib/handlers/mantleGasPriceManager.d.ts +20 -0
  189. package/lib/handlers/mantleGasPriceManager.js +32 -0
  190. package/lib/handlers/mantleGasPriceManager.js.map +1 -0
  191. package/lib/mempool/mempool.d.ts +13 -10
  192. package/lib/mempool/mempool.js +28 -25
  193. package/lib/mempool/mempool.js.map +1 -1
  194. package/lib/mempool/reputationManager.d.ts +4 -6
  195. package/lib/mempool/reputationManager.js +25 -29
  196. package/lib/mempool/reputationManager.js.map +1 -1
  197. package/lib/mempool/store.d.ts +1 -1
  198. package/lib/rpc/estimation/gasEstimationHandler.d.ts +24 -0
  199. package/lib/rpc/estimation/gasEstimationHandler.js +52 -0
  200. package/lib/rpc/estimation/gasEstimationHandler.js.map +1 -0
  201. package/lib/rpc/estimation/gasEstimationsV06.d.ts +19 -0
  202. package/lib/rpc/estimation/gasEstimationsV06.js +150 -0
  203. package/lib/rpc/estimation/gasEstimationsV06.js.map +1 -0
  204. package/lib/rpc/estimation/gasEstimationsV07.d.ts +88 -0
  205. package/lib/rpc/estimation/gasEstimationsV07.js +435 -0
  206. package/lib/rpc/estimation/gasEstimationsV07.js.map +1 -0
  207. package/lib/rpc/estimation/types.d.ts +113 -0
  208. package/lib/rpc/estimation/types.js +125 -0
  209. package/lib/rpc/estimation/types.js.map +1 -0
  210. package/lib/rpc/nonceQueuer.d.ts +10 -6
  211. package/lib/rpc/nonceQueuer.js +9 -9
  212. package/lib/rpc/nonceQueuer.js.map +1 -1
  213. package/lib/rpc/rpcHandler.d.ts +19 -16
  214. package/lib/rpc/rpcHandler.js +82 -71
  215. package/lib/rpc/rpcHandler.js.map +1 -1
  216. package/lib/rpc/server.d.ts +9 -7
  217. package/lib/rpc/server.js +26 -25
  218. package/lib/rpc/server.js.map +1 -1
  219. package/lib/rpc/validation/SafeValidator.d.ts +11 -6
  220. package/lib/rpc/validation/SafeValidator.js +16 -14
  221. package/lib/rpc/validation/SafeValidator.js.map +1 -1
  222. package/lib/rpc/validation/TracerResultParserV06.d.ts +1 -1
  223. package/lib/rpc/validation/TracerResultParserV07.d.ts +1 -1
  224. package/lib/rpc/validation/TracerResultParserV07.js +1 -1
  225. package/lib/rpc/validation/TracerResultParserV07.js.map +1 -1
  226. package/lib/rpc/validation/UnsafeValidator.d.ts +14 -17
  227. package/lib/rpc/validation/UnsafeValidator.js +49 -42
  228. package/lib/rpc/validation/UnsafeValidator.js.map +1 -1
  229. package/lib/types/contracts/ArbitrumL1FeeAbi.d.ts +32 -0
  230. package/lib/types/contracts/ArbitrumL1FeeAbi.js +45 -0
  231. package/lib/types/contracts/ArbitrumL1FeeAbi.js.map +1 -0
  232. package/lib/types/contracts/EntryPointSimulationsV6.d.ts +34 -0
  233. package/lib/types/contracts/EntryPointSimulationsV6.js +51 -0
  234. package/lib/types/contracts/EntryPointSimulationsV6.js.map +1 -0
  235. package/lib/types/contracts/EntryPointSimulationsV7.d.ts +1370 -0
  236. package/lib/types/contracts/{EntryPointSimulations.js → EntryPointSimulationsV7.js} +198 -386
  237. package/lib/types/contracts/EntryPointSimulationsV7.js.map +1 -0
  238. package/lib/types/contracts/IAccountExecute.d.ts +53 -0
  239. package/lib/types/contracts/IAccountExecute.js +71 -0
  240. package/lib/types/contracts/IAccountExecute.js.map +1 -0
  241. package/lib/types/contracts/MantleBvmGasPriceOracle.d.ts +219 -0
  242. package/lib/types/contracts/MantleBvmGasPriceOracle.js +180 -0
  243. package/lib/types/contracts/MantleBvmGasPriceOracle.js.map +1 -0
  244. package/lib/types/contracts/OpL1FeeAbi.d.ts +26 -0
  245. package/lib/types/contracts/OpL1FeeAbi.js +32 -0
  246. package/lib/types/contracts/OpL1FeeAbi.js.map +1 -0
  247. package/lib/types/contracts/PimlicoEntryPointSimulations.d.ts +1 -1
  248. package/lib/types/contracts/PimlicoEntryPointSimulations.js +1 -1
  249. package/lib/types/contracts/PimlicoEntryPointSimulations.js.map +1 -1
  250. package/lib/types/contracts/index.d.ts +5 -1
  251. package/lib/types/contracts/index.js +5 -1
  252. package/lib/types/contracts/index.js.map +1 -1
  253. package/lib/types/interfaces.d.ts +2 -2
  254. package/lib/types/schemas.d.ts +94 -94
  255. package/lib/types/schemas.js +3 -3
  256. package/lib/types/schemas.js.map +1 -1
  257. package/lib/types/utils.d.ts +1 -1
  258. package/lib/utils/bigInt.js +2 -2
  259. package/lib/utils/bigInt.js.map +1 -1
  260. package/lib/utils/rpc-reply.d.ts +1 -1
  261. package/lib/utils/timedQueue.d.ts +12 -0
  262. package/lib/utils/timedQueue.js +55 -0
  263. package/lib/utils/timedQueue.js.map +1 -0
  264. package/lib/utils/userop.d.ts +2 -2
  265. package/lib/utils/userop.js +1 -1
  266. package/lib/utils/userop.js.map +1 -1
  267. package/lib/utils/validation.d.ts +14 -6
  268. package/lib/utils/validation.js +118 -134
  269. package/lib/utils/validation.js.map +1 -1
  270. package/package.json +1 -1
  271. package/esm/rpc/EntryPointSimulationsV07.d.ts +0 -62
  272. package/esm/rpc/EntryPointSimulationsV07.js +0 -410
  273. package/esm/rpc/EntryPointSimulationsV07.js.map +0 -1
  274. package/esm/rpc/ExecuteSimulator.d.ts +0 -37
  275. package/esm/rpc/ExecuteSimulator.js +0 -48
  276. package/esm/rpc/ExecuteSimulator.js.map +0 -1
  277. package/esm/rpc/gasEstimation.d.ts +0 -17
  278. package/esm/rpc/gasEstimation.js +0 -419
  279. package/esm/rpc/gasEstimation.js.map +0 -1
  280. package/esm/types/contracts/EntryPointSimulations.d.ts +0 -152
  281. package/esm/types/contracts/EntryPointSimulations.js.map +0 -1
  282. package/lib/rpc/EntryPointSimulationsV07.d.ts +0 -62
  283. package/lib/rpc/EntryPointSimulationsV07.js +0 -417
  284. package/lib/rpc/EntryPointSimulationsV07.js.map +0 -1
  285. package/lib/rpc/ExecuteSimulator.d.ts +0 -37
  286. package/lib/rpc/ExecuteSimulator.js +0 -51
  287. package/lib/rpc/ExecuteSimulator.js.map +0 -1
  288. package/lib/rpc/gasEstimation.d.ts +0 -17
  289. package/lib/rpc/gasEstimation.js +0 -426
  290. package/lib/rpc/gasEstimation.js.map +0 -1
  291. package/lib/types/contracts/EntryPointSimulations.d.ts +0 -152
  292. package/lib/types/contracts/EntryPointSimulations.js.map +0 -1
@@ -0,0 +1,429 @@
1
+ import { EntryPointV07Abi, EntryPointV07SimulationsAbi, ExecutionErrors, PimlicoEntryPointSimulationsAbi, RpcError, ValidationErrors, targetCallResultSchema } from "../../types/index.js";
2
+ import { getUserOperationHash, toPackedUserOperation } from "../../utils/index.js";
3
+ import { decodeAbiParameters, decodeErrorResult, decodeFunctionResult, encodeFunctionData, slice, toFunctionSelector, toHex } from "viem";
4
+ import { AccountExecuteAbi } from "../../types/contracts/IAccountExecute.js";
5
+ import { simulationValidationResultStruct } from "./types.js";
6
+ export class GasEstimatorV07 {
7
+ config;
8
+ constructor(config) {
9
+ this.config = config;
10
+ }
11
+ async simulateValidation({ entryPoint, userOperation, queuedUserOperations }) {
12
+ const userOperations = [...queuedUserOperations, userOperation];
13
+ const packedUserOperations = userOperations.map((uo) => toPackedUserOperation(uo));
14
+ const simulateValidationLast = encodeFunctionData({
15
+ abi: EntryPointV07SimulationsAbi,
16
+ functionName: "simulateValidationLast",
17
+ args: [packedUserOperations]
18
+ });
19
+ const errorResult = await this.callPimlicoEntryPointSimulations({
20
+ entryPoint,
21
+ entryPointSimulationsCallData: [simulateValidationLast]
22
+ });
23
+ return {
24
+ simulateValidationResult: getSimulateValidationResult(errorResult[0])
25
+ };
26
+ }
27
+ encodeUserOperationCalldata({ op, entryPoint }) {
28
+ const packedOp = toPackedUserOperation(op);
29
+ const executeUserOpMethodSig = toFunctionSelector(AccountExecuteAbi[0]);
30
+ const callDataMethodSig = slice(packedOp.callData, 0, 4);
31
+ if (executeUserOpMethodSig === callDataMethodSig) {
32
+ return encodeFunctionData({
33
+ abi: AccountExecuteAbi,
34
+ functionName: "executeUserOp",
35
+ args: [
36
+ packedOp,
37
+ getUserOperationHash(op, entryPoint, this.config.publicClient.chain.id)
38
+ ]
39
+ });
40
+ }
41
+ return packedOp.callData;
42
+ }
43
+ encodeSimulateHandleOpLast({ userOperation, queuedUserOperations, entryPoint }) {
44
+ const userOperations = [...queuedUserOperations, userOperation];
45
+ const packedUserOperations = userOperations.map((uop) => ({
46
+ packedUserOperation: toPackedUserOperation(uop),
47
+ userOperation: uop,
48
+ userOperationHash: getUserOperationHash(uop, entryPoint, this.config.publicClient.chain.id)
49
+ }));
50
+ const simulateHandleOpCallData = encodeFunctionData({
51
+ abi: EntryPointV07SimulationsAbi,
52
+ functionName: "simulateHandleOpLast",
53
+ args: [packedUserOperations.map((uop) => uop.packedUserOperation)]
54
+ });
55
+ return simulateHandleOpCallData;
56
+ }
57
+ encodeSimulateCallData({ userOperation, queuedUserOperations, entryPoint, gasAllowance = this.config.binarySearchGasAllowance, initialMinGas = 0n }) {
58
+ const queuedOps = queuedUserOperations.map((op) => ({
59
+ op: toPackedUserOperation(op),
60
+ target: op.sender,
61
+ targetCallData: this.encodeUserOperationCalldata({
62
+ op,
63
+ entryPoint
64
+ })
65
+ }));
66
+ const targetOp = {
67
+ op: toPackedUserOperation(userOperation),
68
+ target: userOperation.sender,
69
+ targetCallData: this.encodeUserOperationCalldata({
70
+ op: userOperation,
71
+ entryPoint
72
+ })
73
+ };
74
+ const simulateTargetCallData = encodeFunctionData({
75
+ abi: EntryPointV07SimulationsAbi,
76
+ functionName: "simulateCallData",
77
+ args: [
78
+ queuedOps,
79
+ targetOp,
80
+ entryPoint,
81
+ initialMinGas,
82
+ this.config.binarySearchToleranceDelta,
83
+ gasAllowance
84
+ ]
85
+ });
86
+ return simulateTargetCallData;
87
+ }
88
+ // Try to get the calldata gas again if the initial simulation reverted due to hitting the eth_call gasLimit.
89
+ async retryGetCallDataGas({ entryPoint, optimalGas, minGas, targetOp, queuedOps, stateOverrides, simulateHandleOpLastResult }) {
90
+ const maxRetries = 3;
91
+ let retryCount = 0;
92
+ let currentOptimalGas = optimalGas;
93
+ let currentMinGas = minGas;
94
+ while (retryCount < maxRetries) {
95
+ // OptimalGas represents the current lowest gasLimit, so we set the gasAllowance to search range minGas <-> optimalGas
96
+ const gasAllowance = currentOptimalGas - currentMinGas;
97
+ const simulateCallData = this.encodeSimulateCallData({
98
+ entryPoint,
99
+ userOperation: targetOp,
100
+ queuedUserOperations: queuedOps,
101
+ initialMinGas: currentMinGas,
102
+ gasAllowance
103
+ });
104
+ let cause = await this.callPimlicoEntryPointSimulations({
105
+ entryPoint,
106
+ entryPointSimulationsCallData: [simulateCallData],
107
+ stateOverrides
108
+ });
109
+ cause = cause.map((data) => {
110
+ const decodedDelegateAndError = decodeErrorResult({
111
+ abi: EntryPointV07Abi,
112
+ data: data
113
+ });
114
+ if (!decodedDelegateAndError?.args?.[1]) {
115
+ throw new Error("Unexpected error");
116
+ }
117
+ return decodedDelegateAndError.args[1];
118
+ });
119
+ const simulateCallDataResult = validateTargetCallDataResult(cause[0]);
120
+ if (simulateCallDataResult.result === "failed") {
121
+ return simulateCallDataResult;
122
+ }
123
+ if (simulateCallDataResult.result === "retry") {
124
+ currentOptimalGas = simulateCallDataResult.optimalGas;
125
+ currentMinGas = simulateCallDataResult.minGas;
126
+ retryCount++;
127
+ continue;
128
+ }
129
+ // If we reach here, it means we have a successful result
130
+ return {
131
+ result: "execution",
132
+ data: {
133
+ callDataResult: simulateCallDataResult.data,
134
+ executionResult: simulateHandleOpLastResult.data.executionResult
135
+ }
136
+ };
137
+ }
138
+ // If we've exhausted all retries, return a failure result
139
+ return {
140
+ result: "failed",
141
+ data: "Max retries reached for getting call data gas",
142
+ code: ValidationErrors.SimulateValidation
143
+ };
144
+ }
145
+ async simulateHandleOpV07({ entryPoint, userOperation, queuedUserOperations, stateOverrides = undefined }) {
146
+ const simulateHandleOpLast = this.encodeSimulateHandleOpLast({
147
+ entryPoint,
148
+ userOperation,
149
+ queuedUserOperations
150
+ });
151
+ const simulateCallData = this.encodeSimulateCallData({
152
+ entryPoint,
153
+ userOperation,
154
+ queuedUserOperations
155
+ });
156
+ let cause;
157
+ if (this.config.chainType === "hedera") {
158
+ // due to Hedera specific restrictions, we can't combine these two calls.
159
+ const [simulateHandleOpLastCause, simulateCallDataCause] = await Promise.all([
160
+ this.callPimlicoEntryPointSimulations({
161
+ entryPoint,
162
+ entryPointSimulationsCallData: [simulateHandleOpLast],
163
+ stateOverrides
164
+ }),
165
+ this.callPimlicoEntryPointSimulations({
166
+ entryPoint,
167
+ entryPointSimulationsCallData: [simulateCallData],
168
+ stateOverrides
169
+ })
170
+ ]);
171
+ cause = [simulateHandleOpLastCause[0], simulateCallDataCause[0]];
172
+ }
173
+ else {
174
+ cause = await this.callPimlicoEntryPointSimulations({
175
+ entryPoint,
176
+ entryPointSimulationsCallData: [
177
+ simulateHandleOpLast,
178
+ simulateCallData
179
+ ],
180
+ stateOverrides
181
+ });
182
+ }
183
+ cause = cause.map((data) => {
184
+ const decodedDelegateAndError = decodeErrorResult({
185
+ abi: EntryPointV07Abi,
186
+ data: data
187
+ });
188
+ const delegateAndRevertResponseBytes = decodedDelegateAndError?.args?.[1];
189
+ if (!delegateAndRevertResponseBytes) {
190
+ throw new Error("Unexpected error");
191
+ }
192
+ return delegateAndRevertResponseBytes;
193
+ });
194
+ try {
195
+ const simulateHandleOpLastResult = getSimulateHandleOpResult(cause[0]);
196
+ if (simulateHandleOpLastResult.result === "failed") {
197
+ return simulateHandleOpLastResult;
198
+ }
199
+ const simulateCallDataResult = validateTargetCallDataResult(cause[1]);
200
+ if (simulateCallDataResult.result === "failed") {
201
+ return simulateCallDataResult;
202
+ }
203
+ if (simulateCallDataResult.result === "retry") {
204
+ const { optimalGas, minGas } = simulateCallDataResult;
205
+ return await this.retryGetCallDataGas({
206
+ entryPoint,
207
+ optimalGas,
208
+ minGas,
209
+ targetOp: userOperation,
210
+ queuedOps: queuedUserOperations,
211
+ simulateHandleOpLastResult: simulateHandleOpLastResult,
212
+ stateOverrides
213
+ });
214
+ }
215
+ return {
216
+ result: "execution",
217
+ data: {
218
+ callDataResult: simulateCallDataResult.data,
219
+ executionResult: simulateHandleOpLastResult.data.executionResult
220
+ }
221
+ };
222
+ }
223
+ catch (_e) {
224
+ return {
225
+ result: "failed",
226
+ data: "Unknown error, could not parse simulate handle op result.",
227
+ code: ValidationErrors.SimulateValidation
228
+ };
229
+ }
230
+ }
231
+ async callPimlicoEntryPointSimulations({ entryPoint, entryPointSimulationsCallData, stateOverrides }) {
232
+ const publicClient = this.config.publicClient;
233
+ const blockTagSupport = this.config.blockTagSupport;
234
+ const utilityWalletAddress = this.config.utilityPrivateKey?.address ??
235
+ "0x4337000c2828F5260d8921fD25829F606b9E8680";
236
+ const entryPointSimulationsAddress = this.config.entrypointSimulationContract;
237
+ const fixedGasLimitForEstimation = this.config.fixedGasLimitForEstimation;
238
+ if (!entryPointSimulationsAddress) {
239
+ throw new RpcError("entryPointSimulationsAddress must be provided for V07 UserOperation", ValidationErrors.InvalidFields);
240
+ }
241
+ const callData = encodeFunctionData({
242
+ abi: PimlicoEntryPointSimulationsAbi,
243
+ functionName: "simulateEntryPoint",
244
+ args: [entryPoint, entryPointSimulationsCallData]
245
+ });
246
+ const result = (await publicClient.request({
247
+ method: "eth_call",
248
+ params: [
249
+ {
250
+ to: entryPointSimulationsAddress,
251
+ from: utilityWalletAddress,
252
+ data: callData,
253
+ ...(fixedGasLimitForEstimation !== undefined && {
254
+ gas: `0x${fixedGasLimitForEstimation.toString(16)}`
255
+ })
256
+ },
257
+ blockTagSupport
258
+ ? "latest"
259
+ : toHex(await publicClient.getBlockNumber()),
260
+ // @ts-ignore
261
+ ...(stateOverrides ? [stateOverrides] : [])
262
+ ]
263
+ }));
264
+ const returnBytes = decodeAbiParameters([{ name: "ret", type: "bytes[]" }], result);
265
+ return returnBytes[0];
266
+ }
267
+ }
268
+ const panicCodes = {
269
+ // from https://docs.soliditylang.org/en/v0.8.0/control-structures.html
270
+ 1: "assert(false)",
271
+ 17: "arithmetic overflow/underflow",
272
+ 18: "divide by zero",
273
+ 33: "invalid enum value",
274
+ 34: "storage byte array that is incorrectly encoded",
275
+ 49: ".pop() on an empty array.",
276
+ 50: "array sout-of-bounds or negative index",
277
+ 65: "memory overflow",
278
+ 81: "zero-initialized variable of internal function type"
279
+ };
280
+ export function parseFailedOpWithRevert(data) {
281
+ const methodSig = data.slice(0, 10);
282
+ const dataParams = `0x${data.slice(10)}`;
283
+ if (methodSig === "0x08c379a0") {
284
+ const [err] = decodeAbiParameters([
285
+ {
286
+ name: "err",
287
+ type: "string"
288
+ }
289
+ ], dataParams);
290
+ return err;
291
+ }
292
+ if (methodSig === "0x4e487b71") {
293
+ const [code] = decodeAbiParameters([
294
+ {
295
+ name: "err",
296
+ type: "uint256"
297
+ }
298
+ ], dataParams);
299
+ return panicCodes[Number(code)] ?? `${code}`;
300
+ }
301
+ return data;
302
+ }
303
+ export function getSimulateValidationResult(errorData) {
304
+ const decodedDelegateAndError = decodeErrorResult({
305
+ abi: EntryPointV07Abi,
306
+ data: errorData
307
+ });
308
+ if (!decodedDelegateAndError?.args?.[1]) {
309
+ throw new Error("Unexpected error");
310
+ }
311
+ try {
312
+ const decodedError = decodeErrorResult({
313
+ abi: EntryPointV07SimulationsAbi,
314
+ data: decodedDelegateAndError.args[1]
315
+ });
316
+ if (decodedError &&
317
+ decodedError.errorName === "FailedOp" &&
318
+ decodedError.args) {
319
+ return {
320
+ status: "failed",
321
+ data: decodedError.args[1]
322
+ };
323
+ }
324
+ if (decodedError &&
325
+ decodedError.errorName === "FailedOpWithRevert" &&
326
+ decodedError.args) {
327
+ return {
328
+ status: "failed",
329
+ data: `${decodedError.args?.[1]} - ${parseFailedOpWithRevert(decodedError.args?.[2])}`
330
+ };
331
+ }
332
+ }
333
+ catch {
334
+ const decodedResult = decodeAbiParameters(simulationValidationResultStruct, decodedDelegateAndError.args[1])[0];
335
+ return {
336
+ status: "validation",
337
+ data: decodedResult
338
+ };
339
+ }
340
+ throw new Error("Unexpected error - errorName is not ValidationResult or ValidationResultWithAggregation");
341
+ }
342
+ function validateTargetCallDataResult(data) {
343
+ try {
344
+ const targetCallResult = decodeFunctionResult({
345
+ abi: EntryPointV07SimulationsAbi,
346
+ functionName: "simulateCallData",
347
+ data: data
348
+ });
349
+ const parsedTargetCallResult = targetCallResultSchema.parse(targetCallResult);
350
+ if (parsedTargetCallResult.success) {
351
+ return {
352
+ result: "success",
353
+ data: parsedTargetCallResult
354
+ };
355
+ }
356
+ return {
357
+ result: "failed",
358
+ data: parsedTargetCallResult.returnData,
359
+ code: ExecutionErrors.UserOperationReverted
360
+ };
361
+ }
362
+ catch (_e) {
363
+ // Check if the result hit eth_call gasLimit.
364
+ const simulationOutOfGasSelector = toFunctionSelector("SimulationOutOfGas(uint256 optimalGas, uint256 minGas, uint256 maxGas)");
365
+ if (slice(data, 0, 4) === simulationOutOfGasSelector) {
366
+ const res = decodeErrorResult({
367
+ abi: EntryPointV07SimulationsAbi,
368
+ data: data
369
+ });
370
+ if (res.errorName === "SimulationOutOfGas") {
371
+ const [optimalGas, minGas, maxGas] = res.args;
372
+ return {
373
+ result: "retry",
374
+ optimalGas,
375
+ minGas,
376
+ maxGas
377
+ };
378
+ }
379
+ }
380
+ // no error we go the result
381
+ return {
382
+ result: "failed",
383
+ data: "Unknown error, could not parse target call data result.",
384
+ code: ExecutionErrors.UserOperationReverted
385
+ };
386
+ }
387
+ }
388
+ function getSimulateHandleOpResult(data) {
389
+ try {
390
+ const decodedError = decodeErrorResult({
391
+ abi: EntryPointV07SimulationsAbi,
392
+ data: data
393
+ });
394
+ if (decodedError &&
395
+ decodedError.errorName === "FailedOp" &&
396
+ decodedError.args) {
397
+ return {
398
+ result: "failed",
399
+ data: decodedError.args[1],
400
+ code: ValidationErrors.SimulateValidation
401
+ };
402
+ }
403
+ if (decodedError &&
404
+ decodedError.errorName === "FailedOpWithRevert" &&
405
+ decodedError.args) {
406
+ return {
407
+ result: "failed",
408
+ data: `${decodedError.args[1]} ${parseFailedOpWithRevert(decodedError.args?.[2])}`,
409
+ code: ValidationErrors.SimulateValidation
410
+ };
411
+ }
412
+ }
413
+ catch {
414
+ // no error we go the result
415
+ const decodedResult = decodeFunctionResult({
416
+ abi: EntryPointV07SimulationsAbi,
417
+ functionName: "simulateHandleOp",
418
+ data
419
+ });
420
+ return {
421
+ result: "execution",
422
+ data: {
423
+ executionResult: decodedResult
424
+ }
425
+ };
426
+ }
427
+ throw new Error("Unexpected error");
428
+ }
429
+ //# sourceMappingURL=gasEstimationsV07.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gasEstimationsV07.js","sourceRoot":"","sources":["../../../rpc/estimation/gasEstimationsV07.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,2BAA2B,EAC3B,eAAe,EAEf,+BAA+B,EAC/B,QAAQ,EAIR,gBAAgB,EAEhB,sBAAsB,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEzE,OAAO,EAEH,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,EACL,kBAAkB,EAClB,KAAK,EACR,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAA;AACzE,OAAO,EAEH,gCAAgC,EACnC,MAAM,SAAS,CAAA;AAGhB,MAAM,OAAO,eAAe;IAChB,MAAM,CAAY;IAE1B,YAAY,MAAkB;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,EACrB,UAAU,EACV,aAAa,EACb,oBAAoB,EAKvB;QACG,MAAM,cAAc,GAAG,CAAC,GAAG,oBAAoB,EAAE,aAAa,CAAC,CAAA;QAC/D,M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;aACnC,CAAA;QACd,CAAC;QAED,IACI,YAAY;YACZ,YAAY,CAAC,SAAS,KAAK,oBAAoB;YAC/C,YAAY,CAAC,IAAI,EACnB,CAAC;YACC,OAAO;gBACH,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,uBAAuB,CACpD,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAQ,CAChC,EAAE;gBACH,IAAI,EAAE,gBAAgB,CAAC,kBAAkB;aACnC,CAAA;QACd,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,4BAA4B;QAC5B,MAAM,aAAa,GAAoB,oBAAoB,CAAC;YACxD,GAAG,EAAE,2BAA2B;YAChC,YAAY,EAAE,kBAAkB;YAChC,IAAI;SACP,CAA+B,CAAA;QAEhC,OAAO;YACH,MAAM,EAAE,WAAW;YACnB,IAAI,EAAE;gBACF,eAAe,EAAE,aAAa;aACxB;SACb,CAAA;IACL,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACvC,CAAC"}
@@ -0,0 +1,113 @@
1
+ import type { Address, ExecutionResult, PackedUserOperation, TargetCallResult } from "../../types/index.js";
2
+ import type { Hex } from "viem";
3
+ export type SimulateHandleOpResult<TypeResult extends "failed" | "execution" = "failed" | "execution"> = {
4
+ result: TypeResult;
5
+ data: TypeResult extends "failed" ? string : {
6
+ callDataResult?: TargetCallResult;
7
+ executionResult: ExecutionResult;
8
+ };
9
+ code?: TypeResult extends "failed" ? number : undefined;
10
+ };
11
+ export type CallDataSimulationArgs = {
12
+ op: PackedUserOperation;
13
+ target: Address;
14
+ targetCallData: Hex;
15
+ };
16
+ export type SimulationOutOfGasResult = {
17
+ optimalGas: bigint;
18
+ minGas: bigint;
19
+ maxGas: bigint;
20
+ };
21
+ export declare const simulationValidationResultStruct: readonly [{
22
+ readonly components: readonly [{
23
+ readonly components: readonly [{
24
+ readonly internalType: "uint256";
25
+ readonly name: "preOpGas";
26
+ readonly type: "uint256";
27
+ }, {
28
+ readonly internalType: "uint256";
29
+ readonly name: "prefund";
30
+ readonly type: "uint256";
31
+ }, {
32
+ readonly internalType: "uint256";
33
+ readonly name: "accountValidationData";
34
+ readonly type: "uint256";
35
+ }, {
36
+ readonly internalType: "uint256";
37
+ readonly name: "paymasterValidationData";
38
+ readonly type: "uint256";
39
+ }, {
40
+ readonly internalType: "bytes";
41
+ readonly name: "paymasterContext";
42
+ readonly type: "bytes";
43
+ }];
44
+ readonly internalType: "struct IEntryPoint.ReturnInfo";
45
+ readonly name: "returnInfo";
46
+ readonly type: "tuple";
47
+ }, {
48
+ readonly components: readonly [{
49
+ readonly internalType: "uint256";
50
+ readonly name: "stake";
51
+ readonly type: "uint256";
52
+ }, {
53
+ readonly internalType: "uint256";
54
+ readonly name: "unstakeDelaySec";
55
+ readonly type: "uint256";
56
+ }];
57
+ readonly internalType: "struct IStakeManager.StakeInfo";
58
+ readonly name: "senderInfo";
59
+ readonly type: "tuple";
60
+ }, {
61
+ readonly components: readonly [{
62
+ readonly internalType: "uint256";
63
+ readonly name: "stake";
64
+ readonly type: "uint256";
65
+ }, {
66
+ readonly internalType: "uint256";
67
+ readonly name: "unstakeDelaySec";
68
+ readonly type: "uint256";
69
+ }];
70
+ readonly internalType: "struct IStakeManager.StakeInfo";
71
+ readonly name: "factoryInfo";
72
+ readonly type: "tuple";
73
+ }, {
74
+ readonly components: readonly [{
75
+ readonly internalType: "uint256";
76
+ readonly name: "stake";
77
+ readonly type: "uint256";
78
+ }, {
79
+ readonly internalType: "uint256";
80
+ readonly name: "unstakeDelaySec";
81
+ readonly type: "uint256";
82
+ }];
83
+ readonly internalType: "struct IStakeManager.StakeInfo";
84
+ readonly name: "paymasterInfo";
85
+ readonly type: "tuple";
86
+ }, {
87
+ readonly components: readonly [{
88
+ readonly internalType: "address";
89
+ readonly name: "aggregator";
90
+ readonly type: "address";
91
+ }, {
92
+ readonly components: readonly [{
93
+ readonly internalType: "uint256";
94
+ readonly name: "stake";
95
+ readonly type: "uint256";
96
+ }, {
97
+ readonly internalType: "uint256";
98
+ readonly name: "unstakeDelaySec";
99
+ readonly type: "uint256";
100
+ }];
101
+ readonly internalType: "struct IStakeManager.StakeInfo";
102
+ readonly name: "stakeInfo";
103
+ readonly type: "tuple";
104
+ }];
105
+ readonly internalType: "struct IEntryPoint.AggregatorStakeInfo";
106
+ readonly name: "aggregatorInfo";
107
+ readonly type: "tuple";
108
+ }];
109
+ readonly internalType: "struct IEntryPointSimulations.ValidationResult";
110
+ readonly name: "";
111
+ readonly type: "tuple";
112
+ }];
113
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,122 @@
1
+ export const simulationValidationResultStruct = [
2
+ {
3
+ components: [
4
+ {
5
+ components: [
6
+ {
7
+ internalType: "uint256",
8
+ name: "preOpGas",
9
+ type: "uint256"
10
+ },
11
+ {
12
+ internalType: "uint256",
13
+ name: "prefund",
14
+ type: "uint256"
15
+ },
16
+ {
17
+ internalType: "uint256",
18
+ name: "accountValidationData",
19
+ type: "uint256"
20
+ },
21
+ {
22
+ internalType: "uint256",
23
+ name: "paymasterValidationData",
24
+ type: "uint256"
25
+ },
26
+ {
27
+ internalType: "bytes",
28
+ name: "paymasterContext",
29
+ type: "bytes"
30
+ }
31
+ ],
32
+ internalType: "struct IEntryPoint.ReturnInfo",
33
+ name: "returnInfo",
34
+ type: "tuple"
35
+ },
36
+ {
37
+ components: [
38
+ {
39
+ internalType: "uint256",
40
+ name: "stake",
41
+ type: "uint256"
42
+ },
43
+ {
44
+ internalType: "uint256",
45
+ name: "unstakeDelaySec",
46
+ type: "uint256"
47
+ }
48
+ ],
49
+ internalType: "struct IStakeManager.StakeInfo",
50
+ name: "senderInfo",
51
+ type: "tuple"
52
+ },
53
+ {
54
+ components: [
55
+ {
56
+ internalType: "uint256",
57
+ name: "stake",
58
+ type: "uint256"
59
+ },
60
+ {
61
+ internalType: "uint256",
62
+ name: "unstakeDelaySec",
63
+ type: "uint256"
64
+ }
65
+ ],
66
+ internalType: "struct IStakeManager.StakeInfo",
67
+ name: "factoryInfo",
68
+ type: "tuple"
69
+ },
70
+ {
71
+ components: [
72
+ {
73
+ internalType: "uint256",
74
+ name: "stake",
75
+ type: "uint256"
76
+ },
77
+ {
78
+ internalType: "uint256",
79
+ name: "unstakeDelaySec",
80
+ type: "uint256"
81
+ }
82
+ ],
83
+ internalType: "struct IStakeManager.StakeInfo",
84
+ name: "paymasterInfo",
85
+ type: "tuple"
86
+ },
87
+ {
88
+ components: [
89
+ {
90
+ internalType: "address",
91
+ name: "aggregator",
92
+ type: "address"
93
+ },
94
+ {
95
+ components: [
96
+ {
97
+ internalType: "uint256",
98
+ name: "stake",
99
+ type: "uint256"
100
+ },
101
+ {
102
+ internalType: "uint256",
103
+ name: "unstakeDelaySec",
104
+ type: "uint256"
105
+ }
106
+ ],
107
+ internalType: "struct IStakeManager.StakeInfo",
108
+ name: "stakeInfo",
109
+ type: "tuple"
110
+ }
111
+ ],
112
+ internalType: "struct IEntryPoint.AggregatorStakeInfo",
113
+ name: "aggregatorInfo",
114
+ type: "tuple"
115
+ }
116
+ ],
117
+ internalType: "struct IEntryPointSimulations.ValidationResult",
118
+ name: "",
119
+ type: "tuple"
120
+ }
121
+ ];
122
+ //# sourceMappingURL=types.js.map