diff --git a/src/cli/config/bundler.ts b/src/cli/config/bundler.ts index 52dd6d6a..6f81d0b2 100644 --- a/src/cli/config/bundler.ts +++ b/src/cli/config/bundler.ts @@ -120,7 +120,7 @@ export const bundlerArgsSchema = z.object({ "refilling-wallets": z.boolean().default(true), "aa95-gas-multiplier": z.string().transform((val) => BigInt(val)), "enable-instant-bundling-endpoint": z.boolean(), - "enable-experimental-endpoints": z.boolean() + "enable-experimental-7702-endpoints": z.boolean() }) export const compatibilityArgsSchema = z.object({ diff --git a/src/cli/config/options.ts b/src/cli/config/options.ts index 84bfb55d..0abbd0a7 100644 --- a/src/cli/config/options.ts +++ b/src/cli/config/options.ts @@ -193,9 +193,9 @@ export const bundlerOptions: CliCommandOptions = { type: "boolean", default: false }, - "enable-experimental-endpoints": { + "enable-experimental-7702-endpoints": { description: - "Should the bundler enable the pimlico_sendUserOperation7702 and pimlico_estimateUserOperationGas7702 endpoint", + "Should the bundler enable the pimlico_experimental_sendUserOperation7702 and pimlico_experimental_estimateUserOperationGas7702 endpoint", type: "boolean", default: false } diff --git a/src/cli/parseArgs.ts b/src/cli/parseArgs.ts index f7a5d259..dcf02526 100644 --- a/src/cli/parseArgs.ts +++ b/src/cli/parseArgs.ts @@ -13,7 +13,7 @@ export type CamelCasedProperties = { } function toCamelCase(str: string): string { - return str.replace(/([-_][a-z])/g, (group) => + return str.replace(/([-_][a-z0-9])/g, (group) => group.toUpperCase().replace("-", "").replace("_", "") ) } diff --git a/src/rpc/rpcHandler.ts b/src/rpc/rpcHandler.ts index 2351f665..13ab8503 100644 --- a/src/rpc/rpcHandler.ts +++ b/src/rpc/rpcHandler.ts @@ -299,18 +299,18 @@ export class RpcHandler implements IRpcEndpoint { ...request.params ) } - case "pimlico_sendUserOperation7702": + case "pimlico_experimental_sendUserOperation7702": return { method, - result: await this.pimlico_sendUserOperation7702( + result: await this.pimlico_experimental_sendUserOperation7702( apiVersion, ...request.params ) } - case "pimlico_estimateUserOperationGas7702": + case "pimlico_experimental_estimateUserOperationGas7702": return { method, - result: await this.pimlico_estimateUserOperationGas7702( + result: await this.pimlico_experimental_estimateUserOperationGas7702( apiVersion, request.params[0], request.params[1], @@ -785,16 +785,16 @@ export class RpcHandler implements IRpcEndpoint { return "added" } - async pimlico_estimateUserOperationGas7702( + async pimlico_experimental_estimateUserOperationGas7702( apiVersion: ApiVersion, userOperation: UserOperation, authorization: SignedAuthorization, entryPoint: Address, stateOverrides?: StateOverrides ) { - if (!this.config.enableExperimentalEndpoints) { + if (!this.config.enableExperimental7702Endpoints) { throw new RpcError( - "pimlico_estimateUserOperationGas7702 endpoint is not enabled", + "pimlico_experimental_estimateUserOperationGas7702 endpoint is not enabled", ValidationErrors.InvalidFields ) } @@ -808,15 +808,15 @@ export class RpcHandler implements IRpcEndpoint { }) } - async pimlico_sendUserOperation7702( + async pimlico_experimental_sendUserOperation7702( apiVersion: ApiVersion, userOperation: UserOperation, authorizationSignature: SignedAuthorization, entryPoint: Address ) { - if (!this.config.enableExperimentalEndpoints) { + if (!this.config.enableExperimental7702Endpoints) { throw new RpcError( - "pimlico_sendUserOperation7702 endpoint is not enabled", + "pimlico_experimental_sendUserOperation7702 endpoint is not enabled", ValidationErrors.InvalidFields ) } @@ -1067,7 +1067,7 @@ export class RpcHandler implements IRpcEndpoint { stateOverrides?: StateOverrides authorization?: SignedAuthorization }) { - this.ensureEntryPointIsSupported(entryPoint) + this.ensureEntryPointIsSupported(entryPoint) if (userOperation.maxFeePerGas === 0n) { throw new RpcError( @@ -1148,13 +1148,14 @@ export class RpcHandler implements IRpcEndpoint { simulationUserOperation.maxPriorityFeePerGas = simulationUserOperation.maxFeePerGas - const executionResult = await this.validator.getExecutionResult( - simulationUserOperation, + const executionResult = await this.validator.getExecutionResult({ + userOperation: simulationUserOperation, entryPoint, queuedUserOperations, - true, - deepHexlify(stateOverrides) - ) + addSenderBalanceOverride: true, + stateOverrides: deepHexlify(stateOverrides), + authorizationList: authorization ? [authorization] : undefined + }) let { verificationGasLimit, callGasLimit } = calcVerificationGasAndCallGasLimit( @@ -1236,8 +1237,8 @@ export class RpcHandler implements IRpcEndpoint { // Check if userOperation passes without estimation balance overrides if (isVersion06(simulationUserOperation)) { - await this.validator.getExecutionResult( - { + await this.validator.getExecutionResult({ + userOperation: { ...simulationUserOperation, preVerificationGas, verificationGasLimit, @@ -1247,9 +1248,10 @@ export class RpcHandler implements IRpcEndpoint { }, entryPoint, queuedUserOperations, - false, - deepHexlify(stateOverrides) - ) + addSenderBalanceOverride: false, + stateOverrides: deepHexlify(stateOverrides), + authorizationList: authorization ? [authorization] : undefined + }) } if (isVersion07(simulationUserOperation)) { diff --git a/src/types/schemas.ts b/src/types/schemas.ts index 4b595979..e471d278 100644 --- a/src/types/schemas.ts +++ b/src/types/schemas.ts @@ -364,8 +364,8 @@ const pimlicoSendUserOperationNowRequestSchema = z.object({ params: z.tuple([userOperationSchema, addressSchema]) }) -const pimlicoEstimateUserOperationGas7702RequestSchema = z.object({ - method: z.literal("pimlico_estimateUserOperationGas7702"), +const pimlicoExperimentalEstimateUserOperationGas7702RequestSchema = z.object({ + method: z.literal("pimlico_experimental_estimateUserOperationGas7702"), params: z.union([ z.tuple([ partialUserOperationSchema, @@ -381,8 +381,8 @@ const pimlicoEstimateUserOperationGas7702RequestSchema = z.object({ ]) }) -const pimlicoSendUserOperation7702RequestSchema = z.object({ - method: z.literal("pimlico_sendUserOperation7702"), +const pimlicoExperimentalSendUserOperation7702RequestSchema = z.object({ + method: z.literal("pimlico_experimental_sendUserOperation7702"), params: z.tuple([ userOperationSchema, signedAuthorizationSchema, @@ -412,8 +412,8 @@ const bundlerRequestSchema = z.discriminatedUnion("method", [ pimlicoGetUserOperationGasPriceRequestSchema, pimlicoSendCompressedUserOperationRequestSchema, pimlicoSendUserOperationNowRequestSchema, - pimlicoSendUserOperation7702RequestSchema, - pimlicoEstimateUserOperationGas7702RequestSchema + pimlicoExperimentalSendUserOperation7702RequestSchema, + pimlicoExperimentalEstimateUserOperationGas7702RequestSchema ]) const chainIdResponseSchema = z.object({ @@ -627,13 +627,13 @@ const pimlicoSendUserOperationNowResponseSchema = z.object({ result: userOperationReceiptSchema }) -const pimlicoSendUserOperation7702ResponseSchema = z.object({ - method: z.literal("pimlico_sendUserOperation7702"), +const pimlicoExperimentalSendUserOperation7702ResponseSchema = z.object({ + method: z.literal("pimlico_experimental_sendUserOperation7702"), result: hexData32Schema }) -const pimlicoEstimateUserOperationGas7702ResponseSchema = z.object({ - method: z.literal("pimlico_estimateUserOperationGas7702"), +const pimlicoExperimentalEstimateUserOperation7702ResponseSchema = z.object({ + method: z.literal("pimlico_experimental_estimateUserOperationGas7702"), result: z.union([ z.object({ callGasLimit: hexNumberSchema, @@ -670,8 +670,8 @@ const bundlerResponseSchema = z.discriminatedUnion("method", [ pimlicoGetUserOperationGasPriceResponseSchema, pimlicoSendCompressedUserOperationResponseSchema, pimlicoSendUserOperationNowResponseSchema, - pimlicoSendUserOperation7702ResponseSchema, - pimlicoEstimateUserOperationGas7702ResponseSchema + pimlicoExperimentalSendUserOperation7702ResponseSchema, + pimlicoExperimentalEstimateUserOperation7702ResponseSchema ]) export type BundlingMode = z.infer<