Skip to content
Open
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
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["crates/*", "test/*", "examples/soroban/*"]
members = ["crates/*", "test/*", "examples/soroban/*", "stellar_version"]
exclude = ["test/*", "examples/soroban/*"]

[workspace.package]
Expand All @@ -18,6 +18,7 @@ soroban-sdk = "22.0.0-rc.3"
stellar-xdr = "22.0.0-rc.1.1"
stellar-strkey = "0.0.11"

cargo-run-bin = "1.7.3"
cargo_metadata = "0.18.1"
thiserror = "1.0.38"
sha2 = "0.10.7"
Expand All @@ -31,4 +32,4 @@ strip = "symbols"
debug-assertions = true
panic = "abort"
codegen-units = 1
lto = true
lto = true
6 changes: 4 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export PATH := './target/bin:' + env_var('PATH')
export CONFIG_DIR := 'target/'
# hash := `soroban contract install --wasm ./target/wasm32-unknown-unknown/contracts/example_status_message.wasm`

stellar-version := `cargo run --bin stellar_version`



[private]
Expand All @@ -28,7 +30,7 @@ build:

# Setup the project to use a pinned version of the CLI
setup:
-cargo binstall -y --install-path ./target/bin stellar-cli --version 22.0.1
-cargo binstall -y --install-path ./target/bin stellar-cli --version {{stellar-version}}

# Build loam-cli test contracts to speed up testing
build-cli-test-contracts:
Expand All @@ -47,4 +49,4 @@ create: build
# # Builds contracts. Deploys core subcontract and then redeploys to status message.

redeploy:
./redeploy.sh
./redeploy.sh
7 changes: 7 additions & 0 deletions stellar_version/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "stellar_version"
version = "0.1.0"
edition = "2021"

[dependencies]
cargo_metadata = "0.18.1"
32 changes: 32 additions & 0 deletions stellar_version/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use cargo_metadata::{MetadataCommand, Package};
use std::process;

fn main() {
// Run the `cargo metadata` command to get workspace metadata
let metadata = match MetadataCommand::new().exec() {
Ok(metadata) => metadata,
Err(error) => {
eprintln!("Failed to get cargo metadata: {error}");
process::exit(1);
}
};

// Iterate over all packages in the workspace
for package in metadata.packages {
if let Some(version) = find_stellar_cli_version(&package) {
println!("{version}");
return;
}
}

eprintln!("stellar-cli dependency not found in any crate.");
process::exit(1);
}

fn find_stellar_cli_version(package: &Package) -> Option<String> {
package
.dependencies
.iter()
.find(|dep| dep.name == "soroban-cli")
.map(|dep| dep.req.to_string())
}