From a0ea172486f171b1227c5125df586049b05958dd Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:03:33 +1000 Subject: [PATCH 1/6] Fix option --is-view env var --- cmd/soroban-cli/src/commands/contract/invoke.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 29637dcbd..52efec70a 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -43,7 +43,7 @@ pub struct Cmd { #[arg(skip)] pub wasm: Option, /// Do not sign and submit transaction - #[arg(long, env = "SOROBAN_INVOKE_SIGN", env = "SYSTEM_TEST_VERBOSE_OUTPUT")] + #[arg(long, env = "SOROBAN_INVOKE_VIEW")] pub is_view: bool, /// Function name as subcommand, then arguments for that function as `--arg-name value` #[arg(last = true, id = "CONTRACT_FN_AND_ARGS")] From a69cfe4fee4015dd8941780116a0b5707d717428 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:12:43 +1000 Subject: [PATCH 2/6] improve docs --- cmd/soroban-cli/src/commands/contract/invoke.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 52efec70a..1de8526f4 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -42,7 +42,7 @@ pub struct Cmd { // For testing only #[arg(skip)] pub wasm: Option, - /// Do not sign and submit transaction + /// View the result simulating and do not sign and submit transaction #[arg(long, env = "SOROBAN_INVOKE_VIEW")] pub is_view: bool, /// Function name as subcommand, then arguments for that function as `--arg-name value` From 092c4b587580b31b75e11c3cd83b0c50c5194392 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:45:56 +1000 Subject: [PATCH 3/6] makes backwards compat --- cmd/soroban-cli/src/commands/contract/invoke.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 1de8526f4..1df6cc95d 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -45,6 +45,8 @@ pub struct Cmd { /// View the result simulating and do not sign and submit transaction #[arg(long, env = "SOROBAN_INVOKE_VIEW")] pub is_view: bool, + #[arg(long, env = "SYSTEM_TEST_VERBOSE_OUTPUT", hide = true)] + pub is_view_deprecated: bool, /// Function name as subcommand, then arguments for that function as `--arg-name value` #[arg(last = true, id = "CONTRACT_FN_AND_ARGS")] pub slop: Vec, @@ -148,6 +150,10 @@ impl From for Error { } impl Cmd { + fn is_view(&self) -> bool { + self.is_view || self.is_view_deprecated + } + fn build_host_function_parameters( &self, contract_id: [u8; 32], @@ -328,7 +334,7 @@ impl NetworkRunnable for Cmd { )?; let txn = client.create_assembled_transaction(&tx).await?; let txn = self.fee.apply_to_assembled_txn(txn); - let (return_value, events) = if self.is_view { + let (return_value, events) = if self.is_view() { ( txn.sim_response().results()?[0].xdr.clone(), txn.sim_response().events()?, From 7604de9d7467ad1f83454817c02aea2a121dda37 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:02:29 +1000 Subject: [PATCH 4/6] change how backwards compat to avoid docs visibility --- cmd/soroban-cli/src/commands/contract/invoke.rs | 6 +++--- docs/soroban-cli-full-docs.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 1df6cc95d..8cea67158 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -45,8 +45,6 @@ pub struct Cmd { /// View the result simulating and do not sign and submit transaction #[arg(long, env = "SOROBAN_INVOKE_VIEW")] pub is_view: bool, - #[arg(long, env = "SYSTEM_TEST_VERBOSE_OUTPUT", hide = true)] - pub is_view_deprecated: bool, /// Function name as subcommand, then arguments for that function as `--arg-name value` #[arg(last = true, id = "CONTRACT_FN_AND_ARGS")] pub slop: Vec, @@ -151,7 +149,9 @@ impl From for Error { impl Cmd { fn is_view(&self) -> bool { - self.is_view || self.is_view_deprecated + self.is_view || + // TODO: Remove at next major release. Was added + std::env::var("SYSTEM_TEST_VERBOSE_OUTPUT").as_deref() == Ok("true") } fn build_host_function_parameters( diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index 5600db277..6e06debe9 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -953,7 +953,7 @@ soroban contract invoke ... -- --help ###### **Options:** * `--id ` — Contract ID to invoke -* `--is-view` — Do not sign and submit transaction +* `--is-view` — View the result simulating and do not sign and submit transaction Possible values: `true`, `false` From 3301c688fad1815806343e50245671cfb890a25f Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:11:39 +1000 Subject: [PATCH 5/6] tidy --- cmd/soroban-cli/src/commands/contract/invoke.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 8cea67158..90acb4474 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -150,7 +150,9 @@ impl From for Error { impl Cmd { fn is_view(&self) -> bool { self.is_view || - // TODO: Remove at next major release. Was added + // TODO: Remove at next major release. Was added to retain backwards + // compatibility when this env var used to be used for the --is-view + // option. std::env::var("SYSTEM_TEST_VERBOSE_OUTPUT").as_deref() == Ok("true") } @@ -256,7 +258,7 @@ impl Cmd { } pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> { - let res = self.invoke(global_args).await?; + let res = selVjf.invoke(global_args).await?; println!("{res}"); Ok(()) } From beab4dd4a90a88a2b159b525a77df2f11e6f18c5 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:12:06 +1000 Subject: [PATCH 6/6] fix --- cmd/soroban-cli/src/commands/contract/invoke.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 90acb4474..cd42d818f 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -258,7 +258,7 @@ impl Cmd { } pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> { - let res = selVjf.invoke(global_args).await?; + let res = self.invoke(global_args).await?; println!("{res}"); Ok(()) }