1use crate::cmd::rpc_provider;
2use alloy_primitives::Address;
3use alloy_provider::ext::TxPoolApi;
4use clap::Parser;
5use foundry_cli::{json::print_json_object, opts::RpcOpts};
6
7#[derive(Debug, Parser, Clone)]
9pub enum TxPoolSubcommands {
10 Content {
12 #[command(flatten)]
13 args: RpcOpts,
14 },
15 ContentFrom {
17 #[arg(short, long)]
19 from: Address,
20 #[command(flatten)]
21 args: RpcOpts,
22 },
23 Inspect {
25 #[command(flatten)]
26 args: RpcOpts,
27 },
28 Status {
30 #[command(flatten)]
31 args: RpcOpts,
32 },
33}
34
35impl TxPoolSubcommands {
36 pub async fn run(self) -> eyre::Result<()> {
37 let args = match &self {
38 Self::Content { args }
39 | Self::ContentFrom { args, .. }
40 | Self::Inspect { args }
41 | Self::Status { args } => args,
42 };
43 let provider = rpc_provider(args)?;
44 match self {
45 Self::Content { .. } => print_json_object(provider.txpool_content().await?),
46 Self::ContentFrom { from, .. } => {
47 print_json_object(provider.txpool_content_from(from).await?)
48 }
49 Self::Inspect { .. } => print_json_object(provider.txpool_inspect().await?),
50 Self::Status { .. } => print_json_object(provider.txpool_status().await?),
51 }
52 }
53}