Move utils/quartz-proto to core/quartz-proto Fix Cargo.toml paths Add default working-directory for cosmwasm CI jobs Fix default working-directory Rename .cargo/config -> config.toml Update working-directory Update cosmwasm workflows Update rust.yml paths Add aliases to cargo config.toml Test working-directory Update cosmwasm CI jobs Use --manifest-path Use dtolnay/rust-toolchain action Fix workflow Remove --locked SSH agent SSH agent for schema Remove unused SSH key Exclude cw-tee-mtcs from rust CI jobs Clippy fix cargo fmt Add CONTRIBUTING.md Update README.md
54 lines
1.5 KiB
Rust
54 lines
1.5 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use clap::Parser;
|
|
use cosmrs::{tendermint::chain::Id, AccountId};
|
|
use displaydoc::Display;
|
|
use subtle_encoding::{bech32::decode as bech32_decode, Error as Bech32DecodeError};
|
|
use thiserror::Error;
|
|
use tonic::transport::Endpoint;
|
|
|
|
#[derive(Display, Error, Debug)]
|
|
pub enum AddressError {
|
|
/// Address is not bech32 encoded
|
|
NotBech32Encoded(#[source] Bech32DecodeError),
|
|
/// Human readable part mismatch (expected `wasm`, found {0})
|
|
HumanReadableMismatch(String),
|
|
}
|
|
|
|
#[derive(Debug, Parser)]
|
|
#[command(author, version, about, long_about = None)]
|
|
pub struct Cli {
|
|
/// RPC server address
|
|
#[clap(long, default_value = "http://localhost:11090")]
|
|
pub enclave_addr: Endpoint,
|
|
|
|
/// Blockchain node gRPC URL
|
|
#[arg(short, long, default_value = "tcp://127.0.0.1:9090")]
|
|
pub node_addr: Endpoint,
|
|
|
|
/// Chain-id of MTCS chain
|
|
#[arg(long, default_value = "testing")]
|
|
pub chain_id: Id,
|
|
|
|
/// Smart contract address
|
|
#[arg(short, long, value_parser = wasm_address)]
|
|
pub contract: AccountId,
|
|
|
|
/// Path to TSP secret key file
|
|
#[arg(short, long)]
|
|
pub secret: PathBuf,
|
|
|
|
/// Gas limit for the set-offs submission transaction
|
|
#[arg(long, default_value = "900000000")]
|
|
pub gas_limit: u64,
|
|
}
|
|
|
|
fn wasm_address(address_str: &str) -> Result<AccountId, AddressError> {
|
|
let (hr, _) = bech32_decode(address_str).map_err(AddressError::NotBech32Encoded)?;
|
|
if hr != "wasm" {
|
|
return Err(AddressError::HumanReadableMismatch(hr));
|
|
}
|
|
|
|
Ok(address_str.parse().unwrap())
|
|
}
|