@pimlico/alto 0.0.0-main.20250214T151652 → 0.0.0-main.20250225T152738

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 (197) hide show
  1. package/esm/cli/config/bundler.d.ts +6 -0
  2. package/esm/cli/config/bundler.js +1 -0
  3. package/esm/cli/config/bundler.js.map +1 -1
  4. package/esm/cli/config/options.js +5 -0
  5. package/esm/cli/config/options.js.map +1 -1
  6. package/esm/cli/setupServer.js +4 -4
  7. package/esm/cli/setupServer.js.map +1 -1
  8. package/esm/executor/executorManager.d.ts +9 -9
  9. package/esm/handlers/gasPriceManager.js +6 -0
  10. package/esm/handlers/gasPriceManager.js.map +1 -1
  11. package/esm/mempool/index.d.ts +1 -0
  12. package/esm/mempool/index.js +1 -0
  13. package/esm/mempool/index.js.map +1 -1
  14. package/esm/{rpc → mempool}/nonceQueuer.d.ts +1 -1
  15. package/esm/mempool/nonceQueuer.js.map +1 -0
  16. package/esm/mempool/reputationManager.d.ts +3 -2
  17. package/esm/mempool/reputationManager.js.map +1 -1
  18. package/esm/rpc/createMethodHandler.d.ts +31 -0
  19. package/esm/rpc/createMethodHandler.js +30 -0
  20. package/esm/rpc/createMethodHandler.js.map +1 -0
  21. package/esm/rpc/index.d.ts +0 -1
  22. package/esm/rpc/index.js +0 -1
  23. package/esm/rpc/index.js.map +1 -1
  24. package/esm/rpc/methods/debug_bundler_clearReputation.d.ts +22 -0
  25. package/esm/rpc/methods/debug_bundler_clearReputation.js +12 -0
  26. package/esm/rpc/methods/debug_bundler_clearReputation.js.map +1 -0
  27. package/esm/rpc/methods/debug_bundler_clearState.d.ts +22 -0
  28. package/esm/rpc/methods/debug_bundler_clearState.js +13 -0
  29. package/esm/rpc/methods/debug_bundler_clearState.js.map +1 -0
  30. package/esm/rpc/methods/debug_bundler_dumpMempool.d.ts +468 -0
  31. package/esm/rpc/methods/debug_bundler_dumpMempool.js +13 -0
  32. package/esm/rpc/methods/debug_bundler_dumpMempool.js.map +1 -0
  33. package/esm/rpc/methods/debug_bundler_dumpReputation.d.ts +57 -0
  34. package/esm/rpc/methods/debug_bundler_dumpReputation.js +13 -0
  35. package/esm/rpc/methods/debug_bundler_dumpReputation.js.map +1 -0
  36. package/esm/rpc/methods/debug_bundler_getStakeStatus.d.ts +79 -0
  37. package/esm/rpc/methods/debug_bundler_getStakeStatus.js +14 -0
  38. package/esm/rpc/methods/debug_bundler_getStakeStatus.js.map +1 -0
  39. package/esm/rpc/methods/debug_bundler_sendBundleNow.d.ts +22 -0
  40. package/esm/rpc/methods/debug_bundler_sendBundleNow.js +12 -0
  41. package/esm/rpc/methods/debug_bundler_sendBundleNow.js.map +1 -0
  42. package/esm/rpc/methods/debug_bundler_setBundlingMode.d.ts +22 -0
  43. package/esm/rpc/methods/debug_bundler_setBundlingMode.js +13 -0
  44. package/esm/rpc/methods/debug_bundler_setBundlingMode.js.map +1 -0
  45. package/esm/rpc/methods/debug_bundler_setReputation.d.ts +46 -0
  46. package/esm/rpc/methods/debug_bundler_setReputation.js +13 -0
  47. package/esm/rpc/methods/debug_bundler_setReputation.js.map +1 -0
  48. package/esm/rpc/methods/eth_chainId.d.ts +22 -0
  49. package/esm/rpc/methods/eth_chainId.js +10 -0
  50. package/esm/rpc/methods/eth_chainId.js.map +1 -0
  51. package/esm/rpc/methods/eth_estimateUserOperationGas.d.ts +979 -0
  52. package/esm/rpc/methods/eth_estimateUserOperationGas.js +18 -0
  53. package/esm/rpc/methods/eth_estimateUserOperationGas.js.map +1 -0
  54. package/esm/rpc/methods/eth_getUserOperationByHash.d.ts +878 -0
  55. package/esm/rpc/methods/eth_getUserOperationByHash.js +98 -0
  56. package/esm/rpc/methods/eth_getUserOperationByHash.js.map +1 -0
  57. package/esm/rpc/methods/eth_getUserOperationReceipt.d.ts +412 -0
  58. package/esm/rpc/methods/eth_getUserOperationReceipt.js +11 -0
  59. package/esm/rpc/methods/eth_getUserOperationReceipt.js.map +1 -0
  60. package/esm/rpc/methods/eth_sendUserOperation.d.ts +422 -0
  61. package/esm/rpc/methods/eth_sendUserOperation.js +30 -0
  62. package/esm/rpc/methods/eth_sendUserOperation.js.map +1 -0
  63. package/esm/rpc/methods/eth_supportedEntryPoints.d.ts +22 -0
  64. package/esm/rpc/methods/eth_supportedEntryPoints.js +10 -0
  65. package/esm/rpc/methods/eth_supportedEntryPoints.js.map +1 -0
  66. package/esm/rpc/methods/index.d.ts +3 -0
  67. package/esm/rpc/methods/index.js +45 -0
  68. package/esm/rpc/methods/index.js.map +1 -0
  69. package/esm/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.d.ts +979 -0
  70. package/esm/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.js +20 -0
  71. package/esm/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.js.map +1 -0
  72. package/esm/rpc/methods/pimlico_experimental_sendUserOperation7702.d.ts +422 -0
  73. package/esm/rpc/methods/pimlico_experimental_sendUserOperation7702.js +16 -0
  74. package/esm/rpc/methods/pimlico_experimental_sendUserOperation7702.js.map +1 -0
  75. package/esm/rpc/methods/pimlico_getUserOperationGasPrice.d.ts +131 -0
  76. package/esm/rpc/methods/pimlico_getUserOperationGasPrice.js +30 -0
  77. package/esm/rpc/methods/pimlico_getUserOperationGasPrice.js.map +1 -0
  78. package/esm/rpc/methods/pimlico_getUserOperationStatus.d.ts +43 -0
  79. package/esm/rpc/methods/pimlico_getUserOperationStatus.js +11 -0
  80. package/esm/rpc/methods/pimlico_getUserOperationStatus.js.map +1 -0
  81. package/esm/rpc/methods/pimlico_sendUserOperationNow.d.ts +812 -0
  82. package/esm/rpc/methods/pimlico_sendUserOperationNow.js +41 -0
  83. package/esm/rpc/methods/pimlico_sendUserOperationNow.js.map +1 -0
  84. package/esm/rpc/rpcHandler.d.ts +13 -104
  85. package/esm/rpc/rpcHandler.js +34 -373
  86. package/esm/rpc/rpcHandler.js.map +1 -1
  87. package/esm/rpc/server.d.ts +2 -2
  88. package/esm/rpc/server.js +1 -1
  89. package/esm/rpc/server.js.map +1 -1
  90. package/esm/rpc/validation/TracerResultParserV07.js +5 -5
  91. package/esm/rpc/validation/TracerResultParserV07.js.map +1 -1
  92. package/esm/types/schemas.d.ts +9368 -3502
  93. package/esm/types/schemas.js +213 -273
  94. package/esm/types/schemas.js.map +1 -1
  95. package/esm/utils/userop.d.ts +9 -9
  96. package/esm/utils/userop.js.map +1 -1
  97. package/lib/cli/config/bundler.d.ts +6 -0
  98. package/lib/cli/config/bundler.js +1 -0
  99. package/lib/cli/config/bundler.js.map +1 -1
  100. package/lib/cli/config/options.js +5 -0
  101. package/lib/cli/config/options.js.map +1 -1
  102. package/lib/cli/setupServer.js +3 -3
  103. package/lib/cli/setupServer.js.map +1 -1
  104. package/lib/executor/executorManager.d.ts +9 -9
  105. package/lib/handlers/gasPriceManager.js +6 -0
  106. package/lib/handlers/gasPriceManager.js.map +1 -1
  107. package/lib/mempool/index.d.ts +1 -0
  108. package/lib/mempool/index.js +1 -0
  109. package/lib/mempool/index.js.map +1 -1
  110. package/lib/{rpc → mempool}/nonceQueuer.d.ts +1 -1
  111. package/lib/mempool/nonceQueuer.js.map +1 -0
  112. package/lib/mempool/reputationManager.d.ts +3 -2
  113. package/lib/mempool/reputationManager.js.map +1 -1
  114. package/lib/rpc/createMethodHandler.d.ts +31 -0
  115. package/lib/rpc/createMethodHandler.js +34 -0
  116. package/lib/rpc/createMethodHandler.js.map +1 -0
  117. package/lib/rpc/index.d.ts +0 -1
  118. package/lib/rpc/index.js +0 -1
  119. package/lib/rpc/index.js.map +1 -1
  120. package/lib/rpc/methods/debug_bundler_clearReputation.d.ts +22 -0
  121. package/lib/rpc/methods/debug_bundler_clearReputation.js +15 -0
  122. package/lib/rpc/methods/debug_bundler_clearReputation.js.map +1 -0
  123. package/lib/rpc/methods/debug_bundler_clearState.d.ts +22 -0
  124. package/lib/rpc/methods/debug_bundler_clearState.js +16 -0
  125. package/lib/rpc/methods/debug_bundler_clearState.js.map +1 -0
  126. package/lib/rpc/methods/debug_bundler_dumpMempool.d.ts +468 -0
  127. package/lib/rpc/methods/debug_bundler_dumpMempool.js +16 -0
  128. package/lib/rpc/methods/debug_bundler_dumpMempool.js.map +1 -0
  129. package/lib/rpc/methods/debug_bundler_dumpReputation.d.ts +57 -0
  130. package/lib/rpc/methods/debug_bundler_dumpReputation.js +16 -0
  131. package/lib/rpc/methods/debug_bundler_dumpReputation.js.map +1 -0
  132. package/lib/rpc/methods/debug_bundler_getStakeStatus.d.ts +79 -0
  133. package/lib/rpc/methods/debug_bundler_getStakeStatus.js +17 -0
  134. package/lib/rpc/methods/debug_bundler_getStakeStatus.js.map +1 -0
  135. package/lib/rpc/methods/debug_bundler_sendBundleNow.d.ts +22 -0
  136. package/lib/rpc/methods/debug_bundler_sendBundleNow.js +15 -0
  137. package/lib/rpc/methods/debug_bundler_sendBundleNow.js.map +1 -0
  138. package/lib/rpc/methods/debug_bundler_setBundlingMode.d.ts +22 -0
  139. package/lib/rpc/methods/debug_bundler_setBundlingMode.js +16 -0
  140. package/lib/rpc/methods/debug_bundler_setBundlingMode.js.map +1 -0
  141. package/lib/rpc/methods/debug_bundler_setReputation.d.ts +46 -0
  142. package/lib/rpc/methods/debug_bundler_setReputation.js +16 -0
  143. package/lib/rpc/methods/debug_bundler_setReputation.js.map +1 -0
  144. package/lib/rpc/methods/eth_chainId.d.ts +22 -0
  145. package/lib/rpc/methods/eth_chainId.js +13 -0
  146. package/lib/rpc/methods/eth_chainId.js.map +1 -0
  147. package/lib/rpc/methods/eth_estimateUserOperationGas.d.ts +979 -0
  148. package/lib/rpc/methods/eth_estimateUserOperationGas.js +21 -0
  149. package/lib/rpc/methods/eth_estimateUserOperationGas.js.map +1 -0
  150. package/lib/rpc/methods/eth_getUserOperationByHash.d.ts +878 -0
  151. package/lib/rpc/methods/eth_getUserOperationByHash.js +101 -0
  152. package/lib/rpc/methods/eth_getUserOperationByHash.js.map +1 -0
  153. package/lib/rpc/methods/eth_getUserOperationReceipt.d.ts +412 -0
  154. package/lib/rpc/methods/eth_getUserOperationReceipt.js +14 -0
  155. package/lib/rpc/methods/eth_getUserOperationReceipt.js.map +1 -0
  156. package/lib/rpc/methods/eth_sendUserOperation.d.ts +422 -0
  157. package/lib/rpc/methods/eth_sendUserOperation.js +33 -0
  158. package/lib/rpc/methods/eth_sendUserOperation.js.map +1 -0
  159. package/lib/rpc/methods/eth_supportedEntryPoints.d.ts +22 -0
  160. package/lib/rpc/methods/eth_supportedEntryPoints.js +13 -0
  161. package/lib/rpc/methods/eth_supportedEntryPoints.js.map +1 -0
  162. package/lib/rpc/methods/index.d.ts +3 -0
  163. package/lib/rpc/methods/index.js +49 -0
  164. package/lib/rpc/methods/index.js.map +1 -0
  165. package/lib/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.d.ts +979 -0
  166. package/lib/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.js +23 -0
  167. package/lib/rpc/methods/pimlico_experimental_estimateUserOperationGas7702.js.map +1 -0
  168. package/lib/rpc/methods/pimlico_experimental_sendUserOperation7702.d.ts +422 -0
  169. package/lib/rpc/methods/pimlico_experimental_sendUserOperation7702.js +19 -0
  170. package/lib/rpc/methods/pimlico_experimental_sendUserOperation7702.js.map +1 -0
  171. package/lib/rpc/methods/pimlico_getUserOperationGasPrice.d.ts +131 -0
  172. package/lib/rpc/methods/pimlico_getUserOperationGasPrice.js +33 -0
  173. package/lib/rpc/methods/pimlico_getUserOperationGasPrice.js.map +1 -0
  174. package/lib/rpc/methods/pimlico_getUserOperationStatus.d.ts +43 -0
  175. package/lib/rpc/methods/pimlico_getUserOperationStatus.js +14 -0
  176. package/lib/rpc/methods/pimlico_getUserOperationStatus.js.map +1 -0
  177. package/lib/rpc/methods/pimlico_sendUserOperationNow.d.ts +812 -0
  178. package/lib/rpc/methods/pimlico_sendUserOperationNow.js +44 -0
  179. package/lib/rpc/methods/pimlico_sendUserOperationNow.js.map +1 -0
  180. package/lib/rpc/rpcHandler.d.ts +13 -104
  181. package/lib/rpc/rpcHandler.js +31 -370
  182. package/lib/rpc/rpcHandler.js.map +1 -1
  183. package/lib/rpc/server.d.ts +2 -2
  184. package/lib/rpc/server.js +1 -1
  185. package/lib/rpc/server.js.map +1 -1
  186. package/lib/rpc/validation/TracerResultParserV07.js +4 -4
  187. package/lib/rpc/validation/TracerResultParserV07.js.map +1 -1
  188. package/lib/types/schemas.d.ts +9368 -3502
  189. package/lib/types/schemas.js +261 -348
  190. package/lib/types/schemas.js.map +1 -1
  191. package/lib/utils/userop.d.ts +9 -9
  192. package/lib/utils/userop.js.map +1 -1
  193. package/package.json +2 -1
  194. package/esm/rpc/nonceQueuer.js.map +0 -1
  195. package/lib/rpc/nonceQueuer.js.map +0 -1
  196. /package/esm/{rpc → mempool}/nonceQueuer.js +0 -0
  197. /package/lib/{rpc → mempool}/nonceQueuer.js +0 -0
