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
16 changes: 8 additions & 8 deletions FULL_HELP_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Remove contract alias

Add contract alias

**Usage:** `stellar contract alias add [OPTIONS] --id <CONTRACT_ID> <ALIAS>`
**Usage:** `stellar contract alias add [OPTIONS] --contract-id <CONTRACT_ID> <ALIAS>`

###### **Arguments:**

Expand All @@ -223,7 +223,7 @@ Add contract alias
###### **Options:**

- `--overwrite` — Overwrite the contract alias if it already exists
- `--id <CONTRACT_ID>` — The contract id that will be associated with the alias
- `--contract-id <CONTRACT_ID>` [alias: `id`] — The contract id that will be associated with the alias

###### **RPC Options:**

Expand Down Expand Up @@ -437,7 +437,7 @@ If no keys are specified the contract itself is extended.

- `--ledgers-to-extend <LEDGERS_TO_EXTEND>` — Number of ledgers to extend the entries
- `--ttl-ledger-only` — Only print the new Time To Live ledger
- `--id <CONTRACT_ID>` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended
- `--contract-id <CONTRACT_ID>` [alias: `id`] — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended
- `--key <KEY>` — Storage key (symbols only)
- `--key-xdr <KEY_XDR>` — Storage key (base64-encoded XDR)
- `--wasm <WASM>` — Path to Wasm file of contract code to extend
Expand Down Expand Up @@ -558,7 +558,7 @@ Fetch a contract's Wasm binary

###### **Options:**

- `--id <CONTRACT_ID>` — Contract ID to fetch
- `--contract-id <CONTRACT_ID>` [alias: `id`] — Contract ID to fetch
- `--wasm-hash <WASM_HASH>` — Wasm to fetch
- `-o`, `--out-file <OUT_FILE>` — Where to write output otherwise stdout is used

Expand Down Expand Up @@ -991,7 +991,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 <CONTRACT_ID> --source-account <SOURCE_ACCOUNT> [-- <CONTRACT_FN_AND_ARGS>...]`
**Usage:** `stellar contract invoke [OPTIONS] --contract-id <CONTRACT_ID> --source-account <SOURCE_ACCOUNT> [-- <CONTRACT_FN_AND_ARGS>...]`

###### **Arguments:**

Expand All @@ -1003,7 +1003,7 @@ stellar contract invoke ... -- --help

###### **Options:**

- `--id <CONTRACT_ID>` — Contract ID to invoke
- `--contract-id <CONTRACT_ID>` [alias: `id`] — Contract ID to invoke
- `--is-view` — ⚠️ Deprecated, use `--send=no`. View the result simulating and do not sign and submit transaction
- `--send <SEND>` — Whether or not to send a transaction

Expand Down Expand Up @@ -1078,7 +1078,7 @@ Print the current value of a contract-data ledger entry
- `json`: Json
- `xdr`: XDR

- `--id <CONTRACT_ID>` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended
- `--contract-id <CONTRACT_ID>` [alias: `id`] — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended
- `--key <KEY>` — Storage key (symbols only)
- `--key-xdr <KEY_XDR>` — Storage key (base64-encoded XDR)
- `--wasm <WASM>` — Path to Wasm file of contract code to extend
Expand Down Expand Up @@ -1112,7 +1112,7 @@ If no keys are specificed the contract itself is restored.

###### **Options:**

- `--id <CONTRACT_ID>` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended
- `--contract-id <CONTRACT_ID>` [alias: `id`] — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended
- `--key <KEY>` — Storage key (symbols only)
- `--key-xdr <KEY_XDR>` — Storage key (base64-encoded XDR)
- `--wasm <WASM>` — Path to Wasm file of contract code to extend
Expand Down
44 changes: 44 additions & 0 deletions cmd/crates/soroban-test/tests/it/contract_id_flag.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use soroban_test::TestEnv;

// Every contract subcommand that references an existing contract should expose
// `--contract-id` as the canonical flag with `--id` kept as an alias, matching
// `stellar contract info`.
fn assert_contract_id_flag(subcommand: &[&str]) {
let sandbox = TestEnv::default();
let help = sandbox
.new_assert_cmd("contract")
.args(subcommand)
.arg("--help")
.assert()
.success()
.get_output()
.stdout
.clone();
let help = String::from_utf8(help).unwrap();

assert!(
help.contains("--contract-id"),
"`contract {}` help is missing --contract-id:\n{help}",
subcommand.join(" ")
);
assert!(
help.contains("--id"),
"`contract {}` help is missing the --id alias:\n{help}",
subcommand.join(" ")
);
}

#[test]
fn contract_id_flag_is_consistent_across_commands() {
for subcommand in [
&["invoke"][..],
&["fetch"][..],
&["read"][..],
&["extend"][..],
&["restore"][..],
&["info", "interface"][..],
&["alias", "add"][..],
] {
assert_contract_id_flag(subcommand);
}
}
1 change: 1 addition & 0 deletions cmd/crates/soroban-test/tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod build;
mod config;
#[cfg(unix)]
mod container;
mod contract_id_flag;
#[cfg(feature = "emulator-tests")]
mod emulator;
mod help;
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/alias/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct Cmd {
pub overwrite: bool,

/// The contract id that will be associated with the alias.
#[arg(long = "id")]
#[arg(long = "contract-id", visible_alias = "id")]
pub contract_id: stellar_strkey::Contract,
}

Expand Down
8 changes: 6 additions & 2 deletions cmd/soroban-cli/src/commands/contract/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ use crate::{
#[group(skip)]
pub struct Cmd {
/// Contract ID to fetch
#[arg(long = "id", env = "STELLAR_CONTRACT_ID")]
#[arg(
long = "contract-id",
visible_alias = "id",
env = "STELLAR_CONTRACT_ID"
)]
pub contract_id: Option<config::UnresolvedContract>,
/// Wasm to fetch
#[arg(long = "wasm-hash", conflicts_with = "contract_id")]
Expand Down Expand Up @@ -67,7 +71,7 @@ pub enum Error {
Wasm(#[from] wasm::Error),
#[error("wasm hash is invalid {0:?}")]
InvalidWasmHash(String),
#[error("must provide one of --wasm-hash, or --id")]
#[error("must provide one of --wasm-hash, or --contract-id")]
MissingArg,
}

Expand Down
6 changes: 5 additions & 1 deletion cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ use soroban_spec_tools::contract;
#[group(skip)]
pub struct Cmd {
/// Contract ID to invoke
#[arg(long = "id", env = "STELLAR_CONTRACT_ID")]
#[arg(
long = "contract-id",
visible_alias = "id",
env = "STELLAR_CONTRACT_ID"
)]
pub contract_id: config::UnresolvedContract,

// For testing only
Expand Down
3 changes: 2 additions & 1 deletion cmd/soroban-cli/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ pub struct Args {
/// Contract ID to which owns the data entries.
/// If no keys provided the Contract's instance will be extended
#[arg(
long = "id",
long = "contract-id",
visible_alias = "id",
required_unless_present = "wasm",
required_unless_present = "wasm_hash"
)]
Expand Down
Loading