Skip to content

Commit 90bedb6

Browse files
authored
Release v5.1.1
removed multiple estimations and changed error message (#62)
1 parent 58d0c08 commit 90bedb6

File tree

8 files changed

+37
-39
lines changed

8 files changed

+37
-39
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
## [5.1.1] - 2025-03-19
3+
### Fix
4+
- Removed multiple estimations when paymaster is set in the userOp
25

36
## [5.1.0] - 2025-03-06
47
### Updated

bun.lockb

-406 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@etherspot/modular-sdk",
3-
"version": "5.1.0",
3+
"version": "5.1.1",
44
"description": "Etherspot Modular SDK - build with ERC-7579 smart accounts modules",
55
"keywords": [
66
"ether",

src/sdk/base/BaseAccountAPI.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,15 @@ export abstract class BaseAccountAPI {
459459
partialUserOp.paymaster = paymasterData.result.paymaster;
460460
partialUserOp.paymasterVerificationGasLimit = paymasterData.result.paymasterVerificationGasLimit;
461461
partialUserOp.paymasterPostOpGasLimit = paymasterData.result.paymasterPostOpGasLimit;
462+
if (paymasterData?.result.maxFeePerGas && paymasterData?.result.maxPriorityFeePerGas) {
463+
partialUserOp.maxFeePerGas = paymasterData.result.maxFeePerGas;
464+
partialUserOp.maxPriorityFeePerGas = paymasterData.result.maxPriorityFeePerGas;
465+
}
462466
}
463467
partialUserOp.paymasterData = paymasterData ? paymasterData.result.paymasterData : '0x';
468+
partialUserOp.preVerificationGas = paymasterData ? paymasterData.result.preVerificationGas : this.getPreVerificationGas(partialUserOp);
464469
return {
465470
...partialUserOp,
466-
preVerificationGas: this.getPreVerificationGas(partialUserOp),
467471
signature: info.dummySignature ?? '0x',
468472
};
469473
}
@@ -473,15 +477,6 @@ export abstract class BaseAccountAPI {
473477
* @param userOp the UserOperation to sign (with signature field ignored)
474478
*/
475479
async signUserOp(userOp: UserOperation): Promise<UserOperation> {
476-
if (this.paymasterAPI != null) {
477-
const paymasterData = await this.paymasterAPI.getPaymasterData(userOp);
478-
userOp.verificationGasLimit = paymasterData.result.verificationGasLimit;
479-
userOp.preVerificationGas = paymasterData.result.preVerificationGas;
480-
userOp.callGasLimit = paymasterData.result.callGasLimit;
481-
userOp.paymaster = paymasterData.result.paymaster;
482-
userOp.paymasterVerificationGasLimit = paymasterData.result.paymasterVerificationGasLimit;
483-
userOp.paymasterPostOpGasLimit = paymasterData.result.paymasterPostOpGasLimit;
484-
}
485480
const userOpHash = await this.getUserOpHash(userOp);
486481
const signature = await this.signUserOpHash(userOpHash);
487482
return {

src/sdk/base/EtherspotWalletAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ export class EtherspotWalletAPI extends BaseAccountAPI {
397397
const convertedResult = result.map(item => ({
398398
...item,
399399
// Convert `value` from BigNumberish to bigint
400-
value: typeof item.value === 'bigint' ? item.value : BigInt(item.value.toString()),
400+
value: typeof item.value === 'bigint' ? item.value : BigNumber.from(item.value.toString()).toBigInt(),
401401
}));
402402

403403
//TODO-Test-LibraryFix identify the syntax for viem to pass array of tuple

src/sdk/base/VerifyingPaymasterAPI.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export interface PaymasterResponse {
1919
callGasLimit: string;
2020
paymasterVerificationGasLimit: string;
2121
paymasterPostOpGasLimit: string;
22+
maxFeePerGas?: string;
23+
maxPriorityFeePerGas?: string;
2224
}
2325
}
2426

src/sdk/errorHandler/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const errorMsg = {
22
'429': 'Rate limit exceeded for the given bundler api key. Please contact bundler team for increasing bandwidth.', // Rate limit quota execeeded
3-
'-32521': 'Check for balance in your Smart wallet', // execution reverted
4-
'-32500': `Please make sure you have enough funds for wallet creation.`, // transaction rejected by entryPoint's simulateValidation, during wallet creation or validation
3+
'-32521': 'UserOp failed. Please contact wallet provider for further details', // execution reverted
4+
'-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
55
'-32501': `Check paymaster data`, // transaction rejected by paymaster's validatePaymasterUserOp
66
'-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
77
'-32503': 'validUntil and validAfter cannot be past timestamps', // UserOperation out of time-range

src/sdk/sdk.ts

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -195,31 +195,29 @@ export class ModularSdk {
195195
partialtx.factory = this.etherspotWallet.factoryAddress;
196196
}
197197

198-
const bundlerGasEstimate = await this.bundler.getVerificationGasInfo(partialtx);
199-
200-
// if user has specified the gas prices then use them
201-
if (gasDetails?.maxFeePerGas && gasDetails?.maxPriorityFeePerGas) {
202-
partialtx.maxFeePerGas = gasDetails.maxFeePerGas;
203-
partialtx.maxPriorityFeePerGas = gasDetails.maxPriorityFeePerGas;
204-
}
205-
// if estimation has gas prices use them, otherwise fetch them in a separate call
206-
else if (bundlerGasEstimate.maxFeePerGas && bundlerGasEstimate.maxPriorityFeePerGas) {
207-
partialtx.maxFeePerGas = bundlerGasEstimate.maxFeePerGas;
208-
partialtx.maxPriorityFeePerGas = bundlerGasEstimate.maxPriorityFeePerGas;
209-
} else {
210-
const gas = await this.getGasFee();
211-
partialtx.maxFeePerGas = gas.maxFeePerGas;
212-
partialtx.maxPriorityFeePerGas = gas.maxPriorityFeePerGas;
213-
}
214-
215-
if (bundlerGasEstimate.preVerificationGas) {
216-
partialtx.preVerificationGas = BigNumber.from(bundlerGasEstimate.preVerificationGas);
217-
partialtx.verificationGasLimit = BigNumber.from(bundlerGasEstimate.verificationGasLimit ?? bundlerGasEstimate.verificationGas);
218-
const expectedCallGasLimit = BigNumber.from(bundlerGasEstimate.callGasLimit);
219-
if (!callGasLimit)
220-
partialtx.callGasLimit = expectedCallGasLimit;
221-
else if (BigNumber.from(callGasLimit).lt(expectedCallGasLimit))
222-
throw new ErrorHandler(`CallGasLimit is too low. Expected atleast ${expectedCallGasLimit.toString()}`);
198+
if (!paymasterDetails?.url) {
199+
const bundlerGasEstimate = await this.bundler.getVerificationGasInfo(partialtx);
200+
201+
// if user has specified the gas prices then use them
202+
if (gasDetails?.maxFeePerGas && gasDetails?.maxPriorityFeePerGas) {
203+
partialtx.maxFeePerGas = gasDetails.maxFeePerGas;
204+
partialtx.maxPriorityFeePerGas = gasDetails.maxPriorityFeePerGas;
205+
}
206+
// if estimation has gas prices use them, otherwise fetch them in a separate call
207+
else if (bundlerGasEstimate.maxFeePerGas && bundlerGasEstimate.maxPriorityFeePerGas) {
208+
partialtx.maxFeePerGas = bundlerGasEstimate.maxFeePerGas;
209+
partialtx.maxPriorityFeePerGas = bundlerGasEstimate.maxPriorityFeePerGas;
210+
}
211+
212+
if (bundlerGasEstimate.preVerificationGas) {
213+
partialtx.preVerificationGas = BigNumber.from(bundlerGasEstimate.preVerificationGas);
214+
partialtx.verificationGasLimit = BigNumber.from(bundlerGasEstimate.verificationGasLimit ?? bundlerGasEstimate.verificationGas);
215+
const expectedCallGasLimit = BigNumber.from(bundlerGasEstimate.callGasLimit);
216+
if (!callGasLimit)
217+
partialtx.callGasLimit = expectedCallGasLimit;
218+
else if (BigNumber.from(callGasLimit).lt(expectedCallGasLimit))
219+
throw new ErrorHandler(`CallGasLimit is too low. Expected atleast ${expectedCallGasLimit.toString()}`);
220+
}
223221
}
224222

225223
return partialtx;

0 commit comments

Comments
 (0)