@@ -0,0 +1,41 @@
1
+ import { getUserOperationHash, isVersion06, parseUserOperationReceipt } from "../../utils/index.js";
2
+ import { createMethodHandler } from "../createMethodHandler.js";
3
+ import { RpcError, ValidationErrors, pimlicoSendUserOperationNowSchema } from "../../types/index.js";
4
+ export const pimlicoSendUserOperationNowHandler = createMethodHandler({
5
+ method: "pimlico_sendUserOperationNow",
6
+ schema: pimlicoSendUserOperationNowSchema,
7
+ handler: async ({ rpcHandler, params, apiVersion }) => {
8
+ if (!rpcHandler.config.enableInstantBundlingEndpoint) {
9
+ throw new RpcError("pimlico_sendUserOperationNow endpoint is not enabled", ValidationErrors.InvalidFields);
10
+ }
11
+ const [userOperation, entryPoint] = params;
12
+ rpcHandler.ensureEntryPointIsSupported(entryPoint);
13
+ const opHash = getUserOperationHash(userOperation, entryPoint, rpcHandler.config.publicClient.chain.id);
14
+ await rpcHandler.preMempoolChecks(opHash, userOperation, apiVersion, entryPoint);
15
+ // Prepare bundle
16
+ const userOperationInfo = {
17
+ userOp: userOperation,
18
+ entryPoint,
19
+ userOpHash: getUserOperationHash(userOperation, entryPoint, rpcHandler.config.publicClient.chain.id),
20
+ addedToMempool: Date.now()
21
+ };
22
+ const bundle = {
23
+ entryPoint,
24
+ userOps: [userOperationInfo],
25
+ version: isVersion06(userOperation)
26
+ ? "0.6"
27
+ : "0.7"
28
+ };
29
+ const result = await rpcHandler.executorManager.sendBundleToExecutor(bundle);
30
+ if (!result) {
31
+ throw new RpcError("unhandled error during bundle submission", ValidationErrors.InvalidFields);
32
+ }
33
+ // Wait for receipt.
34
+ const receipt = await rpcHandler.config.publicClient.waitForTransactionReceipt({
35
+ hash: result,
36
+ pollingInterval: 100
37
+ });
38
+ return parseUserOperationReceipt(opHash, receipt);
39
+ }
40
+ });
41
+ //# sourceMappingURL=pimlico_sendUserOperationNow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pimlico_sendUserOperationNow.js","sourceRoot":"","sources":["../../../rpc/methods/pimlico_sendUserOperationNow.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,WAAW,EACX,yBAAyB,EAC5B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EACH,QAAQ,EAGR,gBAAgB,EAChB,iCAAiC,EACpC,MAAM,aAAa,CAAA;AAEpB,MAAM,CAAC,MAAM,kCAAkC,GAAG,mBAAmB,CAAC;IAClE,MAAM,EAAE,8BAA8B;IACtC,MAAM,EAAE,iCAAiC;IACzC,OAAO,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE;QAClD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,6BAA6B,EAAE,CAAC;YACnD,MAAM,IAAI,QAAQ,CACd,sDAAsD,EACtD,gBAAgB,CAAC,aAAa,CACjC,CAAA;QACL,CAAC;QAED,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG,MAAM,CAAA;QAE1C,UAAU,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAA;QAClD,MAAM,MAAM,GAAG,oBAAoB,CAC/B,aAAa,EACb,UAAU,EACV,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAC1C,CAAA;QAED,MAAM,UAAU,CAAC,gBAAgB,CAC7B,MAAM,EACN,aAAa,EACb,UAAU,EACV,UAAU,CACb,CAAA;QAED,iBAAiB;QACjB,MAAM,iBAAiB,GAAe;YAClC,MAAM,EAAE,aAAa;YACrB,UAAU;YACV,UAAU,EAAE,oBAAoB,CAC5B,aAAa,EACb,UAAU,EACV,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAC1C;YACD,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE;SAC7B,CAAA;QACD,MAAM,MAAM,GAAwB;YAChC,UAAU;YACV,OAAO,EAAE,CAAC,iBAAiB,CAAC;YAC5B,OAAO,EAAE,WAAW,CAAC,aAAa,CAAC;gBAC/B,CAAC,CAAE,KAAe;gBAClB,CAAC,CAAE,KAAe;SACzB,CAAA;QACD,MAAM,MAAM,GACR,MAAM,UAAU,CAAC,eAAe,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAA;QAEjE,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,QAAQ,CACd,0CAA0C,EAC1C,gBAAgB,CAAC,aAAa,CACjC,CAAA;QACL,CAAC;QAED,oBAAoB;QACpB,MAAM,OAAO,GACT,MAAM,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,yBAAyB,CAAC;YAC3D,IAAI,EAAE,MAAM;YACZ,eAAe,EAAE,GAAG;SACvB,CAAC,CAAA;QAEN,OAAO,yBAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;CACJ,CAAC,CAAA"}
@@ -1,35 +1,27 @@
1
1
  import type { Executor, ExecutorManager } from "../executor/index.js";
