@pimlico/alto 0.0.2 → 0.0.4

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 (264) 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 +403 -0
  5. package/esm/cli/config/bundler.js +134 -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 +348 -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 +140 -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 +55 -0
  32. package/esm/executor/executor.js +645 -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 +402 -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 +241 -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 +487 -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 +401 -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 +62 -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 +414 -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 +738 -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 +243 -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 +31 -0
  98. package/esm/rpc/validation/SafeValidator.js +330 -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 +561 -0
  105. package/esm/rpc/validation/TracerResultParserV07.js.map +1 -0
  106. package/esm/rpc/validation/UnsafeValidator.d.ts +64 -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 +152 -0
  128. package/esm/types/contracts/EntryPointSimulations.js +1954 -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 +79 -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/lib/cli/config/bundler.d.ts +12 -0
  221. package/lib/cli/config/bundler.js +3 -1
  222. package/lib/cli/config/bundler.js.map +1 -1
  223. package/lib/cli/config/options.js +12 -0
  224. package/lib/cli/config/options.js.map +1 -1
  225. package/lib/cli/handler.js +25 -1
  226. package/lib/cli/handler.js.map +1 -1
  227. package/lib/cli/setupServer.js +1 -1
  228. package/lib/cli/setupServer.js.map +1 -1
  229. package/lib/executor/executor.d.ts +2 -1
  230. package/lib/executor/executor.js +6 -4
  231. package/lib/executor/executor.js.map +1 -1
  232. package/lib/executor/utils.d.ts +1 -1
  233. package/lib/executor/utils.js +4 -4
  234. package/lib/executor/utils.js.map +1 -1
  235. package/lib/mempool/mempool.js +5 -7
  236. package/lib/mempool/mempool.js.map +1 -1
  237. package/lib/mempool/reputationManager.js +7 -3
  238. package/lib/mempool/reputationManager.js.map +1 -1
  239. package/lib/rpc/EntryPointSimulationsV07.d.ts +5 -1
  240. package/lib/rpc/EntryPointSimulationsV07.js +3 -2
  241. package/lib/rpc/EntryPointSimulationsV07.js.map +1 -1
  242. package/lib/rpc/gasEstimation.js +7 -3
  243. package/lib/rpc/gasEstimation.js.map +1 -1
  244. package/lib/rpc/rpcHandler.js +18 -7
  245. package/lib/rpc/rpcHandler.js.map +1 -1
  246. package/lib/rpc/server.js +4 -0
  247. package/lib/rpc/server.js.map +1 -1
  248. package/lib/rpc/validation/SafeValidator.d.ts +2 -6
  249. package/lib/rpc/validation/SafeValidator.js +48 -205
  250. package/lib/rpc/validation/SafeValidator.js.map +1 -1
  251. package/lib/rpc/validation/TracerResultParserV07.js +6 -2
  252. package/lib/rpc/validation/TracerResultParserV07.js.map +1 -1
  253. package/lib/rpc/validation/UnsafeValidator.d.ts +2 -1
  254. package/lib/rpc/validation/UnsafeValidator.js +45 -68
  255. package/lib/rpc/validation/UnsafeValidator.js.map +1 -1
  256. package/lib/types/contracts/EntryPointSimulations.d.ts +0 -1
  257. package/lib/types/contracts/EntryPointSimulations.js +1942 -3
  258. package/lib/types/contracts/EntryPointSimulations.js.map +1 -1
  259. package/lib/types/contracts/PimlicoEntryPointSimulations.d.ts +1 -1
  260. package/lib/types/contracts/PimlicoEntryPointSimulations.js +2 -2
  261. package/lib/types/contracts/PimlicoEntryPointSimulations.js.map +1 -1
  262. package/lib/utils/userop.js +2 -25
  263. package/lib/utils/userop.js.map +1 -1
  264. package/package.json +2 -1
