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

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