From 5fac1383ca3d51d0b9f113f233d9f7c07894bffa Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Thu, 7 Nov 2024 15:07:54 -0800 Subject: [PATCH 1/4] Revert "Resolve identity from default config. (#1711)" (#1715) This reverts commit 9912694cfb6f67c4ccfbcba62a27aa22aa43cc17. --- FULL_HELP_DOCS.md | 64 +++++++-------------------- cmd/soroban-cli/src/config/address.rs | 14 ++---- cmd/soroban-cli/src/config/mod.rs | 7 +-- 3 files changed, 20 insertions(+), 65 deletions(-) diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index 581c2cb87..899c0115e 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -131,7 +131,7 @@ Get Id of builtin Soroban Asset Contract. Deprecated, use `stellar contract id a Deploy builtin Soroban Asset Contract -**Usage:** `stellar contract asset deploy [OPTIONS] --asset ` +**Usage:** `stellar contract asset deploy [OPTIONS] --asset --source-account ` ###### **Options:** @@ -141,8 +141,6 @@ Deploy builtin Soroban Asset Contract * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -348,7 +346,7 @@ Extend the time to live ledger of a contract-data ledger entry. If no keys are specified the contract itself is extended. -**Usage:** `stellar contract extend [OPTIONS] --ledgers-to-extend ` +**Usage:** `stellar contract extend [OPTIONS] --ledgers-to-extend --source-account ` ###### **Options:** @@ -374,8 +372,6 @@ If no keys are specified the contract itself is extended. * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -393,7 +389,7 @@ If no keys are specified the contract itself is extended. Deploy a wasm contract -**Usage:** `stellar contract deploy [OPTIONS] <--wasm |--wasm-hash > [-- ...]` +**Usage:** `stellar contract deploy [OPTIONS] --source-account <--wasm |--wasm-hash > [-- ...]` ###### **Arguments:** @@ -409,8 +405,6 @@ Deploy a wasm contract * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -482,7 +476,7 @@ Deploy builtin Soroban Asset Contract Deploy normal Wasm Contract -**Usage:** `stellar contract id wasm [OPTIONS] --salt ` +**Usage:** `stellar contract id wasm [OPTIONS] --salt --source-account ` ###### **Options:** @@ -492,8 +486,6 @@ Deploy normal Wasm Contract * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -685,7 +677,7 @@ This command will create a Cargo workspace project and add a sample Stellar cont Install a WASM file to the ledger without creating a contract instance -**Usage:** `stellar contract install [OPTIONS] --wasm ` +**Usage:** `stellar contract install [OPTIONS] --source-account --wasm ` ###### **Options:** @@ -694,8 +686,6 @@ Install a WASM file to the ledger without creating a contract instance * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -721,7 +711,7 @@ Generates an "implicit CLI" for the specified contract on-the-fly using the cont stellar contract invoke ... -- --help -**Usage:** `stellar contract invoke [OPTIONS] --id [-- ...]` +**Usage:** `stellar contract invoke [OPTIONS] --id --source-account [-- ...]` ###### **Arguments:** @@ -736,8 +726,6 @@ stellar contract invoke ... -- --help * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -826,7 +814,7 @@ Restore an evicted value for a contract-data legder entry. If no keys are specificed the contract itself is restored. -**Usage:** `stellar contract restore [OPTIONS]` +**Usage:** `stellar contract restore [OPTIONS] --source-account ` ###### **Options:** @@ -852,8 +840,6 @@ If no keys are specificed the contract itself is restored. * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -1472,7 +1458,7 @@ Sign, Simulate, and Send transactions Simulate a transaction envelope from stdin -**Usage:** `stellar tx simulate [OPTIONS]` +**Usage:** `stellar tx simulate [OPTIONS] --source-account ` ###### **Options:** @@ -1481,8 +1467,6 @@ Simulate a transaction envelope from stdin * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -1564,7 +1548,7 @@ Create a new transaction Transfers the XLM balance of an account to another account and removes the source account from the ledger -**Usage:** `stellar tx new account-merge [OPTIONS] --account ` +**Usage:** `stellar tx new account-merge [OPTIONS] --source-account --account ` ###### **Options:** @@ -1580,8 +1564,6 @@ Transfers the XLM balance of an account to another account and removes the sourc * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -1593,7 +1575,7 @@ Transfers the XLM balance of an account to another account and removes the sourc Bumps forward the sequence number of the source account to the given sequence number, invalidating any transaction with a smaller sequence number -**Usage:** `stellar tx new bump-sequence [OPTIONS] --bump-to ` +**Usage:** `stellar tx new bump-sequence [OPTIONS] --source-account --bump-to ` ###### **Options:** @@ -1609,8 +1591,6 @@ Bumps forward the sequence number of the source account to the given sequence nu * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -1622,7 +1602,7 @@ Bumps forward the sequence number of the source account to the given sequence nu Creates, updates, or deletes a trustline Learn more about trustlines https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures/accounts#trustlines -**Usage:** `stellar tx new change-trust [OPTIONS] --line ` +**Usage:** `stellar tx new change-trust [OPTIONS] --source-account --line ` ###### **Options:** @@ -1638,8 +1618,6 @@ Creates, updates, or deletes a trustline Learn more about trustlines https://dev * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -1654,7 +1632,7 @@ Creates, updates, or deletes a trustline Learn more about trustlines https://dev Creates and funds a new account with the specified starting balance -**Usage:** `stellar tx new create-account [OPTIONS] --destination ` +**Usage:** `stellar tx new create-account [OPTIONS] --source-account --destination ` ###### **Options:** @@ -1670,8 +1648,6 @@ Creates and funds a new account with the specified starting balance * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -1686,7 +1662,7 @@ Creates and funds a new account with the specified starting balance Sets, modifies, or deletes a data entry (name/value pair) that is attached to an account Learn more about entries and subentries: https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures/accounts#subentries -**Usage:** `stellar tx new manage-data [OPTIONS] --data-name ` +**Usage:** `stellar tx new manage-data [OPTIONS] --source-account --data-name ` ###### **Options:** @@ -1702,8 +1678,6 @@ Sets, modifies, or deletes a data entry (name/value pair) that is attached to an * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -1716,7 +1690,7 @@ Sets, modifies, or deletes a data entry (name/value pair) that is attached to an Sends an amount in a specific asset to a destination account -**Usage:** `stellar tx new payment [OPTIONS] --destination --amount ` +**Usage:** `stellar tx new payment [OPTIONS] --source-account --destination --amount ` ###### **Options:** @@ -1732,8 +1706,6 @@ Sends an amount in a specific asset to a destination account * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -1749,7 +1721,7 @@ Sends an amount in a specific asset to a destination account Set option for an account such as flags, inflation destination, signers, home domain, and master key weight Learn more about flags: https://developers.stellar.org/docs/learn/glossary#flags Learn more about the home domain: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md Learn more about signers operations and key weight: https://developers.stellar.org/docs/learn/encyclopedia/security/signatures-multisig#multisig -**Usage:** `stellar tx new set-options [OPTIONS]` +**Usage:** `stellar tx new set-options [OPTIONS] --source-account ` ###### **Options:** @@ -1765,8 +1737,6 @@ Set option for an account such as flags, inflation destination, signers, home do * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." @@ -1793,7 +1763,7 @@ Set option for an account such as flags, inflation destination, signers, home do Allows issuing account to configure authorization and trustline flags to an asset The Asset parameter is of the `TrustLineAsset` type. If you are modifying a trustline to a regular asset (i.e. one in a Code:Issuer format), this is equivalent to the Asset type. If you are modifying a trustline to a pool share, however, this is composed of the liquidity pool's unique ID. Learn more about flags: https://developers.stellar.org/docs/learn/glossary#flags -**Usage:** `stellar tx new set-trustline-flags [OPTIONS] --trustor --asset ` +**Usage:** `stellar tx new set-trustline-flags [OPTIONS] --source-account --trustor --asset ` ###### **Options:** @@ -1809,8 +1779,6 @@ Allows issuing account to configure authorization and trustline flags to an asse * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--network ` — Name of network to use from config * `--source-account ` — Account that where transaction originates from. Alias `source`. Can be an identity (--source alice), a public key (--source GDKW...), a muxed account (--source MDA…), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). If `--build-only` or `--sim-only` flags were NOT provided, this key will also be used to sign the final transaction. In that case, trying to sign with public key will fail - - Default value: `` * `--hd-path ` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0` * `--global` — Use global config * `--config-dir ` — Location of config directory, default is "." diff --git a/cmd/soroban-cli/src/config/address.rs b/cmd/soroban-cli/src/config/address.rs index 811548316..066bc8d91 100644 --- a/cmd/soroban-cli/src/config/address.rs +++ b/cmd/soroban-cli/src/config/address.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use crate::xdr; -use super::{locator, secret, Config}; +use super::{locator, secret}; /// Address can be either a public key or eventually an alias of a address. #[derive(Clone, Debug)] @@ -31,16 +31,8 @@ impl FromStr for Address { type Err = Error; fn from_str(value: &str) -> Result { - let mut identity = value.to_string(); - - if value.is_empty() { - if let Ok(config) = Config::new() { - identity = config.defaults.identity.unwrap_or_default(); - } - } - - Ok(xdr::MuxedAccount::from_str(&identity).map_or_else( - |_| Address::AliasOrSecret(identity.to_string()), + Ok(xdr::MuxedAccount::from_str(value).map_or_else( + |_| Address::AliasOrSecret(value.to_string()), Address::MuxedAccount, )) } diff --git a/cmd/soroban-cli/src/config/mod.rs b/cmd/soroban-cli/src/config/mod.rs index 396b2b8cc..11eb179ee 100644 --- a/cmd/soroban-cli/src/config/mod.rs +++ b/cmd/soroban-cli/src/config/mod.rs @@ -47,12 +47,7 @@ pub struct Args { #[command(flatten)] pub network: network::Args, - #[arg( - long, - visible_alias = "source", - env = "STELLAR_ACCOUNT", - default_value = "" - )] + #[arg(long, visible_alias = "source", env = "STELLAR_ACCOUNT")] /// Account that where transaction originates from. Alias `source`. /// Can be an identity (--source alice), a public key (--source GDKW...), /// a muxed account (--source MDA…), a secret key (--source SC36…), From 61550ec2157e5550dfaa967fa20c2ca9e2de4df2 Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Thu, 7 Nov 2024 15:41:20 -0800 Subject: [PATCH 2/4] Load default configuration into env vars. (#1716) --- cmd/soroban-cli/src/cli.rs | 27 +++++++++++++++++++++++++ cmd/soroban-cli/src/commands/env/mod.rs | 23 +++++++++------------ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/cmd/soroban-cli/src/cli.rs b/cmd/soroban-cli/src/cli.rs index 9183d0e30..76c5c3194 100644 --- a/cmd/soroban-cli/src/cli.rs +++ b/cmd/soroban-cli/src/cli.rs @@ -2,6 +2,7 @@ use clap::CommandFactory; use dotenvy::dotenv; use tracing_subscriber::{fmt, EnvFilter}; +use crate::config::Config; use crate::print::Print; use crate::upgrade_check::upgrade_check; use crate::{commands, Root}; @@ -33,6 +34,8 @@ pub async fn main() { } } + set_env_from_config(); + let mut root = Root::new().unwrap_or_else(|e| match e { commands::Error::Clap(e) => { let mut cmd = Root::command(); @@ -86,3 +89,27 @@ pub async fn main() { std::process::exit(1); } } + +// Load ~/.config/stellar/config.toml defaults as env vars. +fn set_env_from_config() { + if let Ok(config) = Config::new() { + set_env_value_from_config("STELLAR_ACCOUNT", config.defaults.identity); + set_env_value_from_config("STELLAR_NETWORK", config.defaults.network); + } +} + +// Set an env var from a config file if the env var is not already set. +// Additionally, a `$NAME_SOURCE` variant will be set, which allows +// `stellar env` to properly identity the source. +fn set_env_value_from_config(name: &str, value: Option) { + let Some(value) = value else { + return; + }; + + std::env::remove_var(format!("{name}_SOURCE")); + + if std::env::var(name).is_err() { + std::env::set_var(name, value); + std::env::set_var(format!("{name}_SOURCE"), "use"); + } +} diff --git a/cmd/soroban-cli/src/commands/env/mod.rs b/cmd/soroban-cli/src/commands/env/mod.rs index 4d745400c..298cac3d2 100644 --- a/cmd/soroban-cli/src/commands/env/mod.rs +++ b/cmd/soroban-cli/src/commands/env/mod.rs @@ -1,9 +1,6 @@ use crate::{ commands::global, - config::{ - locator::{self}, - Config, - }, + config::locator::{self}, print::Print, }; use clap::Parser; @@ -23,14 +20,13 @@ pub enum Error { impl Cmd { pub fn run(&self, global_args: &global::Args) -> Result<(), Error> { let print = Print::new(global_args.quiet); - let config = Config::new()?; let mut lines: Vec<(String, String)> = Vec::new(); - if let Some(data) = get("STELLAR_NETWORK", config.defaults.network) { + if let Some(data) = get("STELLAR_NETWORK") { lines.push(data); } - if let Some(data) = get("STELLAR_ACCOUNT", config.defaults.identity) { + if let Some(data) = get("STELLAR_ACCOUNT") { lines.push(data); } @@ -51,13 +47,14 @@ impl Cmd { } } -fn get(env_var: &str, default_value: Option) -> Option<(String, String)> { - if let Ok(value) = std::env::var(env_var) { - return Some((format!("{env_var}={value}"), "env".to_string())); - } +fn get(env_var: &str) -> Option<(String, String)> { + // The _SOURCE env var is set from cmd/soroban-cli/src/cli.rs#set_env_value_from_config + let source = std::env::var(format!("{env_var}_SOURCE")) + .ok() + .unwrap_or("env".to_string()); - if let Some(value) = default_value { - return Some((format!("{env_var}={value}"), "default".to_string())); + if let Ok(value) = std::env::var(env_var) { + return Some((format!("{env_var}={value}"), source)); } None From 715a2008090afdc6c538a1c373d89709981181d6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 00:55:59 +0000 Subject: [PATCH 3/4] Bump version to 22.0.0-rc.1 (#1717) Co-authored-by: Nando Vieira --- Cargo.lock | 37 ++++++++++--------- Cargo.toml | 14 +++---- cmd/crates/soroban-test/Cargo.toml | 2 +- .../tests/fixtures/bye/Cargo.toml | 2 +- .../tests/fixtures/hello/Cargo.toml | 2 +- .../test-wasms/constructor/Cargo.toml | 2 +- .../test-wasms/custom_account/Cargo.toml | 2 +- .../test-wasms/custom_type/Cargo.toml | 2 +- .../test-wasms/hello_world/Cargo.toml | 2 +- cmd/soroban-cli/Cargo.toml | 2 +- cmd/stellar-cli/Cargo.toml | 2 +- 11 files changed, 34 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6bc90a065..4d3cc0c78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4432,7 +4432,7 @@ dependencies = [ [[package]] name = "soroban-cli" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "assert_cmd", "assert_fs", @@ -4676,7 +4676,7 @@ dependencies = [ [[package]] name = "soroban-hello" -version = "21.5.0" +version = "22.0.0-rc.1" [[package]] name = "soroban-ledger-snapshot" @@ -4813,7 +4813,7 @@ dependencies = [ [[package]] name = "soroban-spec-json" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "pretty_assertions", "serde", @@ -4859,7 +4859,7 @@ dependencies = [ [[package]] name = "soroban-spec-tools" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "base64 0.21.7", "ethnum", @@ -4877,7 +4877,7 @@ dependencies = [ [[package]] name = "soroban-spec-typescript" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "base64 0.21.7", "heck 0.4.1", @@ -4898,7 +4898,7 @@ dependencies = [ [[package]] name = "soroban-test" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "assert_cmd", "assert_fs", @@ -4969,18 +4969,18 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stellar-bye" -version = "21.5.0" +version = "22.0.0-rc.1" [[package]] name = "stellar-cli" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "soroban-cli", ] [[package]] name = "stellar-ledger" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "async-trait", "bollard", @@ -5018,8 +5018,9 @@ dependencies = [ [[package]] name = "stellar-rpc-client" -version = "21.4.0" -source = "git+https://github.com/stellar/rs-stellar-rpc-client?rev=7554d4c87c026313a1f5b3c7ae66a92b5ff7e091#7554d4c87c026313a1f5b3c7ae66a92b5ff7e091" +version = "22.0.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaba3219c517ceba11f99e1f9adb1e801fe8416bc9ff35c6842b5fe8cac19290" dependencies = [ "clap", "hex", @@ -5354,42 +5355,42 @@ dependencies = [ [[package]] name = "test_constructor" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "soroban-sdk 22.0.0-rc.3", ] [[package]] name = "test_custom_account" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "soroban-sdk 21.7.2", ] [[package]] name = "test_custom_types" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "soroban-sdk 21.7.2", ] [[package]] name = "test_hello_world" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "soroban-sdk 21.7.2", ] [[package]] name = "test_swap" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "soroban-sdk 21.7.2", ] [[package]] name = "test_token" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "soroban-sdk 21.7.2", "soroban-token-sdk", @@ -5397,7 +5398,7 @@ dependencies = [ [[package]] name = "test_udt" -version = "21.5.0" +version = "22.0.0-rc.1" dependencies = [ "soroban-sdk 21.7.2", ] diff --git a/Cargo.toml b/Cargo.toml index d5f87b38e..31e92e40b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,24 +19,24 @@ exclude = [ ] [workspace.package] -version = "21.5.0" +version = "22.0.0-rc.1" rust-version = "1.81.0" # Dependencies located in this repo: [workspace.dependencies.soroban-cli] -version = "=21.5.0" +version = "=22.0.0-rc.1" path = "cmd/soroban-cli" [workspace.dependencies.soroban-spec-json] -version = "=21.5.0" +version = "=22.0.0-rc.1" path = "./cmd/crates/soroban-spec-json" [workspace.dependencies.soroban-spec-typescript] -version = "21.5.0" +version = "22.0.0-rc.1" path = "./cmd/crates/soroban-spec-typescript" [workspace.dependencies.soroban-spec-tools] -version = "21.5.0" +version = "22.0.0-rc.1" path = "./cmd/crates/soroban-spec-tools" # Dependencies from the rs-stellar-xdr repo: @@ -63,9 +63,7 @@ version = "=22.0.0-rc.3" # Dependencies from the rs-stellar-rpc-client repo: [workspace.dependencies.soroban-rpc] package = "stellar-rpc-client" -version = "21.4.0" -git = "https://github.com/stellar/rs-stellar-rpc-client" -rev = "7554d4c87c026313a1f5b3c7ae66a92b5ff7e091" +version = "=22.0.0-rc.1" # Dependencies from elsewhere shared by crates: [workspace.dependencies] diff --git a/cmd/crates/soroban-test/Cargo.toml b/cmd/crates/soroban-test/Cargo.toml index b240494e4..d9eb31bdd 100644 --- a/cmd/crates/soroban-test/Cargo.toml +++ b/cmd/crates/soroban-test/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/stellar/soroban-test" authors = ["Stellar Development Foundation "] license = "Apache-2.0" readme = "README.md" -version = "21.5.0" +version = "22.0.0-rc.1" edition = "2021" rust-version.workspace = true autobins = false diff --git a/cmd/crates/soroban-test/tests/fixtures/bye/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/bye/Cargo.toml index 7678eee5e..acee77f4b 100644 --- a/cmd/crates/soroban-test/tests/fixtures/bye/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/bye/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stellar-bye" -version = "21.5.0" +version = "22.0.0-rc.1" edition = "2021" publish = false diff --git a/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml index 0c3b1512f..2a212a532 100644 --- a/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/hello/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "soroban-hello" -version = "21.5.0" +version = "22.0.0-rc.1" edition = "2021" publish = false diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/constructor/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/test-wasms/constructor/Cargo.toml index ef1dd882c..8c38fecb4 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/constructor/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/constructor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_constructor" -version = "21.5.0" +version = "22.0.0-rc.1" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_account/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_account/Cargo.toml index 792925edb..9be386b69 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_account/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_account/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_custom_account" -version = "21.5.0" +version = "22.0.0-rc.1" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml index 398520104..7c4ca5828 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/custom_type/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_custom_types" -version = "21.5.0" +version = "22.0.0-rc.1" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml b/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml index 5f8b1256f..19b7353ca 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_hello_world" -version = "21.5.0" +version = "22.0.0-rc.1" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/cmd/soroban-cli/Cargo.toml b/cmd/soroban-cli/Cargo.toml index efef18e0f..d2a53e6f2 100644 --- a/cmd/soroban-cli/Cargo.toml +++ b/cmd/soroban-cli/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/stellar/stellar-cli" authors = ["Stellar Development Foundation "] license = "Apache-2.0" readme = "README.md" -version = "21.5.0" +version = "22.0.0-rc.1" edition = "2021" rust-version.workspace = true autobins = false diff --git a/cmd/stellar-cli/Cargo.toml b/cmd/stellar-cli/Cargo.toml index 2a388b4de..21e7e307b 100644 --- a/cmd/stellar-cli/Cargo.toml +++ b/cmd/stellar-cli/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/stellar/stellar-cli" authors = ["Stellar Development Foundation "] license = "Apache-2.0" readme = "README.md" -version = "21.5.0" +version = "22.0.0-rc.1" edition = "2021" rust-version.workspace = true autobins = false From f1f95831b13baaecbe6127aa7e28a2d017ccec5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?jeesun=20=EC=A7=80=EC=84=A0?= Date: Sun, 10 Nov 2024 16:48:20 -0800 Subject: [PATCH 4/4] update cli doc url (#1719) --- FULL_HELP_DOCS.md | 2 +- cmd/soroban-cli/src/commands/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index 899c0115e..c7cd9c56c 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -18,7 +18,7 @@ For additional information see: - Stellar Docs: https://developers.stellar.org - Smart Contract Docs: https://developers.stellar.org/docs/build/smart-contracts/overview -- CLI Docs: https://developers.stellar.org/docs/tools/stellar-cli +- CLI Docs: https://developers.stellar.org/docs/tools/developer-tools/cli/stellar-cli To get started generate a new identity: diff --git a/cmd/soroban-cli/src/commands/mod.rs b/cmd/soroban-cli/src/commands/mod.rs index f4344fb9d..25d61364d 100644 --- a/cmd/soroban-cli/src/commands/mod.rs +++ b/cmd/soroban-cli/src/commands/mod.rs @@ -38,7 +38,7 @@ For additional information see: - Stellar Docs: https://developers.stellar.org - Smart Contract Docs: https://developers.stellar.org/docs/build/smart-contracts/overview -- CLI Docs: https://developers.stellar.org/docs/tools/stellar-cli"; +- CLI Docs: https://developers.stellar.org/docs/tools/developer-tools/cli/stellar-cli"; // long_about is shown when someone uses `--help`; short help when using `-h` const LONG_ABOUT: &str = "