Skip to content

Commit

Permalink
Fix option --is-view env var (#1237)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Mar 5, 2024
1 parent 38d8650 commit d2759c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ pub struct Cmd {
// For testing only
#[arg(skip)]
pub wasm: Option<std::path::PathBuf>,
/// Do not sign and submit transaction
#[arg(long, env = "SOROBAN_INVOKE_SIGN", env = "SYSTEM_TEST_VERBOSE_OUTPUT")]
/// 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`
#[arg(last = true, id = "CONTRACT_FN_AND_ARGS")]
Expand Down Expand Up @@ -148,6 +148,14 @@ impl From<Infallible> for Error {
}

impl Cmd {
fn is_view(&self) -> bool {
self.is_view ||
// 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")
}

fn build_host_function_parameters(
&self,
contract_id: [u8; 32],
Expand Down Expand Up @@ -328,7 +336,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()?,
Expand Down
2 changes: 1 addition & 1 deletion docs/soroban-cli-full-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ soroban contract invoke ... -- --help
###### **Options:**

* `--id <CONTRACT_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`

Expand Down

0 comments on commit d2759c2

Please sign in to comment.