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
use std::fmt::Debug;
use crate::commands::global;
pub mod build;
pub mod env_meta;
pub mod interface;
pub mod meta;
pub mod shared;
#[derive(Debug, clap::Subcommand)]
pub enum Cmd {
/// Output the interface of a contract.
///
/// A contract's interface describes the functions, parameters, and
/// types that the contract makes accessible to be called.
///
/// The data outputted by this command is a stream of `SCSpecEntry` XDR values.
/// See the type definitions in [stellar-xdr](https://github.com/stellar/stellar-xdr).
/// [See also XDR data format](https://developers.stellar.org/docs/learn/encyclopedia/data-format/xdr).
///
/// Outputs no data when no data is present in the contract.
Interface(interface::Cmd),
/// Output the metadata stored in a contract.
///
/// A contract's meta is a series of key-value pairs that the contract
/// developer can set with any values to provided metadata about the
/// contract. The meta also contains some information like the version
/// of Rust SDK, and Rust compiler version.
///
/// The data outputted by this command is a stream of `SCMetaEntry` XDR values.
/// See the type definitions in [stellar-xdr](https://github.com/stellar/stellar-xdr).
/// [See also XDR data format](https://developers.stellar.org/docs/learn/encyclopedia/data-format/xdr).
///
/// Outputs no data when no data is present in the contract.
Meta(meta::Cmd),
/// Output the env required metadata stored in a contract.
///
/// Env-meta is information stored in all contracts, in the
/// `contractenvmetav0` WASM custom section, about the environment
/// that the contract was built for. Env-meta allows the Soroban Env
/// to know whether the contract is compatibility with the network in
/// its current configuration.
///
/// The data outputted by this command is a stream of `SCEnvMetaEntry` XDR values.
/// See the type definitions in [stellar-xdr](https://github.com/stellar/stellar-xdr).
/// [See also XDR data format](https://developers.stellar.org/docs/learn/encyclopedia/data-format/xdr).
///
/// Outputs no data when no data is present in the contract.
EnvMeta(env_meta::Cmd),
/// Output the contract build information, if available.
///
/// If the contract has a meta entry like `source_repo=github:user/repo`, this command will try
/// to fetch the attestation information for the WASM file.
Build(build::Cmd),
}
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error(transparent)]
Interface(#[from] interface::Error),
#[error(transparent)]
Meta(#[from] meta::Error),
#[error(transparent)]
EnvMeta(#[from] env_meta::Error),
#[error(transparent)]
Build(#[from] build::Error),
}
impl Cmd {
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
match &self {
Cmd::Interface(interface) => interface.run(global_args).await?,
Cmd::Meta(meta) => meta.run(global_args).await?,
Cmd::EnvMeta(env_meta) => env_meta.run(global_args).await?,
Cmd::Build(build) => build.run(global_args).await?,
}
Ok(())
}
}