Skip to content

Commit

Permalink
upgrade to stellar-cli v22.0 (#173)
Browse files Browse the repository at this point in the history
* upgrade to stellar-cli v22.0
* disable warning
  • Loading branch information
BlaineHeffron authored Dec 11, 2024
1 parent 1864283 commit be02b76
Show file tree
Hide file tree
Showing 12 changed files with 794 additions and 1,309 deletions.
1,953 changes: 701 additions & 1,252 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ loam-soroban-sdk = { path = "./crates/loam-soroban-sdk" }
loam-sdk-macro = { path = "./crates/loam-sdk-macro" }
loam-subcontract-ft = { path = "./crates/loam-subcontract-ft" }

soroban-sdk = "21.2.0"
stellar-xdr = "21.2.0"
soroban-sdk = "21.7.2"
stellar-xdr = "22.0.0-rc.1.1"
stellar-strkey = "0.0.11"

cargo_metadata = "0.18.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/loam-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ doctest = false

[dependencies]
loam-build = { path = "../loam-build", version = "0.7.3" }
soroban-cli = "21.5.0"
soroban-cli = "22.0.0"
clap = { version = "4.1.8", features = [
"derive",
"env",
Expand Down
26 changes: 15 additions & 11 deletions crates/loam-cli/src/commands/build/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use soroban_cli::{commands as cli, CommandParser};
use std::fmt::Debug;
use std::hash::Hash;
use std::process::Command;
use stellar_strkey;
use stellar_strkey::{self, Contract};
use stellar_xdr::curr::Error as xdrError;

use super::env_toml::Network;
Expand Down Expand Up @@ -129,10 +129,12 @@ impl Args {
let soroban_cli::config::network::Network {
rpc_url,
network_passphrase,
..
} = (soroban_cli::config::network::Args {
network: Some(name.clone()),
rpc_url: None,
network_passphrase: None,
rpc_headers: Vec::new(),
})
.get(&soroban_cli::config::locator::Args {
global: false,
Expand Down Expand Up @@ -162,6 +164,7 @@ impl Args {
rpc_url: network.rpc_url.clone(),
network_passphrase: network.network_passphrase.clone(),
network: network.name.clone(),
rpc_headers: network.rpc_headers.clone().unwrap_or_default(),
}
}

Expand All @@ -175,7 +178,7 @@ impl Args {
fn get_contract_alias(
name: &str,
workspace_root: &std::path::Path,
) -> Result<Option<String>, soroban_cli::config::locator::Error> {
) -> Result<Option<Contract>, soroban_cli::config::locator::Error> {
let config_dir = Self::get_config_locator(workspace_root);
let network_passphrase = std::env::var("STELLAR_NETWORK_PASSPHRASE")
.expect("No STELLAR_NETWORK_PASSPHRASE environment variable set");
Expand All @@ -184,13 +187,13 @@ impl Args {

async fn contract_hash_matches(
&self,
contract_id: &str,
contract_id: &Contract,
hash: &str,
network: &Network,
workspace_root: &std::path::Path,
) -> Result<bool, Error> {
let result = cli::contract::fetch::Cmd {
contract_id: contract_id.to_string(),
contract_id: soroban_cli::config::ContractAddress::ContractId(*contract_id),
out_file: None,
locator: Self::get_config_locator(workspace_root),
network: Self::get_network_args(network),
Expand All @@ -215,7 +218,7 @@ impl Args {

fn save_contract_alias(
name: &str,
contract_id: &str,
contract_id: &Contract,
network: &Network,
workspace_root: &std::path::Path,
) -> Result<(), soroban_cli::config::locator::Error> {
Expand Down Expand Up @@ -318,7 +321,7 @@ export default new Client.Client({{
} else {
eprintln!("🔐 creating keys for {:?}", account.name);
cli::keys::generate::Cmd::parse_arg_vec(&[&account.name])?
.run()
.run(&soroban_cli::commands::global::Args::default())
.await?;
}
}
Expand Down Expand Up @@ -367,7 +370,7 @@ export default new Client.Client({{
if stellar_strkey::Contract::from_string(id).is_err() {
return Err(Error::InvalidContractID(id.to_string()));
}
self.generate_contract_bindings(workspace_root, name, id)
self.generate_contract_bindings(workspace_root, name, &id.to_string())
.await?;
} else {
return Err(Error::MissingContractID(name.to_string()));
Expand Down Expand Up @@ -423,7 +426,7 @@ export default new Client.Client({{
};
let contract_id = if let Some(id) = contract_id {
// If we have a contract ID, use it
id
Contract::from_string(&id).map_err(|_| Error::InvalidContractID(id.clone()))?
} else {
// If we don't have a contract ID, proceed with installation and deployment
let wasm_path = workspace_root.join(format!("target/loam/{name}.wasm"));
Expand Down Expand Up @@ -489,7 +492,7 @@ export default new Client.Client({{
}
}
}
self.generate_contract_bindings(workspace_root, &name, &contract_id)
self.generate_contract_bindings(workspace_root, &name, &contract_id.to_string())
.await?;
}

Expand Down Expand Up @@ -533,7 +536,7 @@ export default new Client.Client({{
async fn run_init_script(
&self,
name: &str,
contract_id: &str,
contract_id: &Contract,
init_script: &str,
) -> Result<(), Error> {
let re = Regex::new(r"\$\((.*?)\)").expect("Invalid regex pattern");
Expand All @@ -558,7 +561,8 @@ export default new Client.Client({{
.iter()
.partition(|&part| part.starts_with("STELLAR_ACCOUNT="));

let mut args = vec!["--id", contract_id];
let contract_id_arg = contract_id.to_string();
let mut args = vec!["--id", &contract_id_arg];
if let Some(account) = source_account.first() {
let account = account.strip_prefix("STELLAR_ACCOUNT=").unwrap();
args.extend_from_slice(&["--source-account", account]);
Expand Down
1 change: 1 addition & 0 deletions crates/loam-cli/src/commands/build/env_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub struct Network {
pub name: Option<String>,
pub rpc_url: Option<String>,
pub network_passphrase: Option<String>,
pub rpc_headers: Option<Vec<(String, String)>>,
// run_locally: Option<bool>,
}

Expand Down
8 changes: 6 additions & 2 deletions crates/loam-cli/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ struct ExampleStatusMessage;
pub struct Cmd {
/// The path to the project must be provided to initialize
pub project_path: PathBuf,
/// The name of the project
#[arg(default_value = "loam-example")]
pub name: String,
}
/// Errors that can occur during initialization
#[derive(thiserror::Error, Debug)]
Expand Down Expand Up @@ -53,8 +56,9 @@ impl Cmd {
// Examples cannot currently be added by user
soroban_init::Cmd {
project_path: self.project_path.to_string_lossy().to_string(),
with_example: vec![],
frontend_template: FRONTEND_TEMPLATE.to_string(),
name: self.name.clone(),
with_example: None,
frontend_template: Some(FRONTEND_TEMPLATE.to_string()),
overwrite: true,
}
.run(&soroban_cli::commands::global::Args::default())?;
Expand Down
Loading

0 comments on commit be02b76

Please sign in to comment.