Skip to content

Commit d693f64

Browse files
feat(cast): added custom polling interval args (#12387)
* feat(cast): added custom polling interval args * feat(cast): added a custom alias for poll interval * feat(cast): updated with clippy suggestion * chore: ran formatter
1 parent 2fe3a4b commit d693f64

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crates/cast/src/cmd/send.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use foundry_cli::{
1515
utils,
1616
utils::LoadConfig,
1717
};
18-
use std::{path::PathBuf, str::FromStr};
18+
use std::{path::PathBuf, str::FromStr, time::Duration};
1919

2020
/// CLI arguments for `cast send`.
2121
#[derive(Debug, Parser)]
@@ -41,6 +41,10 @@ pub struct SendTxArgs {
4141
#[arg(long, default_value = "1")]
4242
confirmations: u64,
4343

44+
/// Polling interval for transaction receipts (in seconds).
45+
#[arg(long, alias = "poll-interval", env = "ETH_POLL_INTERVAL")]
46+
poll_interval: Option<u64>,
47+
4448
#[command(subcommand)]
4549
command: Option<SendTxSubcommands>,
4650

@@ -100,6 +104,7 @@ impl SendTxArgs {
100104
unlocked,
101105
path,
102106
timeout,
107+
poll_interval,
103108
} = self;
104109

105110
let blob_data = if let Some(path) = path { Some(std::fs::read(path)?) } else { None };
@@ -135,6 +140,10 @@ impl SendTxArgs {
135140
let config = eth.load_config()?;
136141
let provider = utils::get_provider(&config)?;
137142

143+
if let Some(interval) = poll_interval {
144+
provider.client().set_poll_interval(Duration::from_secs(interval))
145+
}
146+
138147
let builder = CastTxBuilder::new(&provider, tx, &config)
139148
.await?
140149
.with_to(to)
@@ -204,7 +213,6 @@ async fn cast_send<P: Provider<AnyNetwork>>(
204213
) -> Result<()> {
205214
let cast = Cast::new(provider);
206215
let pending_tx = cast.send(tx).await?;
207-
208216
let tx_hash = pending_tx.inner().tx_hash();
209217

210218
if cast_async {

0 commit comments

Comments
 (0)