Skip to content

Commit

Permalink
Remove the hacky implementation in estimateUserOperationGas::callGasL…
Browse files Browse the repository at this point in the history
…imit.
  • Loading branch information
jayden-sudo committed Nov 22, 2023
1 parent 08e1e4b commit 654d182
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-cycles-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@soulwallet/sdk": patch
---

Remove the hacky implementation in estimateUserOperationGas::callGasLimit.
15 changes: 2 additions & 13 deletions packages/soulwallet-sdk/src/soulWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,19 +600,8 @@ export class SoulWallet implements ISoulWallet {
}
userOp.preVerificationGas = userOpGasRet.OK.preVerificationGas;
userOp.verificationGasLimit = userOpGasRet.OK.verificationGasLimit;
// Value of 'gas': Even number: automatic setting,
// Odd number: manually specified. Do not override!
const _callGasLimit = BigInt(userOp.callGasLimit);
const isEven = _callGasLimit % BigInt(2) === BigInt(0);
if (isEven) {
// auto
let _newCallGasLimit = BigInt(userOpGasRet.OK.callGasLimit);
if (_newCallGasLimit % BigInt(2) === BigInt(1)) {
// odd number -> even number
_newCallGasLimit += BigInt(1);
}
userOp.callGasLimit = `0x${_newCallGasLimit.toString(16)}`;
}
userOp.callGasLimit = `0x${BigInt(userOpGasRet.OK.callGasLimit).toString(16)}`;

GasOverhead.calcGasOverhead(userOp, signkeyType);
return new Ok(true);
} finally {
Expand Down

0 comments on commit 654d182

Please sign in to comment.