@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,48 @@
1
+ import { deepHexlify, isVersion06 } from "../../utils/index.js";
2
+ import { toHex } from "viem";
3
+ import { GasEstimatorV06 } from "./gasEstimationsV06.js";
4
+ import { GasEstimatorV07 } from "./gasEstimationsV07.js";
5
+ function getStateOverrides({ addSenderBalanceOverride, userOperation, stateOverride = {} }) {
6
+ const result = { ...stateOverride };
7
+ if (addSenderBalanceOverride) {
8
+ result[userOperation.sender] = {
9
+ ...deepHexlify(stateOverride?.[userOperation.sender] || {}),
10
+ balance: toHex(100000000000000000000000n)
11
+ };
12
+ }
13
+ return result;
14
+ }
15
+ export class GasEstimationHandler {
16
+ gasEstimatorV06;
17
+ gasEstimatorV07;
18
+ constructor(config) {
19
+ this.gasEstimatorV06 = new GasEstimatorV06(config);
20
+ this.gasEstimatorV07 = new GasEstimatorV07(config);
21
+ }
22
+ simulateHandleOp({ userOperation, queuedUserOperations, addSenderBalanceOverride, entryPoint, targetAddress, targetCallData, balanceOverrideEnabled, stateOverrides = {} }) {
23
+ let finalStateOverride = undefined;
24
+ if (balanceOverrideEnabled) {
25
+ finalStateOverride = getStateOverrides({
26
+ userOperation,
27
+ addSenderBalanceOverride,
28
+ stateOverride: stateOverrides
29
+ });
30
+ }
31
+ if (isVersion06(userOperation)) {
32
+ return this.gasEstimatorV06.simulateHandleOpV06({
33
+ userOperation,
34
+ entryPoint,
35
+ targetAddress,
36
+ targetCallData,
37
+ stateOverrides: finalStateOverride
38
+ });
39
+ }
40
+ return this.gasEstimatorV07.simulateHandleOpV07({
41
+ userOperation: userOperation,
42
+ queuedUserOperations: queuedUserOperations,
43
+ entryPoint,
44
+ stateOverrides: finalStateOverride
45
+ });
46
+ }
47
+ }
48
+ //# sourceMappingURL=gasEstimationHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gasEstimationHandler.js","sourceRoot":"","sources":["../../../rpc/estimation/gasEstimationHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAgB,KAAK,EAAE,MAAM,MAAM,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAIrD,SAAS,iBAAiB,CAAC,EACvB,wBAAwB,EACxB,aAAa,EACb,aAAa,GAAG,EAAE,EAKrB;IACG,MAAM,MAAM,GAAmB,EAAE,GAAG,aAAa,EAAE,CAAA;IAEnD,IAAI,wBAAwB,EAAE,CAAC;QAC3B,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG;YAC3B,GAAG,WAAW,CAAC,aAAa,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC3D,OAAO,EAAE,KAAK,CAAC,yBAA0B,CAAC;SAC7C,CAAA;IACL,CAAC;IAED,OAAO,MAAM,CAAA;AACjB,CAAC;AAED,MAAM,OAAO,oBAAoB;IAC7B,eAAe,CAAiB;IAChC,eAAe,CAAiB;IAEhC,YAAY,MAAkB;QAC1B,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAA;QAElD,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAA;IACtD,CAAC;IAED,gBAAgB,CAAC,EACb,aAAa,EACb,oBAAoB,EACpB,wBAAwB,EACxB,UAAU,EACV,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,cAAc,GAAG,EAAE,EAUtB;QACG,IAAI,kBAAkB,GAAG,SAAS,CAAA;QAElC,IAAI,sBAAsB,EAAE,CAAC;YACzB,kBAAkB,GAAG,iBAAiB,CAAC;gBACnC,aAAa;gBACb,wBAAwB;gBACxB,aAAa,EAAE,cAAc;aAChC,CAAC,CAAA;QACN,CAAC;QAED,IAAI,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC;gBAC5C,aAAa;gBACb,UAAU;gBACV,aAAa;gBACb,cAAc;gBACd,cAAc,EAAE,kBAAkB;aACrC,CAAC,CAAA;QACN,CAAC;QAED,OAAO,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC;YAC5C,aAAa,EAAE,aAAiC;YAChD,oBAAoB,EAAE,oBAA0C;YAChE,UAAU;YACV,cAAc,EAAE,kBAAkB;SACrC,CAAC,CAAA;IACN,CAAC;CACJ"}
@@ -0,0 +1,19 @@
1
+ import type { StateOverrides, UserOperationV06 } from "../../types/index.js";
2
+ import type { Hex } from "viem";
3
+ import { type Address } from "viem";
4
+ import type { SimulateHandleOpResult } from "./types.js";
5
+ import type { AltoConfig } from "../../createConfig.js";
6
+ export declare class GasEstimatorV06 {
7
+ private config;
8
+ constructor(config: AltoConfig);
9
+ decodeSimulateHandleOpResult(data: Hex): SimulateHandleOpResult;
10
+ simulateHandleOpV06({ userOperation, targetAddress, targetCallData, entryPoint, useCodeOverride, stateOverrides }: {
11
+ userOperation: UserOperationV06;
12
+ targetAddress: Address;
13
+ targetCallData: Hex;
14
+ entryPoint: Address;
15
+ useCodeOverride?: boolean;
16
+ stateOverrides?: StateOverrides | undefined;
17
+ }): Promise<SimulateHandleOpResult>;
18
+ }
19
+ //# sourceMappingURL=gasEstimationsV06.d.ts.map
@@ -0,0 +1,146 @@
1
+ import { ENTRYPOINT_V06_SIMULATION_OVERRIDE, EntryPointV06Abi, EntryPointV06SimulationsAbi, RpcError, ValidationErrors, executionResultSchema, hexDataSchema } from "../../types/index.js";
2
+ import { decodeErrorResult, encodeFunctionData, toHex } from "viem";
3
+ import { z } from "zod";
4
+ import { deepHexlify } from "../../utils/userop.js";
5
+ import { parseFailedOpWithRevert } from "./gasEstimationsV07.js";
6
+ export class GasEstimatorV06 {
7
+ config;
8
+ constructor(config) {
9
+ this.config = config;
10
+ }
11
+ decodeSimulateHandleOpResult(data) {
12
+ if (data === "0x") {
13
+ throw new RpcError("AA23 reverted: UserOperation called non-existant contract, or reverted with 0x", ValidationErrors.SimulateValidation);
14
+ }
15
+ const decodedError = decodeErrorResult({
16
+ abi: [...EntryPointV06Abi, ...EntryPointV06SimulationsAbi],
17
+ data
18
+ });
19
+ if (decodedError &&
20
+ decodedError.errorName === "FailedOp" &&
21
+ decodedError.args) {
22
+ return {
23
+ result: "failed",
24
+ data: decodedError.args[1]
25
+ };
26
+ }
27
+ // custom error thrown by entryPoint if code override is used
28
+ if (decodedError &&
29
+ decodedError.errorName === "CallPhaseReverted" &&
30
+ decodedError.args) {
31
+ return {
32
+ result: "failed",
33
+ data: decodedError.args[0]
34
+ };
35
+ }
36
+ // custom error thrown by entryPoint if code override is used
37
+ if (decodedError &&
38
+ decodedError.errorName === "FailedOpWithRevert" &&
39
+ decodedError.args) {
40
+ return {
41
+ result: "failed",
42
+ data: `${decodedError.args?.[1]} ${parseFailedOpWithRevert(decodedError.args?.[2])}`
43
+ };
44
+ }
45
+ if (decodedError &&
46
+ decodedError.errorName === "Error" &&
47
+ decodedError.args) {
48
+ return {
49
+ result: "failed",
50
+ data: decodedError.args[0]
51
+ };
52
+ }
53
+ if (decodedError.errorName === "ExecutionResult") {
54
+ const parsedExecutionResult = executionResultSchema.parse(decodedError.args);
55
+ return {
56
+ result: "execution",
57
+ data: {
58
+ executionResult: parsedExecutionResult
59
+ }
60
+ };
61
+ }
62
+ throw new Error("Unexpected error whilst decoding simulateHandleOp result");
63
+ }
64
+ async simulateHandleOpV06({ userOperation, targetAddress, targetCallData, entryPoint, useCodeOverride = true, stateOverrides = undefined }) {
65
+ const publicClient = this.config.publicClient;
66
+ const blockTagSupport = this.config.blockTagSupport;
67
+ const utilityWalletAddress = this.config.utilityPrivateKey?.address ??
68
+ "0x4337000c2828F5260d8921fD25829F606b9E8680";
69
+ const fixedGasLimitForEstimation = this.config.fixedGasLimitForEstimation;
70
+ if (this.config.codeOverrideSupport && useCodeOverride) {
71
+ if (stateOverrides === undefined) {
72
+ stateOverrides = {};
73
+ }
74
+ stateOverrides[entryPoint] = {
75
+ ...deepHexlify(stateOverrides?.[entryPoint] || {}),
76
+ code: ENTRYPOINT_V06_SIMULATION_OVERRIDE
77
+ };
78
+ }
79
+ try {
80
+ await publicClient.request({
81
+ method: "eth_call",
82
+ params: [
83
+ {
84
+ to: entryPoint,
85
+ from: utilityWalletAddress,
86
+ data: encodeFunctionData({
87
+ abi: EntryPointV06Abi,
88
+ functionName: "simulateHandleOp",
89
+ args: [userOperation, targetAddress, targetCallData]
90
+ }),
91
+ ...(fixedGasLimitForEstimation !== undefined && {
92
+ gas: `0x${fixedGasLimitForEstimation.toString(16)}`
93
+ })
94
+ },
95
+ blockTagSupport
96
+ ? "latest"
97
+ : toHex(await publicClient.getBlockNumber()),
98
+ // @ts-ignore
99
+ ...(stateOverrides ? [stateOverrides] : [])
100
+ ]
101
+ });
102
+ }
103
+ catch (e) {
104
+ const err = e;
105
+ if (/return data out of bounds.*|EVM error OutOfOffset.*/.test(err.details)) {
106
+ // out of bound (low level evm error) occurs when paymaster reverts with less than 32bytes
107
+ return {
108
+ result: "failed",
109
+ data: "AA50 postOp revert (paymaster revert data out of bounds)"
110
+ };
111
+ }
112
+ const causeParseResult = z
113
+ .union([
114
+ z.object({
115
+ code: z.literal(3),
116
+ message: z.string(),
117
+ data: hexDataSchema
118
+ }),
119
+ /* Fuse RPCs return in this format. */
120
+ z.object({
121
+ code: z.number(),
122
+ message: z.string().regex(/VM execution error.*/),
123
+ data: z
124
+ .string()
125
+ .transform((data) => data.replace("Reverted ", ""))
126
+ .pipe(hexDataSchema)
127
+ }),
128
+ z.object({
129
+ code: z.number(),
130
+ message: z
131
+ .string()
132
+ .regex(/VM Exception while processing transaction:.*/),
133
+ data: hexDataSchema
134
+ })
135
+ ])
136
+ .safeParse(err.cause);
137
+ if (!causeParseResult.success) {
138
+ throw new Error(JSON.stringify(err.cause));
139
+ }
140
+ const data = causeParseResult.data.data;
141
+ return this.decodeSimulateHandleOpResult(data);
142
+ }
143
+ throw new Error("Unexpected error");
144
+ }
145
+ }
146
+ //# sourceMappingURL=gasEstimationsV06.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gasEstimationsV06.js","sourceRoot":"","sources":["../../../rpc/estimation/gasEstimationsV06.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,kCAAkC,EAClC,gBAAgB,EAChB,2BAA2B,EAC3B,QAAQ,EACR,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EAChB,MAAM,aAAa,CAAA;AAGpB,OAAO,EAEH,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,EACR,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAE7D,MAAM,OAAO,eAAe;IAChB,MAAM,CAAY;IAE1B,YAAY,MAAkB;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,4BAA4B,CAAC,IAAS;QAClC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAChB,MAAM,IAAI,QAAQ,CACd,gFAAgF,EAChF,gBAAgB,CAAC,kBAAkB,CACtC,CAAA;QACL,CAAC;QAED,MAAM,YAAY,GAAG,iBAAiB,CAAC;YACnC,GAAG,EAAE,CAAC,GAAG,gBAAgB,EAAE,GAAG,2BAA2B,CAAC;YAC1D,IAAI;SACP,CAAC,CAAA;QAEF,IACI,YAAY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KAAK,CAAC,CAAA;YAEzB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;YAC9C,CAAC;YAED,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAA;YAEvC,OAAO,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAA;QAClD,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;IACvC,CAAC;CACJ"}
@@ -0,0 +1,88 @@
1
+ import { type StateOverrides, type UserOperationV07, type ValidationResultV07 } from "../../types/index.js";
2
+ import type { Hex } from "viem";
3
+ import { type Address } from "viem";
4
+ import { type SimulateHandleOpResult } from "./types.js";
5
+ import type { AltoConfig } from "../../createConfig.js";
6
+ export declare class GasEstimatorV07 {
7
+ private config;
8
+ constructor(config: AltoConfig);
9
+ simulateValidation({ entryPoint, userOperation, queuedUserOperations }: {
10
+ entryPoint: Address;
11
+ userOperation: UserOperationV07;
12
+ queuedUserOperations: UserOperationV07[];
13
+ }): Promise<{
14
+ simulateValidationResult: {
15
+ status: "validation" | "failed";
16
+ data: string | {
17
+ returnInfo: {
18
+ preOpGas: bigint;
19
+ prefund: bigint;
20
+ paymasterContext: `0x${string}`;
21
+ accountValidationData: bigint;
22
+ paymasterValidationData: bigint;
23
+ accountSigFailed?: boolean | undefined;
24
+ paymasterSigFailed?: boolean | undefined;
25
+ validAfter?: number | undefined;
26
+ validUntil?: number | undefined;
27
+ };
28
+ senderInfo: {
29
+ stake: bigint;
30
+ unstakeDelaySec: bigint;
31
+ addr?: string | undefined;
32
+ };
33
+ factoryInfo: {
34
+ stake: bigint;
35
+ unstakeDelaySec: bigint;
36
+ addr?: string | undefined;
37
+ } | undefined;
38
+ paymasterInfo: {
39
+ stake: bigint;
40
+ unstakeDelaySec: bigint;
41
+ addr?: string | undefined;
42
+ } | undefined;
43
+ };
44
+ };
45
+ }>;
46
+ encodeUserOperationCalldata({ op, entryPoint }: {
47
+ op: UserOperationV07;
48
+ entryPoint: Address;
49
+ }): `0x${string}`;
50
+ encodeSimulateHandleOpLast({ userOperation, queuedUserOperations, entryPoint }: {
51
+ userOperation: UserOperationV07;
52
+ queuedUserOperations: UserOperationV07[];
53
+ entryPoint: Address;
54
+ }): Hex;
55
+ encodeSimulateCallData({ userOperation, queuedUserOperations, entryPoint, gasAllowance, initialMinGas }: {
56
+ userOperation: UserOperationV07;
57
+ queuedUserOperations: UserOperationV07[];
58
+ entryPoint: Address;
59
+ initialMinGas?: bigint;
60
+ gasAllowance?: bigint;
61
+ }): Hex;
62
+ retryGetCallDataGas({ entryPoint, optimalGas, minGas, targetOp, queuedOps, stateOverrides, simulateHandleOpLastResult }: {
63
+ entryPoint: Address;
64
+ optimalGas: bigint;
65
+ minGas: bigint;
66
+ targetOp: UserOperationV07;
67
+ queuedOps: UserOperationV07[];
68
+ stateOverrides?: StateOverrides | undefined;
69
+ simulateHandleOpLastResult: SimulateHandleOpResult<"execution">;
70
+ }): Promise<SimulateHandleOpResult>;
71
+ simulateHandleOpV07({ entryPoint, userOperation, queuedUserOperations, stateOverrides }: {
72
+ entryPoint: Address;
73
+ userOperation: UserOperationV07;
74
+ queuedUserOperations: UserOperationV07[];
75
+ stateOverrides?: StateOverrides | undefined;
76
+ }): Promise<SimulateHandleOpResult>;
77
+ callPimlicoEntryPointSimulations({ entryPoint, entryPointSimulationsCallData, stateOverrides }: {
78
+ entryPoint: Address;
79
+ entryPointSimulationsCallData: Hex[];
80
+ stateOverrides?: StateOverrides;
81
+ }): Promise<readonly `0x${string}`[]>;
82
+ }
83
+ export declare function parseFailedOpWithRevert(data: Hex): string;
84
+ export declare function getSimulateValidationResult(errorData: Hex): {
85
+ status: "failed" | "validation";
86
+ data: ValidationResultV07 | Hex | string;
87
+ };
88
+ //# sourceMappingURL=gasEstimationsV07.d.ts.map