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: stellar contract info * commands require network when network no… #1676

Merged
merged 12 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 19 additions & 0 deletions cmd/soroban-cli/src/commands/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ pub struct Args {
/// Do not cache your simulations and transactions
#[arg(long, env = "STELLAR_NO_CACHE", global = true)]
pub no_cache: bool,

Dhanraj30 marked this conversation as resolved.
Show resolved Hide resolved
/// RPC URL for the Stellar network
#[arg(long, env = "STELLAR_RPC_URL")]
pub rpc_url: Option<String>,

/// Network passphrase for the Stellar network
#[arg(long, env = "STELLAR_NETWORK_PASSPHRASE")]
pub network_passphrase: Option<String>,

/// Network name (e.g., 'testnet', 'mainnet')
#[arg(long, env = "STELLAR_NETWORK")]
pub network: Option<String>,

/// Path to the WebAssembly file
#[arg(long, env = "STELLAR_WASM", global = true)]
pub wasm: Option<PathBuf>,
Dhanraj30 marked this conversation as resolved.
Show resolved Hide resolved
}

#[derive(thiserror::Error, Debug)]
Expand All @@ -61,6 +77,9 @@ pub enum Error {
filepath: PathBuf,
error: soroban_ledger_snapshot::Error,
},

Dhanraj30 marked this conversation as resolved.
Show resolved Hide resolved
#[error("network arg or rpc url and network passphrase are required if using the network")]
Network,
}

impl Args {
Expand Down
12 changes: 12 additions & 0 deletions cmd/soroban-cli/src/commands/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ impl Cmd {
cmd.run(global_args).await?;
}
};

Dhanraj30 marked this conversation as resolved.
Show resolved Hide resolved
// Check if a WASM file is provided; if so, skip the network argument requirement
if global_args.wasm.is_some() {
return Ok(()); // No further checks needed
}

// Ensure network arguments are provided when WASM is not specified
if global_args.rpc_url.is_none() || global_args.network_passphrase.is_none() || global_args.network.is_none() {
return Err(Error::Network); // Inform user that these arguments are required
}


Ok(())
}
}