Skip to content

Commit

Permalink
update endpoint name
Browse files Browse the repository at this point in the history
  • Loading branch information
mouseless0x committed Dec 17, 2024
1 parent cf3c433 commit 479b3fd
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/cli/config/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions src/cli/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ export const bundlerOptions: CliCommandOptions<IBundlerArgsInput> = {
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
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/parseArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type CamelCasedProperties<T> = {
}

function toCamelCase(str: string): string {
return str.replace(/([-_][a-z])/g, (group) =>
return str.replace(/([-_][a-z0-9])/g, (group) =>
group.toUpperCase().replace("-", "").replace("_", "")
)
}
Expand Down
44 changes: 23 additions & 21 deletions src/rpc/rpcHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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
)
}
Expand All @@ -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
)
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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)) {
Expand Down
24 changes: 12 additions & 12 deletions src/types/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -412,8 +412,8 @@ const bundlerRequestSchema = z.discriminatedUnion("method", [
pimlicoGetUserOperationGasPriceRequestSchema,
pimlicoSendCompressedUserOperationRequestSchema,
pimlicoSendUserOperationNowRequestSchema,
pimlicoSendUserOperation7702RequestSchema,
pimlicoEstimateUserOperationGas7702RequestSchema
pimlicoExperimentalSendUserOperation7702RequestSchema,
pimlicoExperimentalEstimateUserOperationGas7702RequestSchema
])

const chainIdResponseSchema = z.object({
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -670,8 +670,8 @@ const bundlerResponseSchema = z.discriminatedUnion("method", [
pimlicoGetUserOperationGasPriceResponseSchema,
pimlicoSendCompressedUserOperationResponseSchema,
pimlicoSendUserOperationNowResponseSchema,
pimlicoSendUserOperation7702ResponseSchema,
pimlicoEstimateUserOperationGas7702ResponseSchema
pimlicoExperimentalSendUserOperation7702ResponseSchema,
pimlicoExperimentalEstimateUserOperation7702ResponseSchema
])

export type BundlingMode = z.infer<
Expand Down

0 comments on commit 479b3fd

Please sign in to comment.