From ddad905341042867b32f02cbe005bcedd5a06f78 Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Wed, 2 Oct 2024 17:12:44 -0700 Subject: [PATCH] Do not require source account when fetching an asset's contract id. (#1647) --- FULL_HELP_DOCS.md | 8 ++------ .../tests/it/integration/cookbook.rs | 2 -- .../src/commands/contract/id/asset.rs | 2 +- cmd/soroban-cli/src/config/mod.rs | 16 ++++++++++++++++ cookbook/deploy-stellar-asset-contract.mdx | 1 - cookbook/payments-and-assets.mdx | 2 +- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index be20ae24a..b8b03c580 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -111,7 +111,7 @@ Utilities to deploy a Stellar Asset Contract or get its id Get Id of builtin Soroban Asset Contract. Deprecated, use `stellar contract id asset` instead -**Usage:** `stellar contract asset id [OPTIONS] --asset --source-account ` +**Usage:** `stellar contract asset id [OPTIONS] --asset ` ###### **Options:** @@ -119,8 +119,6 @@ Get Id of builtin Soroban Asset Contract. Deprecated, use `stellar contract id a * `--rpc-url ` — RPC server endpoint * `--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 -* `--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 "." @@ -444,7 +442,7 @@ Generate the contract id for a given contract or asset Deploy builtin Soroban Asset Contract -**Usage:** `stellar contract id asset [OPTIONS] --asset --source-account ` +**Usage:** `stellar contract id asset [OPTIONS] --asset ` ###### **Options:** @@ -452,8 +450,6 @@ Deploy builtin Soroban Asset Contract * `--rpc-url ` — RPC server endpoint * `--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 -* `--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/crates/soroban-test/tests/it/integration/cookbook.rs b/cmd/crates/soroban-test/tests/it/integration/cookbook.rs index 4c0ad5a63..82b9c5f43 100644 --- a/cmd/crates/soroban-test/tests/it/integration/cookbook.rs +++ b/cmd/crates/soroban-test/tests/it/integration/cookbook.rs @@ -236,8 +236,6 @@ mod tests { .arg("asset") .arg("--asset") .arg("native") - .arg("--source-account") - .arg(source) .assert() .stdout_as_str(); let contract_id = deploy_hello(&sandbox).await; diff --git a/cmd/soroban-cli/src/commands/contract/id/asset.rs b/cmd/soroban-cli/src/commands/contract/id/asset.rs index 63b3017a1..cdf826015 100644 --- a/cmd/soroban-cli/src/commands/contract/id/asset.rs +++ b/cmd/soroban-cli/src/commands/contract/id/asset.rs @@ -13,7 +13,7 @@ pub struct Cmd { pub asset: builder::Asset, #[command(flatten)] - pub config: config::Args, + pub config: config::ArgsLocatorAndNetwork, } #[derive(thiserror::Error, Debug)] pub enum Error { diff --git a/cmd/soroban-cli/src/config/mod.rs b/cmd/soroban-cli/src/config/mod.rs index 5b64a2697..12f571a50 100644 --- a/cmd/soroban-cli/src/config/mod.rs +++ b/cmd/soroban-cli/src/config/mod.rs @@ -129,3 +129,19 @@ impl Pwd for Args { #[derive(Default, Serialize, Deserialize)] pub struct Config {} + +#[derive(Debug, clap::Args, Clone, Default)] +#[group(skip)] +pub struct ArgsLocatorAndNetwork { + #[command(flatten)] + pub network: network::Args, + + #[command(flatten)] + pub locator: locator::Args, +} + +impl ArgsLocatorAndNetwork { + pub fn get_network(&self) -> Result { + Ok(self.network.get(&self.locator)?) + } +} diff --git a/cookbook/deploy-stellar-asset-contract.mdx b/cookbook/deploy-stellar-asset-contract.mdx index 7233acc60..8fca51c48 100644 --- a/cookbook/deploy-stellar-asset-contract.mdx +++ b/cookbook/deploy-stellar-asset-contract.mdx @@ -42,7 +42,6 @@ For any asset, the contract address can be fetched with: ```bash stellar contract id asset \ - --source S... \ --network testnet \ --asset native ``` diff --git a/cookbook/payments-and-assets.mdx b/cookbook/payments-and-assets.mdx index 9849bf3d9..e3be8dafc 100644 --- a/cookbook/payments-and-assets.mdx +++ b/cookbook/payments-and-assets.mdx @@ -35,7 +35,7 @@ stellar keys fund bob 3. Obtain the stellar asset contract ID: ```bash -stellar contract id asset --asset native --source-account alice +stellar contract id asset --asset native ``` 4. Get Bob's public key: