@pimlico/alto 0.0.0-main.20240607T104359 → 0.0.0-staging.20240606T093925

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 (238) hide show
  1. package/lib/cli/index.d.ts +0 -1
  2. package/lib/cli/index.js +0 -1
  3. package/lib/cli/index.js.map +1 -1
  4. package/lib/executor/executor.js +0 -6
  5. package/lib/executor/executor.js.map +1 -1
  6. package/lib/executor/executorManager.js +0 -1
  7. package/lib/executor/executorManager.js.map +1 -1
  8. package/lib/executor/utils.js +1 -3
  9. package/lib/executor/utils.js.map +1 -1
  10. package/lib/index.d.ts +5 -1
  11. package/lib/index.js +120 -1
  12. package/lib/index.js.map +1 -1
  13. package/lib/rpc/server.js +1 -2
  14. package/lib/rpc/server.js.map +1 -1
  15. package/lib/types/mempool.d.ts +1 -2
  16. package/package.json +67 -70
  17. package/esm/cli/alto.d.ts +0 -6
  18. package/esm/cli/alto.js +0 -92
  19. package/esm/cli/alto.js.map +0 -1
  20. package/esm/cli/config/bundler.d.ts +0 -391
  21. package/esm/cli/config/bundler.js +0 -132
  22. package/esm/cli/config/bundler.js.map +0 -1
  23. package/esm/cli/config/index.d.ts +0 -3
  24. package/esm/cli/config/index.js +0 -3
  25. package/esm/cli/config/index.js.map +0 -1
  26. package/esm/cli/config/options.d.ts +0 -11
  27. package/esm/cli/config/options.js +0 -336
  28. package/esm/cli/config/options.js.map +0 -1
  29. package/esm/cli/customTransport.d.ts +0 -14
  30. package/esm/cli/customTransport.js +0 -53
  31. package/esm/cli/customTransport.js.map +0 -1
  32. package/esm/cli/handler.d.ts +0 -3
  33. package/esm/cli/handler.js +0 -116
  34. package/esm/cli/handler.js.map +0 -1
  35. package/esm/cli/index.d.ts +0 -4
  36. package/esm/cli/index.js +0 -4
  37. package/esm/cli/index.js.map +0 -1
  38. package/esm/cli/instrumentation.d.ts +0 -2
  39. package/esm/cli/instrumentation.js +0 -39
  40. package/esm/cli/instrumentation.js.map +0 -1
  41. package/esm/cli/setupServer.d.ts +0 -17
  42. package/esm/cli/setupServer.js +0 -155
  43. package/esm/cli/setupServer.js.map +0 -1
  44. package/esm/cli/util.d.ts +0 -22
  45. package/esm/cli/util.js +0 -30
  46. package/esm/cli/util.js.map +0 -1
  47. package/esm/executor/executor.d.ts +0 -54
  48. package/esm/executor/executor.js +0 -643
  49. package/esm/executor/executor.js.map +0 -1
  50. package/esm/executor/executorManager.d.ts +0 -34
  51. package/esm/executor/executorManager.js +0 -402
  52. package/esm/executor/executorManager.js.map +0 -1
  53. package/esm/executor/index.d.ts +0 -5
  54. package/esm/executor/index.js +0 -5
  55. package/esm/executor/index.js.map +0 -1
  56. package/esm/executor/senderManager.d.ts +0 -17
  57. package/esm/executor/senderManager.js +0 -160
  58. package/esm/executor/senderManager.js.map +0 -1
  59. package/esm/executor/test/utils.d.ts +0 -13
  60. package/esm/executor/test/utils.js +0 -75
  61. package/esm/executor/test/utils.js.map +0 -1
  62. package/esm/executor/utils.d.ts +0 -32
  63. package/esm/executor/utils.js +0 -241
  64. package/esm/executor/utils.js.map +0 -1
  65. package/esm/index.d.ts +0 -2
  66. package/esm/index.js +0 -2
  67. package/esm/index.js.map +0 -1
  68. package/esm/mempool/index.d.ts +0 -5
  69. package/esm/mempool/index.js +0 -5
  70. package/esm/mempool/index.js.map +0 -1
  71. package/esm/mempool/mempool.d.ts +0 -64
  72. package/esm/mempool/mempool.js +0 -489
  73. package/esm/mempool/mempool.js.map +0 -1
  74. package/esm/mempool/monitoring.d.ts +0 -10
  75. package/esm/mempool/monitoring.js +0 -34
  76. package/esm/mempool/monitoring.js.map +0 -1
  77. package/esm/mempool/nullMempool.d.ts +0 -15
  78. package/esm/mempool/nullMempool.js +0 -36
  79. package/esm/mempool/nullMempool.js.map +0 -1
  80. package/esm/mempool/reputationManager.d.ts +0 -115
  81. package/esm/mempool/reputationManager.js +0 -397
  82. package/esm/mempool/reputationManager.js.map +0 -1
  83. package/esm/mempool/store.d.ts +0 -22
  84. package/esm/mempool/store.js +0 -123
  85. package/esm/mempool/store.js.map +0 -1
  86. package/esm/rpc/EntryPointSimulationsV07.d.ts +0 -58
  87. package/esm/rpc/EntryPointSimulationsV07.js +0 -407
  88. package/esm/rpc/EntryPointSimulationsV07.js.map +0 -1
  89. package/esm/rpc/ExecuteSimulator.d.ts +0 -37
  90. package/esm/rpc/ExecuteSimulator.js +0 -48
  91. package/esm/rpc/ExecuteSimulator.js.map +0 -1
  92. package/esm/rpc/gasEstimation.d.ts +0 -17
  93. package/esm/rpc/gasEstimation.js +0 -410
  94. package/esm/rpc/gasEstimation.js.map +0 -1
  95. package/esm/rpc/index.d.ts +0 -5
  96. package/esm/rpc/index.js +0 -5
  97. package/esm/rpc/index.js.map +0 -1
  98. package/esm/rpc/nonceQueuer.d.ts +0 -25
  99. package/esm/rpc/nonceQueuer.js +0 -135
  100. package/esm/rpc/nonceQueuer.js.map +0 -1
  101. package/esm/rpc/rpcHandler.d.ts +0 -64
  102. package/esm/rpc/rpcHandler.js +0 -727
  103. package/esm/rpc/rpcHandler.js.map +0 -1
  104. package/esm/rpc/server.d.ts +0 -31
  105. package/esm/rpc/server.js +0 -239
  106. package/esm/rpc/server.js.map +0 -1
  107. package/esm/rpc/validation/BundlerCollectorTracerV06.d.ts +0 -102
  108. package/esm/rpc/validation/BundlerCollectorTracerV06.js +0 -255
  109. package/esm/rpc/validation/BundlerCollectorTracerV06.js.map +0 -1
  110. package/esm/rpc/validation/BundlerCollectorTracerV07.d.ts +0 -102
  111. package/esm/rpc/validation/BundlerCollectorTracerV07.js +0 -254
  112. package/esm/rpc/validation/BundlerCollectorTracerV07.js.map +0 -1
  113. package/esm/rpc/validation/SafeValidator.d.ts +0 -35
  114. package/esm/rpc/validation/SafeValidator.js +0 -487
  115. package/esm/rpc/validation/SafeValidator.js.map +0 -1
  116. package/esm/rpc/validation/TracerResultParserV06.d.ts +0 -13
  117. package/esm/rpc/validation/TracerResultParserV06.js +0 -578
  118. package/esm/rpc/validation/TracerResultParserV06.js.map +0 -1
  119. package/esm/rpc/validation/TracerResultParserV07.d.ts +0 -33
  120. package/esm/rpc/validation/TracerResultParserV07.js +0 -557
  121. package/esm/rpc/validation/TracerResultParserV07.js.map +0 -1
  122. package/esm/rpc/validation/UnsafeValidator.d.ts +0 -63
  123. package/esm/rpc/validation/UnsafeValidator.js +0 -257
  124. package/esm/rpc/validation/UnsafeValidator.js.map +0 -1
  125. package/esm/rpc/validation/index.d.ts +0 -3
  126. package/esm/rpc/validation/index.js +0 -3
  127. package/esm/rpc/validation/index.js.map +0 -1
  128. package/esm/rpc/validation/tracer.d.ts +0 -122
  129. package/esm/rpc/validation/tracer.js +0 -82
  130. package/esm/rpc/validation/tracer.js.map +0 -1
  131. package/esm/types/contracts/BundleBulker.d.ts +0 -120
  132. package/esm/types/contracts/BundleBulker.js +0 -157
  133. package/esm/types/contracts/BundleBulker.js.map +0 -1
  134. package/esm/types/contracts/CallEngine.d.ts +0 -28
  135. package/esm/types/contracts/CallEngine.js +0 -37
  136. package/esm/types/contracts/CallEngine.js.map +0 -1
  137. package/esm/types/contracts/CodeHashGetter.d.ts +0 -37
  138. package/esm/types/contracts/CodeHashGetter.js +0 -45
  139. package/esm/types/contracts/CodeHashGetter.js.map +0 -1
  140. package/esm/types/contracts/EntryPoint.d.ts +0 -1789
  141. package/esm/types/contracts/EntryPoint.js +0 -2304
  142. package/esm/types/contracts/EntryPoint.js.map +0 -1
  143. package/esm/types/contracts/EntryPointSimulations.d.ts +0 -153
  144. package/esm/types/contracts/EntryPointSimulations.js +0 -15
  145. package/esm/types/contracts/EntryPointSimulations.js.map +0 -1
  146. package/esm/types/contracts/IOpInflator.d.ts +0 -61
  147. package/esm/types/contracts/IOpInflator.js +0 -80
  148. package/esm/types/contracts/IOpInflator.js.map +0 -1
  149. package/esm/types/contracts/IPaymaster.d.ts +0 -3
  150. package/esm/types/contracts/IPaymaster.js +0 -117
  151. package/esm/types/contracts/IPaymaster.js.map +0 -1
  152. package/esm/types/contracts/Inflator.d.ts +0 -65
  153. package/esm/types/contracts/Inflator.js +0 -84
  154. package/esm/types/contracts/Inflator.js.map +0 -1
  155. package/esm/types/contracts/PerOpInflator.d.ts +0 -176
  156. package/esm/types/contracts/PerOpInflator.js +0 -229
  157. package/esm/types/contracts/PerOpInflator.js.map +0 -1
  158. package/esm/types/contracts/PimlicoEntryPointSimulations.d.ts +0 -23
  159. package/esm/types/contracts/PimlicoEntryPointSimulations.js +0 -33
  160. package/esm/types/contracts/PimlicoEntryPointSimulations.js.map +0 -1
  161. package/esm/types/contracts/SenderCreator.d.ts +0 -4
  162. package/esm/types/contracts/SenderCreator.js +0 -23
  163. package/esm/types/contracts/SenderCreator.js.map +0 -1
  164. package/esm/types/contracts/SimpleAccountFactory.d.ts +0 -57
  165. package/esm/types/contracts/SimpleAccountFactory.js +0 -76
  166. package/esm/types/contracts/SimpleAccountFactory.js.map +0 -1
  167. package/esm/types/contracts/TestOpcodesAccount.d.ts +0 -4
  168. package/esm/types/contracts/TestOpcodesAccount.js +0 -281
  169. package/esm/types/contracts/TestOpcodesAccount.js.map +0 -1
  170. package/esm/types/contracts/TestOpcodesAccountFactory.d.ts +0 -4
  171. package/esm/types/contracts/TestOpcodesAccountFactory.js +0 -23
  172. package/esm/types/contracts/TestOpcodesAccountFactory.js.map +0 -1
  173. package/esm/types/contracts/TestStorageAccount.d.ts +0 -4
  174. package/esm/types/contracts/TestStorageAccount.js +0 -313
  175. package/esm/types/contracts/TestStorageAccount.js.map +0 -1
  176. package/esm/types/contracts/index.d.ts +0 -17
  177. package/esm/types/contracts/index.js +0 -17
  178. package/esm/types/contracts/index.js.map +0 -1
  179. package/esm/types/gasPrice.d.ts +0 -110
  180. package/esm/types/gasPrice.js +0 -52
  181. package/esm/types/gasPrice.js.map +0 -1
  182. package/esm/types/index.d.ts +0 -11
  183. package/esm/types/index.js +0 -11
  184. package/esm/types/index.js.map +0 -1
  185. package/esm/types/interfaces.d.ts +0 -26
  186. package/esm/types/interfaces.js +0 -2
  187. package/esm/types/interfaces.js.map +0 -1
  188. package/esm/types/mempool.d.ts +0 -79
  189. package/esm/types/mempool.js +0 -16
  190. package/esm/types/mempool.js.map +0 -1
  191. package/esm/types/schemas.d.ts +0 -4791
  192. package/esm/types/schemas.js +0 -497
  193. package/esm/types/schemas.js.map +0 -1
  194. package/esm/types/test/validationTestErrors.d.ts +0 -3
  195. package/esm/types/test/validationTestErrors.js +0 -229
  196. package/esm/types/test/validationTestErrors.js.map +0 -1
  197. package/esm/types/utils.d.ts +0 -24
  198. package/esm/types/utils.js +0 -30
  199. package/esm/types/utils.js.map +0 -1
  200. package/esm/types/validation.d.ts +0 -14327
  201. package/esm/types/validation.js +0 -304
  202. package/esm/types/validation.js.map +0 -1
  203. package/esm/utils/bigInt.d.ts +0 -3
  204. package/esm/utils/bigInt.js +0 -9
  205. package/esm/utils/bigInt.js.map +0 -1
  206. package/esm/utils/compressionHandler.d.ts +0 -11
  207. package/esm/utils/compressionHandler.js +0 -39
  208. package/esm/utils/compressionHandler.js.map +0 -1
  209. package/esm/utils/gasPriceManager.d.ts +0 -34
  210. package/esm/utils/gasPriceManager.js +0 -338
  211. package/esm/utils/gasPriceManager.js.map +0 -1
  212. package/esm/utils/helpers.d.ts +0 -4
  213. package/esm/utils/helpers.js +0 -13
  214. package/esm/utils/helpers.js.map +0 -1
  215. package/esm/utils/index.d.ts +0 -11
  216. package/esm/utils/index.js +0 -10
  217. package/esm/utils/index.js.map +0 -1
  218. package/esm/utils/logger.d.ts +0 -6
  219. package/esm/utils/logger.js +0 -76
  220. package/esm/utils/logger.js.map +0 -1
  221. package/esm/utils/metrics.d.ts +0 -22
  222. package/esm/utils/metrics.js +0 -150
  223. package/esm/utils/metrics.js.map +0 -1
  224. package/esm/utils/rpc-reply.d.ts +0 -17
  225. package/esm/utils/rpc-reply.js +0 -41
  226. package/esm/utils/rpc-reply.js.map +0 -1
  227. package/esm/utils/test.d.ts +0 -17
  228. package/esm/utils/test.js +0 -130
  229. package/esm/utils/test.js.map +0 -1
  230. package/esm/utils/userop.d.ts +0 -49
  231. package/esm/utils/userop.js +0 -408
  232. package/esm/utils/userop.js.map +0 -1
  233. package/esm/utils/validation.d.ts +0 -65
  234. package/esm/utils/validation.js +0 -461
  235. package/esm/utils/validation.js.map +0 -1
  236. package/lib/cli/alto.d.ts +0 -6
  237. package/lib/cli/alto.js +0 -123
  238. package/lib/cli/alto.js.map +0 -1