2
2
  import type { EventManager, GasPriceManager } from "../handlers/index.js";
3
- import type { InterfaceReputationManager, MemoryMempool, Monitor } from "../mempool/index.js";
4
- import type { ApiVersion, BundlerClearReputationResponseResult, StateOverrides } from "../types/index.js";
5
- import { type Address, type BundlerClearMempoolResponseResult, type BundlerClearStateResponseResult, type BundlerDumpMempoolResponseResult, type BundlerDumpReputationsResponseResult, type BundlerGetStakeStatusResponseResult, type BundlerRequest, type BundlerResponse, type BundlerSendBundleNowResponseResult, type BundlerSetBundlingModeResponseResult, type BundlerSetReputationsRequestParams, type BundlingMode, type ChainIdResponseResult, type EstimateUserOperationGasResponseResult, type GetUserOperationByHashResponseResult, type GetUserOperationReceiptResponseResult, type HexData32, type InterfaceValidator, type PimlicoGetUserOperationGasPriceResponseResult, type PimlicoGetUserOperationStatusResponseResult, type SendUserOperationResponseResult, type SupportedEntryPointsResponseResult, type UserOperation } from "../types/index.js";
3
+ import type { InterfaceReputationManager, MemoryMempool, Monitor, NonceQueuer } from "../mempool/index.js";
4
+ import type { ApiVersion, BundlerRequest, StateOverrides } from "../types/index.js";
5
+ import { type Address, type InterfaceValidator, type UserOperation } from "../types/index.js";
6
6
  import type { Logger, Metrics } from "../utils/index.js";
