Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix option --is-view env var #1237

Merged
merged 6 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading