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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use std::any::Any;
use solana_program::pubkey::Pubkey;
use clap::{Parser, Subcommand};
use common::init::{Matche};
use crate::CONFIG_FILE;

#[derive(Parser)]
#[clap(name = "aaa", author, version, about, long_about = None)]
#[clap(propagate_version = true)]
pub struct Cli {
    /// crema cli config, consistent with the solana cli config (default: $HOME/.config/solana/cli/config.yml)
    #[clap(long, short, value_parser, global = true, takes_value = true,
    default_value_t = {
    if let Some(ref config_file) = * CONFIG_FILE {
    config_file.to_string()
    } else {
    String::new()
    }
    }
    )]
    pub config_file: String,
    /// owner key default from config file Keypair
    #[clap(long, short, value_parser, global = true, takes_value = true)]
    pub owner: Option<String>,
    // config_file: String,
    // owner: String,
    #[clap(subcommand)]
    pub command: MintWrapperCli,
}

impl Matche for Cli {
    fn as_any(&self) -> &dyn Any {
        self
    }
    fn get_config_file(&self) -> &str {
        self.config_file.as_str()
    }
    fn get_owner(&self) -> &str {
        let s = self.owner.as_ref();
        if s.is_some() {
            s.unwrap().as_str()
        } else {
            ""
        }
    }
}

#[derive(Subcommand)]
pub enum MintWrapperCli {
    /// Create a quarry_mint_wrapper:MintWrapper
    New {
        /// The token mint address
        mint: Pubkey,
        /// The token mint hardcap
        hardcap: u64,
    },
    /// Get the quarry_mint_wrapper:MintWrapper list
    List,
    /// Get the quarry_mint_wrapper:MintWrapper information
    Info {
        /// The mint wrapper address.
        wrapper: Pubkey,
    },
    /// Transfer mint authority from mintWrapper to wallet
    BackAuthority {
        /// The mint wrapper address
        wrapper: Pubkey,
        /// The dest Authority
        authority: Pubkey,
    },
    /// Transfer mint authority to mintWrapper
    TransferAuthority {
        /// The mint wrapper address
        wrapper: Pubkey,
    },
    /// The quarry_mint_wrapper:Minter sub commands
    Minter {
        #[clap(subcommand)]
        command: MinterCommands,
    },
}

#[derive(Subcommand)]
pub enum MinterCommands {
    /// Create a new quarry_mint_wrapper:Minter
    New {
        /// The mint wrapper address
        wrapper: Pubkey,
        /// The minter allowance
        allowance: u64,
        /// The minter authority address
        authority: Pubkey,
    },
    /// Get quarry_mint_wrapper:Minter list
    List {
        /// The mint wrapper address
        wrapper: String,
    },
    /// Get the quarry_mint_wrapper:Minter information
    Info {
        /// The mint wrapper address
        wrapper: Pubkey,
        /// The authority of the minter
        authority: Pubkey,
    },
    /// Update the quarry_mint_wrapper:Minter allowance
    Update {
        /// The mint wrapper address
        wrapper: Pubkey,
        /// The authority of the minter
        allowance: u64,
        /// The minter's new allowance.
        authority: Pubkey,
    },
    /// Update the quarry_mint_wrapper:Minter allowance
    Mint {
        /// The mint wrapper address
        wrapper: Pubkey,
        /// The dest owner
        owner: Pubkey,
        /// The minter's new allowance.
        amount: f64,
    },
}