7
7
  import { type Hex } from "viem";
8
- import type { NonceQueuer } from "./nonceQueuer.js";
9
8
  import type { AltoConfig } from "../createConfig.js";
10
- export interface IRpcEndpoint {
11
- handleMethod(request: BundlerRequest, apiVersion: ApiVersion): Promise<BundlerResponse>;
12
- eth_chainId(): ChainIdResponseResult;
13
- eth_supportedEntryPoints(): SupportedEntryPointsResponseResult;
14
- eth_estimateUserOperationGas(apiVersion: ApiVersion, userOperation: UserOperation, entryPoint: Address, stateOverrides?: StateOverrides): Promise<EstimateUserOperationGasResponseResult>;
15
- eth_sendUserOperation(apiVersion: ApiVersion, userOperation: UserOperation, entryPoint: Address): Promise<SendUserOperationResponseResult>;
16
- eth_getUserOperationByHash(userOperationHash: HexData32): Promise<GetUserOperationByHashResponseResult>;
17
- eth_getUserOperationReceipt(userOperationHash: HexData32): Promise<GetUserOperationReceiptResponseResult>;
18
- }
19
- export declare class RpcHandler implements IRpcEndpoint {
9
+ import type { MethodHandler } from "./createMethodHandler.js";
10
+ export declare class RpcHandler {
20
11
  config: AltoConfig;
21
12
  validator: InterfaceValidator;
22
13
  mempool: MemoryMempool;
23
14
  executor: Executor;
24
15
  monitor: Monitor;
25
16
  nonceQueuer: NonceQueuer;
26
- logger: Logger;
27
- metrics: Metrics;
28
17
  executorManager: ExecutorManager;
29
18
  reputationManager: InterfaceReputationManager;
30
- gasPriceManager: GasPriceManager;
19
+ metrics: Metrics;
31
20
  eventManager: EventManager;
32
- constructor({ config, validator, mempool, executor, monitor, nonceQueuer, executorManager, reputationManager, metrics, gasPriceManager, eventManager }: {
21
+ gasPriceManager: GasPriceManager;
22
+ logger: Logger;
23
+ private methodHandlers;
24
+ constructor({ config, validator, mempool, executor, monitor, nonceQueuer, executorManager, reputationManager, metrics, eventManager, gasPriceManager }: {
33
25
  config: AltoConfig;
34
26
  validator: InterfaceValidator;
35
27
  mempool: MemoryMempool;
@@ -42,96 +34,13 @@ export declare class RpcHandler implements IRpcEndpoint {
42
34
  eventManager: EventManager;
43
35
  gasPriceManager: GasPriceManager;
44
36
  });
45
- handleMethod(request: BundlerRequest, apiVersion: ApiVersion): Promise<BundlerResponse>;
37
+ registerHandler(handler: MethodHandler): void;
38
+ handleMethod(request: BundlerRequest, apiVersion: ApiVersion): Promise<any>;
46
39
  ensureEntryPointIsSupported(entryPoint: Address): void;
47
40
  ensureDebugEndpointsAreEnabled(methodName: string): void;
41
+ ensureExperimentalEndpointsAreEnabled(methodName: string): void;
48
42
  preMempoolChecks(opHash: Hex, userOperation: UserOperation, apiVersion: ApiVersion, entryPoint: Address): Promise<void>;
49
- eth_chainId(): ChainIdResponseResult;
50
- eth_supportedEntryPoints(): SupportedEntryPointsResponseResult;
51
- eth_estimateUserOperationGas(apiVersion: ApiVersion, userOperation: UserOperation, entryPoint: Address, stateOverrides?: StateOverrides): Promise<EstimateUserOperationGasResponseResult>;
52
- eth_sendUserOperation(apiVersion: ApiVersion, userOperation: UserOperation, entryPoint: Address): Promise<SendUserOperationResponseResult>;
53
- eth_getUserOperationByHash(userOperationHash: HexData32): Promise<GetUserOperationByHashResponseResult>;
54
- eth_getUserOperationReceipt(userOperationHash: HexData32): Promise<GetUserOperationReceiptResponseResult>;
55
- debug_bundler_clearState(): BundlerClearStateResponseResult;
56
- debug_bundler_clearMempool(): BundlerClearMempoolResponseResult;
57
- debug_bundler_dumpMempool(entryPoint: Address): Promise<BundlerDumpMempoolResponseResult>;
58
- debug_bundler_sendBundleNow(): Promise<BundlerSendBundleNowResponseResult>;
59
- debug_bundler_setBundlingMode(bundlingMode: BundlingMode): Promise<BundlerSetBundlingModeResponseResult>;
60
- debug_bundler_dumpReputation(entryPoint: Address): BundlerDumpReputationsResponseResult;
61
- debug_bundler_getStakeStatus(address: Address, entryPoint: Address): Promise<BundlerGetStakeStatusResponseResult>;
62
- debug_bundler_setReputation(args: BundlerSetReputationsRequestParams): BundlerSetBundlingModeResponseResult;
63
- debug_bundler_clearReputation(): BundlerClearReputationResponseResult;
64
- pimlico_getUserOperationStatus(userOperationHash: HexData32): PimlicoGetUserOperationStatusResponseResult;
65
- pimlico_getUserOperationGasPrice(): Promise<PimlicoGetUserOperationGasPriceResponseResult>;
66
43
  addToMempoolIfValid(userOperation: UserOperation, entryPoint: Address, apiVersion: ApiVersion): Promise<"added" | "queued">;
67
- pimlico_experimental_estimateUserOperationGas7702(apiVersion: ApiVersion, userOperation: UserOperation, entryPoint: Address, stateOverrides?: StateOverrides): Promise<{
68
- preVerificationGas: bigint;
69
- verificationGasLimit: bigint;
70
- callGasLimit: bigint;
71
- paymasterVerificationGasLimit: bigint;
72
- paymasterPostOpGasLimit: bigint;
73
- verificationGas?: undefined;
74
- } | {
75
- preVerificationGas: bigint;
76
- verificationGasLimit: bigint;
77
- callGasLimit: bigint;
78
- paymasterVerificationGasLimit?: undefined;
79
- paymasterPostOpGasLimit?: undefined;
80
- verificationGas?: undefined;
81
- } | {
82
- preVerificationGas: bigint;
83
- verificationGas: bigint;
84
- verificationGasLimit: bigint;
85
- callGasLimit: bigint;
86
- paymasterVerificationGasLimit?: undefined;
87
- paymasterPostOpGasLimit?: undefined;
88
- }>;
89
- pimlico_experimental_sendUserOperation7702(apiVersion: ApiVersion, userOperation: UserOperation, entryPoint: Address): Promise<`0x${string}`>;
90
- pimlico_sendUserOperationNow(apiVersion: ApiVersion, userOperation: UserOperation, entryPoint: Address): Promise<{
91
- sender: `0x${string}`;
92
- userOpHash: `0x${string}`;
93
- nonce: bigint;
94
- success: boolean;
95
- actualGasCost: bigint;
96
- actualGasUsed: bigint;
97
- entryPoint: `0x${string}`;
98
- logs: {
99
- address: `0x${string}`;
100
- data: `0x${string}`;
101
- blockNumber: bigint;
102
- blockHash: `0x${string}`;
103
- transactionHash: `0x${string}`;
104
- logIndex: bigint;
105
- transactionIndex: bigint;
106
- topics: `0x${string}`[];
107
- }[];
108
- receipt: {
109
- to: `0x${string}` | null;
110
- gasUsed: bigint;
111
- status: bigint | null;
112
- contractAddress: `0x${string}` | null;
113
- blockNumber: bigint;
114
- blockHash: `0x${string}`;
115
- transactionHash: `0x${string}`;
116
- transactionIndex: bigint;
117
- from: `0x${string}`;
118
- cumulativeGasUsed: bigint;
119
- logs: {
120
- address: `0x${string}`;
121
- data: `0x${string}`;
122
- blockNumber: bigint;
123
- blockHash: `0x${string}`;
124
- transactionHash: `0x${string}`;
125
- logIndex: bigint;
126
- transactionIndex: bigint;
127
- topics: `0x${string}`[];
128
- }[];
129
- logsBloom: string;
130
- effectiveGasPrice?: bigint | null | undefined;
131
- };
132
- paymaster?: `0x${string}` | undefined;
133
- reason?: `0x${string}` | undefined;
134
- }>;
135
44
  validateEip7702Auth(userOperation: UserOperation): Promise<void>;
136
45
  getNonceValue(userOperation: UserOperation, entryPoint: Address): Promise<bigint>;
137
46
  estimateGas({ apiVersion, userOperation, entryPoint, stateOverrides }: {
@@ -1,8 +1,9 @@
1
- import { EntryPointV06Abi, EntryPointV07Abi, RpcError, ValidationErrors, bundlerGetStakeStatusResponseSchema } from "../types/index.js";
2
- import { calcPreVerificationGas, calcVerificationGasAndCallGasLimit, deepHexlify, getAAError, getNonceKeyAndSequence, getUserOperationHash, isVersion06, isVersion07, maxBigInt, parseUserOperationReceipt, scaleBigIntByPercent, toUnpackedUserOperation } from "../utils/index.js";
3
- import { TransactionNotFoundError, decodeFunctionData, getAbiItem, getAddress, getContract, slice, toFunctionSelector } from "viem";
1
+ import { EntryPointV06Abi, EntryPointV07Abi, RpcError, ValidationErrors } from "../types/index.js";
2
+ import { calcPreVerificationGas, calcVerificationGasAndCallGasLimit, deepHexlify, getAAError, getNonceKeyAndSequence, getUserOperationHash, isVersion06, isVersion07, maxBigInt, scaleBigIntByPercent } from "../utils/index.js";
3
+ import { getContract } from "viem";
4
4
  import { base, baseSepolia, optimism } from "viem/chains";
5
5
  import { recoverAuthorizationAddress } from "viem/experimental";
6
+ import { registerHandlers } from "./methods/index.js";
6
7
  export class RpcHandler {
7
8
  config;
8
9
  validator;
@@ -10,133 +11,44 @@ export class RpcHandler {
10
11
  executor;
11
12
  monitor;
12
13
  nonceQueuer;
13
- logger;
14
- metrics;
15
14
  executorManager;
16
15
  reputationManager;
17
- gasPriceManager;
16
+ metrics;
18
17
  eventManager;
19
- constructor({ config, validator, mempool, executor, monitor, nonceQueuer, executorManager, reputationManager, metrics, gasPriceManager, eventManager }) {
18
+ gasPriceManager;
19
+ logger;
20
+ methodHandlers;
21
+ constructor({ config, validator, mempool, executor, monitor, nonceQueuer, executorManager, reputationManager, metrics, eventManager, gasPriceManager }) {
20
22
  this.config = config;
21
23
  this.validator = validator;
22
24
  this.mempool = mempool;
23
25
  this.executor = executor;
24
26
  this.monitor = monitor;
25
27
  this.nonceQueuer = nonceQueuer;
26
- this.logger = config.getLogger({ module: "rpc" }, {
27
- level: config.rpcLogLevel || config.logLevel
28
- });
29
- this.metrics = metrics;
30
28
  this.executorManager = executorManager;
31
29
  this.reputationManager = reputationManager;
32
- this.gasPriceManager = gasPriceManager;
30
+ this.metrics = metrics;
33
31
  this.eventManager = eventManager;
32
+ this.gasPriceManager = gasPriceManager;
33
+ this.logger = config.getLogger({ module: "rpc" }, {
34
+ level: config.rpcLogLevel || config.logLevel
35
+ });
36
+ this.methodHandlers = new Map();
37
+ registerHandlers(this);
38
+ }
39
+ registerHandler(handler) {
40
+ this.methodHandlers.set(handler.method, handler);
34
41
  }
35
42
  async handleMethod(request, apiVersion) {
36
- // call the method with the params
37
- const method = request.method;
38
- switch (method) {
39
- case "eth_chainId":
40
- return {
41
- method,
42
- result: this.eth_chainId(...request.params)
43
- };
44
- case "eth_supportedEntryPoints":
45
- return {
46
- method,
47
- result: this.eth_supportedEntryPoints(...request.params)
48
- };
49
- case "eth_estimateUserOperationGas":
50
- return {
51
- method,
52
- result: await this.eth_estimateUserOperationGas(apiVersion, request.params[0], request.params[1], request.params[2])
53
- };
54
- case "eth_sendUserOperation":
55
- return {
56
- method,
57
- result: await this.eth_sendUserOperation(apiVersion, ...request.params)
58
- };
59
- case "eth_getUserOperationByHash":
60
- return {
61
- method,
62
- result: await this.eth_getUserOperationByHash(...request.params)
63
- };
64
- case "eth_getUserOperationReceipt":
65
- return {
66
- method,
67
- result: await this.eth_getUserOperationReceipt(...request.params)
68
- };
69
- case "debug_bundler_clearMempool":
70
- return {
71
- method,
72
- result: this.debug_bundler_clearMempool(...request.params)
73
- };
74
- case "debug_bundler_clearState":
75
- return {
76
- method,
77
- result: this.debug_bundler_clearState(...request.params)
78
- };
79
- case "debug_bundler_dumpMempool":
80
- return {
81
- method,
82
- result: await this.debug_bundler_dumpMempool(...request.params)
83
- };
84
- case "debug_bundler_sendBundleNow":
85
- return {
86
- method,
87
- result: await this.debug_bundler_sendBundleNow(...request.params)
88
- };
89
- case "debug_bundler_setBundlingMode":
90
- return {
91
- method,
92
- result: await this.debug_bundler_setBundlingMode(...request.params)
93
- };
94
- case "debug_bundler_clearReputation":
95
- return {
96
- method,
97
- result: this.debug_bundler_clearReputation(...request.params)
98
- };
99
- case "debug_bundler_setReputation":
100
- return {
101
- method,
102
- result: this.debug_bundler_setReputation(request.params)
103
- };
104
- case "debug_bundler_dumpReputation":
105
- return {
106
- method,
107
- result: this.debug_bundler_dumpReputation(...request.params)
108
- };
109
- case "debug_bundler_getStakeStatus":
110
- return {
111
- method,
112
- result: await this.debug_bundler_getStakeStatus(...request.params)
113
- };
114
- case "pimlico_getUserOperationStatus":
115
- return {
116
- method,
117
- result: this.pimlico_getUserOperationStatus(...request.params)
118
- };
119
- case "pimlico_getUserOperationGasPrice":
120
- return {
121
- method,
122
- result: await this.pimlico_getUserOperationGasPrice(...request.params)
123
- };
124
- case "pimlico_sendUserOperationNow":
125
- return {
126
- method,
127
- result: await this.pimlico_sendUserOperationNow(apiVersion, ...request.params)
128
- };
129
- case "pimlico_experimental_sendUserOperation7702":
130
- return {
131
- method,
132
- result: await this.pimlico_experimental_sendUserOperation7702(apiVersion, ...request.params)
133
- };
134
- case "pimlico_experimental_estimateUserOperationGas7702":
135
- return {
136
- method,
137
- result: await this.pimlico_experimental_estimateUserOperationGas7702(apiVersion, request.params[0], request.params[1], request.params[2])
138
- };
139
- }
43
+ const handler = this.methodHandlers.get(request.method);
44
+ if (!handler) {
45
+ throw new RpcError("Method not supported", ValidationErrors.InvalidFields);
46
+ }
47
+ return await handler.handler({
48
+ rpcHandler: this,
49
+ params: request.params,
50
+ apiVersion
51
+ });
140
52
  }
141
53
  ensureEntryPointIsSupported(entryPoint) {
142
54
  if (!this.config.entrypoints.includes(entryPoint)) {
@@ -148,6 +60,11 @@ export class RpcHandler {
148
60
  throw new RpcError(`${methodName} is only available in development environment`);
149
61
  }
150
62
  }
63
+ ensureExperimentalEndpointsAreEnabled(methodName) {
64
+ if (!this.config.enableExperimental7702Endpoints) {
65
+ throw new RpcError(`${methodName} endpoint is not enabled`, ValidationErrors.InvalidFields);
66
+ }
67
+ }
151
68
  async preMempoolChecks(opHash, userOperation, apiVersion, entryPoint) {
152
69
  if (this.config.legacyTransactions &&
153
70
  userOperation.maxFeePerGas !== userOperation.maxPriorityFeePerGas) {
@@ -190,208 +107,6 @@ export class RpcHandler {
190
107
  }
191
108
  }
192
109
  }
193
- eth_chainId() {
194
- return BigInt(this.config.publicClient.chain.id);
195
- }
196
- eth_supportedEntryPoints() {
197
- return this.config.entrypoints;
198
- }
199
- async eth_estimateUserOperationGas(apiVersion, userOperation, entryPoint, stateOverrides) {
200
- return await this.estimateGas({
201
- apiVersion,
202
- userOperation,
203
- entryPoint,
204
- stateOverrides
205
- });
206
- }
207
- async eth_sendUserOperation(apiVersion, userOperation, entryPoint) {
208
- const hash = getUserOperationHash(userOperation, entryPoint, this.config.publicClient.chain.id);
209
- this.eventManager.emitReceived(hash);
210
- let status = "rejected";
211
- try {
212
- status = await this.addToMempoolIfValid(userOperation, entryPoint, apiVersion);
213
- return hash;
214
- }
215
- catch (error) {
216
- status = "rejected";
217
- throw error;
218
- }
219
- finally {
220
- this.metrics.userOperationsReceived
221
- .labels({
222
- status,
223
- type: "regular"
224
- })
225
- .inc();
226
- }
227
- }
228
- async eth_getUserOperationByHash(userOperationHash) {
229
- const userOperationEventAbiItem = getAbiItem({
230
- abi: EntryPointV06Abi,
231
- name: "UserOperationEvent"
232
- });
233
- let fromBlock;
234
- let toBlock;
235
- if (this.config.maxBlockRange !== undefined) {
236
- const latestBlock = await this.config.publicClient.getBlockNumber();
237
- fromBlock = latestBlock - BigInt(this.config.maxBlockRange);
238
- if (fromBlock < 0n) {
239
- fromBlock = 0n;
240
- }
241
- toBlock = "latest";
242
- }
243
- const filterResult = await this.config.publicClient.getLogs({
244
- address: this.config.entrypoints,
245
- event: userOperationEventAbiItem,
246
- fromBlock,
247
- toBlock,
248
- args: {
249
- userOpHash: userOperationHash
250
- }
251
- });
252
- if (filterResult.length === 0) {
253
- return null;
254
- }
255
- const userOperationEvent = filterResult[0];
256
- const txHash = userOperationEvent.transactionHash;
257
- if (txHash === null) {
258
- // transaction pending
259
- return null;
260
- }
261
- const getTransaction = async (txHash) => {
262
- try {
263
- return await this.config.publicClient.getTransaction({
264
- hash: txHash
265
- });
266
- }
267
- catch (e) {
268
- if (e instanceof TransactionNotFoundError) {
269
- return getTransaction(txHash);
270
- }
271
- throw e;
272
- }
273
- };
274
- const tx = await getTransaction(txHash);
275
- if (!tx.to) {
276
- return null;
277
- }
278
- let op;
279
- try {
280
- const decoded = decodeFunctionData({
281
- abi: [...EntryPointV06Abi, ...EntryPointV07Abi],
282
- data: tx.input
283
- });
284
- if (decoded.functionName !== "handleOps") {
285
- return null;
286
- }
287
- const ops = decoded.args[0];
288
- const foundOp = ops.find((op) => op.sender === userOperationEvent.args.sender &&
289
- op.nonce === userOperationEvent.args.nonce);
290
- if (foundOp === undefined) {
291
- return null;
292
- }
293
- const handleOpsV07AbiItem = getAbiItem({
294
- abi: EntryPointV07Abi,
295
- name: "handleOps"
296
- });
297
- const handleOpsV07Selector = toFunctionSelector(handleOpsV07AbiItem);
298
- if (slice(tx.input, 0, 4) === handleOpsV07Selector) {
299
- op = toUnpackedUserOperation(foundOp);
300
- }
301
- else {
302
- op = foundOp;
303
- }
304
- }
305
- catch {
306
- return null;
307
- }
308
- const result = {
309
- userOperation: Object.fromEntries(Object.entries(op).filter(([_, v]) => v !== null)),
310
- entryPoint: getAddress(tx.to),
311
- transactionHash: txHash,
312
- blockHash: tx.blockHash ?? "0x",
313
- blockNumber: BigInt(tx.blockNumber ?? 0n)
314
- };
315
- return result;
316
- }
317
- eth_getUserOperationReceipt(userOperationHash) {
318
- return this.executorManager.getUserOperationReceipt(userOperationHash);
319
- }
320
- debug_bundler_clearState() {
321
- this.ensureDebugEndpointsAreEnabled("debug_bundler_clearState");
322
- this.mempool.clear();
323
- this.reputationManager.clear();
324
- return "ok";
325
- }
326
- debug_bundler_clearMempool() {
327
- this.ensureDebugEndpointsAreEnabled("debug_bundler_clearMempool");
328
- this.mempool.clear();
329
- this.reputationManager.clearEntityCount();
330
- return "ok";
331
- }
332
- debug_bundler_dumpMempool(entryPoint) {
333
- this.ensureDebugEndpointsAreEnabled("debug_bundler_dumpMempool");
334
- this.ensureEntryPointIsSupported(entryPoint);
335
- return Promise.resolve(this.mempool.dumpOutstanding());
336
- }
337
- async debug_bundler_sendBundleNow() {
338
- this.ensureDebugEndpointsAreEnabled("debug_bundler_sendBundleNow");
339
- await this.executorManager.sendBundleNow();
340
- return "ok";
341
- }
342
- async debug_bundler_setBundlingMode(bundlingMode) {
343
- this.ensureDebugEndpointsAreEnabled("debug_bundler_setBundlingMode");
344
- await this.executorManager.setBundlingMode(bundlingMode);
345
- return "ok";
346
- }
347
- debug_bundler_dumpReputation(entryPoint) {
348
- this.ensureDebugEndpointsAreEnabled("debug_bundler_setReputation");
349
- this.ensureEntryPointIsSupported(entryPoint);
350
- return this.reputationManager.dumpReputations(entryPoint);
351
- }
352
- async debug_bundler_getStakeStatus(address, entryPoint) {
353
- this.ensureDebugEndpointsAreEnabled("debug_bundler_getStakeStatus");
354
- this.ensureEntryPointIsSupported(entryPoint);
355
- return bundlerGetStakeStatusResponseSchema.parse({
356
- method: "debug_bundler_getStakeStatus",
357
- result: await this.reputationManager.getStakeStatus(entryPoint, address)
358
- }).result;
359
- }
360
- debug_bundler_setReputation(args) {
361
- this.ensureDebugEndpointsAreEnabled("debug_bundler_setReputation");
362
- this.reputationManager.setReputation(args[1], args[0]);
363
- return "ok";
364
- }
365
- debug_bundler_clearReputation() {
366
- this.ensureDebugEndpointsAreEnabled("debug_bundler_clearReputation");
367
- this.reputationManager.clear();
368
- return "ok";
369
- }
370
- pimlico_getUserOperationStatus(userOperationHash) {
371
- return this.monitor.getUserOperationStatus(userOperationHash);
372
- }
373
- async pimlico_getUserOperationGasPrice() {
374
- let { maxFeePerGas, maxPriorityFeePerGas } = await this.gasPriceManager.getGasPrice();
375
- if (this.config.chainType === "hedera") {
376
- maxFeePerGas /= 10n ** 9n;
377
- maxPriorityFeePerGas /= 10n ** 9n;
378
- }
379
- const { slow, standard, fast } = this.config.gasPriceMultipliers;
380
- return {
381
- slow: {
382
- maxFeePerGas: (maxFeePerGas * slow) / 100n,
383
- maxPriorityFeePerGas: (maxPriorityFeePerGas * slow) / 100n
384
- },
385
- standard: {
386
- maxFeePerGas: (maxFeePerGas * standard) / 100n,
387
- maxPriorityFeePerGas: (maxPriorityFeePerGas * standard) / 100n
388
- },
389
- fast: {
390
- maxFeePerGas: (maxFeePerGas * fast) / 100n,
391
- maxPriorityFeePerGas: (maxPriorityFeePerGas * fast) / 100n
392
- }
393
- };
394
- }
395
110
  // check if we want to bundle userOperation. If yes, add to mempool
396
111
  async addToMempoolIfValid(userOperation, entryPoint, apiVersion) {
397
112
  this.ensureEntryPointIsSupported(entryPoint);
@@ -446,60 +161,6 @@ export class RpcHandler {
446
161
  }
447
162
  return "added";
448
163
  }
449
- async pimlico_experimental_estimateUserOperationGas7702(apiVersion, userOperation, entryPoint, stateOverrides) {
450
- if (!this.config.enableExperimental7702Endpoints) {
451
- throw new RpcError("pimlico_experimental_estimateUserOperationGas7702 endpoint is not enabled", ValidationErrors.InvalidFields);
452
- }
453
- await this.validateEip7702Auth(userOperation);
454
- return await this.estimateGas({
455
- apiVersion,
456
- userOperation,
457
- entryPoint,
458
- stateOverrides
459
- });
460
- }
461
- async pimlico_experimental_sendUserOperation7702(apiVersion, userOperation, entryPoint) {
462
- if (!this.config.enableExperimental7702Endpoints) {
463
- throw new RpcError("pimlico_experimental_sendUserOperation7702 endpoint is not enabled", ValidationErrors.InvalidFields);
464
- }
465
- this.ensureEntryPointIsSupported(entryPoint);
466
- await this.validateEip7702Auth(userOperation);
467
- await this.addToMempoolIfValid(userOperation, entryPoint, apiVersion);
468
- return getUserOperationHash(userOperation, entryPoint, this.config.publicClient.chain.id);
469
- }
470
- async pimlico_sendUserOperationNow(apiVersion, userOperation, entryPoint) {
471
- if (!this.config.enableInstantBundlingEndpoint) {
472
- throw new RpcError("pimlico_sendUserOperationNow endpoint is not enabled", ValidationErrors.InvalidFields);
473
- }
474
- this.ensureEntryPointIsSupported(entryPoint);
475
- const opHash = getUserOperationHash(userOperation, entryPoint, this.config.publicClient.chain.id);
476
- await this.preMempoolChecks(opHash, userOperation, apiVersion, entryPoint);
477
- // Prepare bundle
478
- const userOperationInfo = {
479
- userOp: userOperation,
480
- entryPoint,
481
- userOpHash: getUserOperationHash(userOperation, entryPoint, this.config.publicClient.chain.id),
482
- addedToMempool: Date.now()
483
- };
484
- const bundle = {
485
- entryPoint,
486
- userOps: [userOperationInfo],
487
- version: isVersion06(userOperation)
488
- ? "0.6"
489
- : "0.7"
490
- };
491
- const result = await this.executorManager.sendBundleToExecutor(bundle);
492
- if (!result) {
493
- throw new RpcError("unhandled error during bundle submission", ValidationErrors.InvalidFields);
494
- }
495
- // Wait for receipt.
496
- const receipt = await this.config.publicClient.waitForTransactionReceipt({
497
- hash: result,
498
- pollingInterval: 100
499
- });
500
- const userOperationReceipt = parseUserOperationReceipt(opHash, receipt);
501
- return userOperationReceipt;
502
- }
503
164
  async validateEip7702Auth(userOperation) {
504
165
  if (!userOperation.eip7702auth) {
505
166
  throw new RpcError("UserOperation is missing eip7702auth", ValidationErrors.InvalidFields);
@@ -538,7 +199,7 @@ export class RpcHandler {
538
199
  }
539
200
  async estimateGas({ apiVersion, userOperation, entryPoint, stateOverrides }) {
540
201
  this.ensureEntryPointIsSupported(entryPoint);
541
- if (userOperation.maxFeePerGas === 0n) {
202
+ if (userOperation.maxFeePerGas === 0n && !this.config.isGasFreeChain) {
542
203
  throw new RpcError("user operation max fee per gas must be larger than 0 during gas estimation");
543
204
  }
544
205
  // Check if the nonce is valid