diff --git a/.changeset/brave-pots-love.md b/.changeset/brave-pots-love.md new file mode 100644 index 00000000..a4c7f418 --- /dev/null +++ b/.changeset/brave-pots-love.md @@ -0,0 +1,6 @@ +--- +"permissionless": patch +--- + +Add sponsorship policies option to pimlicoPaymasterClient +Update Safe 4337 module version to 0.2.0 diff --git a/src/accounts/signerToSafeSmartAccount.ts b/src/accounts/signerToSafeSmartAccount.ts index afbe6814..27035a4f 100644 --- a/src/accounts/signerToSafeSmartAccount.ts +++ b/src/accounts/signerToSafeSmartAccount.ts @@ -61,7 +61,7 @@ const SAFE_VERSION_TO_ADDRESSES_MAP: { } } = { "1.4.1": { - ADD_MODULES_LIB_ADDRESS: "0x191EFDC03615B575922289DC339F4c70aC5C30Af", + ADD_MODULES_LIB_ADDRESS: "0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb", SAFE_4337_MODULE_ADDRESS: "0x39E54Bb2b3Aa444b4B39DEe15De3b7809c36Fc38", SAFE_PROXY_FACTORY_ADDRESS: "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67", diff --git a/src/actions/pimlico.ts b/src/actions/pimlico.ts index 3ccaf459..b6b5a8d6 100644 --- a/src/actions/pimlico.ts +++ b/src/actions/pimlico.ts @@ -8,7 +8,7 @@ import { getUserOperationStatus } from "./pimlico/getUserOperationStatus.js" import { - type SponsorUserOperationParameters, + type PimlocoSponsorUserOperationParameters, type SponsorUserOperationReturnType, sponsorUserOperation } from "./pimlico/sponsorUserOperation.js" @@ -26,7 +26,7 @@ export type { GetUserOperationGasPriceReturnType, GetUserOperationStatusParameters, GetUserOperationStatusReturnType, - SponsorUserOperationParameters, + PimlocoSponsorUserOperationParameters, SponsorUserOperationReturnType, PimlicoBundlerActions, PimlicoPaymasterClientActions diff --git a/src/actions/pimlico/sponsorUserOperation.ts b/src/actions/pimlico/sponsorUserOperation.ts index 7e9fe42f..284e5867 100644 --- a/src/actions/pimlico/sponsorUserOperation.ts +++ b/src/actions/pimlico/sponsorUserOperation.ts @@ -7,7 +7,7 @@ import type { } from "../../types/userOperation.js" import { deepHexlify } from "../../utils/deepHexlify.js" -export type SponsorUserOperationParameters = { +export type PimlocoSponsorUserOperationParameters = { userOperation: PartialBy< UserOperation, | "callGasLimit" @@ -16,6 +16,7 @@ export type SponsorUserOperationParameters = { | "paymasterAndData" > entryPoint: Address + sponsorshipPolicyId?: string } export type SponsorUserOperationReturnType = { @@ -31,7 +32,7 @@ export type SponsorUserOperationReturnType = { * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/sponsorUserOperation * * @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler. - * @param args {@link sponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint. + * @param args {@link PimlocoSponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint. * @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType} * * @@ -56,14 +57,26 @@ export const sponsorUserOperation = async < TAccount extends Account | undefined = Account | undefined >( client: Client, - args: SponsorUserOperationParameters + args: PimlocoSponsorUserOperationParameters ): Promise => { const response = await client.request({ method: "pm_sponsorUserOperation", - params: [ - deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex, - args.entryPoint - ] + params: args.sponsorshipPolicyId + ? [ + deepHexlify( + args.userOperation + ) as UserOperationWithBigIntAsHex, + args.entryPoint, + { + sponsorshipPolicyId: args.sponsorshipPolicyId + } + ] + : [ + deepHexlify( + args.userOperation + ) as UserOperationWithBigIntAsHex, + args.entryPoint + ] }) return { diff --git a/src/clients/decorators/pimlico.ts b/src/clients/decorators/pimlico.ts index bcbcdb63..6930cfdc 100644 --- a/src/clients/decorators/pimlico.ts +++ b/src/clients/decorators/pimlico.ts @@ -9,7 +9,7 @@ import { getUserOperationStatus } from "../../actions/pimlico/getUserOperationStatus.js" import { - type SponsorUserOperationParameters, + type PimlocoSponsorUserOperationParameters, type SponsorUserOperationReturnType, sponsorUserOperation } from "../../actions/pimlico/sponsorUserOperation.js" @@ -78,7 +78,7 @@ export type PimlicoPaymasterClientActions = { * * https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/sponsorUserOperation * - * @param args {@link SponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint. + * @param args {@link PimlocoSponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint. * @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType} * * @example @@ -97,14 +97,14 @@ export type PimlicoPaymasterClientActions = { * */ sponsorUserOperation: ( - args: SponsorUserOperationParameters + args: PimlocoSponsorUserOperationParameters ) => Promise } export const pimlicoPaymasterActions = ( client: Client ): PimlicoPaymasterClientActions => ({ - sponsorUserOperation: async (args: SponsorUserOperationParameters) => + sponsorUserOperation: async (args: PimlocoSponsorUserOperationParameters) => sponsorUserOperation(client as PimlicoPaymasterClient, args) }) diff --git a/src/types/pimlico.ts b/src/types/pimlico.ts index cc921189..519dca08 100644 --- a/src/types/pimlico.ts +++ b/src/types/pimlico.ts @@ -53,7 +53,10 @@ export type PimlicoPaymasterRpcSchema = [ | "verificationGasLimit" | "paymasterAndData" >, - entryPoint: Address + entryPoint: Address, + metadata?: { + sponsorshipPolicyId?: string + } ] ReturnType: { paymasterAndData: Hex