Skip to content

Commit

Permalink
fix: overrides calculation and indent
Browse files Browse the repository at this point in the history
  • Loading branch information
sherifahmed990 committed Apr 12, 2024
1 parent 77979d0 commit 0c059ff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 50 deletions.
60 changes: 24 additions & 36 deletions src/account/Safe/SafeAccountWebAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 ||
Expand Down Expand Up @@ -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;
}

Expand Down
22 changes: 8 additions & 14 deletions src/paymaster/CandidePaymaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0c059ff

Please sign in to comment.