From 6f733899123b63b2d0d7da5465962a3ebbe7b6ed Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 1 May 2024 22:15:00 +1000 Subject: [PATCH 1/5] Add xdr command to root --- cmd/soroban-cli/src/commands/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/soroban-cli/src/commands/mod.rs b/cmd/soroban-cli/src/commands/mod.rs index fc052fee0..74d1304eb 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().await?, + Cmd::Xdr(xdr) => xdr.run()?, Cmd::Network(network) => network.run().await?, Cmd::Version(version) => version.run(), Cmd::Keys(id) => id.run().await?, @@ -132,6 +133,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), @@ -151,6 +154,8 @@ pub enum Error { #[error(transparent)] Lab(#[from] lab::Error), #[error(transparent)] + Xdr(#[from] stellar_xdr::cli::Error), + #[error(transparent)] Config(#[from] config::Error), #[error(transparent)] Clap(#[from] clap::error::Error), From 06a61633e6054daf0397c058ae4abc4ece6d3a33 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 1 May 2024 23:05:21 +1000 Subject: [PATCH 2/5] update docs --- docs/soroban-cli-full-docs.md | 154 ++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index 68b9adc98..24e5e7b16 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -63,6 +63,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) @@ -108,6 +115,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 @@ -1547,6 +1555,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 From 46df81794afd0e4aa52a9b489ab646146f717700 Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Wed, 1 May 2024 12:47:28 -0400 Subject: [PATCH 3/5] fix: remove async --- cmd/soroban-cli/src/commands/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/soroban-cli/src/commands/mod.rs b/cmd/soroban-cli/src/commands/mod.rs index 74d1304eb..747532d4f 100644 --- a/cmd/soroban-cli/src/commands/mod.rs +++ b/cmd/soroban-cli/src/commands/mod.rs @@ -95,7 +95,7 @@ impl Root { Cmd::Completion(completion) => completion.run(), Cmd::Contract(contract) => contract.run(&self.global_args).await?, Cmd::Events(events) => events.run().await?, - Cmd::Lab(lab) => lab.run().await?, + Cmd::Lab(lab) => lab.run()?, Cmd::Xdr(xdr) => xdr.run()?, Cmd::Network(network) => network.run().await?, Cmd::Version(version) => version.run(), From 192c89922bc8a87176681ce3f3a0e3a3ad0b2f6a Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Wed, 1 May 2024 12:48:28 -0400 Subject: [PATCH 4/5] fix: clippy --- cmd/soroban-cli/src/commands/contract/invoke.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index cd42d818f..8b8a39bae 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -296,6 +296,7 @@ impl NetworkRunnable for Cmd { type Error = Error; type Result = String; + #[allow(clippy::map_clone)] async fn run_against_rpc_server( &self, global_args: Option<&global::Args>, From a4444e1b4faa077b8926dd5dc15279d39ee29ff7 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Thu, 2 May 2024 07:02:41 +1000 Subject: [PATCH 5/5] Revert "fix: clippy" This reverts commit 192c89922bc8a87176681ce3f3a0e3a3ad0b2f6a. --- cmd/soroban-cli/src/commands/contract/invoke.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 8b8a39bae..cd42d818f 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -296,7 +296,6 @@ impl NetworkRunnable for Cmd { type Error = Error; type Result = String; - #[allow(clippy::map_clone)] async fn run_against_rpc_server( &self, global_args: Option<&global::Args>,