From 75698c827015533e32acb1f535bdf6b738876217 Mon Sep 17 00:00:00 2001 From: livingrockrises <90545960+livingrockrises@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:51:21 +0400 Subject: [PATCH] added flag to skip calldata approval patch (#441) --- packages/account/src/BiconomySmartAccountV2.ts | 6 ++++++ packages/account/src/utils/Types.ts | 4 ++++ packages/paymaster/src/utils/Types.ts | 2 ++ 3 files changed, 12 insertions(+) diff --git a/packages/account/src/BiconomySmartAccountV2.ts b/packages/account/src/BiconomySmartAccountV2.ts index 1f7d38389..76679b043 100644 --- a/packages/account/src/BiconomySmartAccountV2.ts +++ b/packages/account/src/BiconomySmartAccountV2.ts @@ -620,6 +620,12 @@ export class BiconomySmartAccountV2 extends BaseSmartContractAccount { Logger.log("there is a feeQuote: ", feeQuote); if (!spender) throw new Error(ERROR_MESSAGES.SPENDER_REQUIRED); if (!feeQuote) throw new Error(ERROR_MESSAGES.FAILED_FEE_QUOTE_FETCH); + if (paymasterServiceData.skipPatchCallData && paymasterServiceData.skipPatchCallData === true) { + return this.getPaymasterAndData(userOp, { + ...paymasterServiceData, + feeTokenAddress: feeQuote.tokenAddress, + }); + } const partialUserOp = await this.buildTokenPaymasterUserOp(userOp, { ...paymasterServiceData, spender, diff --git a/packages/account/src/utils/Types.ts b/packages/account/src/utils/Types.ts index 353eae5ee..b9f50d2f6 100644 --- a/packages/account/src/utils/Types.ts +++ b/packages/account/src/utils/Types.ts @@ -80,6 +80,8 @@ export type BiconomyTokenPaymasterRequest = { spender: Hex; /** maxApproval: If set to true, the paymaster will approve the maximum amount of tokens required for the transaction. Not recommended */ maxApproval?: boolean; + /* skip option to patch callData if approval is already given to the paymaster */ + skipPatchCallData?: boolean; }; export type RequireAtLeastOne = Pick> & @@ -218,6 +220,8 @@ export type PaymasterUserOperationDto = SponsorUserOperationDto & spender?: Hex; /** Not recommended */ maxApproval?: boolean; + /* skip option to patch callData if approval is already given to the paymaster */ + skipPatchCallData?: boolean; }; export type InitializeV2Data = { diff --git a/packages/paymaster/src/utils/Types.ts b/packages/paymaster/src/utils/Types.ts index 16a8f5a51..9d5f849d4 100644 --- a/packages/paymaster/src/utils/Types.ts +++ b/packages/paymaster/src/utils/Types.ts @@ -106,6 +106,8 @@ export type BiconomyTokenPaymasterRequest = { spender: Hex; /** Not recommended */ maxApproval?: boolean; + /* skip option to patch callData if approval is already given to the paymaster */ + skipPatchCallData?: boolean; }; export type FeeQuotesOrDataResponse = {