Skip to content

Commit

Permalink
Do not require source account when reading contract. (#1658)
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando authored Oct 8, 2024
1 parent 46c534e commit ba23e00
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 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
2 changes: 0 additions & 2 deletions cmd/crates/soroban-test/tests/it/integration/cookbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ mod tests {
.arg("xdr")
.arg("--key")
.arg("COUNTER")
.arg("--source-account")
.arg(source)
.assert()
.stdout_as_str();
let key_xdr = read_xdr.split(',').next().unwrap_or("").trim();
Expand Down
15 changes: 9 additions & 6 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 @@ -89,6 +89,8 @@ pub enum Error {
OnlyDataAllowed,
#[error(transparent)]
Locator(#[from] locator::Error),
#[error(transparent)]
Network(#[from] config::network::Error),
}

impl Cmd {
Expand Down Expand Up @@ -179,14 +181,15 @@ 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 network = config.get_network()?;
let locator = self.config.locator.clone();
let network = self.config.network.get(&locator)?;

tracing::trace!(?network);
let client = Client::new(&network.rpc_url)?;
let keys = self.key.parse_keys(&config.locator, &network)?;
let keys = self.key.parse_keys(&locator, &network)?;
Ok(client.get_full_ledger_entries(&keys).await?)
}
}
2 changes: 1 addition & 1 deletion cookbook/contract-lifecycle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ stellar contract invoke --id <CONTRACT_ID> --source alice --network testnet -- f
6. View the contract's state:

```bash
stellar contract read --id <CONTRACT_ID> --network testnet --source alice --durability <DURABILITY> --key <KEY>
stellar contract read --id <CONTRACT_ID> --network testnet --durability <DURABILITY> --key <KEY>
```

Note: `<DURABILITY>` is either `persistent` or `temporary`. `KEY` provides the key of the storage entry being read.
Expand Down

0 comments on commit ba23e00

Please sign in to comment.