Skip to content
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
15 changes: 5 additions & 10 deletions src/sdk/base/BaseAccountAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
}
Expand All @@ -473,15 +477,6 @@ export abstract class BaseAccountAPI {
* @param userOp the UserOperation to sign (with signature field ignored)
*/
async signUserOp(userOp: UserOperation): Promise<UserOperation> {
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 {
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/base/EtherspotWalletAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/sdk/base/VerifyingPaymasterAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface PaymasterResponse {
callGasLimit: string;
paymasterVerificationGasLimit: string;
paymasterPostOpGasLimit: string;
maxFeePerGas?: string;
maxPriorityFeePerGas?: string;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/sdk/errorHandler/constants.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
48 changes: 23 additions & 25 deletions src/sdk/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down