Skip to content

Commit

Permalink
max fee per gas config
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan committed Jun 13, 2024
1 parent 95ff272 commit 652f9d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 13 additions & 3 deletions check/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ impl DeployConfig {
gas: Option<U256>,
client: &SignerClient,
) -> Result<TransactionReceipt> {
let mut tx = TypedTransaction::Eip1559(tx);
if let Some(gas) = gas {
tx.set_gas(gas);
let mut tx = tx;
tx.gas = gas;
if let Some(max_fee) = self.max_fee_per_gas_gwei {
tx.max_fee_per_gas = Some(gwei_to_wei(max_fee)?);
}
let tx = TypedTransaction::Eip1559(tx);

let tx = client.send_transaction(tx, None).await?;
let tx_hash = tx.tx_hash();
Expand Down Expand Up @@ -230,3 +232,11 @@ fn format_gas(gas: U256) -> String {
text.pink()
}
}

fn gwei_to_wei(gwei: U256) -> Result<U256> {
let wei_per_gwei: U256 = U256::from(10u64.pow(9));
match gwei.checked_mul(wei_per_gwei) {
Some(wei) => Ok(wei),
None => bail!("overflow occurred while converting gwei to wei"),
}
}
5 changes: 4 additions & 1 deletion check/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// For licensing, see https://github.com/OffchainLabs/cargo-stylus/blob/main/licenses/COPYRIGHT.md

use clap::{ArgGroup, Args, Parser};
use ethers::types::H160;
use ethers::types::{H160, U256};
use eyre::{eyre, Context, Result};
use std::path::PathBuf;
use tokio::runtime::Builder;
Expand Down Expand Up @@ -83,6 +83,9 @@ struct DeployConfig {
/// Only perform gas estimation.
#[arg(long)]
estimate_gas: bool,
#[arg(long)]
/// Optional max fee per gas in gwei units.
max_fee_per_gas_gwei: Option<U256>,
}

#[derive(Clone, Debug, Args)]
Expand Down

0 comments on commit 652f9d2

Please sign in to comment.