Skip to content

Feat/valid for seconds #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/legal-coats-see.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Added validForSeconds field to pm_sponsorUserOperation, removed deprecated label on pm_sponsorUserOperation
36 changes: 25 additions & 11 deletions packages/permissionless/actions/pimlico/sponsorUserOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
import type { PimlicoRpcSchema } from "../../types/pimlico.js"
import { deepHexlify } from "../../utils/deepHexlify.js"

type PaymasterContext = {
sponsorshipPolicyId?: string
validForSeconds?: number
meta?: Record<string, string>
[key: string]: unknown
}

export type PimlicoSponsorUserOperationParameters<
entryPointVersion extends "0.6" | "0.7"
> = {
Expand Down Expand Up @@ -40,6 +47,7 @@
version: entryPointVersion
}
sponsorshipPolicyId?: string
paymasterContext?: PaymasterContext | unknown
}

export type SponsorUserOperationReturnType<
Expand All @@ -66,9 +74,6 @@
: never)
>

/**
* @deprecated Use `getPaymasterData` instead
*/
export const sponsorUserOperation = async <
entryPointVersion extends "0.6" | "0.7" = "0.6" | "0.7"
>(
Expand All @@ -80,20 +85,29 @@
>,
args: PimlicoSponsorUserOperationParameters<entryPointVersion>
): Promise<SponsorUserOperationReturnType<entryPointVersion>> => {
const { sponsorshipPolicyId, paymasterContext, userOperation, entryPoint } =
args

Check warning on line 89 in packages/permissionless/actions/pimlico/sponsorUserOperation.ts

View check run for this annotation

Codecov / codecov/patch

packages/permissionless/actions/pimlico/sponsorUserOperation.ts#L88-L89

Added lines #L88 - L89 were not covered by tests

const finalPaymasterContext =
sponsorshipPolicyId !== undefined
? {
...(paymasterContext ?? {}),
sponsorshipPolicyId
}
: paymasterContext

Check warning on line 97 in packages/permissionless/actions/pimlico/sponsorUserOperation.ts

View check run for this annotation

Codecov / codecov/patch

packages/permissionless/actions/pimlico/sponsorUserOperation.ts#L91-L97

Added lines #L91 - L97 were not covered by tests

const response = await client.request({
method: "pm_sponsorUserOperation",
params: args.sponsorshipPolicyId
params: finalPaymasterContext

Check warning on line 101 in packages/permissionless/actions/pimlico/sponsorUserOperation.ts

View check run for this annotation

Codecov / codecov/patch

packages/permissionless/actions/pimlico/sponsorUserOperation.ts#L101

Added line #L101 was not covered by tests
? [
deepHexlify(args.userOperation),
args.entryPoint.address,
{
sponsorshipPolicyId: args.sponsorshipPolicyId
}
deepHexlify(userOperation),
entryPoint.address,
finalPaymasterContext

Check warning on line 105 in packages/permissionless/actions/pimlico/sponsorUserOperation.ts

View check run for this annotation

Codecov / codecov/patch

packages/permissionless/actions/pimlico/sponsorUserOperation.ts#L103-L105

Added lines #L103 - L105 were not covered by tests
]
: [deepHexlify(args.userOperation), args.entryPoint.address]
: [deepHexlify(userOperation), entryPoint.address]

Check warning on line 107 in packages/permissionless/actions/pimlico/sponsorUserOperation.ts

View check run for this annotation

Codecov / codecov/patch

packages/permissionless/actions/pimlico/sponsorUserOperation.ts#L107

Added line #L107 was not covered by tests
})

if (args.entryPoint.version === "0.6") {
if (entryPoint.version === "0.6") {

Check warning on line 110 in packages/permissionless/actions/pimlico/sponsorUserOperation.ts

View check run for this annotation

Codecov / codecov/patch

packages/permissionless/actions/pimlico/sponsorUserOperation.ts#L110

Added line #L110 was not covered by tests
const responseV06 = response as {
paymasterAndData: Hex
preVerificationGas: Hex
Expand Down
3 changes: 0 additions & 3 deletions packages/permissionless/clients/decorators/pimlico.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ export type PimlicoActions<
Omit<SendCompressedUserOperationParameters, "entryPointAddress">
>
) => Promise<Hash>
/**
* @deprecated Use `getPaymasterData` instead
*/
sponsorUserOperation: (
args: Omit<
PimlicoSponsorUserOperationParameters<entryPointVersion>,
Expand Down
Loading