Skip to content

Commit

Permalink
Fix estimation on non legacy chains for scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrigada committed Jan 24, 2025
1 parent c427960 commit e555f10
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions crates/script/src/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,26 @@ impl BundledState {
}),
),
(false, _, _) => {
let mut fees = provider.estimate_eip1559_fees(None).await.wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?;
if self.script_config.config.zksync.run_in_zk_mode() {
// NOTE(zk): We need to avoid estimating eip1559 fees for zk transactions
// as the fee is estimated later. This branch is for non legacy chains (zkchains).
(Some(provider.get_gas_price().await?), None)
} else {
let mut fees = provider
.estimate_eip1559_fees(None)
.await
.wrap_err("Failed to estimate EIP1559 fees. This chain might not support EIP1559, try adding --legacy to your command.")?;

if let Some(gas_price) = self.args.with_gas_price {
fees.max_fee_per_gas = gas_price.to();
}
if let Some(gas_price) = self.args.with_gas_price {
fees.max_fee_per_gas = gas_price.to();
}

if let Some(priority_gas_price) = self.args.priority_gas_price {
fees.max_priority_fee_per_gas = priority_gas_price.to();
}
if let Some(priority_gas_price) = self.args.priority_gas_price {
fees.max_priority_fee_per_gas = priority_gas_price.to();
}

(None, Some(fees))
(None, Some(fees))
}
}
};

Expand Down

0 comments on commit e555f10

Please sign in to comment.