diff --git a/bolt-cli/src/cli.rs b/bolt-cli/src/cli.rs index 646c0a546..c0e708c18 100644 --- a/bolt-cli/src/cli.rs +++ b/bolt-cli/src/cli.rs @@ -101,6 +101,14 @@ pub struct SendCommand { #[clap(long, env = "BLOB", default_value = "false")] pub blob: bool, + /// The max fee per gas in gwei. + #[clap(long, env = "MAX_FEE")] + pub max_fee: Option, + + /// The max priority fee per gas in gwei. + #[clap(long, env = "PRIORITY_FEE", default_value = "2")] + pub priority_fee: String, + /// If set, the transaction will target the devnet environment. /// This is only used in Kurtosis for internal testing purposes #[clap(long, hide = true, env = "DEVNET", default_value = "false")] diff --git a/bolt-cli/src/commands/send.rs b/bolt-cli/src/commands/send.rs index c2b7367eb..788894b70 100644 --- a/bolt-cli/src/commands/send.rs +++ b/bolt-cli/src/commands/send.rs @@ -4,7 +4,7 @@ use alloy::{ consensus::{BlobTransactionSidecar, SidecarBuilder, SimpleCoder, Transaction}, eips::eip2718::Encodable2718, network::{EthereumWallet, TransactionBuilder, TransactionBuilder4844}, - primitives::{keccak256, Address, B256, U256}, + primitives::{keccak256, utils::parse_units, Address, B256, U256}, providers::{ProviderBuilder, SendableTx}, rpc::types::TransactionRequest, signers::{local::PrivateKeySigner, Signer}, @@ -25,16 +25,29 @@ impl SendCommand { /// Run the `send` command. pub async fn run(self) -> Result<()> { let wallet: PrivateKeySigner = self.private_key.parse().wrap_err("invalid private key")?; + let max_fee = self.max_fee.as_ref().map(|fee| { + parse_units(fee, "gwei").expect("Correct unit").try_into().expect("Correct unit") + }); + + let priority_fee = parse_units(&self.priority_fee, "gwei") + .expect("Correct unit") + .try_into() + .expect("Correct unit"); if self.devnet { self.send_devnet_transaction(&wallet).await } else { - self.send_transaction(&wallet).await + self.send_transaction(&wallet, max_fee, priority_fee).await } } /// Send a transaction. - async fn send_transaction(self, wallet: &PrivateKeySigner) -> Result<()> { + async fn send_transaction( + self, + wallet: &PrivateKeySigner, + max_fee: Option, + priority_fee: u128, + ) -> Result<()> { let transaction_signer = EthereumWallet::from(wallet.clone()); let provider = ProviderBuilder::new() .with_recommended_fillers() @@ -73,6 +86,12 @@ impl SendCommand { for _ in 0..self.count { // generate a simple self-transfer of ETH let mut req = create_tx_request(wallet.address(), self.blob); + if let Some(max_fee) = max_fee { + req.set_max_fee_per_gas(max_fee); + } + + req.set_max_priority_fee_per_gas(priority_fee); + if let Some(next_nonce) = next_nonce { req.set_nonce(next_nonce); } diff --git a/bolt-cli/src/common/keystore.rs b/bolt-cli/src/common/keystore.rs index 464a1e5cd..76e8ce061 100644 --- a/bolt-cli/src/common/keystore.rs +++ b/bolt-cli/src/common/keystore.rs @@ -51,7 +51,7 @@ impl KeystoreSecret { /// Load the keystore passwords from a directory containing individual password files. pub fn from_directory(root_dir: &str) -> Result { let mut secrets = HashMap::new(); - for entry in fs::read_dir(&root_dir) + for entry in fs::read_dir(root_dir) .wrap_err(format!("failed to read secrets directory. path: {}", &root_dir))? { let entry = entry.wrap_err("Failed to read secrets directory entry")?;