From 278159ff8c3f9a132691bc6fd39b043cb09c298e Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Thu, 7 Nov 2024 14:19:41 -0800 Subject: [PATCH] Revert "Resolve identity from default config. (#1711)" 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 6f3882ce62..48cc98aa9d 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -130,7 +130,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:** @@ -140,8 +140,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 "." @@ -347,7 +345,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:** @@ -373,8 +371,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 "." @@ -392,7 +388,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:** @@ -408,8 +404,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 "." @@ -481,7 +475,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:** @@ -491,8 +485,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 "." @@ -684,7 +676,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:** @@ -693,8 +685,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 "." @@ -720,7 +710,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:** @@ -735,8 +725,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 "." @@ -825,7 +813,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:** @@ -851,8 +839,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 "." @@ -1391,7 +1377,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:** @@ -1400,8 +1386,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 "." @@ -1483,7 +1467,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:** @@ -1499,8 +1483,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 "." @@ -1512,7 +1494,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:** @@ -1528,8 +1510,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 "." @@ -1541,7 +1521,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:** @@ -1557,8 +1537,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 "." @@ -1573,7 +1551,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:** @@ -1589,8 +1567,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 "." @@ -1605,7 +1581,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:** @@ -1621,8 +1597,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 "." @@ -1635,7 +1609,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:** @@ -1651,8 +1625,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 "." @@ -1668,7 +1640,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:** @@ -1684,8 +1656,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 "." @@ -1712,7 +1682,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:** @@ -1728,8 +1698,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 811548316f..066bc8d918 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 396b2b8ccd..11eb179eea 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…),