Skip to content

Commit

Permalink
Merge branch 'main' into feat/add_stellar_ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman authored Feb 4, 2025
2 parents c850e44 + 85142ca commit b3ea407
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cmd/soroban-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ doctest = false

[features]
default = []
version_lt_23 = []
version_gte_23 = []
opt = ["dep:wasm-opt"]
emulator-tests = ["stellar-ledger/emulator-tests"]

Expand Down
19 changes: 19 additions & 0 deletions cmd/soroban-cli/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
fn main() {
crate_git_revision::init();
set_protocol_features();
}

fn set_protocol_features() {
let version = env!("CARGO_PKG_VERSION");
let major_version: u32 = version
.split('.')
.next()
.unwrap_or("0")
.parse()
.unwrap_or(0);

if major_version < 23 {
println!("cargo:rustc-cfg=feature=\"version_lt_23\"");
}

if major_version >= 23 {
println!("cargo:rustc-cfg=feature=\"version_gte_23\"");
}
}
14 changes: 13 additions & 1 deletion cmd/soroban-cli/src/commands/contract/arg_parsing.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::collections::HashMap;
use std::convert::TryInto;
use std::env;
use std::ffi::OsString;
use std::fmt::Debug;
use std::path::PathBuf;
Expand Down Expand Up @@ -53,14 +54,25 @@ pub enum Error {
Config(#[from] config::Error),
}

fn running_cmd() -> String {
let mut args: Vec<String> = env::args().collect();

if let Some(pos) = args.iter().position(|arg| arg == "--") {
args.truncate(pos);
}

format!("{} --", args.join(" "))
}

pub fn build_host_function_parameters(
contract_id: &stellar_strkey::Contract,
slop: &[OsString],
spec_entries: &[ScSpecEntry],
config: &config::Args,
) -> Result<(String, Spec, InvokeContractArgs, Vec<SigningKey>), Error> {
let spec = Spec(Some(spec_entries.to_vec()));
let mut cmd = clap::Command::new(contract_id.to_string())

let mut cmd = clap::Command::new(running_cmd())
.no_binary_name(true)
.term_width(300)
.max_term_width(300);
Expand Down
13 changes: 9 additions & 4 deletions cmd/soroban-cli/src/commands/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ pub enum Cmd {
/// By default, when starting a testnet container, without any optional arguments, it will run the equivalent of the following docker command:
///
/// `docker run --rm -p 8000:8000 --name stellar stellar/quickstart:testing --testnet --enable rpc,horizon`
#[cfg(feature = "version_lt_23")]
Start(crate::commands::container::StartCmd),

/// ⚠️ Deprecated: use `stellar container stop` instead
///
/// Stop a network started with `network start`. For example, if you ran `stellar network start local`, you can use `stellar network stop local` to stop it.
#[cfg(feature = "version_lt_23")]
Stop(crate::commands::container::StopCmd),

/// Set the default network that will be used on all commands.
Expand All @@ -47,6 +49,7 @@ pub enum Cmd {
/// ⚠️ Deprecated: use `stellar container` instead
///
/// Commands to start, stop and get logs for a quickstart container
#[cfg(feature = "version_lt_23")]
#[command(subcommand)]
Container(crate::commands::container::Cmd),
}
Expand All @@ -65,14 +68,15 @@ pub enum Error {
#[error(transparent)]
Ls(#[from] ls::Error),

// TODO: remove once `network start` is removed
#[cfg(feature = "version_lt_23")]
#[error(transparent)]
Start(#[from] crate::commands::container::start::Error),

// TODO: remove once `network stop` is removed
#[cfg(feature = "version_lt_23")]
#[error(transparent)]
Stop(#[from] crate::commands::container::stop::Error),

#[cfg(feature = "version_lt_23")]
#[error(transparent)]
Container(#[from] crate::commands::container::Error),

Expand Down Expand Up @@ -100,14 +104,15 @@ impl Cmd {
Cmd::Add(cmd) => cmd.run()?,
Cmd::Rm(new) => new.run()?,
Cmd::Ls(cmd) => cmd.run()?,
#[cfg(feature = "version_lt_23")]
Cmd::Container(cmd) => cmd.run(global_args).await?,

// TODO Remove this once `network start` is removed
#[cfg(feature = "version_lt_23")]
Cmd::Start(cmd) => {
eprintln!("⚠️ Warning: `network start` has been deprecated. Use `container start` instead");
cmd.run(global_args).await?;
}
// TODO Remove this once `network stop` is removed
#[cfg(feature = "version_lt_23")]
Cmd::Stop(cmd) => {
println!(
"⚠️ Warning: `network stop` has been deprecated. Use `container stop` instead"
Expand Down

0 comments on commit b3ea407

Please sign in to comment.