cargo_tangle/create/
types.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use clap::{Args, ValueEnum};

#[derive(Debug, Clone, Args)]
pub struct CreateArgs {
    /// The name of the blueprint
    #[arg(short, long, value_name = "NAME", env = "NAME")]
    pub name: String,

    #[command(flatten)]
    pub blueprint_type: BlueprintType,
}

#[derive(Debug, Clone, Args)]
#[group(required = false, multiple = false)]
pub struct BlueprintType {
    /// Create a Tangle blueprint
    #[arg(long, conflicts_with = "eigenlayer")]
    pub tangle: bool,

    /// Create an EigenLayer blueprint
    #[arg(long, value_name = "VARIANT", value_enum, num_args = 0..=1, default_value = "bls")]
    pub eigenlayer: Option<EigenlayerVariant>,
}

impl Default for BlueprintType {
    fn default() -> Self {
        Self {
            tangle: true,
            eigenlayer: None,
        }
    }
}

#[derive(Debug, Default, Clone, Copy, ValueEnum)]
pub enum EigenlayerVariant {
    #[default]
    BLS,
    ECDSA,
}

impl BlueprintType {
    pub fn get_type(&self) -> Option<BlueprintVariant> {
        if self.tangle {
            Some(BlueprintVariant::Tangle)
        } else {
            self.eigenlayer.map(BlueprintVariant::Eigenlayer)
        }
    }
}

#[derive(Debug, Clone)]
pub enum BlueprintVariant {
    Tangle,
    Eigenlayer(EigenlayerVariant),
}