@pimlico/alto 0.0.0-staging.20240606T095015 → 0.0.0-staging.20240606T101054

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 (149) hide show
  1. package/lib/cli/alto.d.ts +6 -0
  2. package/lib/cli/alto.js +123 -0
  3. package/lib/cli/alto.js.map +1 -0
  4. package/lib/cli/config/bundler.js +76 -73
  5. package/lib/cli/config/bundler.js.map +1 -1
  6. package/lib/cli/config/index.js +18 -2
  7. package/lib/cli/config/index.js.map +1 -1
  8. package/lib/cli/config/options.js +13 -10
  9. package/lib/cli/config/options.js.map +1 -1
  10. package/lib/cli/customTransport.js +11 -7
  11. package/lib/cli/customTransport.js.map +1 -1
  12. package/lib/cli/handler.js +28 -24
  13. package/lib/cli/handler.js.map +1 -1
  14. package/lib/cli/index.d.ts +1 -0
  15. package/lib/cli/index.js +19 -2
  16. package/lib/cli/index.js.map +1 -1
  17. package/lib/cli/instrumentation.js +22 -20
  18. package/lib/cli/instrumentation.js.map +1 -1
  19. package/lib/cli/setupServer.js +21 -17
  20. package/lib/cli/setupServer.js.map +1 -1
  21. package/lib/cli/util.js +5 -1
  22. package/lib/cli/util.js.map +1 -1
  23. package/lib/executor/executor.js +84 -56
  24. package/lib/executor/executor.js.map +1 -1
  25. package/lib/executor/executorManager.js +11 -7
  26. package/lib/executor/executorManager.js.map +1 -1
  27. package/lib/executor/index.js +20 -4
  28. package/lib/executor/index.js.map +1 -1
  29. package/lib/executor/senderManager.js +12 -8
  30. package/lib/executor/senderManager.js.map +1 -1
  31. package/lib/executor/test/utils.js +28 -22
  32. package/lib/executor/test/utils.js.map +1 -1
  33. package/lib/executor/utils.js +61 -31
  34. package/lib/executor/utils.js.map +1 -1
  35. package/lib/index.d.ts +1 -5
  36. package/lib/index.js +3 -91
  37. package/lib/index.js.map +1 -1
  38. package/lib/mempool/index.js +20 -4
  39. package/lib/mempool/index.js.map +1 -1
  40. package/lib/mempool/mempool.js +59 -55
  41. package/lib/mempool/mempool.js.map +1 -1
  42. package/lib/mempool/monitoring.js +5 -1
  43. package/lib/mempool/monitoring.js.map +1 -1
  44. package/lib/mempool/nullMempool.js +5 -1
  45. package/lib/mempool/nullMempool.js.map +1 -1
  46. package/lib/mempool/reputationManager.js +49 -44
  47. package/lib/mempool/reputationManager.js.map +1 -1
  48. package/lib/mempool/store.js +5 -1
  49. package/lib/mempool/store.js.map +1 -1
  50. package/lib/rpc/EntryPointSimulationsV07.js +50 -44
  51. package/lib/rpc/EntryPointSimulationsV07.js.map +1 -1
  52. package/lib/rpc/ExecuteSimulator.js +5 -2
  53. package/lib/rpc/ExecuteSimulator.js.map +1 -1
  54. package/lib/rpc/gasEstimation.js +69 -62
  55. package/lib/rpc/gasEstimation.js.map +1 -1
  56. package/lib/rpc/index.js +20 -4
  57. package/lib/rpc/index.js.map +1 -1
  58. package/lib/rpc/nonceQueuer.js +20 -16
  59. package/lib/rpc/nonceQueuer.js.map +1 -1
  60. package/lib/rpc/rpcHandler.js +103 -76
  61. package/lib/rpc/rpcHandler.js.map +1 -1
  62. package/lib/rpc/server.js +56 -26
  63. package/lib/rpc/server.js.map +1 -1
  64. package/lib/rpc/validation/BundlerCollectorTracerV06.js +5 -1
  65. package/lib/rpc/validation/BundlerCollectorTracerV06.js.map +1 -1
  66. package/lib/rpc/validation/BundlerCollectorTracerV07.js +5 -1
  67. package/lib/rpc/validation/BundlerCollectorTracerV07.js.map +1 -1
  68. package/lib/rpc/validation/SafeValidator.js +69 -65
  69. package/lib/rpc/validation/SafeValidator.js.map +1 -1
  70. package/lib/rpc/validation/TracerResultParserV06.js +30 -26
  71. package/lib/rpc/validation/TracerResultParserV06.js.map +1 -1
  72. package/lib/rpc/validation/TracerResultParserV07.js +36 -29
  73. package/lib/rpc/validation/TracerResultParserV07.js.map +1 -1
  74. package/lib/rpc/validation/UnsafeValidator.js +73 -46
  75. package/lib/rpc/validation/UnsafeValidator.js.map +1 -1
  76. package/lib/rpc/validation/index.js +18 -2
  77. package/lib/rpc/validation/index.js.map +1 -1
  78. package/lib/rpc/validation/tracer.js +37 -7
  79. package/lib/rpc/validation/tracer.js.map +1 -1
  80. package/lib/types/contracts/BundleBulker.js +4 -1
  81. package/lib/types/contracts/BundleBulker.js.map +1 -1
  82. package/lib/types/contracts/CallEngine.js +4 -1
  83. package/lib/types/contracts/CallEngine.js.map +1 -1
  84. package/lib/types/contracts/CodeHashGetter.js +5 -2
  85. package/lib/types/contracts/CodeHashGetter.js.map +1 -1
  86. package/lib/types/contracts/EntryPoint.js +7 -4
  87. package/lib/types/contracts/EntryPoint.js.map +1 -1
  88. package/lib/types/contracts/EntryPointSimulations.js +6 -3
  89. package/lib/types/contracts/EntryPointSimulations.js.map +1 -1
  90. package/lib/types/contracts/IOpInflator.js +4 -1
  91. package/lib/types/contracts/IOpInflator.js.map +1 -1
  92. package/lib/types/contracts/IPaymaster.js +4 -1
  93. package/lib/types/contracts/IPaymaster.js.map +1 -1
  94. package/lib/types/contracts/Inflator.js +4 -1
  95. package/lib/types/contracts/Inflator.js.map +1 -1
  96. package/lib/types/contracts/PerOpInflator.js +4 -1
  97. package/lib/types/contracts/PerOpInflator.js.map +1 -1
  98. package/lib/types/contracts/PimlicoEntryPointSimulations.js +5 -2
  99. package/lib/types/contracts/PimlicoEntryPointSimulations.js.map +1 -1
  100. package/lib/types/contracts/SenderCreator.js +5 -2
  101. package/lib/types/contracts/SenderCreator.js.map +1 -1
  102. package/lib/types/contracts/SimpleAccountFactory.js +5 -2
  103. package/lib/types/contracts/SimpleAccountFactory.js.map +1 -1
  104. package/lib/types/contracts/TestOpcodesAccount.js +5 -2
  105. package/lib/types/contracts/TestOpcodesAccount.js.map +1 -1
  106. package/lib/types/contracts/TestOpcodesAccountFactory.js +5 -2
  107. package/lib/types/contracts/TestOpcodesAccountFactory.js.map +1 -1
  108. package/lib/types/contracts/TestStorageAccount.js +5 -2
  109. package/lib/types/contracts/TestStorageAccount.js.map +1 -1
  110. package/lib/types/contracts/index.js +32 -16
  111. package/lib/types/contracts/index.js.map +1 -1
  112. package/lib/types/gasPrice.js +17 -14
  113. package/lib/types/gasPrice.js.map +1 -1
  114. package/lib/types/index.js +26 -10
  115. package/lib/types/index.js.map +1 -1
  116. package/lib/types/interfaces.js +2 -1
  117. package/lib/types/mempool.js +10 -5
  118. package/lib/types/mempool.js.map +1 -1
  119. package/lib/types/schemas.js +284 -254
  120. package/lib/types/schemas.js.map +1 -1
  121. package/lib/types/test/validationTestErrors.js +5 -2
  122. package/lib/types/test/validationTestErrors.js.map +1 -1
  123. package/lib/types/utils.js +9 -5
  124. package/lib/types/utils.js.map +1 -1
  125. package/lib/types/validation.js +142 -139
  126. package/lib/types/validation.js.map +1 -1
  127. package/lib/utils/bigInt.js +7 -2
  128. package/lib/utils/bigInt.js.map +1 -1
  129. package/lib/utils/compressionHandler.js +11 -7
  130. package/lib/utils/compressionHandler.js.map +1 -1
  131. package/lib/utils/gasPriceManager.js +57 -30
  132. package/lib/utils/gasPriceManager.js.map +1 -1
  133. package/lib/utils/helpers.js +10 -5
  134. package/lib/utils/helpers.js.map +1 -1
  135. package/lib/utils/index.js +25 -9
  136. package/lib/utils/index.js.map +1 -1
  137. package/lib/utils/logger.js +19 -10
  138. package/lib/utils/logger.js.map +1 -1
  139. package/lib/utils/metrics.js +24 -20
  140. package/lib/utils/metrics.js.map +1 -1
  141. package/lib/utils/rpc-reply.js +3 -1
  142. package/lib/utils/rpc-reply.js.map +1 -1
  143. package/lib/utils/test.js +67 -36
  144. package/lib/utils/test.js.map +1 -1
  145. package/lib/utils/userop.js +107 -62
  146. package/lib/utils/userop.js.map +1 -1
  147. package/lib/utils/validation.js +99 -64
  148. package/lib/utils/validation.js.map +1 -1
  149. package/package.json +5 -6
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../rpc/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../rpc/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,2CAAwB;AACxB,+CAA4B;AAC5B,gDAA6B"}
@@ -1,7 +1,10 @@
1
- import { EntryPointV06Abi, deriveUserOperation, EntryPointV07Abi } from "../types/index.js";
2
- import { getNonceKeyAndValue, getUserOperationHash, isVersion06 } from "../utils/index.js";
3
- import { getContract } from "viem";
4
- export class NonceQueuer {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NonceQueuer = void 0;
4
+ const types_1 = require("../types/index.js");
5
+ const utils_1 = require("../utils/index.js");
6
+ const viem_1 = require("viem");
7
+ class NonceQueuer {
5
8
  queuedUserOperations = [];
6
9
  mempool;
7
10
  publicClient;
@@ -37,11 +40,11 @@ export class NonceQueuer {
37
40
  this.logger.info({ availableOps: availableOps.map((qop) => qop.userOperationHash) }, "submitted user operations from nonce queue");
38
41
  }
39
42
  add(mempoolUserOperation, entryPoint) {
40
- const userOperation = deriveUserOperation(mempoolUserOperation);
41
- const [nonceKey, nonceValue] = getNonceKeyAndValue(userOperation.nonce);
43
+ const userOperation = (0, types_1.deriveUserOperation)(mempoolUserOperation);
44
+ const [nonceKey, nonceValue] = (0, utils_1.getNonceKeyAndValue)(userOperation.nonce);
42
45
  this.queuedUserOperations.push({
43
46
  entryPoint,
44
- userOperationHash: getUserOperationHash(deriveUserOperation(mempoolUserOperation), entryPoint, this.publicClient.chain.id),
47
+ userOperationHash: (0, utils_1.getUserOperationHash)((0, types_1.deriveUserOperation)(mempoolUserOperation), entryPoint, this.publicClient.chain.id),
45
48
  mempoolUserOperation: mempoolUserOperation,
46
49
  nonceKey: nonceKey,
47
50
  nonceValue: nonceValue,
@@ -65,11 +68,11 @@ export class NonceQueuer {
65
68
  try {
66
69
  results = await publicClient.multicall({
67
70
  contracts: queuedUserOperations.map((qop) => {
68
- const userOperation = deriveUserOperation(qop.mempoolUserOperation);
69
- const isUserOpV06 = isVersion06(userOperation);
71
+ const userOperation = (0, types_1.deriveUserOperation)(qop.mempoolUserOperation);
72
+ const isUserOpV06 = (0, utils_1.isVersion06)(userOperation);
70
73
  return {
71
74
  address: qop.entryPoint,
72
- abi: isUserOpV06 ? EntryPointV06Abi : EntryPointV07Abi,
75
+ abi: isUserOpV06 ? types_1.EntryPointV06Abi : types_1.EntryPointV07Abi,
73
76
  functionName: "getNonce",
74
77
  args: [userOperation.sender, qop.nonceKey]
75
78
  };
@@ -80,19 +83,19 @@ export class NonceQueuer {
80
83
  catch (error) {
81
84
  this.logger.error({ error: JSON.stringify(error) }, "error fetching with multiCall");
82
85
  results = await Promise.all(queuedUserOperations.map(async (qop) => {
83
- const userOperation = deriveUserOperation(qop.mempoolUserOperation);
86
+ const userOperation = (0, types_1.deriveUserOperation)(qop.mempoolUserOperation);
84
87
  try {
85
- const isUserOpV06 = isVersion06(userOperation);
88
+ const isUserOpV06 = (0, utils_1.isVersion06)(userOperation);
86
89
  const entryPointContract = isUserOpV06
87
- ? getContract({
88
- abi: EntryPointV06Abi,
90
+ ? (0, viem_1.getContract)({
91
+ abi: types_1.EntryPointV06Abi,
89
92
  address: qop.entryPoint,
90
93
  client: {
91
94
  public: publicClient
92
95
  }
93
96
  })
94
- : getContract({
95
- abi: EntryPointV07Abi,
97
+ : (0, viem_1.getContract)({
98
+ abi: types_1.EntryPointV07Abi,
96
99
  address: qop.entryPoint,
97
100
  client: {
98
101
  public: publicClient
@@ -132,4 +135,5 @@ export class NonceQueuer {
132
135
  return currentOutstandingOps;
133
136
  }
134
137
  }
138
+ exports.NonceQueuer = NonceQueuer;
135
139
  //# sourceMappingURL=nonceQueuer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nonceQueuer.js","sourceRoot":"","sources":["../../rpc/nonceQueuer.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAEhB,mBAAmB,E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, EntryPointV07Abi, IOpInflatorAbi, RpcError, ValidationErrors, bundlerGetStakeStatusResponseSchema, deriveUserOperation, logSchema, receiptSchema } from "../types/index.js";
2
- import { calcPreVerificationGas, calcVerificationGasAndCallGasLimit, getNonceKeyAndValue, getUserOperationHash, isVersion06, isVersion07, maxBigInt, toUnpackedUserOperation } from "../utils/index.js";
3
- import { TransactionNotFoundError, TransactionReceiptNotFoundError, decodeFunctionData, getAbiItem, getAddress, getContract, encodeEventTopics, zeroAddress, decodeEventLog, parseAbi } from "viem";
4
- import * as chains from "viem/chains";
5
- import { z } from "zod";
6
- import { fromZodError } from "zod-validation-error";
7
- export class RpcHandler {
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.RpcHandler = void 0;
27
+ const types_1 = require("../types/index.js");
28
+ const utils_1 = require("../utils/index.js");
29
+ const viem_1 = require("viem");
30
+ const chains = __importStar(require("viem/chains"));
31
+ const zod_1 = require("zod");
32
+ const zod_validation_error_1 = require("zod-validation-error");
33
+ class RpcHandler {
8
34
  entryPoints;
9
35
  publicClient;
10
36
  validator;
@@ -155,9 +181,9 @@ export class RpcHandler {
155
181
  throw new Error(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
156
182
  }
157
183
  if (userOperation.maxFeePerGas === 0n) {
158
- throw new RpcError("user operation max fee per gas must be larger than 0 during gas estimation");
184
+ throw new types_1.RpcError("user operation max fee per gas must be larger than 0 during gas estimation");
159
185
  }
160
- const preVerificationGas = ((await calcPreVerificationGas(this.publicClient, userOperation, entryPoint, this.chainId, this.chainType, this.gasPriceManager, false)) *
186
+ const preVerificationGas = ((await (0, utils_1.calcPreVerificationGas)(this.publicClient, userOperation, entryPoint, this.chainId, this.chainType, this.gasPriceManager, false)) *
161
187
  110n) /
162
188
  100n;
163
189
  userOperation.preVerificationGas = 1000000n;
@@ -171,7 +197,7 @@ export class RpcHandler {
171
197
  userOperation.verificationGasLimit = 1000000n;
172
198
  userOperation.callGasLimit = 1000000n;
173
199
  }
174
- if (isVersion07(userOperation)) {
200
+ if ((0, utils_1.isVersion07)(userOperation)) {
175
201
  userOperation.paymasterPostOpGasLimit = 2000000n;
176
202
  userOperation.paymasterVerificationGasLimit = 5000000n;
177
203
  }
@@ -184,27 +210,27 @@ export class RpcHandler {
184
210
  // If the nonce is less than the current nonce, the user operation has already been executed
185
211
  // If the nonce is greater than the current nonce, we may have missing user operations in the mempool
186
212
  const currentNonceValue = await this.getNonceValue(userOperation, entryPoint);
187
- const [, userOperationNonceValue] = getNonceKeyAndValue(userOperation.nonce);
213
+ const [, userOperationNonceValue] = (0, utils_1.getNonceKeyAndValue)(userOperation.nonce);
188
214
  let queuedUserOperations = [];
189
215
  if (userOperationNonceValue < currentNonceValue) {
190
- throw new RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", ValidationErrors.InvalidFields);
216
+ throw new types_1.RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", types_1.ValidationErrors.InvalidFields);
191
217
  }
192
218
  if (userOperationNonceValue > currentNonceValue) {
193
219
  // Nonce queues are supported only for v7 user operations
194
- if (isVersion06(userOperation)) {
195
- throw new RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", ValidationErrors.InvalidFields);
220
+ if ((0, utils_1.isVersion06)(userOperation)) {
221
+ throw new types_1.RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", types_1.ValidationErrors.InvalidFields);
196
222
  }
197
223
  queuedUserOperations = await this.mempool.getQueuedUserOperations(userOperation, entryPoint, currentNonceValue);
198
224
  if (userOperationNonceValue >
199
225
  currentNonceValue + BigInt(queuedUserOperations.length)) {
200
- throw new RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", ValidationErrors.InvalidFields);
226
+ throw new types_1.RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", types_1.ValidationErrors.InvalidFields);
201
227
  }
202
228
  }
203
229
  const executionResult = await this.validator.getExecutionResult(userOperation, entryPoint, queuedUserOperations, stateOverrides);
204
- let { verificationGasLimit, callGasLimit } = calcVerificationGasAndCallGasLimit(userOperation, executionResult.data.executionResult, this.chainId, executionResult.data.callDataResult);
230
+ let { verificationGasLimit, callGasLimit } = (0, utils_1.calcVerificationGasAndCallGasLimit)(userOperation, executionResult.data.executionResult, this.chainId, executionResult.data.callDataResult);
205
231
  let paymasterVerificationGasLimit = 0n;
206
232
  let paymasterPostOpGasLimit = 0n;
207
- if (isVersion07(userOperation) &&
233
+ if ((0, utils_1.isVersion07)(userOperation) &&
208
234
  userOperation.paymaster !== null &&
209
235
  "paymasterVerificationGasLimit" in
210
236
  executionResult.data.executionResult &&
@@ -227,12 +253,12 @@ export class RpcHandler {
227
253
  }
228
254
  if (this.chainId === chains.base.id ||
229
255
  this.chainId === chains.optimism.id) {
230
- callGasLimit = maxBigInt(callGasLimit, 120000n);
256
+ callGasLimit = (0, utils_1.maxBigInt)(callGasLimit, 120000n);
231
257
  }
232
258
  if (userOperation.callData === "0x") {
233
259
  callGasLimit = 0n;
234
260
  }
235
- if (isVersion07(userOperation)) {
261
+ if ((0, utils_1.isVersion07)(userOperation)) {
236
262
  return {
237
263
  preVerificationGas,
238
264
  verificationGasLimit,
@@ -259,7 +285,7 @@ export class RpcHandler {
259
285
  let status = "rejected";
260
286
  try {
261
287
  status = await this.addToMempoolIfValid(userOperation, entryPoint, apiVersion);
262
- const hash = getUserOperationHash(userOperation, entryPoint, this.chainId);
288
+ const hash = (0, utils_1.getUserOperationHash)(userOperation, entryPoint, this.chainId);
263
289
  return hash;
264
290
  }
265
291
  catch (error) {
@@ -276,8 +302,8 @@ export class RpcHandler {
276
302
  }
277
303
  }
278
304
  async eth_getUserOperationByHash(userOperationHash) {
279
- const userOperationEventAbiItem = getAbiItem({
280
- abi: EntryPointV06Abi,
305
+ const userOperationEventAbiItem = (0, viem_1.getAbiItem)({
306
+ abi: types_1.EntryPointV06Abi,
281
307
  name: "UserOperationEvent"
282
308
  });
283
309
  let fromBlock = undefined;
@@ -313,7 +339,7 @@ export class RpcHandler {
313
339
  return await this.publicClient.getTransaction({ hash: txHash });
314
340
  }
315
341
  catch (e) {
316
- if (e instanceof TransactionNotFoundError) {
342
+ if (e instanceof viem_1.TransactionNotFoundError) {
317
343
  return getTransaction(txHash);
318
344
  }
319
345
  throw e;
@@ -325,8 +351,8 @@ export class RpcHandler {
325
351
  }
326
352
  let op = undefined;
327
353
  try {
328
- const decoded = decodeFunctionData({
329
- abi: EntryPointV06Abi,
354
+ const decoded = (0, viem_1.decodeFunctionData)({
355
+ abi: types_1.EntryPointV06Abi,
330
356
  data: tx.input
331
357
  });
332
358
  if (decoded.functionName !== "handleOps") {
@@ -343,8 +369,8 @@ export class RpcHandler {
343
369
  return null;
344
370
  }
345
371
  const result = {
346
- userOperation: isVersion06(op) ? op : toUnpackedUserOperation(op),
347
- entryPoint: getAddress(tx.to),
372
+ userOperation: (0, utils_1.isVersion06)(op) ? op : (0, utils_1.toUnpackedUserOperation)(op),
373
+ entryPoint: (0, viem_1.getAddress)(tx.to),
348
374
  transactionHash: txHash,
349
375
  blockHash: tx.blockHash ?? "0x",
350
376
  blockNumber: BigInt(tx.blockNumber ?? 0n)
@@ -352,8 +378,8 @@ export class RpcHandler {
352
378
  return result;
353
379
  }
354
380
  async eth_getUserOperationReceipt(userOperationHash) {
355
- const userOperationEventAbiItem = getAbiItem({
356
- abi: EntryPointV06Abi,
381
+ const userOperationEventAbiItem = (0, viem_1.getAbiItem)({
382
+ abi: types_1.EntryPointV06Abi,
357
383
  name: "UserOperationEvent"
358
384
  });
359
385
  let fromBlock = undefined;
@@ -402,7 +428,7 @@ export class RpcHandler {
402
428
  });
403
429
  }
404
430
  catch (e) {
405
- if (e instanceof TransactionReceiptNotFoundError) {
431
+ if (e instanceof viem_1.TransactionReceiptNotFoundError) {
406
432
  continue;
407
433
  }
408
434
  throw e;
@@ -420,13 +446,13 @@ export class RpcHandler {
420
446
  // transaction pending
421
447
  return null;
422
448
  }
423
- const userOperationRevertReasonAbi = parseAbi([
449
+ const userOperationRevertReasonAbi = (0, viem_1.parseAbi)([
424
450
  "event UserOperationRevertReason(bytes32 indexed userOpHash, address indexed sender, uint256 nonce, bytes revertReason)"
425
451
  ]);
426
- const userOperationRevertReasonTopicEvent = encodeEventTopics({
452
+ const userOperationRevertReasonTopicEvent = (0, viem_1.encodeEventTopics)({
427
453
  abi: userOperationRevertReasonAbi
428
454
  })[0];
429
- let entryPoint = zeroAddress;
455
+ let entryPoint = viem_1.zeroAddress;
430
456
  let revertReason = undefined;
431
457
  let startIndex = -1;
432
458
  let endIndex = -1;
@@ -447,7 +473,7 @@ export class RpcHandler {
447
473
  // process UserOperationRevertReason
448
474
  if (log.topics[1] === userOperationEvent.topics[1]) {
449
475
  // it's our userOpHash. capture revert reason.
450
- const decodedLog = decodeEventLog({
476
+ const decodedLog = (0, viem_1.decodeEventLog)({
451
477
  abi: userOperationRevertReasonAbi,
452
478
  data: log.data,
453
479
  topics: log.topics
@@ -460,21 +486,21 @@ export class RpcHandler {
460
486
  throw new Error("fatal: no UserOperationEvent in logs");
461
487
  }
462
488
  const filteredLogs = logs.slice(startIndex + 1, endIndex);
463
- const logsParsing = z.array(logSchema).safeParse(filteredLogs);
489
+ const logsParsing = zod_1.z.array(types_1.logSchema).safeParse(filteredLogs);
464
490
  if (!logsParsing.success) {
465
- const err = fromZodError(logsParsing.error);
491
+ const err = (0, zod_validation_error_1.fromZodError)(logsParsing.error);
466
492
  throw err;
467
493
  }
468
- const receiptParsing = receiptSchema.safeParse({
494
+ const receiptParsing = types_1.receiptSchema.safeParse({
469
495
  ...receipt,
470
496
  status: receipt.status === "success" ? 1 : 0
471
497
  });
472
498
  if (!receiptParsing.success) {
473
- const err = fromZodError(receiptParsing.error);
499
+ const err = (0, zod_validation_error_1.fromZodError)(receiptParsing.error);
474
500
  throw err;
475
501
  }
476
502
  let paymaster = userOperationEvent.args.paymaster;
477
- paymaster = paymaster === zeroAddress ? undefined : paymaster;
503
+ paymaster = paymaster === viem_1.zeroAddress ? undefined : paymaster;
478
504
  const userOperationReceipt = {
479
505
  userOpHash: userOperationHash,
480
506
  entryPoint,
@@ -492,7 +518,7 @@ export class RpcHandler {
492
518
  }
493
519
  debug_bundler_clearState() {
494
520
  if (!this.enableDebugEndpoints) {
495
- throw new RpcError("debug_bundler_clearState is only available in development environment");
521
+ throw new types_1.RpcError("debug_bundler_clearState is only available in development environment");
496
522
  }
497
523
  this.mempool.clear();
498
524
  this.reputationManager.clear();
@@ -500,7 +526,7 @@ export class RpcHandler {
500
526
  }
501
527
  debug_bundler_clearMempool() {
502
528
  if (!this.enableDebugEndpoints) {
503
- throw new RpcError("debug_bundler_clearMempool is only available in development environment");
529
+ throw new types_1.RpcError("debug_bundler_clearMempool is only available in development environment");
504
530
  }
505
531
  this.mempool.clear();
506
532
  this.reputationManager.clearEntityCount();
@@ -508,53 +534,53 @@ export class RpcHandler {
508
534
  }
509
535
  async debug_bundler_dumpMempool(entryPoint) {
510
536
  if (!this.enableDebugEndpoints) {
511
- throw new RpcError("debug_bundler_dumpMempool is only available in development environment");
537
+ throw new types_1.RpcError("debug_bundler_dumpMempool is only available in development environment");
512
538
  }
513
539
  if (!this.entryPoints.includes(entryPoint)) {
514
- throw new RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
540
+ throw new types_1.RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
515
541
  }
516
542
  return this.mempool
517
543
  .dumpOutstanding()
518
- .map((userOpInfo) => deriveUserOperation(userOpInfo.mempoolUserOperation));
544
+ .map((userOpInfo) => (0, types_1.deriveUserOperation)(userOpInfo.mempoolUserOperation));
519
545
  }
520
546
  async debug_bundler_sendBundleNow() {
521
547
  if (!this.enableDebugEndpoints) {
522
- throw new RpcError("debug_bundler_sendBundleNow is only available in development environment");
548
+ throw new types_1.RpcError("debug_bundler_sendBundleNow is only available in development environment");
523
549
  }
524
550
  const transactions = await this.executorManager.bundleNow();
525
551
  return transactions[0];
526
552
  }
527
553
  debug_bundler_setBundlingMode(bundlingMode) {
528
554
  if (!this.enableDebugEndpoints) {
529
- throw new RpcError("debug_bundler_setBundlingMode is only available in development environment");
555
+ throw new types_1.RpcError("debug_bundler_setBundlingMode is only available in development environment");
530
556
  }
531
557
  this.executorManager.setBundlingMode(bundlingMode);
532
558
  return "ok";
533
559
  }
534
560
  debug_bundler_dumpReputation(entryPoint) {
535
561
  if (!this.enableDebugEndpoints) {
536
- throw new RpcError("debug_bundler_setRe is only available in development environment");
562
+ throw new types_1.RpcError("debug_bundler_setRe is only available in development environment");
537
563
  }
538
564
  if (!this.entryPoints.includes(entryPoint)) {
539
- throw new RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
565
+ throw new types_1.RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
540
566
  }
541
567
  return this.reputationManager.dumpReputations(entryPoint);
542
568
  }
543
569
  async debug_bundler_getStakeStatus(address, entryPoint) {
544
570
  if (!this.enableDebugEndpoints) {
545
- throw new RpcError("debug_bundler_getStakeStatus is only available in development environment");
571
+ throw new types_1.RpcError("debug_bundler_getStakeStatus is only available in development environment");
546
572
  }
547
573
  if (!this.entryPoints.includes(entryPoint)) {
548
- throw new RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
574
+ throw new types_1.RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
549
575
  }
550
- return bundlerGetStakeStatusResponseSchema.parse({
576
+ return types_1.bundlerGetStakeStatusResponseSchema.parse({
551
577
  method: "debug_bundler_getStakeStatus",
552
578
  result: await this.reputationManager.getStakeStatus(entryPoint, address)
553
579
  }).result;
554
580
  }
555
581
  debug_bundler_setReputation(args) {
556
582
  if (!this.enableDebugEndpoints) {
557
- throw new RpcError("debug_bundler_setReputation is only available in development environment");
583
+ throw new types_1.RpcError("debug_bundler_setReputation is only available in development environment");
558
584
  }
559
585
  this.reputationManager.setReputation(args[1], args[0]);
560
586
  return "ok";
@@ -582,15 +608,15 @@ export class RpcHandler {
582
608
  }
583
609
  // check if we want to bundle userOperation. If yes, add to mempool
584
610
  async addToMempoolIfValid(op, entryPoint, apiVersion) {
585
- const userOperation = deriveUserOperation(op);
611
+ const userOperation = (0, types_1.deriveUserOperation)(op);
586
612
  if (!this.entryPoints.includes(entryPoint)) {
587
- throw new RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
613
+ throw new types_1.RpcError(`EntryPoint ${entryPoint} not supported, supported EntryPoints: ${this.entryPoints.join(", ")}`);
588
614
  }
589
615
  if (this.chainId === chains.celoAlfajores.id ||
590
616
  this.chainId === chains.celo.id) {
591
617
  if (userOperation.maxFeePerGas !==
592
618
  userOperation.maxPriorityFeePerGas) {
593
- throw new RpcError("maxPriorityFeePerGas must equal maxFeePerGas on Celo chains");
619
+ throw new types_1.RpcError("maxPriorityFeePerGas must equal maxFeePerGas on Celo chains");
594
620
  }
595
621
  }
596
622
  if (apiVersion !== "v1") {
@@ -600,24 +626,24 @@ export class RpcHandler {
600
626
  });
601
627
  }
602
628
  if (userOperation.verificationGasLimit < 10000n) {
603
- throw new RpcError("verificationGasLimit must be at least 10000");
629
+ throw new types_1.RpcError("verificationGasLimit must be at least 10000");
604
630
  }
605
631
  this.logger.trace({ userOperation, entryPoint }, "beginning validation");
606
632
  if (userOperation.preVerificationGas === 0n ||
607
633
  userOperation.verificationGasLimit === 0n) {
608
- throw new RpcError("user operation gas limits must be larger than 0");
634
+ throw new types_1.RpcError("user operation gas limits must be larger than 0");
609
635
  }
610
636
  const currentNonceValue = await this.getNonceValue(userOperation, entryPoint);
611
- const [, userOperationNonceValue] = getNonceKeyAndValue(userOperation.nonce);
637
+ const [, userOperationNonceValue] = (0, utils_1.getNonceKeyAndValue)(userOperation.nonce);
612
638
  if (userOperationNonceValue < currentNonceValue) {
613
- throw new RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", ValidationErrors.InvalidFields);
639
+ throw new types_1.RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", types_1.ValidationErrors.InvalidFields);
614
640
  }
615
641
  if (userOperationNonceValue > currentNonceValue + 10n) {
616
- throw new RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", ValidationErrors.InvalidFields);
642
+ throw new types_1.RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", types_1.ValidationErrors.InvalidFields);
617
643
  }
618
644
  let queuedUserOperations = [];
619
645
  if (userOperationNonceValue > currentNonceValue &&
620
- isVersion07(userOperation)) {
646
+ (0, utils_1.isVersion07)(userOperation)) {
621
647
  queuedUserOperations = await this.mempool.getQueuedUserOperations(userOperation, entryPoint, currentNonceValue);
622
648
  }
623
649
  if (userOperationNonceValue ===
@@ -625,7 +651,7 @@ export class RpcHandler {
625
651
  if (this.dangerousSkipUserOperationValidation) {
626
652
  const success = this.mempool.add(op, entryPoint);
627
653
  if (!success) {
628
- throw new RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", ValidationErrors.InvalidFields);
654
+ throw new types_1.RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", types_1.ValidationErrors.InvalidFields);
629
655
  }
630
656
  }
631
657
  else {
@@ -637,7 +663,7 @@ export class RpcHandler {
637
663
  await this.mempool.checkEntityMultipleRoleViolation(userOperation);
638
664
  const success = this.mempool.add(op, entryPoint, validationResult.referencedContracts);
639
665
  if (!success) {
640
- throw new RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", ValidationErrors.InvalidFields);
666
+ throw new types_1.RpcError("UserOperation reverted during simulation with reason: AA25 invalid account nonce", types_1.ValidationErrors.InvalidFields);
641
667
  }
642
668
  return "added";
643
669
  }
@@ -657,7 +683,7 @@ export class RpcHandler {
657
683
  };
658
684
  // check userOps inputs.
659
685
  status = await this.addToMempoolIfValid(compressedUserOp, entryPoint, apiVersion);
660
- const hash = getUserOperationHash(inflatedOp, entryPoint, this.chainId);
686
+ const hash = (0, utils_1.getUserOperationHash)(inflatedOp, entryPoint, this.chainId);
661
687
  return hash;
662
688
  }
663
689
  catch (error) {
@@ -676,16 +702,16 @@ export class RpcHandler {
676
702
  async validateAndInflateCompressedUserOperation(inflatorAddress, compressedCalldata) {
677
703
  // check if inflator is registered with our PerOpInflator.
678
704
  if (this.compressionHandler === null) {
679
- throw new RpcError("Endpoint not supported");
705
+ throw new types_1.RpcError("Endpoint not supported");
680
706
  }
681
707
  const inflatorId = await this.compressionHandler.getInflatorRegisteredId(inflatorAddress, this.publicClient);
682
708
  if (inflatorId === 0) {
683
- throw new RpcError(`Inflator ${inflatorAddress} is not registered`, ValidationErrors.InvalidFields);
709
+ throw new types_1.RpcError(`Inflator ${inflatorAddress} is not registered`, types_1.ValidationErrors.InvalidFields);
684
710
  }
685
711
  // infalte + start to validate user op.
686
- const inflatorContract = getContract({
712
+ const inflatorContract = (0, viem_1.getContract)({
687
713
  address: inflatorAddress,
688
- abi: IOpInflatorAbi,
714
+ abi: types_1.IOpInflatorAbi,
689
715
  client: {
690
716
  public: this.publicClient
691
717
  }
@@ -697,31 +723,32 @@ export class RpcHandler {
697
723
  ]);
698
724
  }
699
725
  catch (e) {
700
- throw new RpcError(`Inflator ${inflatorAddress} failed to inflate calldata ${compressedCalldata}, due to ${e}`, ValidationErrors.InvalidFields);
726
+ throw new types_1.RpcError(`Inflator ${inflatorAddress} failed to inflate calldata ${compressedCalldata}, due to ${e}`, types_1.ValidationErrors.InvalidFields);
701
727
  }
702
728
  // check if perUseropIsRegisterd to target BundleBulker
703
729
  const perOpInflatorId = this.compressionHandler.perOpInflatorId;
704
730
  if (perOpInflatorId === 0) {
705
- throw new RpcError(`PerUserOp ${this.compressionHandler.perOpInflatorAddress} has not been registered with BundelBulker`, ValidationErrors.InvalidFields);
731
+ throw new types_1.RpcError(`PerUserOp ${this.compressionHandler.perOpInflatorAddress} has not been registered with BundelBulker`, types_1.ValidationErrors.InvalidFields);
706
732
  }
707
733
  return { inflatedOp, inflatorId };
708
734
  }
709
735
  async getNonceValue(userOperation, entryPoint) {
710
- const entryPointContract = getContract({
736
+ const entryPointContract = (0, viem_1.getContract)({
711
737
  address: entryPoint,
712
- abi: isVersion06(userOperation)
713
- ? EntryPointV06Abi
714
- : EntryPointV07Abi,
738
+ abi: (0, utils_1.isVersion06)(userOperation)
739
+ ? types_1.EntryPointV06Abi
740
+ : types_1.EntryPointV07Abi,
715
741
  client: {
716
742
  public: this.publicClient
717
743
  }
718
744
  });
719
- const [nonceKey] = getNonceKeyAndValue(userOperation.nonce);
745
+ const [nonceKey] = (0, utils_1.getNonceKeyAndValue)(userOperation.nonce);
720
746
  const getNonceResult = await entryPointContract.read.getNonce([userOperation.sender, nonceKey], {
721
747
  blockTag: "latest"
722
748
  });
723
- const [_, currentNonceValue] = getNonceKeyAndValue(getNonceResult);
749
+ const [_, currentNonceValue] = (0, utils_1.getNonceKeyAndValue)(getNonceResult);
724
750
  return currentNonceValue;
725
751
  }
726
752
  }
753
+ exports.RpcHandler = RpcHandler;
727
754
  //# sourceMappingURL=rpcHandler.js.map