@@ -0,0 +1,160 @@
1
+ import { CallEngineAbi } from "../types/index.js";
2
+ import { Semaphore } from "async-mutex";
3
+ import { formatEther, getContract } from "viem";
4
+ const waitForTransactionReceipt = async (publicClient, tx) => {
5
+ try {
6
+ return await publicClient.waitForTransactionReceipt({ hash: tx });
7
+ }
8
+ catch {
9
+ return await waitForTransactionReceipt(publicClient, tx);
10
+ }
11
+ };
12
+ export class SenderManager {
13
+ wallets;
14
+ utilityAccount;
15
+ availableWallets;
16
+ logger;
17
+ metrics;
18
+ legacyTransactions;
19
+ semaphore;
20
+ gasPriceManager;
21
+ constructor(wallets, utilityAccount, logger, metrics, legacyTransactions, gasPriceManager, maxSigners) {
22
+ if (maxSigners !== undefined && wallets.length > maxSigners) {
23
+ this.wallets = wallets.slice(0, maxSigners);
24
+ this.availableWallets = wallets.slice(0, maxSigners);
25
+ }
26
+ else {
27
+ this.wallets = wallets;
28
+ this.availableWallets = wallets;
29
+ }
30
+ this.utilityAccount = utilityAccount;
31
+ this.logger = logger;
32
+ this.metrics = metrics;
33
+ this.legacyTransactions = legacyTransactions;
34
+ metrics.walletsAvailable.set(this.availableWallets.length);
35
+ metrics.walletsTotal.set(this.wallets.length);
36
+ this.semaphore = new Semaphore(this.availableWallets.length);
37
+ this.gasPriceManager = gasPriceManager;
38
+ }
39
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
40
+ async validateAndRefillWallets(publicClient, walletClient, minBalance) {
41
+ if (!(minBalance && this.utilityAccount)) {
42
+ return;
43
+ }
44
+ const utilityWalletBalance = await publicClient.getBalance({
45
+ address: this.utilityAccount.address
46
+ });
47
+ const balancesMissing = {};
48
+ const balanceRequestPromises = this.availableWallets.map(async (wallet) => {
49
+ const balance = await publicClient.getBalance({
50
+ address: wallet.address
51
+ });
52
+ if (balance < minBalance) {
53
+ const missingBalance = (minBalance * 6n) / 5n - balance;
54
+ balancesMissing[wallet.address] = missingBalance;
55
+ }
56
+ });
57
+ await Promise.all(balanceRequestPromises);
58
+ const totalBalanceMissing = Object.values(balancesMissing).reduce((a, b) => a + b, 0n);
59
+ if (utilityWalletBalance < (totalBalanceMissing * 11n) / 10n) {
60
+ this.logger.info({ balancesMissing, totalBalanceMissing }, "balances missing");
61
+ this.logger.error({
62
+ minBalance,
63
+ utilityWalletBalance,
64
+ totalBalanceMissing,
65
+ utilityAccount: this.utilityAccount.address
66
+ }, "utility wallet has insufficient balance to refill wallets");
67
+ throw new Error(`utility wallet ${this.utilityAccount.address} has insufficient balance ${formatEther(utilityWalletBalance)} < ${formatEther(totalBalanceMissing)}`);
68
+ }
69
+ if (Object.keys(balancesMissing).length > 0) {
70
+ const { maxFeePerGas, maxPriorityFeePerGas } = await this.gasPriceManager.getGasPrice();
71
+ if (walletClient.chain.id === 59140 ||
72
+ walletClient.chain.id === 137 ||
73
+ walletClient.chain.id === 10) {
74
+ const instructions = [];
75
+ for (const [address, missingBalance] of Object.entries(balancesMissing)) {
76
+ instructions.push({
77
+ to: address,
78
+ value: missingBalance,
79
+ data: "0x"
80
+ });
81
+ }
82
+ let refillAddress;
83
+ if (walletClient.chain.id === 59140) {
84
+ refillAddress = "0xEad1aC3DF6F96b91491d6396F4d1610C5638B4Db";
85
+ }
86
+ else if (walletClient.chain.id === 137) {
87
+ refillAddress = "0x3402DB43152dAB9ab72fa805fdD5f391cD3E3822";
88
+ }
89
+ else {
90
+ refillAddress = "0x3402DB43152dAB9ab72fa805fdD5f391cD3E3822";
91
+ }
92
+ const callEngine = getContract({
93
+ abi: CallEngineAbi,
94
+ address: refillAddress,
95
+ client: {
96
+ public: publicClient,
97
+ wallet: walletClient
98
+ }
99
+ });
100
+ const tx = await callEngine.write.execute([instructions], {
101
+ account: this.utilityAccount,
102
+ value: totalBalanceMissing,
103
+ maxFeePerGas: maxFeePerGas * 2n,
104
+ maxPriorityFeePerGas: maxPriorityFeePerGas * 2n
105
+ });
106
+ await waitForTransactionReceipt(publicClient, tx);
107
+ for (const [address, missingBalance] of Object.entries(balancesMissing)) {
108
+ this.logger.info({ tx, executor: address, missingBalance }, "refilled wallet");
109
+ }
110
+ }
111
+ else {
112
+ for (const [address, missingBalance] of Object.entries(balancesMissing)) {
113
+ const tx = await walletClient.sendTransaction({
114
+ account: this.utilityAccount,
115
+ // @ts-ignore
116
+ to: address,
117
+ value: missingBalance,
118
+ maxFeePerGas: this.legacyTransactions
119
+ ? undefined
120
+ : maxFeePerGas,
121
+ maxPriorityFeePerGas: this.legacyTransactions
122
+ ? undefined
123
+ : maxPriorityFeePerGas,
124
+ gasPrice: this.legacyTransactions
125
+ ? maxFeePerGas
126
+ : undefined
127
+ });
128
+ await waitForTransactionReceipt(publicClient, tx);
129
+ this.logger.info({ tx, executor: address, missingBalance }, "refilled wallet");
130
+ }
131
+ }
132
+ }
133
+ else {
134
+ this.logger.info("no wallets need to be refilled");
135
+ }
136
+ }
137
+ async getWallet() {
138
+ this.logger.trace(`waiting for semaphore with count ${this.semaphore.getValue()}`);
139
+ await this.semaphore.waitForUnlock();
140
+ await this.semaphore.acquire();
141
+ const wallet = this.availableWallets.shift();
142
+ // should never happen because of semaphore
143
+ if (!wallet) {
144
+ this.semaphore.release();
145
+ this.logger.error("no more wallets");
146
+ throw new Error("no more wallets");
147
+ }
148
+ this.logger.trace({ executor: wallet.address }, "got wallet from sender manager");
149
+ this.metrics.walletsAvailable.set(this.availableWallets.length);
150
+ return wallet;
151
+ }
152
+ pushWallet(wallet) {
153
+ this.availableWallets.push(wallet);
154
+ this.semaphore.release();
155
+ this.logger.trace({ executor: wallet.address }, "pushed wallet to sender manager");
156
+ this.metrics.walletsAvailable.set(this.availableWallets.length);
157
+ return;
158
+ }
159
+ }
160
+ //# sourceMappingURL=senderManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"senderManager.js","sourceRoot":"","sources":["../../executor/senderManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAIhB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,SAAS,EAA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b,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,EAC5B,gCAAgC,CACnC,CAAA;QAED,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAE/D,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,UAAU,CAAC,MAAe;QACtB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAClC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAA;QACxB,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,EAC5B,iCAAiC,CACpC,CAAA;QACD,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAC/D,OAAM;IACV,CAAC;CACJ"}
@@ -0,0 +1,13 @@
1
+ import { type Address, type HexData, UserOperationV06 } from "../../types/index.js";
2
+ import { type Clients } from "../../utils/index.js";
3
+ import { type Account } from "viem";
4
+ export declare const TEST_OP: UserOperationV06;
5
+ export declare function getSender(entryPoint: Address, initCode: HexData, clients: Clients): Promise<Address>;
6
+ export declare function createOp(entryPoint: Address, simpleAccountFactory: Address, signer: Account, clients: Clients, maxFeePerGas?: bigint, nonce?: bigint): Promise<UserOperationV06>;
7
+ export declare const generateAccounts: (clients: Clients) => Promise<(import("viem").CustomSource & {
8
+ address: `0x${string}`;
9
+ publicKey: `0x${string}`;
10
+ source: "privateKey";
11
+ type: "local";
12
+ })[]>;
13
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,75 @@
1
+ import { EntryPointV06Abi } from "../../types/index.js";
2
+ import { SimpleAccountFactoryAbi } from "../../types/index.js";
3
+ import { getUserOpHash, parseSenderAddressError } from "../../utils/index.js";
4
+ import { concat, encodeFunctionData, getContract, parseEther } from "viem";
5
+ import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
6
+ import { foundry } from "viem/chains";
7
+ export const TEST_OP = {
8
+ sender: "0x0000000000000000000000000000000000000000",
9
+ nonce: 0n,
10
+ initCode: "0x",
11
+ callData: "0x",
12
+ callGasLimit: 100000n,
13
+ verificationGasLimit: 1000000n,
14
+ preVerificationGas: 60000n,
15
+ maxFeePerGas: 1n,
16
+ maxPriorityFeePerGas: 1n,
17
+ paymasterAndData: "0x",
18
+ signature: "0x"
19
+ };
20
+ export async function getSender(entryPoint, initCode, clients) {
21
+ const entryPointContract = getContract({
22
+ address: entryPoint,
23
+ abi: EntryPointV06Abi,
24
+ client: {
25
+ public: clients.public
26
+ }
27
+ });
28
+ const sender = await entryPointContract.simulate
29
+ .getSenderAddress([initCode])
30
+ .then((_) => {
31
+ throw new Error("Expected error");
32
+ })
33
+ .catch((e) => {
34
+ return parseSenderAddressError(e);
35
+ });
36
+ await clients.test.setBalance({ address: sender, value: parseEther("1") });
37
+ return sender;
38
+ }
39
+ export async function createOp(entryPoint, simpleAccountFactory, signer, clients, maxFeePerGas, nonce) {
40
+ const initCode = concat([
41
+ simpleAccountFactory,
42
+ encodeFunctionData({
43
+ abi: SimpleAccountFactoryAbi,
44
+ functionName: "createAccount",
45
+ args: [signer.address, 0n]
46
+ })
47
+ ]);
48
+ const sender = await getSender(entryPoint, initCode, clients);
49
+ const op = Object.assign({}, TEST_OP);
50
+ op.sender = sender;
51
+ op.initCode = initCode;
52
+ op.nonce = nonce ?? 0n;
53
+ op.maxFeePerGas = maxFeePerGas ?? (await clients.public.getGasPrice());
54
+ const opHash = getUserOpHash(op, entryPoint, foundry.id);
55
+ const signature = await clients.wallet.signMessage({
56
+ account: signer,
57
+ message: { raw: opHash }
58
+ });
59
+ op.signature = signature;
60
+ return op;
61
+ }
62
+ export const generateAccounts = async (clients) => {
63
+ const accountsPromises = [...Array(10)].map(async (_) => {
64
+ const privateKey = generatePrivateKey();
65
+ const account = privateKeyToAccount(privateKey);
66
+ await clients.test.setBalance({
67
+ address: account.address,
68
+ value: parseEther("100")
69
+ });
70
+ return account;
71
+ });
72
+ const accounts = await Promise.all(accountsPromises);
73
+ return accounts;
74
+ };
75
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../executor/test/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,gBAAgB,EAGnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAEH,aAAa,EACb,uBAAuB,EAC1B,MAAM,aAAa,CAAA;AACpB,OAAO,EAEH,MAAM,EACN,kBAAkB,EAClB,WAAW,EACX,UAAU,EACb,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,MAAM,CAAC,MAAM,OAAO,GAAqB;IACrC,MAAM,EAAE,4CAA4C;IACpD,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,OAAQ;IACtB,oBAAoB,EAAE,QAAU;IAChC,kBAAkB,EAAE,MAAO;IAC3B,YAAY,EAAE,EAAE;IAChB,oBAAoB,EAAE,EAAE;IACxB,gBAAgB,EAAE,IAAI;IACtB,SAAS,EAAE,IAAI;CAClB,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAC3B,UAAmB,EACnB,QAAiB,EACjB,OAAgB;IAEhB,MAAM,kBAAkB,GAAG,WAAW,CAAC;QACnC,OAAO,EAAE,UAAU;QACnB,GAAG,EAAE,gBAAgB;QACrB,MAAM,EAAE;YACJ,MAAM,EAAE,OAAO,CAAC,MAAM;SACzB;KACJ,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,QAAQ;SAC3C,gBAAgB,CAAC,CAA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AC,CAAA;IAExD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;QAC/C,OAAO,EAAE,MAAM;QACf,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;KAC3B,CAAC,CAAA;IACF,EAAE,CAAC,SAAS,GAAG,SAAS,CAAA;IAExB,OAAO,EAAE,CAAA;AACb,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,OAAgB,EAAE,EAAE;IACvD,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;QACpD,MAAM,UAAU,GAAG,kBAAkB,EAAE,CAAA;QACvC,MAAM,OAAO,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAA;QAC/C,MAAM,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;YAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC;SAC3B,CAAC,CAAA;QACF,OAAO,OAAO,CAAA;IAClB,CAAC,CAAC,CAAA;IAEF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IACpD,OAAO,QAAQ,CAAA;AACnB,CAAC,CAAA"}
@@ -0,0 +1,32 @@
1
+ import type { InterfaceReputationManager } from "../mempool/index.js";
2
+ import { type BundleResult, type CompressedUserOperation, EntryPointV06Abi, EntryPointV07Abi, type TransactionInfo, type UserOperationWithHash } from "../types/index.js";
3
+ import type { Logger } from "../utils/index.js";
4
+ import { type Account, type Address, type Chain, type GetContractReturnType, type Hex, type PublicClient, type Transport, type WalletClient } from "viem";
5
+ export declare function simulatedOpsToResults(simulatedOps: {
6
+ owh: UserOperationWithHash;
7
+ reason: string | undefined;
8
+ }[], transactionInfo: TransactionInfo): BundleResult[];
9
+ export type DefaultFilterOpsAndEstimateGasParams = {
10
+ ep: GetContractReturnType<typeof EntryPointV06Abi | typeof EntryPointV07Abi, {
11
+ public: PublicClient;
12
+ wallet: WalletClient;
13
+ }>;
14
+ type: "default";
15
+ };
16
+ export type CompressedFilterOpsAndEstimateGasParams = {
17
+ publicClient: PublicClient;
18
+ bundleBulker: Address;
19
+ perOpInflatorId: number;
20
+ type: "compressed";
21
+ };
22
+ export declare function createCompressedCalldata(compressedOps: CompressedUserOperation[], perOpInflatorId: number): Hex;
23
+ export declare function filterOpsAndEstimateGas(entryPoint: Address, callContext: DefaultFilterOpsAndEstimateGasParams | CompressedFilterOpsAndEstimateGasParams, wallet: Account, ops: UserOperationWithHash[], nonce: number, maxFeePerGas: bigint, maxPriorityFeePerGas: bigint, blockTag: "latest" | "pending" | undefined, onlyPre1559: boolean, fixedGasLimitForEstimation: bigint | undefined, reputationManager: InterfaceReputationManager, logger: Logger): Promise<{
24
+ simulatedOps: {
25
+ owh: UserOperationWithHash;
26
+ reason: string | undefined;
27
+ }[];
28
+ gasLimit: bigint;
29
+ resubmitAllOps: boolean;
30
+ }>;
31
+ export declare function flushStuckTransaction(publicClient: PublicClient, walletClient: WalletClient<Transport, Chain, Account | undefined>, wallet: Account, gasPrice: bigint, logger: Logger, entryPoint: Address): Promise<void>;
32
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,241 @@
1
+ import { EntryPointV06Abi, EntryPointV07Abi, deriveUserOperation, failedOpErrorSchema, failedOpWithRevertErrorSchema } from "../types/index.js";
2
+ import { getRevertErrorData, isVersion06, parseViemError, toPackedUserOperation, transactionIncluded } from "../utils/index.js";
3
+ import * as sentry from "@sentry/node";
4
+ import { ContractFunctionRevertedError, EstimateGasExecutionError, FeeCapTooLowError, concat, decodeErrorResult, hexToBytes, numberToHex } from "viem";
5
+ export function simulatedOpsToResults(simulatedOps, transactionInfo) {
6
+ return simulatedOps.map((sop) => {
7
+ if (sop.reason === undefined) {
8
+ return {
9
+ status: "success",
10
+ value: {
11
+ userOperation: {
12
+ entryPoint: transactionInfo.entryPoint,
13
+ mempoolUserOperation: sop.owh.mempoolUserOperation,
14
+ userOperationHash: sop.owh.userOperationHash,
15
+ lastReplaced: Date.now(),
16
+ firstSubmitted: Date.now()
17
+ },
18
+ transactionInfo
19
+ }
20
+ };
21
+ }
22
+ return {
23
+ status: "failure",
24
+ error: {
25
+ entryPoint: transactionInfo.entryPoint,
26
+ userOperation: sop.owh.mempoolUserOperation,
27
+ userOpHash: sop.owh.userOperationHash,
28
+ reason: sop.reason
29
+ }
30
+ };
31
+ });
32
+ }
33
+ export function createCompressedCalldata(compressedOps, perOpInflatorId) {
34
+ const bundleBulkerPayload = numberToHex(perOpInflatorId, { size: 4 }); // bytes used in BundleBulker
35
+ const perOpInflatorPayload = numberToHex(compressedOps.length, { size: 1 }); // bytes used in perOpInflator
36
+ return compressedOps.reduce((currentCallData, op) => {
37
+ const nextCallData = concat([
38
+ numberToHex(op.inflatorId, { size: 4 }),
39
+ numberToHex(hexToBytes(op.compressedCalldata).length, {
40
+ size: 2
41
+ }),
42
+ op.compressedCalldata
43
+ ]);
44
+ return concat([currentCallData, nextCallData]);
45
+ }, concat([bundleBulkerPayload, perOpInflatorPayload]));
46
+ }
47
+ export async function filterOpsAndEstimateGas(entryPoint, callContext, wallet, ops, nonce, maxFeePerGas, maxPriorityFeePerGas, blockTag, onlyPre1559, fixedGasLimitForEstimation, reputationManager, logger) {
48
+ const simulatedOps = ops.map((owh) => {
49
+ return { owh, reason: undefined };
50
+ });
51
+ let gasLimit;
52
+ // TODO compressed ops are not supported in V07
53
+ const isUserOpV06 = callContext.type === "default"
54
+ ? isVersion06(simulatedOps[0].owh.mempoolUserOperation)
55
+ : true;
56
+ while (simulatedOps.filter((op) => op.reason === undefined).length > 0) {
57
+ try {
58
+ const gasOptions = onlyPre1559
59
+ ? { gasPrice: maxFeePerGas }
60
+ : { maxFeePerGas, maxPriorityFeePerGas };
61
+ if (callContext.type === "default") {
62
+ const ep = callContext.ep;
63
+ const opsToSend = simulatedOps
64
+ .filter((op) => op.reason === undefined)
65
+ .map((op) => {
66
+ return isUserOpV06
67
+ ? op.owh.mempoolUserOperation
68
+ : toPackedUserOperation(op.owh
69
+ .mempoolUserOperation);
70
+ });
71
+ gasLimit = await ep.estimateGas.handleOps(
72
+ // @ts-ignore - ep is set correctly for opsToSend, but typescript doesn't know that
73
+ [opsToSend, wallet.address], {
74
+ account: wallet,
75
+ nonce: nonce,
76
+ blockTag: blockTag,
77
+ ...(fixedGasLimitForEstimation !== undefined && {
78
+ gas: fixedGasLimitForEstimation
79
+ }),
80
+ ...gasOptions
81
+ });
82
+ }
83
+ else {
84
+ const { publicClient, bundleBulker, perOpInflatorId } = callContext;
85
+ const opsToSend = simulatedOps
86
+ .filter((op) => op.reason === undefined)
87
+ .map((op) => op.owh
88
+ .mempoolUserOperation);
89
+ gasLimit = await publicClient.estimateGas({
90
+ to: bundleBulker,
91
+ account: wallet,
92
+ data: createCompressedCalldata(opsToSend, perOpInflatorId),
93
+ gas: fixedGasLimitForEstimation,
94
+ nonce: nonce,
95
+ blockTag: blockTag,
96
+ ...gasOptions
97
+ });
98
+ }
99
+ return { simulatedOps, gasLimit, resubmitAllOps: false };
100
+ }
101
+ catch (err) {
102
+ logger.error({ err, blockTag }, "error estimating gas");
103
+ const e = parseViemError(err);
104
+ if (e instanceof ContractFunctionRevertedError) {
105
+ const failedOpError = failedOpErrorSchema.safeParse(e.data);
106
+ const failedOpWithRevertError = failedOpWithRevertErrorSchema.safeParse(e.data);
107
+ let errorData = undefined;
108
+ if (failedOpError.success) {
109
+ errorData = failedOpError.data.args;
110
+ }
111
+ if (failedOpWithRevertError.success) {
112
+ errorData = failedOpWithRevertError.data.args;
113
+ }
114
+ if (errorData) {
115
+ logger.debug({
116
+ errorData,
117
+ userOpHashes: simulatedOps
118
+ .filter((op) => op.reason === undefined)
119
+ .map((op) => op.owh.userOperationHash)
120
+ }, "user op in batch invalid");
121
+ const failingOp = simulatedOps.filter((op) => op.reason === undefined)[Number(errorData.opIndex)];
122
+ failingOp.reason = `${errorData.reason}${errorData?.inner
123
+ ? ` - ${errorData.inner}`
124
+ : ""}`;
125
+ reputationManager.crashedHandleOps(deriveUserOperation(failingOp.owh.mempoolUserOperation), entryPoint, failingOp.reason);
126
+ }
127
+ if (!(failedOpError.success || failedOpWithRevertError.success)) {
128
+ sentry.captureException(err);
129
+ logger.error({
130
+ error: `${failedOpError.error} ${failedOpWithRevertError.error}`
131
+ }, "failed to parse failedOpError");
132
+ return {
133
+ simulatedOps: [],
134
+ gasLimit: 0n,
135
+ resubmitAllOps: false
136
+ };
137
+ }
138
+ }
139
+ else if (e instanceof EstimateGasExecutionError ||
140
+ err instanceof EstimateGasExecutionError) {
141
+ if (e?.cause instanceof FeeCapTooLowError) {
142
+ logger.info({ error: e.shortMessage }, "error estimating gas due to max fee < basefee");
143
+ return {
144
+ simulatedOps: simulatedOps,
145
+ gasLimit: 0n,
146
+ resubmitAllOps: true
147
+ };
148
+ }
149
+ try {
150
+ let errorHexData = "0x";
151
+ if (err instanceof EstimateGasExecutionError) {
152
+ errorHexData = getRevertErrorData(err);
153
+ }
154
+ else {
155
+ errorHexData = e?.details.split("Reverted ")[1];
156
+ }
157
+ const errorResult = decodeErrorResult({
158
+ abi: isUserOpV06 ? EntryPointV06Abi : EntryPointV07Abi,
159
+ data: errorHexData
160
+ });
161
+ logger.debug({
162
+ errorName: errorResult.errorName,
163
+ args: errorResult.args,
164
+ userOpHashes: simulatedOps
165
+ .filter((op) => op.reason === undefined)
166
+ .map((op) => op.owh.userOperationHash)
167
+ }, "user op in batch invalid");
168
+ if (errorResult.errorName !== "FailedOpWithRevert" &&
169
+ errorResult.errorName !== "FailedOp") {
170
+ logger.error({
171
+ errorName: errorResult.errorName,
172
+ args: errorResult.args
173
+ }, "unexpected error result");
174
+ return {
175
+ simulatedOps: [],
176
+ gasLimit: 0n,
177
+ resubmitAllOps: false
178
+ };
179
+ }
180
+ const failingOp = simulatedOps.filter((op) => op.reason === undefined)[Number(errorResult.args[0])];
181
+ failingOp.reason = errorResult.args[1];
182
+ }
183
+ catch (e) {
184
+ logger.error({ error: JSON.stringify(err) }, "failed to parse error result");
185
+ return {
186
+ simulatedOps: [],
187
+ gasLimit: 0n,
188
+ resubmitAllOps: false
189
+ };
190
+ }
191
+ }
192
+ else {
193
+ sentry.captureException(err);
194
+ logger.error({ error: JSON.stringify(err), blockTag }, "error estimating gas");
195
+ return { simulatedOps: [], gasLimit: 0n, resubmitAllOps: false };
196
+ }
197
+ }
198
+ }
199
+ return { simulatedOps, gasLimit: 0n, resubmitAllOps: false };
200
+ }
201
+ export async function flushStuckTransaction(publicClient, walletClient, wallet, gasPrice, logger, entryPoint) {
202
+ const latestNonce = await publicClient.getTransactionCount({
203
+ address: wallet.address,
204
+ blockTag: "latest"
205
+ });
206
+ const pendingNonce = await publicClient.getTransactionCount({
207
+ address: wallet.address,
208
+ blockTag: "pending"
209
+ });
210
+ logger.debug({ latestNonce, pendingNonce, wallet: wallet.address }, "checking for stuck transactions");
211
+ // same nonce is okay
212
+ if (latestNonce === pendingNonce) {
213
+ return;
214
+ }
215
+ // one nonce ahead is also okay
216
+ if (latestNonce + 1 === pendingNonce) {
217
+ return;
218
+ }
219
+ logger.info({ latestNonce, pendingNonce, wallet: wallet.address }, "found stuck transaction, flushing");
220
+ for (let nonceToFlush = latestNonce; nonceToFlush < pendingNonce; nonceToFlush++) {
221
+ try {
222
+ const txHash = await walletClient.sendTransaction({
223
+ account: wallet,
224
+ to: wallet.address,
225
+ value: 0n,
226
+ nonce: nonceToFlush,
227
+ maxFeePerGas: gasPrice,
228
+ maxPriorityFeePerGas: gasPrice
229
+ });
230
+ logger.debug({ txHash, nonce: nonceToFlush, wallet: wallet.address }, "flushed stuck transaction");
231
+ // TODO: We don't know if the entrypoint is the V06 or V07. So we try and catch both.
232
+ await transactionIncluded(true, txHash, publicClient, entryPoint);
233
+ await transactionIncluded(false, txHash, publicClient, entryPoint);
234
+ }
235
+ catch (e) {
236
+ sentry.captureException(e);
237
+ logger.warn({ error: e }, "error flushing stuck transaction");
238
+ }
239
+ }
240
+ }
241
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../executor/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAGH,gBAAgB,EAChB,gBAAgB,EAOhB,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,EAChC,MAAM,aAAa,CAAA;AAEpB,OAAO,EACH,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACtB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAIH,6BAA6B,EAC7B,yBAAyB,EACzB,iBAAiB,EAMjB,MAAM,EACN,iBAAiB,EACjB,UAAU,EACV,WAAW,EACd,MAAM,MAAM,CAAA;AAEb,MAAM,UAAU,qBAAqB,CACjC,YAGG,EACH,eAAgC;IAEhC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAC5B,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO;gBACH,MAAM,EAAE,SAAS;gBACjB,KAAK,EAAE;oBACH,aAAa,EAAE;wBACX,UAAU,EAAE,eAAe,CAAC,UAAU;wBACtC,oBAAoB,EAAE,GAAG,CAAC,GAAG,CAAC,oBAAoB;wBAClD,iBAAiB,EAAE,GAAG,CAAC,GAAG,CAAC,iBAAiB;wBAC5C,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE;wBACxB,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE;qBAC7B;oBACD,eAAe;iBAClB;aACJ,CAAA;QACL,CAAC;QACD,OAAO;YACH,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE;gBACH,UAAU,EAAE,eAAe,CAAC,UAAU;gBACtC,aAAa,EAAE,GAAG,CAAC,GAAG,CAAC,oBAAoB;gBAC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B,oBAAoB,EAAE,QAAQ;aACjC,CAAC,CAAA;YAEF,MAAM,CAAC,KAAK,CACR,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,EACvD,2BAA2B,CAC9B,CAAA;YAED,qFAAqF;YACrF,MAAM,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,CAAA;YACjE,MAAM,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,CAAA;QACtE,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;YAC1B,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,kCAAkC,CAAC,CAAA;QACjE,CAAC;IACL,CAAC;AACL,CAAC"}
package/esm/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import "./cli/alto.js";
2
+ //# sourceMappingURL=index.d.ts.map
package/esm/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import "./cli/alto.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from "./mempool.js";
2
+ export * from "./monitoring.js";
3
+ export * from "./reputationManager.js";
4
+ export * from "./nullMempool.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ export * from "./mempool.js";
2
+ export * from "./monitoring.js";
3
+ export * from "./reputationManager.js";
4
+ export * from "./nullMempool.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../mempool/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA"}
@@ -0,0 +1,64 @@
1
+ import type { Metrics } from "../utils/index.js";
2
+ import { type InterfaceValidator, type MempoolUserOperation, type ReferencedCodeHashes, type StorageMap, type SubmittedUserOperation, type TransactionInfo, type UserOperation, type UserOperationInfo } from "../types/index.js";
3
+ import type { HexData32 } from "../types/index.js";
4
+ import type { Logger } from "../utils/index.js";
5
+ import { type Address, type Chain, type PublicClient, type Transport } from "viem";
6
+ import type { Monitor } from "./monitoring.js";
7
+ import { type InterfaceReputationManager } from "./reputationManager.js";
8
+ export declare class MemoryMempool {
9
+ private monitor;
10
+ private publicClient;
11
+ private reputationManager;
12
+ private store;
13
+ private throttledEntityBundleCount;
14
+ private logger;
15
+ private validator;
16
+ private safeMode;
17
+ private parallelUserOpsMaxSize;
18
+ private queuedUserOpsMaxSize;
19
+ private onlyUniqueSendersPerBundle;
20
+ constructor(monitor: Monitor, reputationManager: InterfaceReputationManager, validator: InterfaceValidator, publicClient: PublicClient<Transport, Chain>, safeMode: boolean, logger: Logger, metrics: Metrics, parallelUserOpsMaxSize: number, queuedUserOpsMaxSize: number, onlyUniqueSendersPerBundle: boolean, throttledEntityBundleCount?: number);
21
+ replaceSubmitted(userOperation: UserOperationInfo, transactionInfo: TransactionInfo): void;
22
+ markSubmitted(userOpHash: `0x${string}`, transactionInfo: TransactionInfo): void;
23
+ dumpOutstanding(): UserOperationInfo[];
24
+ dumpProcessing(): UserOperationInfo[];
25
+ dumpSubmittedOps(): SubmittedUserOperation[];
26
+ removeSubmitted(userOpHash: `0x${string}`): void;
27
+ removeProcessing(userOpHash: `0x${string}`): void;
28
+ checkEntityMultipleRoleViolation(op: UserOperation): Promise<void>;
29
+ getKnownEntities(): {
30
+ sender: Set<Address>;
31
+ paymasters: Set<Address>;
32
+ factories: Set<Address>;
33
+ };
34
+ add(mempoolUserOperation: MempoolUserOperation, entryPoint: Address, referencedContracts?: ReferencedCodeHashes): boolean;
35
+ shouldSkip(opInfo: UserOperationInfo, paymasterDeposit: {
36
+ [paymaster: string]: bigint;
37
+ }, stakedEntityCount: {
38
+ [addr: string]: number;
39
+ }, knownEntities: {
40
+ sender: Set<`0x${string}`>;
41
+ paymasters: Set<`0x${string}`>;
42
+ factories: Set<`0x${string}`>;
43
+ }, senders: Set<string>, storageMap: StorageMap): Promise<{
44
+ skip: boolean;
45
+ paymasterDeposit: {
46
+ [paymaster: string]: bigint;
47
+ };
48
+ stakedEntityCount: {
49
+ [addr: string]: number;
50
+ };
51
+ knownEntities: {
52
+ sender: Set<`0x${string}`>;
53
+ paymasters: Set<`0x${string}`>;
54
+ factories: Set<`0x${string}`>;
55
+ };
56
+ senders: Set<string>;
57
+ storageMap: StorageMap;
58
+ }>;
59
+ process(maxGasLimit: bigint, minOps?: number): Promise<UserOperationInfo[]>;
60
+ get(opHash: HexData32): UserOperation | null;
61
+ getQueuedUserOperations(userOperation: UserOperation, entryPoint: Address, _currentNonceValue?: bigint): Promise<UserOperation[]>;
62
+ clear(): void;
63
+ }
64
+ //# sourceMappingURL=mempool.d.ts.map