@@ -1,338 +0,0 @@
1
- import { RpcError, gasStationResult } from "../types/index.js";
2
- import { maxBigInt, minBigInt } from "./index.js";
3
- import * as sentry from "@sentry/node";
4
- import { parseGwei } from "viem";
5
- import * as chains from "viem/chains";
6
- var ChainId;
7
- (function (ChainId) {
8
- ChainId[ChainId["Goerli"] = 5] = "Goerli";
9
- ChainId[ChainId["Polygon"] = 137] = "Polygon";
10
- ChainId[ChainId["Mumbai"] = 80001] = "Mumbai";
11
- ChainId[ChainId["LineaTestnet"] = 59140] = "LineaTestnet";
12
- ChainId[ChainId["Linea"] = 59144] = "Linea";
13
- })(ChainId || (ChainId = {}));
14
- const MIN_POLYGON_GAS_PRICE = parseGwei("31");
15
- const MIN_MUMBAI_GAS_PRICE = parseGwei("1");
16
- function getGasStationUrl(chainId) {
17
- switch (chainId) {
18
- case ChainId.Polygon:
19
- return "https://gasstation.polygon.technology/v2";
20
- case ChainId.Mumbai:
21
- return "https://gasstation-testnet.polygon.technology/v2";
22
- }
23
- }
24
- export class GasPriceManager {
25
- chain;
26
- publicClient;
27
- legacyTransactions;
28
- logger;
29
- queueBaseFeePerGas = []; // Store pairs of [price, timestamp]
30
- queueMaxFeePerGas = []; // Store pairs of [price, timestamp]
31
- queueMaxPriorityFeePerGas = []; // Store pairs of [price, timestamp]
32
- maxQueueSize;
33
- gasBumpMultiplier;
34
- constructor(chain, publicClient, legacyTransactions, logger, gasBumpMultiplier, gasPriceTimeValidityInSeconds = 10) {
35
- this.maxQueueSize = gasPriceTimeValidityInSeconds;
36
- this.chain = chain;
37
- this.publicClient = publicClient;
38
- this.legacyTransactions = legacyTransactions;
39
- this.logger = logger;
40
- this.gasBumpMultiplier = gasBumpMultiplier;
41
- }
42
- getDefaultGasFee(chainId) {
43
- switch (chainId) {
44
- case ChainId.Polygon:
45
- return MIN_POLYGON_GAS_PRICE;
46
- case ChainId.Mumbai:
47
- return MIN_MUMBAI_GAS_PRICE;
48
- default:
49
- return 0n;
50
- }
51
- }
52
- async getPolygonGasPriceParameters() {
53
- const gasStationUrl = getGasStationUrl(this.chain.id);
54
- try {
55
- const data = await (await fetch(gasStationUrl)).json();
56
- // take the standard speed here, SDK options will define the extra tip
57
- const parsedData = gasStationResult.parse(data);
58
- return parsedData.fast;
59
- }
60
- catch (e) {
61
- this.logger.error({ error: e }, "failed to get gas price from gas station, using default");
62
- return null;
63
- }
64
- }
65
- bumpTheGasPrice(gasPriceParameters) {
66
- const bumpAmount = this.gasBumpMultiplier;
67
- const maxPriorityFeePerGas = maxBigInt(gasPriceParameters.maxPriorityFeePerGas, this.getDefaultGasFee(this.chain.id));
68
- const maxFeePerGas = maxBigInt(gasPriceParameters.maxFeePerGas, maxPriorityFeePerGas);
69
- const result = {
70
- maxFeePerGas: (maxFeePerGas * bumpAmount) / 100n,
71
- maxPriorityFeePerGas: (maxPriorityFeePerGas * bumpAmount) / 100n
72
- };
73
- if (this.chain.id === chains.celo.id ||
74
- this.chain.id === chains.celoAlfajores.id) {
75
- const maxFee = maxBigInt(result.maxFeePerGas, result.maxPriorityFeePerGas);
76
- return {
77
- maxFeePerGas: maxFee,
78
- maxPriorityFeePerGas: maxFee
79
- };
80
- }
81
- if (this.chain.id === chains.dfk.id) {
82
- const maxFeePerGas = maxBigInt(5000000000n, result.maxFeePerGas);
83
- const maxPriorityFeePerGas = maxBigInt(5000000000n, result.maxPriorityFeePerGas);
84
- return {
85
- maxFeePerGas,
86
- maxPriorityFeePerGas
87
- };
88
- }
89
- // set a minimum maxPriorityFee & maxFee to 1.5gwei on avalanche (because eth_maxPriorityFeePerGas returns 0)
90
- if (this.chain.id === chains.avalanche.id) {
91
- const maxFeePerGas = maxBigInt(parseGwei("1.5"), result.maxFeePerGas);
92
- const maxPriorityFeePerGas = maxBigInt(parseGwei("1.5"), result.maxPriorityFeePerGas);
93
- return {
94
- maxFeePerGas,
95
- maxPriorityFeePerGas
96
- };
97
- }
98
- return result;
99
- }
100
- async getFallBackMaxPriorityFeePerGas(publicClient, gasPrice) {
101
- const feeHistory = await publicClient.getFeeHistory({
102
- blockCount: 10,
103
- rewardPercentiles: [20],
104
- blockTag: "latest"
105
- });
106
- if (feeHistory.reward === undefined || feeHistory.reward === null) {
107
- return gasPrice;
108
- }
109
- const feeAverage = feeHistory.reward.reduce((acc, cur) => cur[0] + acc, 0n) / 10n;
110
- return minBigInt(feeAverage, gasPrice);
111
- }
112
- async getNextBaseFee(publicClient) {
113
- const block = await publicClient.getBlock({
114
- blockTag: "latest"
115
- });
116
- const currentBaseFeePerGas = block.baseFeePerGas || (await publicClient.getGasPrice());
117
- const currentGasUsed = block.gasUsed;
118
- const gasTarget = block.gasLimit / 2n;
119
- if (currentGasUsed === gasTarget) {
120
- return currentBaseFeePerGas;
121
- }
122
- if (currentGasUsed > gasTarget) {
123
- const gasUsedDelta = currentGasUsed - gasTarget;
124
- const baseFeePerGasDelta = maxBigInt((currentBaseFeePerGas * gasUsedDelta) / gasTarget / 8n, 1n);
125
- return currentBaseFeePerGas + baseFeePerGasDelta;
126
- }
127
- const gasUsedDelta = currentGasUsed - gasTarget;
128
- const baseFeePerGasDelta = (currentBaseFeePerGas * gasUsedDelta) / gasTarget / 8n;
129
- return currentBaseFeePerGas - baseFeePerGasDelta;
130
- }
131
- async getLegacyTransactionGasPrice() {
132
- let gasPrice;
133
- try {
134
- const gasInfo = await this.publicClient.estimateFeesPerGas({
135
- chain: this.chain,
136
- type: "legacy"
137
- });
138
- gasPrice = gasInfo.gasPrice;
139
- }
140
- catch (e) {
141
- sentry.captureException(e);
142
- this.logger.error("failed to fetch legacy gasPrices from estimateFeesPerGas", { error: e });
143
- gasPrice = undefined;
144
- }
145
- if (gasPrice === undefined) {
146
- this.logger.warn("gasPrice is undefined, using fallback value");
147
- try {
148
- gasPrice = await this.publicClient.getGasPrice();
149
- }
150
- catch (e) {
151
- this.logger.error("failed to get fallback gasPrice");
152
- sentry.captureException(e);
153
- throw e;
154
- }
155
- }
156
- return {
157
- maxFeePerGas: gasPrice,
158
- maxPriorityFeePerGas: gasPrice
159
- };
160
- }
161
- async estimateGasPrice() {
162
- let maxFeePerGas;
163
- let maxPriorityFeePerGas;
164
- try {
165
- const fees = await this.publicClient.estimateFeesPerGas({
166
- chain: this.chain
167
- });
168
- maxFeePerGas = fees.maxFeePerGas;
169
- maxPriorityFeePerGas = fees.maxPriorityFeePerGas;
170
- }
171
- catch (e) {
172
- sentry.captureException(e);
173
- this.logger.error("failed to fetch eip-1559 gasPrices from estimateFeesPerGas", { error: e });
174
- maxFeePerGas = undefined;
175
- maxPriorityFeePerGas = undefined;
176
- }
177
- if (maxPriorityFeePerGas === undefined) {
178
- this.logger.warn("maxPriorityFeePerGas is undefined, using fallback value");
179
- try {
180
- maxPriorityFeePerGas =
181
- await this.getFallBackMaxPriorityFeePerGas(this.publicClient, maxFeePerGas ?? 0n);
182
- }
183
- catch (e) {
184
- this.logger.error("failed to get fallback maxPriorityFeePerGas");
185
- sentry.captureException(e);
186
- throw e;
187
- }
188
- }
189
- if (maxFeePerGas === undefined) {
190
- this.logger.warn("maxFeePerGas is undefined, using fallback value");
191
- try {
192
- maxFeePerGas =
193
- (await this.getNextBaseFee(this.publicClient)) +
194
- maxPriorityFeePerGas;
195
- }
196
- catch (e) {
197
- this.logger.error("failed to get fallback maxFeePerGas");
198
- sentry.captureException(e);
199
- throw e;
200
- }
201
- }
202
- if (maxPriorityFeePerGas === 0n) {
203
- maxPriorityFeePerGas = maxFeePerGas / 200n;
204
- }
205
- return { maxFeePerGas, maxPriorityFeePerGas };
206
- }
207
- saveBaseFeePerGas(gasPrice, timestamp) {
208
- const queue = this.queueBaseFeePerGas;
209
- const last = queue.length > 0 ? queue[queue.length - 1] : null;
210
- if (!last || timestamp - last.timestamp >= 1000) {
211
- if (queue.length >= this.maxQueueSize) {
212
- queue.shift();
213
- }
214
- queue.push({ baseFeePerGas: gasPrice, timestamp });
215
- }
216
- else if (gasPrice < last.baseFeePerGas) {
217
- last.baseFeePerGas = gasPrice;
218
- last.timestamp = timestamp;
219
- }
220
- }
221
- saveMaxFeePerGas(gasPrice, timestamp) {
222
- const queue = this.queueMaxFeePerGas;
223
- const last = queue.length > 0 ? queue[queue.length - 1] : null;
224
- if (!last || timestamp - last.timestamp >= 1000) {
225
- if (queue.length >= this.maxQueueSize) {
226
- queue.shift();
227
- }
228
- queue.push({ maxFeePerGas: gasPrice, timestamp });
229
- }
230
- else if (gasPrice < last.maxFeePerGas) {
231
- last.maxFeePerGas = gasPrice;
232
- last.timestamp = timestamp;
233
- }
234
- }
235
- saveMaxPriorityFeePerGas(gasPrice, timestamp) {
236
- const queue = this.queueMaxPriorityFeePerGas;
237
- const last = queue.length > 0 ? queue[queue.length - 1] : null;
238
- if (!last || timestamp - last.timestamp >= 1000) {
239
- if (queue.length >= this.maxQueueSize) {
240
- queue.shift();
241
- }
242
- queue.push({ maxPriorityFeePerGas: gasPrice, timestamp });
243
- }
244
- else if (gasPrice < last.maxPriorityFeePerGas) {
245
- last.maxPriorityFeePerGas = gasPrice;
246
- last.timestamp = timestamp;
247
- }
248
- }
249
- saveGasPrice(gasPrice, timestamp) {
250
- return new Promise((resolve) => {
251
- this.saveMaxFeePerGas(gasPrice.maxFeePerGas, timestamp);
252
- this.saveMaxPriorityFeePerGas(gasPrice.maxPriorityFeePerGas, timestamp);
253
- resolve();
254
- });
255
- }
256
- async innerGetGasPrice() {
257
- let maxFeePerGas = 0n;
258
- let maxPriorityFeePerGas = 0n;
259
- if (this.chain.id === chains.polygon.id ||
260
- this.chain.id === chains.polygonMumbai.id) {
261
- const polygonEstimate = await this.getPolygonGasPriceParameters();
262
- if (polygonEstimate) {
263
- const gasPrice = this.bumpTheGasPrice({
264
- maxFeePerGas: polygonEstimate.maxFeePerGas,
265
- maxPriorityFeePerGas: polygonEstimate.maxPriorityFeePerGas
266
- });
267
- return {
268
- maxFeePerGas: maxBigInt(gasPrice.maxFeePerGas, maxFeePerGas),
269
- maxPriorityFeePerGas: maxBigInt(gasPrice.maxPriorityFeePerGas, maxPriorityFeePerGas)
270
- };
271
- }
272
- }
273
- if (this.legacyTransactions) {
274
- const gasPrice = this.bumpTheGasPrice(await this.getLegacyTransactionGasPrice());
275
- return {
276
- maxFeePerGas: maxBigInt(gasPrice.maxFeePerGas, maxFeePerGas),
277
- maxPriorityFeePerGas: maxBigInt(gasPrice.maxPriorityFeePerGas, maxPriorityFeePerGas)
278
- };
279
- }
280
- const estimatedPrice = await this.estimateGasPrice();
281
- maxFeePerGas = estimatedPrice.maxFeePerGas;
282
- maxPriorityFeePerGas = estimatedPrice.maxPriorityFeePerGas;
283
- const gasPrice = this.bumpTheGasPrice({
284
- maxFeePerGas,
285
- maxPriorityFeePerGas
286
- });
287
- return {
288
- maxFeePerGas: maxBigInt(gasPrice.maxFeePerGas, maxFeePerGas),
289
- maxPriorityFeePerGas: maxBigInt(gasPrice.maxPriorityFeePerGas, maxPriorityFeePerGas)
290
- };
291
- }
292
- async getBaseFee() {
293
- const latestBlock = await this.publicClient.getBlock();
294
- if (latestBlock.baseFeePerGas === null) {
295
- throw new RpcError("block does not have baseFeePerGas");
296
- }
297
- const baseFee = latestBlock.baseFeePerGas;
298
- this.saveBaseFeePerGas(baseFee, Date.now());
299
- return baseFee;
300
- }
301
- async getGasPrice() {
302
- const gasPrice = await this.innerGetGasPrice();
303
- this.saveGasPrice({
304
- maxFeePerGas: gasPrice.maxFeePerGas,
305
- maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas
306
- }, Date.now());
307
- return gasPrice;
308
- }
309
- async getMaxBaseFeePerGas() {
310
- if (this.queueBaseFeePerGas.length === 0) {
311
- await this.getBaseFee();
312
- }
313
- return this.queueBaseFeePerGas.reduce((acc, cur) => maxBigInt(cur.baseFeePerGas, acc), this.queueBaseFeePerGas[0].baseFeePerGas);
314
- }
315
- async getMinMaxFeePerGas() {
316
- if (this.queueMaxFeePerGas.length === 0) {
317
- await this.getGasPrice();
318
- }
319
- return this.queueMaxFeePerGas.reduce((acc, cur) => minBigInt(cur.maxFeePerGas, acc), this.queueMaxFeePerGas[0].maxFeePerGas);
320
- }
321
- async getMinMaxPriorityFeePerGas() {
322
- if (this.queueMaxPriorityFeePerGas.length === 0) {
323
- await this.getGasPrice();
324
- }
325
- return this.queueMaxPriorityFeePerGas.reduce((acc, cur) => minBigInt(cur.maxPriorityFeePerGas, acc), this.queueMaxPriorityFeePerGas[0].maxPriorityFeePerGas);
326
- }
327
- async validateGasPrice(gasPrice) {
328
- const lowestMaxFeePerGas = await this.getMinMaxFeePerGas();
329
- const lowestMaxPriorityFeePerGas = await this.getMinMaxPriorityFeePerGas();
330
- if (gasPrice.maxFeePerGas < lowestMaxFeePerGas) {
331
- throw new RpcError(`maxFeePerGas must be at least ${lowestMaxFeePerGas} (current maxFeePerGas: ${gasPrice.maxFeePerGas}) - use pimlico_getUserOperationGasPrice to get the current gas price`);
332
- }
333
- if (gasPrice.maxPriorityFeePerGas < lowestMaxPriorityFeePerGas) {
334
- throw new RpcError(`maxPriorityFeePerGas must be at least ${lowestMaxPriorityFeePerGas} (current maxPriorityFeePerGas: ${gasPrice.maxPriorityFeePerGas}) - use pimlico_getUserOperationGasPrice to get the current gas price`);
335
- }
336
- }
337
- }
338
- //# sourceMappingURL=gasPriceManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gasPriceManager.js","sourceRoot":"","sources":["../../utils/gasPriceManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,gBAAgB,EAEnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAe,MAAM,aA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QAAQ,CAAC,YAAY,uEAAuE,CAC7K,CAAA;QACL,CAAC;QAED,IAAI,QAAQ,CAAC,oBAAoB,GAAG,0BAA0B,EAAE,CAAC;YAC7D,MAAM,IAAI,QAAQ,CACd,yCAAyC,0BAA0B,mCAAmC,QAAQ,CAAC,oBAAoB,uEAAuE,CAC7M,CAAA;QACL,CAAC;IACL,CAAC;CACJ"}
@@ -1,4 +0,0 @@
1
- import { type Address } from "viem";
2
- export declare const areAddressesEqual: (a: Address, b: Address) => boolean;
3
- export declare function getRevertErrorData(err: unknown): `0x${string}` | undefined;
4
- //# sourceMappingURL=helpers.d.ts.map
@@ -1,13 +0,0 @@
1
- import { getAddress, BaseError } from "viem";
2
- /// Ensure proper equality by converting both addresses into their checksum type
3
- export const areAddressesEqual = (a, b) => {
4
- return getAddress(a) === getAddress(b);
5
- };
6
- export function getRevertErrorData(err) {
7
- // biome-ignore lint/style/useBlockStatements:
8
- if (!(err instanceof BaseError))
9
- return undefined;
10
- const error = err.walk();
11
- return typeof error?.data === "object" ? error.data?.data : error.data;
12
- }
13
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,UAAU,EACV,SAAS,EAEZ,MAAM,MAAM,CAAA;AAEb,gFAAgF;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAU,EAAE,CAAU,EAAE,EAAE;IACxD,OAAO,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAA;AAC1C,CAAC,CAAA;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC3C,8CAA8C;IAC9C,IAAI,CAAC,CAAC,GAAG,YAAY,SAAS,CAAC;QAAE,OAAO,SAAS,CAAA;IACjD,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAsB,CAAA;IAC5C,OAAO,OAAO,KAAK,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA;AAC1E,CAAC"}
@@ -1,11 +0,0 @@
1
- export * from "./logger.js";
2
- export * from "./metrics.js";
3
- export * from "./bigInt.js";
4
- export * from "./gasPriceManager.js";
5
- export * from "./test.js";
6
- export * from "./validation.js";
7
- export * from "./userop.js";
8
- export * from "./compressionHandler.js";
9
- export * from "./helpers.js";
10
- export { Logger } from "pino";
11
- //# sourceMappingURL=index.d.ts.map
@@ -1,10 +0,0 @@
1
- export * from "./logger.js";
2
- export * from "./metrics.js";
3
- export * from "./bigInt.js";
4
- export * from "./gasPriceManager.js";
5
- export * from "./test.js";
6
- export * from "./validation.js";
7
- export * from "./userop.js";
8
- export * from "./compressionHandler.js";
9
- export * from "./helpers.js";
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA"}
@@ -1,6 +0,0 @@
1
- import type { Logger } from "./index.js";
2
- import { type SerializerFn } from "pino";
3
- export declare const customSerializer: SerializerFn;
4
- export declare const initDebugLogger: (level?: string) => Logger;
5
- export declare const initProductionLogger: (level: string) => Logger;
6
- //# sourceMappingURL=logger.d.ts.map
@@ -1,76 +0,0 @@
1
- import logger from "pino";
2
- import { toHex } from "viem";
3
- // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
4
- function bigintToJson(_key, value) {
5
- if (typeof value === "bigint") {
6
- return toHex(value);
7
- }
8
- return value;
9
- }
10
- function logLevel(label) {
11
- return {
12
- level: label
13
- };
14
- }
15
- function stringifyWithCircularHandling(obj,
16
- // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
17
- replacer) {
18
- // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
19
- const cache = new Set();
20
- return JSON.stringify(obj, (key, value) => {
21
- if (typeof value === "object" && value !== null) {
22
- if (cache.has(value)) {
23
- return; // Circular reference found, discard the key
24
- }
25
- cache.add(value);
26
- }
27
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
28
- return replacer ? replacer(key, value) : value;
29
- });
30
- }
31
- export const customSerializer = (input) => {
32
- const output = {};
33
- for (const key in input) {
34
- if (Object.prototype.hasOwnProperty.call(input, key)) {
35
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
36
- const value = input[key];
37
- if (typeof value === "object" && value !== null) {
38
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument
39
- output[key] = JSON.parse(stringifyWithCircularHandling(value, bigintToJson));
40
- }
41
- else {
42
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
43
- output[key] = bigintToJson(key, value);
44
- }
45
- }
46
- }
47
- return output;
48
- };
49
- export const initDebugLogger = (level = "debug") => {
50
- const l = logger({
51
- transport: {
52
- target: "pino-pretty",
53
- options: {
54
- colorize: true
55
- }
56
- },
57
- formatters: {
58
- level: logLevel,
59
- log: customSerializer
60
- }
61
- });
62
- l.level = level;
63
- return l;
64
- };
65
- export const initProductionLogger = (level) => {
66
- const l = logger({
67
- base: undefined, // do not log pid and hostname, we don't need it
68
- formatters: {
69
- level: logLevel,
70
- log: customSerializer
71
- }
72
- });
73
- l.level = level;
74
- return l;
75
- };
76
- //# sourceMappingURL=logger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../utils/logger.ts"],"names":[],"mappings":"AACA,OAAO,MAA6B,MAAM,MAAM,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,C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AQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC9C,0GAA0G;gBAC1G,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CACpB,6BAA6B,CAAC,KAAK,EAAE,YAAY,CAAC,CACrD,CAAA;YACL,CAAC;iBAAM,CAAC;gBACJ,mEAAmE;gBACnE,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YAC1C,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAK,GAAG,OAAO,EAAU,EAAE;IACvD,MAAM,CAAC,GAAG,MAAM,CAAC;QACb,SAAS,EAAE;YACP,MAAM,EAAE,aAAa;YACrB,OAAO,EAAE;gBACL,QAAQ,EAAE,IAAI;aACjB;SACJ;QACD,UAAU,EAAE;YACR,KAAK,EAAE,QAAQ;YACf,GAAG,EAAE,gBAAgB;SACxB;KACJ,CAAC,CAAA;IAEF,CAAC,CAAC,KAAK,GAAG,KAAK,CAAA;IAEf,OAAO,CAAC,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC1D,MAAM,CAAC,GAAG,MAAM,CAAC;QACb,IAAI,EAAE,SAAS,EAAE,gDAAgD;QACjE,UAAU,EAAE;YACR,KAAK,EAAE,QAAQ;YACf,GAAG,EAAE,gBAAgB;SACxB;KACJ,CAAC,CAAA;IACF,CAAC,CAAC,KAAK,GAAG,KAAK,CAAA;IACf,OAAO,CAAC,CAAA;AACZ,CAAC,CAAA"}
@@ -1,22 +0,0 @@
1
- import { Counter, Gauge, Histogram, type Registry } from "prom-client";
2
- export type Metrics = ReturnType<typeof createMetrics>;
3
- export declare function createMetrics(registry: Registry, register?: boolean): {
4
- httpRequests: Counter<"code" | "method" | "route" | "network" | "chainId" | "rpc_method" | "rpc_status">;
5
- httpRequestsDuration: Histogram<"code" | "method" | "route" | "network" | "chainId" | "rpc_method" | "rpc_status" | "api_version">;
6
- userOperationsInMempool: Gauge<"status" | "network" | "chainId">;
7
- walletsAvailable: Gauge<never>;
8
- walletsTotal: Gauge<never>;
9
- userOperationsOnChain: Counter<"status">;
10
- userOperationsSubmitted: Counter<"status">;
11
- bundlesIncluded: Counter<never>;
12
- bundlesSubmitted: Counter<"status">;
13
- userOperationsReceived: Counter<"type" | "status">;
14
- userOperationsValidationSuccess: Counter<never>;
15
- userOperationsValidationFailure: Counter<never>;
16
- userOperationInclusionDuration: Histogram<never>;
17
- verificationGasLimitEstimationTime: Histogram<never>;
18
- verificationGasLimitEstimationCount: Histogram<never>;
19
- replacedTransactions: Counter<"reason" | "status">;
20
- userOperationsResubmitted: Counter<never>;
21
- };
22
- //# sourceMappingURL=metrics.d.ts.map