From 0c059ff454edd2caf66aa4dc2a14069e215f0589 Mon Sep 17 00:00:00 2001 From: Sherif Abdelmoatty Date: Fri, 12 Apr 2024 17:27:09 +0300 Subject: [PATCH] fix: overrides calculation and indent --- src/account/Safe/SafeAccountWebAuth.ts | 60 +++++++++++--------------- src/paymaster/CandidePaymaster.ts | 22 ++++------ 2 files changed, 32 insertions(+), 50 deletions(-) diff --git a/src/account/Safe/SafeAccountWebAuth.ts b/src/account/Safe/SafeAccountWebAuth.ts index fc738c2..8982dd4 100644 --- a/src/account/Safe/SafeAccountWebAuth.ts +++ b/src/account/Safe/SafeAccountWebAuth.ts @@ -546,21 +546,17 @@ export class SafeAccountWebAuth extends SafeAccount { maxFeePerGas = overrids.maxFeePerGas ?? - maxFeePerGas * - BigInt( - Math.floor( - ((overrids.maxFeePerGasPercentageMultiplier ?? 0) + 100) / 100, - ), - ); + ( + maxFeePerGas * + BigInt((overrids.maxFeePerGasPercentageMultiplier ?? 0) + 100) + )/100n; + maxPriorityFeePerGas = overrids.maxPriorityFeePerGas ?? - maxPriorityFeePerGas * - BigInt( - Math.floor( - ((overrids.maxPriorityFeePerGasPercentageMultiplier ?? 0) + 100) / - 100, - ), - ); + ( + maxPriorityFeePerGas * + BigInt((overrids.maxPriorityFeePerGasPercentageMultiplier ?? 0) + 100) + )/100n; const userOperation: UserOperation = { ...UserOperationDummyValues, @@ -575,7 +571,6 @@ export class SafeAccountWebAuth extends SafeAccount { let preVerificationGas = UserOperationDummyValues.preVerificationGas; let verificationGasLimit = UserOperationDummyValues.verificationGasLimit; let callGasLimit = UserOperationDummyValues.callGasLimit; - if ( overrids.preVerificationGas == null || @@ -618,35 +613,28 @@ export class SafeAccountWebAuth extends SafeAccount { ) { throw RangeError("callGasLimit overrid can't be negative"); } + userOperation.preVerificationGas = overrids.preVerificationGas ?? - preVerificationGas * - BigInt( - Math.floor( - ((overrids.preVerificationGasPercentageMultiplier ?? 0) + 100) / - 100, - ), - ); + ( + preVerificationGas * + BigInt((overrids.preVerificationGasPercentageMultiplier ?? 0) + 100) + )/100n; userOperation.verificationGasLimit = overrids.verificationGasLimit ?? - verificationGasLimit * - BigInt( - Math.floor( - ((overrids.verificationGasLimitPercentageMultiplier ?? 0) + 100) / - 100, - ), - ); - + ( + verificationGasLimit * + BigInt((overrids.verificationGasLimitPercentageMultiplier ?? 0) + 100) + )/100n; + userOperation.callGasLimit = overrids.callGasLimit ?? - callGasLimit * - BigInt( - Math.floor( - ((overrids.callGasLimitPercentageMultiplier ?? 0) + 100) / 100, - ), - ); - + ( + callGasLimit * + BigInt((overrids.callGasLimitPercentageMultiplier ?? 0) + 100) + )/100n; + return userOperation; } diff --git a/src/paymaster/CandidePaymaster.ts b/src/paymaster/CandidePaymaster.ts index 4f399d8..ffd89c1 100644 --- a/src/paymaster/CandidePaymaster.ts +++ b/src/paymaster/CandidePaymaster.ts @@ -272,28 +272,22 @@ export class CandidePaymaster extends Paymaster { overrides.preVerificationGas ?? ( preVerificationGas * - BigInt( - ((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100) - ) + BigInt((overrides.preVerificationGasPercentageMultiplier ?? 0) + 100) )/100n; - userOperation.verificationGasLimit = + userOperation.verificationGasLimit = overrides.verificationGasLimit ?? ( verificationGasLimit * - BigInt( - ((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100) - ) + BigInt((overrides.verificationGasLimitPercentageMultiplier ?? 0) + 100) )/100n; userOperation.callGasLimit = - overrides.callGasLimit ?? - ( - callGasLimit * - BigInt( - ((overrides.callGasLimitPercentageMultiplier ?? 0) + 100) - ) - )/100n; + overrides.callGasLimit ?? + ( + callGasLimit * + BigInt((overrides.callGasLimitPercentageMultiplier ?? 0) + 100) + )/100n; //add small buffer to preVerification gas userOperation.preVerificationGas = userOperation.preVerificationGas + 100n;