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
pub mod bindings;
pub mod deploy;
pub mod inspect;
pub mod install;
pub mod invoke;
pub mod optimize;
pub mod read;
#[derive(Debug, clap::Subcommand)]
pub enum Cmd {
/// Generate code client bindings for a contract
Bindings(bindings::Cmd),
/// Deploy a contract
Deploy(deploy::Cmd),
/// Inspect a WASM file listing contract functions, meta, etc
Inspect(inspect::Cmd),
/// Install a WASM file to the ledger without creating a contract instance
Install(install::Cmd),
/// Invoke a contract function
///
/// Generates an "implicit CLI" for the specified contract on-the-fly using the contract's
/// schema, which gets embedded into every Soroban contract. The "slop" in this command,
/// everything after the `--`, gets passed to this implicit CLI. Get in-depth help for a given
/// contract:
///
/// soroban contract invoke ... -- --help
Invoke(invoke::Cmd),
/// Optimize a WASM file
Optimize(optimize::Cmd),
/// Print the current value of a contract-data ledger entry
Read(read::Cmd),
}
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error(transparent)]
Bindings(#[from] bindings::Error),
#[error(transparent)]
Deploy(#[from] deploy::Error),
#[error(transparent)]
Inspect(#[from] inspect::Error),
#[error(transparent)]
Install(#[from] install::Error),
#[error(transparent)]
Invoke(#[from] invoke::Error),
#[error(transparent)]
Optimize(#[from] optimize::Error),
#[error(transparent)]
Read(#[from] read::Error),
}
impl Cmd {
pub async fn run(&self) -> Result<(), Error> {
match &self {
Cmd::Bindings(bindings) => bindings.run()?,
Cmd::Deploy(deploy) => deploy.run().await?,
Cmd::Inspect(inspect) => inspect.run()?,
Cmd::Install(install) => install.run().await?,
Cmd::Invoke(invoke) => invoke.run().await?,
Cmd::Optimize(optimize) => optimize.run()?,
Cmd::Read(read) => read.run()?,
}
Ok(())
}
}