diff --git a/.changeset/legal-coats-see.md b/.changeset/legal-coats-see.md new file mode 100644 index 00000000..71525057 --- /dev/null +++ b/.changeset/legal-coats-see.md @@ -0,0 +1,5 @@ +--- +"permissionless": patch +--- + +Added validForSeconds field to pm_sponsorUserOperation, removed deprecated label on pm_sponsorUserOperation diff --git a/packages/permissionless/actions/pimlico/sponsorUserOperation.ts b/packages/permissionless/actions/pimlico/sponsorUserOperation.ts index 920c1971..3bf78cf1 100644 --- a/packages/permissionless/actions/pimlico/sponsorUserOperation.ts +++ b/packages/permissionless/actions/pimlico/sponsorUserOperation.ts @@ -12,6 +12,13 @@ import type { UserOperation } from "viem/account-abstraction" import type { PimlicoRpcSchema } from "../../types/pimlico.js" import { deepHexlify } from "../../utils/deepHexlify.js" +type PaymasterContext = { + sponsorshipPolicyId?: string + validForSeconds?: number + meta?: Record + [key: string]: unknown +} + export type PimlicoSponsorUserOperationParameters< entryPointVersion extends "0.6" | "0.7" > = { @@ -40,6 +47,7 @@ export type PimlicoSponsorUserOperationParameters< version: entryPointVersion } sponsorshipPolicyId?: string + paymasterContext?: PaymasterContext | unknown } export type SponsorUserOperationReturnType< @@ -66,9 +74,6 @@ export type SponsorUserOperationReturnType< : never) > -/** - * @deprecated Use `getPaymasterData` instead - */ export const sponsorUserOperation = async < entryPointVersion extends "0.6" | "0.7" = "0.6" | "0.7" >( @@ -80,20 +85,29 @@ export const sponsorUserOperation = async < >, args: PimlicoSponsorUserOperationParameters ): Promise> => { + const { sponsorshipPolicyId, paymasterContext, userOperation, entryPoint } = + args + + const finalPaymasterContext = + sponsorshipPolicyId !== undefined + ? { + ...(paymasterContext ?? {}), + sponsorshipPolicyId + } + : paymasterContext + const response = await client.request({ method: "pm_sponsorUserOperation", - params: args.sponsorshipPolicyId + params: finalPaymasterContext ? [ - deepHexlify(args.userOperation), - args.entryPoint.address, - { - sponsorshipPolicyId: args.sponsorshipPolicyId - } + deepHexlify(userOperation), + entryPoint.address, + finalPaymasterContext ] - : [deepHexlify(args.userOperation), args.entryPoint.address] + : [deepHexlify(userOperation), entryPoint.address] }) - if (args.entryPoint.version === "0.6") { + if (entryPoint.version === "0.6") { const responseV06 = response as { paymasterAndData: Hex preVerificationGas: Hex diff --git a/packages/permissionless/clients/decorators/pimlico.ts b/packages/permissionless/clients/decorators/pimlico.ts index 53830724..cdaa5d66 100644 --- a/packages/permissionless/clients/decorators/pimlico.ts +++ b/packages/permissionless/clients/decorators/pimlico.ts @@ -102,9 +102,6 @@ export type PimlicoActions< Omit > ) => Promise - /** - * @deprecated Use `getPaymasterData` instead - */ sponsorUserOperation: ( args: Omit< PimlicoSponsorUserOperationParameters,