From 88e3b46d2fc4c3be932d9db38aabb3b9beb21ba1 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Thu, 2 May 2024 06:35:07 +1000 Subject: [PATCH 1/2] Remove deprecated config command (#1305) * Remove deprecated config command * update docs --- cmd/soroban-cli/src/commands/config/mod.rs | 22 +- cmd/soroban-cli/src/commands/mod.rs | 6 - docs/soroban-cli-full-docs.md | 346 --------------------- 3 files changed, 1 insertion(+), 373 deletions(-) diff --git a/cmd/soroban-cli/src/commands/config/mod.rs b/cmd/soroban-cli/src/commands/config/mod.rs index 3c5f4cca4..efe99f0d8 100644 --- a/cmd/soroban-cli/src/commands/config/mod.rs +++ b/cmd/soroban-cli/src/commands/config/mod.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use clap::{arg, command, Parser}; +use clap::{arg, command}; use serde::{Deserialize, Serialize}; use crate::Pwd; @@ -12,16 +12,6 @@ use super::{keys, network}; pub mod locator; pub mod secret; -#[derive(Debug, Parser)] -pub enum Cmd { - /// Configure different networks. Depraecated, use `soroban network` instead. - #[command(subcommand)] - Network(network::Cmd), - /// Identity management. Deprecated, use `soroban keys` instead. - #[command(subcommand)] - Identity(keys::Cmd), -} - #[derive(thiserror::Error, Debug)] pub enum Error { #[error(transparent)] @@ -34,16 +24,6 @@ pub enum Error { Config(#[from] locator::Error), } -impl Cmd { - pub async fn run(&self) -> Result<(), Error> { - match &self { - Cmd::Identity(identity) => identity.run().await?, - Cmd::Network(network) => network.run().await?, - } - Ok(()) - } -} - #[derive(Debug, clap::Args, Clone, Default)] #[group(skip)] pub struct Args { diff --git a/cmd/soroban-cli/src/commands/mod.rs b/cmd/soroban-cli/src/commands/mod.rs index ab673a411..1f4a5daae 100644 --- a/cmd/soroban-cli/src/commands/mod.rs +++ b/cmd/soroban-cli/src/commands/mod.rs @@ -99,7 +99,6 @@ impl Root { Cmd::Network(network) => network.run().await?, Cmd::Version(version) => version.run(), Cmd::Keys(id) => id.run().await?, - Cmd::Config(c) => c.run().await?, }; Ok(()) } @@ -118,9 +117,6 @@ pub enum Cmd { /// Print shell completion code for the specified shell. #[command(long_about = completion::LONG_ABOUT)] Completion(completion::Cmd), - /// Deprecated, use `soroban keys` and `soroban network` instead - #[command(subcommand)] - Config(config::Cmd), /// Tools for smart contract developers #[command(subcommand)] Contract(contract::Cmd), @@ -151,8 +147,6 @@ pub enum Error { #[error(transparent)] Lab(#[from] lab::Error), #[error(transparent)] - Config(#[from] config::Error), - #[error(transparent)] Clap(#[from] clap::error::Error), #[error(transparent)] Plugin(#[from] plugin::Error), diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index 4bdcfc5a3..77a2ab8e1 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -6,21 +6,6 @@ This document contains the help content for the `soroban` command-line program. * [`soroban`↴](#soroban) * [`soroban completion`↴](#soroban-completion) -* [`soroban config`↴](#soroban-config) -* [`soroban config network`↴](#soroban-config-network) -* [`soroban config network add`↴](#soroban-config-network-add) -* [`soroban config network rm`↴](#soroban-config-network-rm) -* [`soroban config network ls`↴](#soroban-config-network-ls) -* [`soroban config network start`↴](#soroban-config-network-start) -* [`soroban config network stop`↴](#soroban-config-network-stop) -* [`soroban config identity`↴](#soroban-config-identity) -* [`soroban config identity add`↴](#soroban-config-identity-add) -* [`soroban config identity address`↴](#soroban-config-identity-address) -* [`soroban config identity fund`↴](#soroban-config-identity-fund) -* [`soroban config identity generate`↴](#soroban-config-identity-generate) -* [`soroban config identity ls`↴](#soroban-config-identity-ls) -* [`soroban config identity rm`↴](#soroban-config-identity-rm) -* [`soroban config identity show`↴](#soroban-config-identity-show) * [`soroban contract`↴](#soroban-contract) * [`soroban contract asset`↴](#soroban-contract-asset) * [`soroban contract asset id`↴](#soroban-contract-asset-id) @@ -100,7 +85,6 @@ Full CLI reference: https://github.com/stellar/soroban-tools/tree/main/docs/soro ###### **Subcommands:** * `completion` — Print shell completion code for the specified shell -* `config` — Deprecated, use `soroban keys` and `soroban network` instead * `contract` — Tools for smart contract developers * `events` — Watch the network for contract events * `keys` — Create and manage identities including keys and addresses @@ -159,336 +143,6 @@ To enable autocomplete permanently, run: -## `soroban config` - -Deprecated, use `soroban keys` and `soroban network` instead - -**Usage:** `soroban config ` - -###### **Subcommands:** - -* `network` — Configure different networks. Depraecated, use `soroban network` instead -* `identity` — Identity management. Deprecated, use `soroban keys` instead - - - -## `soroban config network` - -Configure different networks. Depraecated, use `soroban network` instead - -**Usage:** `soroban config network ` - -###### **Subcommands:** - -* `add` — Add a new network -* `rm` — Remove a network -* `ls` — List networks -* `start` — Start network -* `stop` — Stop a network started with `network start`. For example, if you ran `soroban network start local`, you can use `soroban network stop local` to stop it - - - -## `soroban config network add` - -Add a new network - -**Usage:** `soroban config network add [OPTIONS] --rpc-url --network-passphrase ` - -###### **Arguments:** - -* `` — Name of network - -###### **Options:** - -* `--rpc-url ` — RPC server endpoint -* `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server -* `--global` — Use global config - - Possible values: `true`, `false` - -* `--config-dir ` — Location of config directory, default is "." - - - -## `soroban config network rm` - -Remove a network - -**Usage:** `soroban config network rm [OPTIONS] ` - -###### **Arguments:** - -* `` — Network to remove - -###### **Options:** - -* `--global` — Use global config - - Possible values: `true`, `false` - -* `--config-dir ` — Location of config directory, default is "." - - - -## `soroban config network ls` - -List networks - -**Usage:** `soroban config network ls [OPTIONS]` - -###### **Options:** - -* `--global` — Use global config - - Possible values: `true`, `false` - -* `--config-dir ` — Location of config directory, default is "." -* `-l`, `--long` — Get more info about the networks - - Possible values: `true`, `false` - - - - -## `soroban config network start` - -Start network - -Start a container running a Stellar node, RPC, API, and friendbot (faucet). - -soroban network start [OPTIONS] - -By default, when starting a testnet container, without any optional arguments, it will run the equivalent of the following docker command: docker run --rm -p 8000:8000 --name stellar stellar/quickstart:testing --testnet --enable-soroban-rpc - -**Usage:** `soroban config network start [OPTIONS] ` - -###### **Arguments:** - -* `` — Network to start - - Possible values: `local`, `testnet`, `futurenet`, `pubnet` - - -###### **Options:** - -* `-d`, `--docker-host ` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock -* `-l`, `--limits ` — Optional argument to specify the limits for the local network only -* `-p`, `--ports-mapping ` — Argument to specify the HOST_PORT:CONTAINER_PORT mapping - - Default value: `8000:8000` -* `-t`, `--image-tag-override ` — Optional argument to override the default docker image tag for the given network -* `-v`, `--protocol-version ` — Optional argument to specify the protocol version for the local network only - - - -## `soroban config network stop` - -Stop a network started with `network start`. For example, if you ran `soroban network start local`, you can use `soroban network stop local` to stop it - -**Usage:** `soroban config network stop [OPTIONS] ` - -###### **Arguments:** - -* `` — Network to stop - - Possible values: `local`, `testnet`, `futurenet`, `pubnet` - - -###### **Options:** - -* `-d`, `--docker-host ` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock - - - -## `soroban config identity` - -Identity management. Deprecated, use `soroban keys` instead - -**Usage:** `soroban config identity ` - -###### **Subcommands:** - -* `add` — Add a new identity (keypair, ledger, macOS keychain) -* `address` — Given an identity return its address (public key) -* `fund` — Fund an identity on a test network -* `generate` — Generate a new identity with a seed phrase, currently 12 words -* `ls` — List identities -* `rm` — Remove an identity -* `show` — Given an identity return its private key - - - -## `soroban config identity add` - -Add a new identity (keypair, ledger, macOS keychain) - -**Usage:** `soroban config identity add [OPTIONS] ` - -###### **Arguments:** - -* `` — Name of identity - -###### **Options:** - -* `--secret-key` — Add using secret_key Can provide with SOROBAN_SECRET_KEY - - Possible values: `true`, `false` - -* `--seed-phrase` — Add using 12 word seed phrase to generate secret_key - - Possible values: `true`, `false` - -* `--global` — Use global config - - Possible values: `true`, `false` - -* `--config-dir ` — Location of config directory, default is "." - - - -## `soroban config identity address` - -Given an identity return its address (public key) - -**Usage:** `soroban config identity address [OPTIONS] ` - -###### **Arguments:** - -* `` — Name of identity to lookup, default test identity used if not provided - -###### **Options:** - -* `--hd-path ` — If identity is a seed phrase use this hd path, default is 0 -* `--global` — Use global config - - Possible values: `true`, `false` - -* `--config-dir ` — Location of config directory, default is "." - - - -## `soroban config identity fund` - -Fund an identity on a test network - -**Usage:** `soroban config identity fund [OPTIONS] ` - -###### **Arguments:** - -* `` — Name of identity to lookup, default test identity used if not provided - -###### **Options:** - -* `--rpc-url ` — RPC server endpoint -* `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server -* `--network ` — Name of network to use from config -* `--hd-path ` — If identity is a seed phrase use this hd path, default is 0 -* `--global` — Use global config - - Possible values: `true`, `false` - -* `--config-dir ` — Location of config directory, default is "." - - - -## `soroban config identity generate` - -Generate a new identity with a seed phrase, currently 12 words - -**Usage:** `soroban config identity generate [OPTIONS] ` - -###### **Arguments:** - -* `` — Name of identity - -###### **Options:** - -* `--no-fund` — Do not fund address - - Possible values: `true`, `false` - -* `--seed ` — Optional seed to use when generating seed phrase. Random otherwise -* `-s`, `--as-secret` — Output the generated identity as a secret key - - Possible values: `true`, `false` - -* `--global` — Use global config - - Possible values: `true`, `false` - -* `--config-dir ` — Location of config directory, default is "." -* `--hd-path ` — When generating a secret key, which hd_path should be used from the original seed_phrase -* `-d`, `--default-seed` — Generate the default seed phrase. Useful for testing. Equivalent to --seed 0000000000000000 - - Possible values: `true`, `false` - -* `--rpc-url ` — RPC server endpoint -* `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server -* `--network ` — Name of network to use from config - - - -## `soroban config identity ls` - -List identities - -**Usage:** `soroban config identity ls [OPTIONS]` - -###### **Options:** - -* `--global` — Use global config - - Possible values: `true`, `false` - -* `--config-dir ` — Location of config directory, default is "." -* `-l`, `--long` - - Possible values: `true`, `false` - - - - -## `soroban config identity rm` - -Remove an identity - -**Usage:** `soroban config identity rm [OPTIONS] ` - -###### **Arguments:** - -* `` — Identity to remove - -###### **Options:** - -* `--global` — Use global config - - Possible values: `true`, `false` - -* `--config-dir ` — Location of config directory, default is "." - - - -## `soroban config identity show` - -Given an identity return its private key - -**Usage:** `soroban config identity show [OPTIONS] ` - -###### **Arguments:** - -* `` — Name of identity to lookup, default is test identity - -###### **Options:** - -* `--hd-path ` — If identity is a seed phrase use this hd path, default is 0 -* `--global` — Use global config - - Possible values: `true`, `false` - -* `--config-dir ` — Location of config directory, default is "." - - - ## `soroban contract` Tools for smart contract developers From 8c04c94ea48a30e718acb492b7a79e80cda7728a Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Thu, 2 May 2024 07:19:14 +1000 Subject: [PATCH 2/2] Add xdr command to root (#1307) --- cmd/soroban-cli/src/commands/mod.rs | 5 + docs/soroban-cli-full-docs.md | 154 ++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+) diff --git a/cmd/soroban-cli/src/commands/mod.rs b/cmd/soroban-cli/src/commands/mod.rs index 1f4a5daae..4aaa3e645 100644 --- a/cmd/soroban-cli/src/commands/mod.rs +++ b/cmd/soroban-cli/src/commands/mod.rs @@ -96,6 +96,7 @@ impl Root { Cmd::Contract(contract) => contract.run(&self.global_args).await?, Cmd::Events(events) => events.run().await?, Cmd::Lab(lab) => lab.run()?, + Cmd::Xdr(xdr) => xdr.run()?, Cmd::Network(network) => network.run().await?, Cmd::Version(version) => version.run(), Cmd::Keys(id) => id.run().await?, @@ -128,6 +129,8 @@ pub enum Cmd { /// Experiment with early features and expert tools #[command(subcommand)] Lab(lab::Cmd), + /// Decode and encode XDR + Xdr(stellar_xdr::cli::Root), /// Start and configure networks #[command(subcommand)] Network(network::Cmd), @@ -147,6 +150,8 @@ pub enum Error { #[error(transparent)] Lab(#[from] lab::Error), #[error(transparent)] + Xdr(#[from] stellar_xdr::cli::Error), + #[error(transparent)] Clap(#[from] clap::error::Error), #[error(transparent)] Plugin(#[from] plugin::Error), diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index 77a2ab8e1..5b9f8002d 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -45,6 +45,13 @@ This document contains the help content for the `soroban` command-line program. * [`soroban lab xdr decode`↴](#soroban-lab-xdr-decode) * [`soroban lab xdr encode`↴](#soroban-lab-xdr-encode) * [`soroban lab xdr version`↴](#soroban-lab-xdr-version) +* [`soroban xdr`↴](#soroban-xdr) +* [`soroban xdr types`↴](#soroban-xdr-types) +* [`soroban xdr types list`↴](#soroban-xdr-types-list) +* [`soroban xdr guess`↴](#soroban-xdr-guess) +* [`soroban xdr decode`↴](#soroban-xdr-decode) +* [`soroban xdr encode`↴](#soroban-xdr-encode) +* [`soroban xdr version`↴](#soroban-xdr-version) * [`soroban network`↴](#soroban-network) * [`soroban network add`↴](#soroban-network-add) * [`soroban network rm`↴](#soroban-network-rm) @@ -89,6 +96,7 @@ Full CLI reference: https://github.com/stellar/soroban-tools/tree/main/docs/soro * `events` — Watch the network for contract events * `keys` — Create and manage identities including keys and addresses * `lab` — Experiment with early features and expert tools +* `xdr` — Decode and encode XDR * `network` — Start and configure networks * `version` — Print version information @@ -1132,6 +1140,152 @@ Print version information +## `soroban xdr` + +Decode and encode XDR + +**Usage:** `soroban xdr [CHANNEL] ` + +###### **Subcommands:** + +* `types` — View information about types +* `guess` — Guess the XDR type +* `decode` — Decode XDR +* `encode` — Encode XDR +* `version` — Print version information + +###### **Arguments:** + +* `` — Channel of XDR to operate on + + Default value: `+curr` + + Possible values: `+curr`, `+next` + + + + +## `soroban xdr types` + +View information about types + +**Usage:** `soroban xdr types ` + +###### **Subcommands:** + +* `list` — + + + +## `soroban xdr types list` + +**Usage:** `soroban xdr types list [OPTIONS]` + +###### **Options:** + +* `--output ` + + Default value: `plain` + + Possible values: `plain`, `json`, `json-formatted` + + + + +## `soroban xdr guess` + +Guess the XDR type + +**Usage:** `soroban xdr guess [OPTIONS] [FILE]` + +###### **Arguments:** + +* `` — File to decode, or stdin if omitted + +###### **Options:** + +* `--input ` + + Default value: `single-base64` + + Possible values: `single`, `single-base64`, `stream`, `stream-base64`, `stream-framed` + +* `--output ` + + Default value: `list` + + Possible values: `list` + +* `--certainty ` — Certainty as an arbitrary value + + Default value: `2` + + + +## `soroban xdr decode` + +Decode XDR + +**Usage:** `soroban xdr decode [OPTIONS] --type [FILES]...` + +###### **Arguments:** + +* `` — Files to decode, or stdin if omitted + +###### **Options:** + +* `--type ` — XDR type to decode +* `--input ` + + Default value: `stream-base64` + + Possible values: `single`, `single-base64`, `stream`, `stream-base64`, `stream-framed` + +* `--output ` + + Default value: `json` + + Possible values: `json`, `json-formatted`, `rust-debug`, `rust-debug-formatted` + + + + +## `soroban xdr encode` + +Encode XDR + +**Usage:** `soroban xdr encode [OPTIONS] --type [FILES]...` + +###### **Arguments:** + +* `` — Files to encode, or stdin if omitted + +###### **Options:** + +* `--type ` — XDR type to encode +* `--input ` + + Default value: `json` + + Possible values: `json` + +* `--output ` + + Default value: `single-base64` + + Possible values: `single`, `single-base64` + + + + +## `soroban xdr version` + +Print version information + +**Usage:** `soroban xdr version` + + + ## `soroban network` Start and configure networks