Skip to content

Commit

Permalink
Do not require source account when reading contract.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Oct 7, 2024
1 parent 46c534e commit 34d92bb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 1 addition & 3 deletions FULL_HELP_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ Optimize a WASM file

Print the current value of a contract-data ledger entry

**Usage:** `stellar contract read [OPTIONS] --source-account <SOURCE_ACCOUNT>`
**Usage:** `stellar contract read [OPTIONS]`

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

Expand Down Expand Up @@ -781,8 +781,6 @@ Print the current value of a contract-data ledger entry
* `--rpc-url <RPC_URL>` — RPC server endpoint
* `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
* `--network <NETWORK>` — Name of network to use from config
* `--source-account <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 <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 <CONFIG_DIR>` — Location of config directory, default is "."

Expand Down
8 changes: 4 additions & 4 deletions cmd/soroban-cli/src/commands/contract/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Cmd {
#[command(flatten)]
pub key: key::Args,
#[command(flatten)]
config: config::Args,
config: config::ArgsLocatorAndNetwork,
}

#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ValueEnum)]
Expand Down Expand Up @@ -179,10 +179,10 @@ impl NetworkRunnable for Cmd {

async fn run_against_rpc_server(
&self,
_: Option<&global::Args>,
config: Option<&config::Args>,
_global_args: Option<&global::Args>,
_config: Option<&config::Args>,
) -> Result<FullLedgerEntries, Error> {
let config = config.unwrap_or(&self.config);
let config: config::Args = self.config.clone().into();
let network = config.get_network()?;
tracing::trace!(?network);
let client = Client::new(&network.rpc_url)?;
Expand Down
11 changes: 11 additions & 0 deletions cmd/soroban-cli/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,14 @@ impl ArgsLocatorAndNetwork {
Ok(self.network.get(&self.locator)?)
}
}

impl From<ArgsLocatorAndNetwork> for Args {
fn from(value: ArgsLocatorAndNetwork) -> Self {
Args {
network: value.network,
source_account: Address::AliasOrSecret(String::new()),
hd_path: Some(0),
locator: value.locator,
}
}
}

0 comments on commit 34d92bb

Please sign in to comment.