unc-cli-rs 0.8.0

human-friendly console utility that helps to interact with unc Protocol from command line.
Documentation
#[derive(Debug, Clone, clap::Parser)]
/// This is a legacy `call` command. Once you run it with the specified arguments, new syntax command will be suggested.
pub struct CallArgs {
    contract_account_id: String,
    method_name: String,
    #[clap(long, default_value_t = false)]
    base64: bool,
    args: String,
    #[clap(long, aliases = ["account_id", "accountId"])]
    account_id: String,
    #[clap(long, default_value_t = 30_000_000_000_000)]
    gas: u64,
    #[clap(long, default_value = "0")]
    deposit: String,
    #[clap(allow_hyphen_values = true, num_args = 0..)]
    _unknown_args: Vec<String>,
}

impl CallArgs {
    pub fn to_cli_args(&self, network_config: String) -> Vec<String> {
        let format_args = if self.base64 {
            "base64-args"
        } else {
            "json-args"
        };
        vec![
            "contract".to_owned(),
            "call-function".to_owned(),
            "as-transaction".to_owned(),
            self.contract_account_id.to_owned(),
            self.method_name.to_owned(),
            format_args.to_owned(),
            self.args.to_owned(),
            "prepaid-gas".to_owned(),
            format!("{} TeraGas", self.gas / 1_000_000_000_000),
            "attached-deposit".to_owned(),
            format!("{} unc", self.deposit),
            "sign-as".to_owned(),
            self.account_id.to_owned(),
            "network-config".to_owned(),
            network_config,
            "sign-with-keychain".to_owned(),
            "send".to_owned(),
        ]
    }
}