Skip to content

Commit

Permalink
fix: populateTransaction estimate fee only if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
petarTxFusion committed Jan 17, 2025
1 parent 6476368 commit 8c85348
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,10 @@ export class Signer extends AdapterL2(ethers.JsonRpcSigner) {
}
if (
!tx.gasLimit ||
(!tx.gasPrice && (!tx.maxFeePerGas || !tx.maxPriorityFeePerGas))
(!tx.gasPrice &&
(!tx.maxFeePerGas ||
tx.maxPriorityFeePerGas === null ||
tx.maxPriorityFeePerGas === undefined))
) {
const fee = await this.providerL2!.estimateFee(tx);
tx.gasLimit ??= fee.gasLimit;
Expand Down
4 changes: 3 additions & 1 deletion src/smart-account-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export const populateTransactionECDSA: TransactionBuilder = async (
if (
!populatedTx.gasLimit ||
(!populatedTx.gasPrice &&
(!populatedTx.maxFeePerGas || !populatedTx.maxPriorityFeePerGas))
(!populatedTx.maxFeePerGas ||
populatedTx.maxPriorityFeePerGas === null ||
populatedTx.maxPriorityFeePerGas === undefined))
) {
let fromToUse = populatedTx.from;
const isContractAccount =
Expand Down
4 changes: 3 additions & 1 deletion src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,9 @@ export class Wallet extends AdapterL2(AdapterL1(ethers.Wallet)) {
!tx.customData ||
!tx.customData.gasPerPubdata ||
(!populated.gasPrice &&
(!populated.maxFeePerGas || !populated.maxPriorityFeePerGas))
(!populated.maxFeePerGas ||
populated.maxPriorityFeePerGas === null ||
populated.maxPriorityFeePerGas === undefined))
) {
fee = await this.provider.estimateFee(populated);
populated.gasLimit ??= fee.gasLimit;
Expand Down

0 comments on commit 8c85348

Please sign in to comment.