mithril_client_cli/commands/cardano_transaction/
mod.rs

1//! Commands for the Cardano Transaction Snapshot artifact & Cardano Transactions Proof
2mod certify;
3mod snapshot_list;
4mod snapshot_show;
5
6pub use certify::*;
7pub use snapshot_list::*;
8pub use snapshot_show::*;
9
10use crate::CommandContext;
11use clap::Subcommand;
12use mithril_client::MithrilResult;
13
14/// Cardano transactions management
15#[derive(Subcommand, Debug, Clone)]
16#[command(about = "Cardano transactions management (alias: ctx)")]
17pub enum CardanoTransactionCommands {
18    /// Cardano transaction snapshot commands
19    #[clap(subcommand)]
20    Snapshot(CardanoTransactionSnapshotCommands),
21
22    /// Certify that a given list of transaction hashes are included in the Cardano transactions set
23    #[clap(arg_required_else_help = false)]
24    Certify(CardanoTransactionsCertifyCommand),
25}
26
27/// Cardano transactions set
28#[derive(Subcommand, Debug, Clone)]
29pub enum CardanoTransactionSnapshotCommands {
30    /// List Cardano transaction sets
31    #[clap(arg_required_else_help = false)]
32    List(CardanoTransactionSnapshotListCommand),
33
34    /// Show Cardano transaction sets
35    #[clap(arg_required_else_help = false)]
36    Show(CardanoTransactionsSnapshotShowCommand),
37}
38
39impl CardanoTransactionCommands {
40    /// Execute Cardano transaction command
41    pub async fn execute(&self, config_builder: CommandContext) -> MithrilResult<()> {
42        match self {
43            Self::Snapshot(cmd) => cmd.execute(config_builder).await,
44            Self::Certify(cmd) => cmd.execute(config_builder).await,
45        }
46    }
47}
48
49impl CardanoTransactionSnapshotCommands {
50    /// Execute Cardano transaction snapshot command
51    pub async fn execute(&self, config_builder: CommandContext) -> MithrilResult<()> {
52        match self {
53            Self::List(cmd) => cmd.execute(config_builder).await,
54            Self::Show(cmd) => cmd.execute(config_builder).await,
55        }
56    }
57}