diff --git a/.changeset/tasty-pugs-smell.md b/.changeset/tasty-pugs-smell.md new file mode 100644 index 00000000..d3bc318f --- /dev/null +++ b/.changeset/tasty-pugs-smell.md @@ -0,0 +1,5 @@ +--- +"permissionless": patch +--- + +Fixed use of getPaymasterData twice in prepareUserOperationForErc20Paymaster diff --git a/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts b/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts index 5b7b83bd..e4ea72ce 100644 --- a/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts +++ b/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts @@ -12,6 +12,8 @@ import { } from "viem" import { type BundlerClient, + type GetPaymasterDataParameters, + type GetPaymasterDataReturnType, type PrepareUserOperationParameters, type PrepareUserOperationRequest, type PrepareUserOperationReturnType, @@ -196,6 +198,28 @@ export const prepareUserOperationForErc20Paymaster = "prepareUserOperation" )({ ...parameters, + paymaster: { + getPaymasterData: ( + args: GetPaymasterDataParameters + ): Promise => { + const paymaster = + parameters.paymaster ?? bundlerClient?.paymaster + + if (typeof paymaster === "object") { + const { getPaymasterStubData } = paymaster + + if (getPaymasterStubData) { + return getPaymasterStubData(args) + } + } + + return getAction( + bundlerClient, + getPaymasterData_, + "getPaymasterData" + )(args) + } + }, calls: callsWithDummyApproval } as unknown as PrepareUserOperationParameters)