diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f8ac1e..f6366ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## [5.1.1] - 2025-03-19 +### Fix +- Removed multiple estimations when paymaster is set in the userOp ## [5.1.0] - 2025-03-06 ### Updated diff --git a/bun.lockb b/bun.lockb index 0036472..6c05a02 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index ae180a4..305511e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@etherspot/modular-sdk", - "version": "5.1.0", + "version": "5.1.1", "description": "Etherspot Modular SDK - build with ERC-7579 smart accounts modules", "keywords": [ "ether", diff --git a/src/sdk/base/BaseAccountAPI.ts b/src/sdk/base/BaseAccountAPI.ts index 58b41f5..1f47ac2 100644 --- a/src/sdk/base/BaseAccountAPI.ts +++ b/src/sdk/base/BaseAccountAPI.ts @@ -459,11 +459,15 @@ export abstract class BaseAccountAPI { partialUserOp.paymaster = paymasterData.result.paymaster; partialUserOp.paymasterVerificationGasLimit = paymasterData.result.paymasterVerificationGasLimit; partialUserOp.paymasterPostOpGasLimit = paymasterData.result.paymasterPostOpGasLimit; + if (paymasterData?.result.maxFeePerGas && paymasterData?.result.maxPriorityFeePerGas) { + partialUserOp.maxFeePerGas = paymasterData.result.maxFeePerGas; + partialUserOp.maxPriorityFeePerGas = paymasterData.result.maxPriorityFeePerGas; + } } partialUserOp.paymasterData = paymasterData ? paymasterData.result.paymasterData : '0x'; + partialUserOp.preVerificationGas = paymasterData ? paymasterData.result.preVerificationGas : this.getPreVerificationGas(partialUserOp); return { ...partialUserOp, - preVerificationGas: this.getPreVerificationGas(partialUserOp), signature: info.dummySignature ?? '0x', }; } @@ -473,15 +477,6 @@ export abstract class BaseAccountAPI { * @param userOp the UserOperation to sign (with signature field ignored) */ async signUserOp(userOp: UserOperation): Promise { - if (this.paymasterAPI != null) { - const paymasterData = await this.paymasterAPI.getPaymasterData(userOp); - userOp.verificationGasLimit = paymasterData.result.verificationGasLimit; - userOp.preVerificationGas = paymasterData.result.preVerificationGas; - userOp.callGasLimit = paymasterData.result.callGasLimit; - userOp.paymaster = paymasterData.result.paymaster; - userOp.paymasterVerificationGasLimit = paymasterData.result.paymasterVerificationGasLimit; - userOp.paymasterPostOpGasLimit = paymasterData.result.paymasterPostOpGasLimit; - } const userOpHash = await this.getUserOpHash(userOp); const signature = await this.signUserOpHash(userOpHash); return { diff --git a/src/sdk/base/EtherspotWalletAPI.ts b/src/sdk/base/EtherspotWalletAPI.ts index e459207..030c732 100644 --- a/src/sdk/base/EtherspotWalletAPI.ts +++ b/src/sdk/base/EtherspotWalletAPI.ts @@ -397,7 +397,7 @@ export class EtherspotWalletAPI extends BaseAccountAPI { const convertedResult = result.map(item => ({ ...item, // Convert `value` from BigNumberish to bigint - value: typeof item.value === 'bigint' ? item.value : BigInt(item.value.toString()), + value: typeof item.value === 'bigint' ? item.value : BigNumber.from(item.value.toString()).toBigInt(), })); //TODO-Test-LibraryFix identify the syntax for viem to pass array of tuple diff --git a/src/sdk/base/VerifyingPaymasterAPI.ts b/src/sdk/base/VerifyingPaymasterAPI.ts index 3442a45..07a3eb8 100644 --- a/src/sdk/base/VerifyingPaymasterAPI.ts +++ b/src/sdk/base/VerifyingPaymasterAPI.ts @@ -19,6 +19,8 @@ export interface PaymasterResponse { callGasLimit: string; paymasterVerificationGasLimit: string; paymasterPostOpGasLimit: string; + maxFeePerGas?: string; + maxPriorityFeePerGas?: string; } } diff --git a/src/sdk/errorHandler/constants.ts b/src/sdk/errorHandler/constants.ts index f0e1bb8..47aeabf 100644 --- a/src/sdk/errorHandler/constants.ts +++ b/src/sdk/errorHandler/constants.ts @@ -1,7 +1,7 @@ export const errorMsg = { '429': 'Rate limit exceeded for the given bundler api key. Please contact bundler team for increasing bandwidth.', // Rate limit quota execeeded - '-32521': 'Check for balance in your Smart wallet', // execution reverted - '-32500': `Please make sure you have enough funds for wallet creation.`, // transaction rejected by entryPoint's simulateValidation, during wallet creation or validation + '-32521': 'UserOp failed. Please contact wallet provider for further details', // execution reverted + '-32500': `Please make sure you have enough funds for wallet creation. If problem still persists please contact wallet provider`, // transaction rejected by entryPoint's simulateValidation, during wallet creation or validation '-32501': `Check paymaster data`, // transaction rejected by paymaster's validatePaymasterUserOp '-32502': 'If using skandha bundler or the default one, please report this issue on https://github.com/etherspot/skandha/issues or ticket on https://discord.etherspot.io', //transaction rejected because of opcode validation '-32503': 'validUntil and validAfter cannot be past timestamps', // UserOperation out of time-range diff --git a/src/sdk/sdk.ts b/src/sdk/sdk.ts index 69e79cb..5bac052 100644 --- a/src/sdk/sdk.ts +++ b/src/sdk/sdk.ts @@ -195,31 +195,29 @@ export class ModularSdk { partialtx.factory = this.etherspotWallet.factoryAddress; } - const bundlerGasEstimate = await this.bundler.getVerificationGasInfo(partialtx); - - // if user has specified the gas prices then use them - if (gasDetails?.maxFeePerGas && gasDetails?.maxPriorityFeePerGas) { - partialtx.maxFeePerGas = gasDetails.maxFeePerGas; - partialtx.maxPriorityFeePerGas = gasDetails.maxPriorityFeePerGas; - } - // if estimation has gas prices use them, otherwise fetch them in a separate call - else if (bundlerGasEstimate.maxFeePerGas && bundlerGasEstimate.maxPriorityFeePerGas) { - partialtx.maxFeePerGas = bundlerGasEstimate.maxFeePerGas; - partialtx.maxPriorityFeePerGas = bundlerGasEstimate.maxPriorityFeePerGas; - } else { - const gas = await this.getGasFee(); - partialtx.maxFeePerGas = gas.maxFeePerGas; - partialtx.maxPriorityFeePerGas = gas.maxPriorityFeePerGas; - } - - if (bundlerGasEstimate.preVerificationGas) { - partialtx.preVerificationGas = BigNumber.from(bundlerGasEstimate.preVerificationGas); - partialtx.verificationGasLimit = BigNumber.from(bundlerGasEstimate.verificationGasLimit ?? bundlerGasEstimate.verificationGas); - const expectedCallGasLimit = BigNumber.from(bundlerGasEstimate.callGasLimit); - if (!callGasLimit) - partialtx.callGasLimit = expectedCallGasLimit; - else if (BigNumber.from(callGasLimit).lt(expectedCallGasLimit)) - throw new ErrorHandler(`CallGasLimit is too low. Expected atleast ${expectedCallGasLimit.toString()}`); + if (!paymasterDetails?.url) { + const bundlerGasEstimate = await this.bundler.getVerificationGasInfo(partialtx); + + // if user has specified the gas prices then use them + if (gasDetails?.maxFeePerGas && gasDetails?.maxPriorityFeePerGas) { + partialtx.maxFeePerGas = gasDetails.maxFeePerGas; + partialtx.maxPriorityFeePerGas = gasDetails.maxPriorityFeePerGas; + } + // if estimation has gas prices use them, otherwise fetch them in a separate call + else if (bundlerGasEstimate.maxFeePerGas && bundlerGasEstimate.maxPriorityFeePerGas) { + partialtx.maxFeePerGas = bundlerGasEstimate.maxFeePerGas; + partialtx.maxPriorityFeePerGas = bundlerGasEstimate.maxPriorityFeePerGas; + } + + if (bundlerGasEstimate.preVerificationGas) { + partialtx.preVerificationGas = BigNumber.from(bundlerGasEstimate.preVerificationGas); + partialtx.verificationGasLimit = BigNumber.from(bundlerGasEstimate.verificationGasLimit ?? bundlerGasEstimate.verificationGas); + const expectedCallGasLimit = BigNumber.from(bundlerGasEstimate.callGasLimit); + if (!callGasLimit) + partialtx.callGasLimit = expectedCallGasLimit; + else if (BigNumber.from(callGasLimit).lt(expectedCallGasLimit)) + throw new ErrorHandler(`CallGasLimit is too low. Expected atleast ${expectedCallGasLimit.toString()}`); + } } return partialtx;