diff --git a/Cargo.toml b/Cargo.toml index 3e55a7e8df..8758b42ce3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,49 +69,27 @@ version = "=20.3.1" version = "20.3.0" path = "cmd/soroban-cli" -[workspace.dependencies.soroban-rpc] -version = "20.2.0" -path = "cmd/crates/soroban-rpc" - [workspace.dependencies.stellar-xdr] version = "=20.1.0" default-features = true [workspace.dependencies] -stellar-strkey = "0.0.7" -sep5 = "0.0.2" base64 = "0.21.2" thiserror = "1.0.46" sha2 = "0.10.7" ethnum = "1.3.2" hex = "0.4.3" itertools = "0.10.0" - -serde-aux = "4.1.2" +sep5 = "0.0.2" serde_json = "1.0.82" serde = "1.0.82" - -clap = { version = "4.1.8", features = [ - "derive", - "env", - "deprecated", - "string", -] } -clap_complete = "4.1.4" +stellar-strkey = "0.0.7" tracing = "0.1.37" tracing-subscriber = "0.3.16" tracing-appender = "0.2.2" which = "4.4.0" wasmparser = "0.90.0" -termcolor = "1.1.3" -termcolor_output = "1.0.1" -ed25519-dalek = "2.0.0" - -# networking -http = "1.0.0" -jsonrpsee-http-client = "0.20.1" -jsonrpsee-core = "0.20.1" -tokio = "1.28.1" + # [patch."https://github.com/stellar/rs-soroban-env"] # soroban-env-host = { path = "../rs-soroban-env/soroban-env-host/" } diff --git a/cmd/crates/soroban-rpc/Cargo.toml b/cmd/crates/soroban-rpc/Cargo.toml deleted file mode 100644 index 966597a22b..0000000000 --- a/cmd/crates/soroban-rpc/Cargo.toml +++ /dev/null @@ -1,51 +0,0 @@ -[package] -name = "soroban-rpc" -description = "Soroban RPC client for rust" -homepage = "https://github.com/stellar/soroban-tools" -repository = "https://github.com/stellar/soroban-tools" -authors = ["Stellar Development Foundation "] -license = "Apache-2.0" -readme = "README.md" -version.workspace = true -edition = "2021" -rust-version.workspace = true -autobins = false - - -[lib] -crate-type = ["rlib"] - - -[dependencies] -soroban-sdk = { version = "=20.3.0", git = "https://github.com/stellar/rs-soroban-sdk", rev = "4aef54ff9295c2fca4c5b9fbd2c92d0ff99f67de" } -soroban-spec-tools = { version = "20.2.0", path = "../soroban-spec-tools" } -soroban-env-host = { version = "=20.2.0", git = "https://github.com/stellar/rs-soroban-env", rev = "1bfc0f2a2ee134efc1e1b0d5270281d0cba61c2e" } -stellar-strkey = "0.0.7" -stellar-xdr = { version = "=20.1.0", default-features = true, features = ["curr", "std", "serde"] } -soroban-spec = { version = "=20.3.0", git = "https://github.com/stellar/rs-soroban-sdk", rev = "4aef54ff9295c2fca4c5b9fbd2c92d0ff99f67de" } - -termcolor = "1.1.3" -termcolor_output = "1.0.1" -clap = { version = "4.1.8", features = ["derive", "env", "deprecated", "string"] } -serde_json = "1.0.82" -serde-aux = "4.1.2" -itertools = "0.10.0" -ethnum = "1.3.2" -hex = "0.4.3" -wasmparser = "0.90.0" -base64 = "0.21.2" -thiserror = "1.0.46" -serde = "1.0.82" -tokio = "1.28.1" -sha2 = "0.10.7" -ed25519-dalek = "2.0.0" -tracing = "0.1.40" - -# networking -jsonrpsee-http-client = "0.20.1" -jsonrpsee-core = "0.20.1" -http = "1.0.0" - - -[dev-dependencies] -which = "4.4.0" diff --git a/cmd/crates/soroban-rpc/README.md b/cmd/crates/soroban-rpc/README.md deleted file mode 100644 index 9185b7fd05..0000000000 --- a/cmd/crates/soroban-rpc/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# soroban-rpc - -Tools and utilities for soroban rpc. diff --git a/cmd/crates/soroban-rpc/src/log.rs b/cmd/crates/soroban-rpc/src/log.rs deleted file mode 100644 index 3612681484..0000000000 --- a/cmd/crates/soroban-rpc/src/log.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod diagnostic_events; -pub use diagnostic_events::*; diff --git a/cmd/crates/soroban-rpc/src/log/diagnostic_events.rs b/cmd/crates/soroban-rpc/src/log/diagnostic_events.rs deleted file mode 100644 index 68af67a4eb..0000000000 --- a/cmd/crates/soroban-rpc/src/log/diagnostic_events.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub fn diagnostic_events(events: &[impl std::fmt::Debug], level: tracing::Level) { - for (i, event) in events.iter().enumerate() { - if level == tracing::Level::TRACE { - tracing::trace!("{i}: {event:#?}"); - } else if level == tracing::Level::INFO { - tracing::info!("{i}: {event:#?}"); - } else if level == tracing::Level::ERROR { - tracing::error!("{i}: {event:#?}"); - } - } -} diff --git a/cmd/crates/soroban-spec-tools/Cargo.toml b/cmd/crates/soroban-spec-tools/Cargo.toml index 514b82924b..61a32c1371 100644 --- a/cmd/crates/soroban-spec-tools/Cargo.toml +++ b/cmd/crates/soroban-spec-tools/Cargo.toml @@ -20,8 +20,6 @@ crate-type = ["rlib"] soroban-spec = { workspace = true } stellar-strkey = { workspace = true } stellar-xdr = { workspace = true, features = ["curr", "std", "serde"] } -soroban-env-host = { workspace = true } - serde_json = { workspace = true } itertools = { workspace = true } ethnum = { workspace = true } diff --git a/cmd/crates/soroban-spec-tools/src/lib.rs b/cmd/crates/soroban-spec-tools/src/lib.rs index bc3c2a3866..7f310fd996 100644 --- a/cmd/crates/soroban-spec-tools/src/lib.rs +++ b/cmd/crates/soroban-spec-tools/src/lib.rs @@ -13,7 +13,6 @@ use stellar_xdr::curr::{ UInt128Parts, UInt256Parts, Uint256, VecM, }; -pub mod contract; pub mod utils; #[derive(thiserror::Error, Debug)] diff --git a/cmd/crates/soroban-test/tests/it/help.rs b/cmd/crates/soroban-test/tests/it/help.rs index a66c449ed3..6d4680e772 100644 --- a/cmd/crates/soroban-test/tests/it/help.rs +++ b/cmd/crates/soroban-test/tests/it/help.rs @@ -1,11 +1,11 @@ use soroban_cli::commands::contract; use soroban_test::TestEnv; -use crate::util::{invoke_custom as invoke, CUSTOM_TYPES, DEFAULT_CONTRACT_ID}; +use crate::util::{invoke_custom as invoke, CUSTOM_TYPES}; async fn invoke_custom(func: &str, args: &str) -> Result { let e = &TestEnv::default(); - invoke(e, DEFAULT_CONTRACT_ID, func, args, &CUSTOM_TYPES.path()).await + invoke(e, "1", func, args, &CUSTOM_TYPES.path()).await } #[tokio::test] diff --git a/cmd/crates/soroban-test/tests/it/integration/dotenv.rs b/cmd/crates/soroban-test/tests/it/integration/dotenv.rs index 7c0f25b3fc..d7d56aaf3b 100644 --- a/cmd/crates/soroban-test/tests/it/integration/dotenv.rs +++ b/cmd/crates/soroban-test/tests/it/integration/dotenv.rs @@ -35,7 +35,7 @@ fn current_env_not_overwritten() { write_env_file(e, &contract_id()); e.new_assert_cmd("contract") - .env("SOROBAN_CONTRACT_ID", "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4") + .env("SOROBAN_CONTRACT_ID", "2") .arg("invoke") .arg("--") .arg("hello") @@ -51,10 +51,7 @@ fn cli_args_have_priority() { deploy_hello(e); write_env_file(e, &contract_id()); e.new_assert_cmd("contract") - .env( - "SOROBAN_CONTRACT_ID", - "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - ) + .env("SOROBAN_CONTRACT_ID", "2") .arg("invoke") .arg("--id") .arg(TEST_CONTRACT_ID) diff --git a/cmd/crates/soroban-test/tests/it/integration/hello_world.rs b/cmd/crates/soroban-test/tests/it/integration/hello_world.rs index 7bd8d596a7..7714f70dd4 100644 --- a/cmd/crates/soroban-test/tests/it/integration/hello_world.rs +++ b/cmd/crates/soroban-test/tests/it/integration/hello_world.rs @@ -1,4 +1,3 @@ -use predicates::boolean::PredicateBooleanExt; use soroban_cli::commands::{ contract::{self, fetch}, keys, @@ -20,23 +19,7 @@ async fn invoke() { extend_contract(sandbox, id, HELLO_WORLD).await; // Note that all functions tested here have no state invoke_hello_world(sandbox, id); - sandbox - .new_assert_cmd("events") - .arg("--start-ledger=20") - .arg("--id") - .arg(id) - .assert() - .stdout(predicates::str::contains(id).not()) - .success(); invoke_hello_world_with_lib(sandbox, id).await; - sandbox - .new_assert_cmd("events") - .arg("--start-ledger=20") - .arg("--id") - .arg(id) - .assert() - .stdout(predicates::str::contains(id)) - .success(); invoke_hello_world_with_lib_two(sandbox, id).await; invoke_auth(sandbox, id); invoke_auth_with_identity(sandbox, id).await; @@ -56,7 +39,6 @@ fn invoke_hello_world(sandbox: &TestEnv, id: &str) { sandbox .new_assert_cmd("contract") .arg("invoke") - .arg("--is-view") .arg("--id") .arg(id) .arg("--") diff --git a/cmd/crates/soroban-test/tests/it/util.rs b/cmd/crates/soroban-test/tests/it/util.rs index 112d5f841a..6d62510126 100644 --- a/cmd/crates/soroban-test/tests/it/util.rs +++ b/cmd/crates/soroban-test/tests/it/util.rs @@ -68,5 +68,3 @@ pub async fn invoke_custom( i.invoke(&soroban_cli::commands::global::Args::default()) .await } - -pub const DEFAULT_CONTRACT_ID: &str = "CDR6QKTWZQYW6YUJ7UP7XXZRLWQPFRV6SWBLQS4ZQOSAF4BOUD77OO5Z"; diff --git a/cmd/soroban-cli/src/commands/contract/bindings/typescript.rs b/cmd/soroban-cli/src/commands/contract/bindings/typescript.rs index 091f8255a9..19c7eecd66 100644 --- a/cmd/soroban-cli/src/commands/contract/bindings/typescript.rs +++ b/cmd/soroban-cli/src/commands/contract/bindings/typescript.rs @@ -1,15 +1,17 @@ use std::{ffi::OsString, fmt::Debug, path::PathBuf}; use clap::{command, Parser}; -use soroban_spec_tools::contract as contract_spec; use soroban_spec_typescript::{self as typescript, boilerplate::Project}; -use crate::commands::{ - config::locator, - contract::{self, fetch}, - network::{self, Network}, -}; use crate::wasm; +use crate::{ + commands::{ + config::locator, + contract::{self, fetch}, + network::{self, Network}, + }, + utils::contract_spec::{self, ContractSpec}, +}; #[derive(Parser, Debug, Clone)] #[group(skip)] @@ -76,7 +78,7 @@ impl Cmd { network: self.network.clone(), }; let bytes = fetch.get_bytes().await?; - contract_spec::Spec::new(&bytes)?.spec + ContractSpec::new(&bytes)?.spec }; if self.output_dir.is_file() { return Err(Error::IsFile(self.output_dir.clone())); diff --git a/cmd/soroban-cli/src/commands/contract/extend.rs b/cmd/soroban-cli/src/commands/contract/extend.rs index 86ea23b55b..7e9f1e98ca 100644 --- a/cmd/soroban-cli/src/commands/contract/extend.rs +++ b/cmd/soroban-cli/src/commands/contract/extend.rs @@ -144,18 +144,15 @@ impl Cmd { }), }; - let res = client + let (result, meta, events) = client .prepare_and_send_transaction(&tx, &key, &[], &network.network_passphrase, None, None) .await?; - let events = res.events()?; + tracing::trace!(?result); + tracing::trace!(?meta); if !events.is_empty() { tracing::info!("Events:\n {events:#?}"); } - let meta = res - .result_meta - .as_ref() - .ok_or(Error::MissingOperationResult)?; // The transaction from core will succeed regardless of whether it actually found & extended // the entry, so we have to inspect the result meta to tell if it worked or not. diff --git a/cmd/soroban-cli/src/commands/contract/inspect.rs b/cmd/soroban-cli/src/commands/contract/inspect.rs index e66bf83fdb..355c18ca81 100644 --- a/cmd/soroban-cli/src/commands/contract/inspect.rs +++ b/cmd/soroban-cli/src/commands/contract/inspect.rs @@ -1,6 +1,5 @@ use clap::{command, Parser}; use soroban_env_host::xdr; -use soroban_spec_tools::contract; use std::{fmt::Debug, path::PathBuf}; use tracing::debug; @@ -29,7 +28,7 @@ pub enum Error { #[error(transparent)] Xdr(#[from] xdr::Error), #[error(transparent)] - Spec(#[from] contract::Error), + Spec(#[from] crate::utils::contract_spec::Error), } impl Cmd { diff --git a/cmd/soroban-cli/src/commands/contract/install.rs b/cmd/soroban-cli/src/commands/contract/install.rs index c2fa6d889d..905775298a 100644 --- a/cmd/soroban-cli/src/commands/contract/install.rs +++ b/cmd/soroban-cli/src/commands/contract/install.rs @@ -112,10 +112,14 @@ impl Cmd { build_install_contract_code_tx(contract, sequence + 1, self.fee.fee, &key)?; // Currently internal errors are not returned if the contract code is expired - if let Some(TransactionResult { - result: TransactionResultResult::TxInternalError, - .. - }) = client + if let ( + TransactionResult { + result: TransactionResultResult::TxInternalError, + .. + }, + _, + _, + ) = client .prepare_and_send_transaction( &tx_without_preflight, &key, @@ -125,8 +129,6 @@ impl Cmd { None, ) .await? - .result - .as_ref() { // Now just need to restore it and don't have to install again restore::Cmd { @@ -151,7 +153,7 @@ impl Cmd { } } -fn get_contract_meta_sdk_version(wasm_spec: &soroban_spec_tools::contract::Spec) -> Option { +fn get_contract_meta_sdk_version(wasm_spec: &utils::contract_spec::ContractSpec) -> Option { let rs_sdk_version_option = if let Some(_meta) = &wasm_spec.meta_base64 { wasm_spec.meta.iter().find(|entry| match entry { ScMetaEntry::ScMetaV0(ScMetaV0 { key, .. }) => { diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 720c3c6f80..669342b065 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -28,8 +28,13 @@ use super::super::{ config::{self, locator}, events, }; -use crate::{commands::global, rpc, Pwd}; -use soroban_spec_tools::{contract, Spec}; +use crate::{ + commands::global, + rpc::{self, Client}, + utils::{self, contract_spec}, + Pwd, +}; +use soroban_spec_tools::Spec; #[derive(Parser, Debug, Default, Clone)] #[allow(clippy::struct_excessive_bools)] @@ -44,12 +49,6 @@ pub struct Cmd { /// Output the cost execution to stderr #[arg(long = "cost")] pub cost: bool, - /// Number of instructions to simulate - #[arg(long)] - pub instructions: Option, - /// Do not sign and submit transaction - #[arg(long, env = "SOROBAN_INVOKE_SIGN", env = "SYSTEM_TEST_VERBOSE_OUTPUT")] - pub is_view: bool, /// Function name as subcommand, then arguments for that function as `--arg-name value` #[arg(last = true, id = "CONTRACT_FN_AND_ARGS")] pub slop: Vec, @@ -141,7 +140,7 @@ pub enum Error { #[error(transparent)] StrKey(#[from] stellar_strkey::DecodeError), #[error(transparent)] - ContractSpec(#[from] contract::Error), + ContractSpec(#[from] contract_spec::Error), #[error("")] MissingFileArg(PathBuf), } @@ -276,7 +275,7 @@ impl Cmd { // For testing wasm arg parsing let _ = self.build_host_function_parameters(contract_id, spec_entries)?; } - let client = rpc::Client::new(&network.rpc_url)?; + let client = Client::new(&network.rpc_url)?; client .verify_network_passphrase(Some(&network.network_passphrase)) .await?; @@ -300,31 +299,29 @@ impl Cmd { self.fee.fee, &key, )?; - let mut txn = client.create_assembled_transaction(&tx).await?; - if let Some(instructions) = self.instructions { - txn = txn.set_max_instructions(instructions); - } - let (return_value, events) = if self.is_view { - ( - txn.sim_response().results()?[0].xdr.clone(), - txn.sim_response().events()?, + + let (result, meta, events) = client + .prepare_and_send_transaction( + &tx, + &key, + &signers, + &network.network_passphrase, + Some(log_events), + (global_args.verbose || global_args.very_verbose || self.cost) + .then_some(log_resources), ) - } else { - let res = client - .send_assembled_transaction( - txn, - &key, - &signers, - &network.network_passphrase, - Some(log_events), - (global_args.verbose || global_args.very_verbose || self.cost) - .then_some(log_resources), - ) - .await?; - (res.return_value()?, res.contract_events()?) - }; + .await?; + tracing::debug!(?result); crate::log::diagnostic_events(&events, tracing::Level::INFO); + let xdr::TransactionMeta::V3(xdr::TransactionMetaV3 { + soroban_meta: Some(xdr::SorobanTransactionMeta { return_value, .. }), + .. + }) = meta + else { + return Err(Error::MissingOperationResult); + }; + output_to_string(&spec, &return_value, &function) } @@ -347,7 +344,7 @@ impl Cmd { impl Cmd { fn contract_id(&self) -> Result<[u8; 32], Error> { - soroban_spec_tools::utils::contract_id_from_str(&self.contract_id) + utils::contract_id_from_str(&self.contract_id) .map_err(|e| Error::CannotParseContractId(self.contract_id.clone(), e)) } } diff --git a/cmd/soroban-cli/src/commands/contract/read.rs b/cmd/soroban-cli/src/commands/contract/read.rs index f25b6c2c0e..842832d5f3 100644 --- a/cmd/soroban-cli/src/commands/contract/read.rs +++ b/cmd/soroban-cli/src/commands/contract/read.rs @@ -120,7 +120,7 @@ impl Cmd { let ( LedgerKey::ContractData(LedgerKeyContractData { key, .. }), LedgerEntryData::ContractData(ContractDataEntry { val, .. }), - ) = &(key, val) + ) = (key, val) else { return Err(Error::OnlyDataAllowed); }; diff --git a/cmd/soroban-cli/src/commands/contract/restore.rs b/cmd/soroban-cli/src/commands/contract/restore.rs index 6ed39f8929..38b8a84a19 100644 --- a/cmd/soroban-cli/src/commands/contract/restore.rs +++ b/cmd/soroban-cli/src/commands/contract/restore.rs @@ -148,15 +148,11 @@ impl Cmd { }), }; - let res = client + let (result, meta, events) = client .prepare_and_send_transaction(&tx, &key, &[], &network.network_passphrase, None, None) .await?; - let meta = res - .result_meta - .as_ref() - .ok_or(Error::MissingOperationResult)?; - let events = res.events()?; + tracing::trace!(?result); tracing::trace!(?meta); if !events.is_empty() { tracing::info!("Events:\n {events:#?}"); @@ -181,7 +177,7 @@ impl Cmd { operations[0].changes.len() ); } - parse_operations(operations).ok_or(Error::MissingOperationResult) + parse_operations(&operations).ok_or(Error::MissingOperationResult) } } diff --git a/cmd/soroban-cli/src/key.rs b/cmd/soroban-cli/src/key.rs index 2290e857e4..e9901abd2c 100644 --- a/cmd/soroban-cli/src/key.rs +++ b/cmd/soroban-cli/src/key.rs @@ -59,7 +59,7 @@ pub struct Args { )] pub wasm_hash: Option, /// Storage entry durability - #[arg(long, value_enum, required = true, default_value = "persistent")] + #[arg(long, value_enum, required = true)] pub durability: Durability, } @@ -83,7 +83,7 @@ impl Args { } else if let Some(wasm_hash) = &self.wasm_hash { return Ok(vec![LedgerKey::ContractCode(LedgerKeyContractCode { hash: xdr::Hash( - soroban_spec_tools::utils::contract_id_from_str(wasm_hash) + utils::contract_id_from_str(wasm_hash) .map_err(|e| Error::CannotParseContractId(wasm_hash.clone(), e))?, ), })]); diff --git a/cmd/soroban-cli/src/lib.rs b/cmd/soroban-cli/src/lib.rs index ef443853bc..3aad487c82 100644 --- a/cmd/soroban-cli/src/lib.rs +++ b/cmd/soroban-cli/src/lib.rs @@ -3,17 +3,17 @@ clippy::must_use_candidate, clippy::missing_panics_doc )] -pub(crate) use soroban_rpc as rpc; -use std::path::Path; - pub mod commands; pub mod fee; pub mod key; pub mod log; +pub mod rpc; pub mod toid; pub mod utils; pub mod wasm; +use std::path::Path; + pub use commands::Root; pub fn parse_cmd(s: &str) -> Result diff --git a/cmd/crates/soroban-rpc/src/fixtures/event_response.json b/cmd/soroban-cli/src/rpc/fixtures/event_response.json similarity index 100% rename from cmd/crates/soroban-rpc/src/fixtures/event_response.json rename to cmd/soroban-cli/src/rpc/fixtures/event_response.json diff --git a/cmd/crates/soroban-rpc/src/lib.rs b/cmd/soroban-cli/src/rpc/mod.rs similarity index 92% rename from cmd/crates/soroban-rpc/src/lib.rs rename to cmd/soroban-cli/src/rpc/mod.rs index 95c3692e1f..535426292b 100644 --- a/cmd/crates/soroban-rpc/src/lib.rs +++ b/cmd/soroban-cli/src/rpc/mod.rs @@ -21,20 +21,15 @@ use std::{ str::FromStr, time::{Duration, Instant}, }; -use stellar_xdr::curr::ContractEventType; use termcolor::{Color, ColorChoice, StandardStream, WriteColor}; use termcolor_output::colored; use tokio::time::sleep; -pub mod log; -mod txn; - -pub use txn::Assembled; +use crate::utils::contract_spec; -use soroban_spec_tools::contract; +mod txn; const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION"); -pub(crate) const DEFAULT_TRANSACTION_FEES: u32 = 100; pub type LogEvents = fn( footprint: &LedgerFootprint, @@ -93,7 +88,7 @@ pub enum Error { #[error("unexpected contract code data type: {0:?}")] UnexpectedContractCodeDataType(LedgerEntryData), #[error(transparent)] - CouldNotParseContractSpec(#[from] contract::Error), + CouldNotParseContractSpec(#[from] contract_spec::Error), #[error("unexpected contract code got token")] UnexpectedToken(ContractDataEntry), #[error(transparent)] @@ -104,9 +99,6 @@ pub enum Error { LargeFee(u64), #[error("Cannot authorize raw transactions")] CannotAuthorizeRawTransaction, - - #[error("Missing result for tnx")] - MissingOp, } #[derive(serde::Deserialize, serde::Serialize, Debug)] @@ -178,41 +170,6 @@ impl TryInto for GetTransactionResponseRaw { } } -impl GetTransactionResponse { - /// - /// # Errors - pub fn return_value(&self) -> Result { - if let Some(xdr::TransactionMeta::V3(xdr::TransactionMetaV3 { - soroban_meta: Some(xdr::SorobanTransactionMeta { return_value, .. }), - .. - })) = &self.result_meta - { - Ok(return_value.clone()) - } else { - Err(Error::MissingOp) - } - } - - /// - /// # Errors - pub fn events(&self) -> Result, Error> { - self.result_meta - .as_ref() - .map(extract_events) - .ok_or(Error::MissingOp) - } - - /// - /// # Errors - pub fn contract_events(&self) -> Result, Error> { - Ok(self - .events()? - .into_iter() - .filter(|e| matches!(e.event.type_, ContractEventType::Contract)) - .collect::>()) - } -} - #[derive(serde::Deserialize, serde::Serialize, Debug)] pub struct LedgerEntryResult { pub key: String, @@ -316,8 +273,6 @@ pub struct SimulateTransactionResponse { } impl SimulateTransactionResponse { - /// - /// # Errors pub fn results(&self) -> Result, Error> { self.results .iter() @@ -339,8 +294,6 @@ impl SimulateTransactionResponse { .collect() } - /// - /// # Errors pub fn events(&self) -> Result, Error> { self.events .iter() @@ -348,8 +301,6 @@ impl SimulateTransactionResponse { .collect() } - /// - /// # Errors pub fn transaction_data(&self) -> Result { Ok(SorobanTransactionData::from_xdr_base64( &self.transaction_data, @@ -392,7 +343,6 @@ pub struct GetEventsResponse { // Reference](https://docs.google.com/document/d/1TZUDgo_3zPz7TiPMMHVW_mtogjLyPL0plvzGMsxSz6A/edit#bookmark=id.35t97rnag3tx) // [Code // Reference](https://github.com/stellar/soroban-tools/blob/bac1be79e8c2590c9c35ad8a0168aab0ae2b4171/cmd/soroban-rpc/internal/methods/get_events.go#L182-L203) -#[must_use] pub fn does_topic_match(topic: &[String], filter: &[String]) -> bool { filter.len() == topic.len() && filter @@ -447,13 +397,10 @@ impl Display for Event { } impl Event { - /// - /// # Errors pub fn parse_cursor(&self) -> Result<(u64, i32), Error> { parse_cursor(&self.id) } - /// - /// # Errors + pub fn pretty_print(&self) -> Result<(), Box> { let mut stdout = StandardStream::stdout(ColorChoice::Auto); if !stdout.supports_color() { @@ -555,8 +502,6 @@ pub struct Client { } impl Client { - /// - /// # Errors pub fn new(base_url: &str) -> Result { // Add the port to the base URL if there is no port explicitly included // in the URL and the scheme allows us to infer a default port. @@ -587,8 +532,6 @@ impl Client { }) } - /// - /// # Errors fn client(&self) -> Result { let url = self.base_url.clone(); let mut headers = HeaderMap::new(); @@ -600,8 +543,6 @@ impl Client { .build(url)?) } - /// - /// # Errors pub async fn friendbot_url(&self) -> Result { let network = self.get_network().await?; tracing::trace!("{network:#?}"); @@ -612,8 +553,7 @@ impl Client { ) }) } - /// - /// # Errors + pub async fn verify_network_passphrase(&self, expected: Option<&str>) -> Result { let server = self.get_network().await?.passphrase; if let Some(expected) = expected { @@ -627,15 +567,11 @@ impl Client { Ok(server) } - /// - /// # Errors pub async fn get_network(&self) -> Result { tracing::trace!("Getting network"); Ok(self.client()?.request("getNetwork", rpc_params![]).await?) } - /// - /// # Errors pub async fn get_latest_ledger(&self) -> Result { tracing::trace!("Getting latest ledger"); Ok(self @@ -644,8 +580,6 @@ impl Client { .await?) } - /// - /// # Errors pub async fn get_account(&self, address: &str) -> Result { tracing::trace!("Getting address {}", address); let key = LedgerKey::Account(LedgerKeyAccount { @@ -677,12 +611,10 @@ soroban config identity fund {address} --helper-url "# } } - /// - /// # Errors pub async fn send_transaction( &self, tx: &TransactionEnvelope, - ) -> Result { + ) -> Result<(TransactionResult, TransactionMeta, Vec), Error> { let client = self.client()?; tracing::trace!("Sending:\n{tx:#?}"); let SendTransactionResponse { @@ -724,8 +656,14 @@ soroban config identity fund {address} --helper-url "# "SUCCESS" => { // TODO: the caller should probably be printing this tracing::trace!("{response:#?}"); - - return Ok(response); + let GetTransactionResponse { + result, + result_meta, + .. + } = response; + let meta = result_meta.ok_or(Error::MissingResult)?; + let events = extract_events(&meta); + return Ok((result.ok_or(Error::MissingResult)?, meta, events)); } "FAILED" => { tracing::error!("{response:#?}"); @@ -749,8 +687,6 @@ soroban config identity fund {address} --helper-url "# } } - /// - /// # Errors pub async fn simulate_transaction( &self, tx: &TransactionEnvelope, @@ -767,69 +703,33 @@ soroban config identity fund {address} --helper-url "# match response.error { None => Ok(response), Some(e) => { - log::diagnostic_events(&response.events, tracing::Level::ERROR); + crate::log::diagnostic_events(&response.events, tracing::Level::ERROR); Err(Error::TransactionSimulationFailed(e)) } } } - /// - /// # Errors - pub async fn send_assembled_transaction( + pub async fn prepare_and_send_transaction( &self, - txn: txn::Assembled, + tx_without_preflight: &Transaction, source_key: &ed25519_dalek::SigningKey, signers: &[ed25519_dalek::SigningKey], network_passphrase: &str, log_events: Option, log_resources: Option, - ) -> Result { - let seq_num = txn.sim_response().latest_ledger + 60; //5 min; + ) -> Result<(TransactionResult, TransactionMeta, Vec), Error> { + let txn = txn::Assembled::new(tx_without_preflight, self).await?; + let seq_num = txn.sim_res().latest_ledger + 60; //5 min; let authorized = txn .handle_restore(self, source_key, network_passphrase) .await? .authorize(self, source_key, signers, seq_num, network_passphrase) .await?; authorized.log(log_events, log_resources)?; - let tx = authorized.sign(source_key, network_passphrase)?; self.send_transaction(&tx).await } - /// - /// # Errors - pub async fn prepare_and_send_transaction( - &self, - tx_without_preflight: &Transaction, - source_key: &ed25519_dalek::SigningKey, - signers: &[ed25519_dalek::SigningKey], - network_passphrase: &str, - log_events: Option, - log_resources: Option, - ) -> Result { - let txn = txn::Assembled::new(tx_without_preflight, self).await?; - self.send_assembled_transaction( - txn, - source_key, - signers, - network_passphrase, - log_events, - log_resources, - ) - .await - } - - /// - /// # Errors - pub async fn create_assembled_transaction( - &self, - txn: &Transaction, - ) -> Result { - txn::Assembled::new(txn, self).await - } - - /// - /// # Errors pub async fn get_transaction(&self, tx_id: &str) -> Result { Ok(self .client()? @@ -837,8 +737,6 @@ soroban config identity fund {address} --helper-url "# .await?) } - /// - /// # Errors pub async fn get_ledger_entries( &self, keys: &[LedgerKey], @@ -849,7 +747,7 @@ soroban config identity fund {address} --helper-url "# if base64_result.is_err() { return Err(Error::Xdr(XdrError::Invalid)); } - base64_keys.push(k.to_xdr_base64(Limits::none())?); + base64_keys.push(k.to_xdr_base64(Limits::none()).unwrap()); } Ok(self .client()? @@ -857,8 +755,6 @@ soroban config identity fund {address} --helper-url "# .await?) } - /// - /// # Errors pub async fn get_full_ledger_entries( &self, ledger_keys: &[LedgerKey], @@ -899,8 +795,7 @@ soroban config identity fund {address} --helper-url "# latest_ledger, }) } - /// - /// # Errors + pub async fn get_events( &self, start: EventStart, @@ -940,8 +835,6 @@ soroban config identity fund {address} --helper-url "# Ok(self.client()?.request("getEvents", oparams).await?) } - /// - /// # Errors pub async fn get_contract_data( &self, contract_id: &[u8; 32], @@ -965,8 +858,6 @@ soroban config identity fund {address} --helper-url "# } } - /// - /// # Errors pub async fn get_remote_wasm(&self, contract_id: &[u8; 32]) -> Result, Error> { match self.get_contract_data(contract_id).await? { xdr::ContractDataEntry { @@ -981,8 +872,6 @@ soroban config identity fund {address} --helper-url "# } } - /// - /// # Errors pub async fn get_remote_wasm_from_hash(&self, hash: xdr::Hash) -> Result, Error> { let code_key = LedgerKey::ContractCode(xdr::LedgerKeyContractCode { hash: hash.clone() }); let contract_data = self.get_ledger_entries(&[code_key]).await?; @@ -999,8 +888,7 @@ soroban config identity fund {address} --helper-url "# scval => Err(Error::UnexpectedContractCodeDataType(scval)), } } - /// - /// # Errors + pub async fn get_remote_contract_spec( &self, contract_id: &[u8; 32], @@ -1010,11 +898,11 @@ soroban config identity fund {address} --helper-url "# xdr::ScVal::ContractInstance(xdr::ScContractInstance { executable: xdr::ContractExecutable::Wasm(hash), .. - }) => Ok( - contract::Spec::new(&self.get_remote_wasm_from_hash(hash).await?) - .map_err(Error::CouldNotParseContractSpec)? - .spec, - ), + }) => Ok(contract_spec::ContractSpec::new( + &self.get_remote_wasm_from_hash(hash).await?, + ) + .map_err(Error::CouldNotParseContractSpec)? + .spec), xdr::ScVal::ContractInstance(xdr::ScContractInstance { executable: xdr::ContractExecutable::StellarAsset, .. @@ -1051,7 +939,7 @@ fn extract_events(tx_meta: &TransactionMeta) -> Vec { } } -pub(crate) fn parse_cursor(c: &str) -> Result<(u64, i32), Error> { +pub fn parse_cursor(c: &str) -> Result<(u64, i32), Error> { let (toid_part, event_index) = c.split('-').collect_tuple().ok_or(Error::InvalidCursor)?; let toid_part: u64 = toid_part.parse().map_err(|_| Error::InvalidCursor)?; let start_index: i32 = event_index.parse().map_err(|_| Error::InvalidCursor)?; diff --git a/cmd/crates/soroban-rpc/src/txn.rs b/cmd/soroban-cli/src/rpc/txn.rs similarity index 82% rename from cmd/crates/soroban-rpc/src/txn.rs rename to cmd/soroban-cli/src/rpc/txn.rs index 35b0c71924..9e36938ddd 100644 --- a/cmd/crates/soroban-rpc/src/txn.rs +++ b/cmd/soroban-cli/src/rpc/txn.rs @@ -2,16 +2,16 @@ use ed25519_dalek::Signer; use sha2::{Digest, Sha256}; use soroban_env_host::xdr::{ self, AccountId, DecoratedSignature, ExtensionPoint, Hash, HashIdPreimage, - HashIdPreimageSorobanAuthorization, InvokeHostFunctionOp, LedgerFootprint, Limits, Memo, - Operation, OperationBody, Preconditions, PublicKey, ReadXdr, RestoreFootprintOp, ScAddress, - ScMap, ScSymbol, ScVal, Signature, SignatureHint, SorobanAddressCredentials, + HashIdPreimageSorobanAuthorization, InvokeHostFunctionOp, Limits, Memo, Operation, + OperationBody, Preconditions, PublicKey, ReadXdr, RestoreFootprintOp, ScAddress, ScMap, + ScSymbol, ScVal, Signature, SignatureHint, SorobanAddressCredentials, SorobanAuthorizationEntry, SorobanAuthorizedFunction, SorobanCredentials, SorobanResources, SorobanTransactionData, Transaction, TransactionEnvelope, TransactionExt, TransactionSignaturePayload, TransactionSignaturePayloadTaggedTransaction, TransactionV1Envelope, Uint256, VecM, WriteXdr, }; -use super::{Client, Error, RestorePreamble, SimulateTransactionResponse}; +use crate::rpc::{Client, Error, RestorePreamble, SimulateTransactionResponse}; use super::{LogEvents, LogResources}; @@ -20,35 +20,13 @@ pub struct Assembled { sim_res: SimulateTransactionResponse, } -/// Represents an assembled transaction ready to be signed and submitted to the network. impl Assembled { - /// - /// Creates a new `Assembled` transaction. - /// - /// # Arguments - /// - /// * `txn` - The original transaction. - /// * `client` - The client used for simulation and submission. - /// - /// # Errors - /// - /// Returns an error if simulation fails or if assembling the transaction fails. pub async fn new(txn: &Transaction, client: &Client) -> Result { let sim_res = Self::simulate(txn, client).await?; let txn = assemble(txn, &sim_res)?; Ok(Self { txn, sim_res }) } - /// - /// Calculates the hash of the assembled transaction. - /// - /// # Arguments - /// - /// * `network_passphrase` - The network passphrase. - /// - /// # Errors - /// - /// Returns an error if generating the hash fails. pub fn hash(&self, network_passphrase: &str) -> Result<[u8; 32], xdr::Error> { let signature_payload = TransactionSignaturePayload { network_id: Hash(Sha256::digest(network_passphrase).into()), @@ -57,23 +35,12 @@ impl Assembled { Ok(Sha256::digest(signature_payload.to_xdr(Limits::none())?).into()) } - /// - /// Signs the assembled transaction. - /// - /// # Arguments - /// - /// * `key` - The signing key. - /// * `network_passphrase` - The network passphrase. - /// - /// # Errors - /// - /// Returns an error if signing the transaction fails. pub fn sign( self, key: &ed25519_dalek::SigningKey, network_passphrase: &str, ) -> Result { - let tx = self.transaction(); + let tx = self.txn(); let tx_hash = self.hash(network_passphrase)?; let tx_signature = key.sign(&tx_hash); @@ -88,17 +55,6 @@ impl Assembled { })) } - /// - /// Simulates the assembled transaction. - /// - /// # Arguments - /// - /// * `tx` - The original transaction. - /// * `client` - The client used for simulation. - /// - /// # Errors - /// - /// Returns an error if simulation fails. pub async fn simulate( tx: &Transaction, client: &Client, @@ -111,18 +67,6 @@ impl Assembled { .await } - /// - /// Handles the restore process for the assembled transaction. - /// - /// # Arguments - /// - /// * `client` - The client used for submission. - /// * `source_key` - The signing key of the source account. - /// * `network_passphrase` - The network passphrase. - /// - /// # Errors - /// - /// Returns an error if the restore process fails. pub async fn handle_restore( self, client: &Client, @@ -133,7 +77,7 @@ impl Assembled { // Build and submit the restore transaction client .send_transaction( - &Assembled::new(&restore(self.transaction(), restore_preamble)?, client) + &Assembled::new(&restore(self.txn(), restore_preamble)?, client) .await? .sign(source_key, network_passphrase)?, ) @@ -144,20 +88,14 @@ impl Assembled { } } - /// Returns a reference to the original transaction. - #[must_use] - pub fn transaction(&self) -> &Transaction { + pub fn txn(&self) -> &Transaction { &self.txn } - /// Returns a reference to the simulation response. - #[must_use] - pub fn sim_response(&self) -> &SimulateTransactionResponse { + pub fn sim_res(&self) -> &SimulateTransactionResponse { &self.sim_res } - /// - /// # Errors pub async fn authorize( self, client: &Client, @@ -167,7 +105,7 @@ impl Assembled { network_passphrase: &str, ) -> Result { if let Some(txn) = sign_soroban_authorizations( - self.transaction(), + self.txn(), source_key, signers, seq_num, @@ -179,16 +117,12 @@ impl Assembled { } } - #[must_use] pub fn bump_seq_num(mut self) -> Self { self.txn.seq_num.0 += 1; self } - /// - /// # Errors - #[must_use] - pub fn auth_entries(&self) -> VecM { + pub fn auth(&self) -> VecM { self.txn .operations .first() @@ -203,8 +137,6 @@ impl Assembled { .unwrap_or_default() } - /// - /// # Errors pub fn log( &self, log_events: Option, @@ -219,55 +151,15 @@ impl Assembled { log(resources); } if let Some(log) = log_events { - log(footprint, &[self.auth_entries()], &self.sim_res.events()?); + log(footprint, &[self.auth()], &self.sim_res.events()?); }; } Ok(()) } - - #[must_use] - pub fn requires_auth(&self) -> bool { - requires_auth(&self.txn).is_some() - } - - #[must_use] - pub fn is_view(&self) -> bool { - let TransactionExt::V1(SorobanTransactionData { - resources: - SorobanResources { - footprint: LedgerFootprint { read_write, .. }, - .. - }, - .. - }) = &self.txn.ext - else { - return false; - }; - read_write.is_empty() - } - - #[must_use] - pub fn set_max_instructions(mut self, instructions: u32) -> Self { - if let TransactionExt::V1(SorobanTransactionData { - resources: - SorobanResources { - instructions: ref mut i, - .. - }, - .. - }) = &mut self.txn.ext - { - tracing::trace!("setting max instructions to {instructions} from {i}"); - *i = instructions; - } - self - } } // Apply the result of a simulateTransaction onto a transaction envelope, preparing it for // submission to the network. -/// -/// # Errors pub fn assemble( raw: &Transaction, simulation: &SimulateTransactionResponse, @@ -314,7 +206,7 @@ pub fn assemble( } // update the fees of the actual transaction to meet the minimum resource fees. - let classic_transaction_fees = crate::DEFAULT_TRANSACTION_FEES; + let classic_transaction_fees = crate::fee::Args::default().fee; // Pad the fees up by 15% for a bit of wiggle room. tx.fee = (tx.fee.max( classic_transaction_fees @@ -328,21 +220,6 @@ pub fn assemble( Ok(tx) } -fn requires_auth(txn: &Transaction) -> Option { - let [op @ Operation { - body: OperationBody::InvokeHostFunction(InvokeHostFunctionOp { auth, .. }), - .. - }] = txn.operations.as_slice() - else { - return None; - }; - matches!( - auth.first().map(|x| &x.root_invocation.function), - Some(&SorobanAuthorizedFunction::ContractFn(_)) - ) - .then(move || op.clone()) -} - // Use the given source_key and signers, to sign all SorobanAuthorizationEntry's in the given // transaction. If unable to sign, return an error. fn sign_soroban_authorizations( @@ -353,8 +230,18 @@ fn sign_soroban_authorizations( network_passphrase: &str, ) -> Result, Error> { let mut tx = raw.clone(); - let Some(mut op) = requires_auth(&tx) else { - return Ok(None); + let mut op = match tx.operations.as_slice() { + [op @ Operation { + body: OperationBody::InvokeHostFunction(InvokeHostFunctionOp { auth, .. }), + .. + }] if matches!( + auth.first().map(|x| &x.root_invocation.function), + Some(&SorobanAuthorizedFunction::ContractFn(_)) + ) => + { + op.clone() + } + _ => return Ok(None), }; let Operation { @@ -491,8 +378,6 @@ fn sign_soroban_authorization_entry( Ok(auth) } -/// -/// # Errors pub fn restore(parent: &Transaction, restore: &RestorePreamble) -> Result { let transaction_data = SorobanTransactionData::from_xdr_base64(&restore.transaction_data, Limits::none())?; @@ -513,7 +398,8 @@ pub fn restore(parent: &Transaction, restore: &RestorePreamble) -> Result Result<[u8; 32], stellar_strkey::DecodeError> { - Ok( - if let Ok(strkey) = stellar_strkey::Contract::from_string(contract_id) { - strkey.0 - } else { + stellar_strkey::Contract::from_string(contract_id) + .map(|strkey| strkey.0) + .or_else(|_| { // strkey failed, try to parse it as a hex string, for backwards compatibility. soroban_spec_tools::utils::padded_hex_from_str(contract_id, 32) .map_err(|_| stellar_strkey::DecodeError::Invalid)? .try_into() - .map_err(|_| stellar_strkey::DecodeError::Invalid)? - }, - ) + .map_err(|_| stellar_strkey::DecodeError::Invalid) + }) + .map_err(|_| stellar_strkey::DecodeError::Invalid) } /// # Errors @@ -199,5 +198,47 @@ mod tests { ), Err(err) => panic!("Failed to parse contract id: {err}"), } + + // hex + match contract_id_from_str( + "363eaa3867841fbad0f4ed88c779e4fe66e56a2470dc98c0ec9c073d05c7b103", + ) { + Ok(contract_id) => assert_eq!( + contract_id, + [ + 0x36, 0x3e, 0xaa, 0x38, 0x67, 0x84, 0x1f, 0xba, 0xd0, 0xf4, 0xed, 0x88, 0xc7, + 0x79, 0xe4, 0xfe, 0x66, 0xe5, 0x6a, 0x24, 0x70, 0xdc, 0x98, 0xc0, 0xec, 0x9c, + 0x07, 0x3d, 0x05, 0xc7, 0xb1, 0x03, + ] + ), + Err(err) => panic!("Failed to parse contract id: {err}"), + } + + // unpadded-hex + match contract_id_from_str("1") { + Ok(contract_id) => assert_eq!( + contract_id, + [ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + ] + ), + Err(err) => panic!("Failed to parse contract id: {err}"), + } + + // invalid hex + match contract_id_from_str("foobar") { + Ok(_) => panic!("Expected parsing to fail"), + Err(err) => assert_eq!(err, stellar_strkey::DecodeError::Invalid), + } + + // hex too long (33 bytes) + match contract_id_from_str( + "000000000000000000000000000000000000000000000000000000000000000000", + ) { + Ok(_) => panic!("Expected parsing to fail"), + Err(err) => assert_eq!(err, stellar_strkey::DecodeError::Invalid), + } } } diff --git a/cmd/crates/soroban-spec-tools/src/contract.rs b/cmd/soroban-cli/src/utils/contract_spec.rs similarity index 98% rename from cmd/crates/soroban-spec-tools/src/contract.rs rename to cmd/soroban-cli/src/utils/contract_spec.rs index 2d0d857cd7..b4f24abec8 100644 --- a/cmd/crates/soroban-spec-tools/src/contract.rs +++ b/cmd/soroban-cli/src/utils/contract_spec.rs @@ -10,7 +10,7 @@ use soroban_env_host::xdr::{ StringM, WriteXdr, }; -pub struct Spec { +pub struct ContractSpec { pub env_meta_base64: Option, pub env_meta: Vec, pub meta_base64: Option, @@ -38,7 +38,7 @@ pub enum Error { Parser(#[from] wasmparser::BinaryReaderError), } -impl Spec { +impl ContractSpec { pub fn new(bytes: &[u8]) -> Result { let mut env_meta: Option<&[u8]> = None; let mut meta: Option<&[u8]> = None; @@ -87,7 +87,7 @@ impl Spec { vec![] }; - Ok(Spec { + Ok(ContractSpec { env_meta_base64, env_meta, meta_base64, @@ -108,7 +108,7 @@ impl Spec { } } -impl Display for Spec { +impl Display for ContractSpec { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if let Some(env_meta) = &self.env_meta_base64 { writeln!(f, "Env Meta: {env_meta}")?; diff --git a/cmd/soroban-cli/src/wasm.rs b/cmd/soroban-cli/src/wasm.rs index 4b8a7f8ca8..fce44c7c56 100644 --- a/cmd/soroban-cli/src/wasm.rs +++ b/cmd/soroban-cli/src/wasm.rs @@ -1,12 +1,11 @@ use clap::arg; use soroban_env_host::xdr::{self, LedgerKey, LedgerKeyContractCode}; -use soroban_spec_tools::contract::{self, Spec}; use std::{ fs, io, path::{Path, PathBuf}, }; -use crate::utils::{self}; +use crate::utils::{self, contract_spec::ContractSpec}; #[derive(thiserror::Error, Debug)] pub enum Error { @@ -26,7 +25,7 @@ pub enum Error { #[error(transparent)] Parser(#[from] wasmparser::BinaryReaderError), #[error(transparent)] - ContractSpec(#[from] contract::Error), + ContractSpec(#[from] crate::utils::contract_spec::Error), } #[derive(Debug, clap::Args, Clone)] @@ -61,9 +60,9 @@ impl Args { /// # Errors /// May fail to read wasm file or parse xdr section - pub fn parse(&self) -> Result { + pub fn parse(&self) -> Result { let contents = self.read()?; - Ok(Spec::new(&contents)?) + Ok(ContractSpec::new(&contents)?) } } diff --git a/docs/soroban-cli-full-docs.md b/docs/soroban-cli-full-docs.md index 578d2ac406..9e9587d29a 100644 --- a/docs/soroban-cli-full-docs.md +++ b/docs/soroban-cli-full-docs.md @@ -110,28 +110,13 @@ Full CLI reference: https://github.com/stellar/soroban-tools/tree/main/docs/soro ###### **Options:** * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `-f`, `--filter-logs ` — Filter logs output. To turn on "soroban_cli::log::footprint=debug" or off "=off". Can also use env var `RUST_LOG` * `-q`, `--quiet` — Do not write logs to stderr including `INFO` - - Possible values: `true`, `false` - * `-v`, `--verbose` — Log DEBUG events - - Possible values: `true`, `false` - * `--very-verbose` — Log DEBUG and TRACE events - - Possible values: `true`, `false` - * `--list` — List installed plugins. E.g. `soroban-hello` - Possible values: `true`, `false` - - ## `soroban completion` @@ -200,9 +185,6 @@ Add a new network * `--rpc-url ` — RPC server endpoint * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -220,9 +202,6 @@ Remove a network ###### **Options:** * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -236,15 +215,9 @@ List networks ###### **Options:** * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `-l`, `--long` — Get more info about the networks - Possible values: `true`, `false` - - ## `soroban config identity` @@ -278,17 +251,8 @@ Add a new identity (keypair, ledger, macOS keychain) ###### **Options:** * `--secret-key` — Add using secret_key Can provide with SOROBAN_SECRET_KEY - - Possible values: `true`, `false` - * `--seed-phrase` — Add using 12 word seed phrase to generate secret_key - - Possible values: `true`, `false` - * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -307,9 +271,6 @@ Given an identity return its address (public key) * `--hd-path ` — If identity is a seed phrase use this hd path, default is 0 * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -331,9 +292,6 @@ Fund an identity on a test network * `--network ` — Name of network to use from config * `--hd-path ` — If identity is a seed phrase use this hd path, default is 0 * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -351,24 +309,12 @@ Generate a new identity with a seed phrase, currently 12 words ###### **Options:** * `--no-fund` — Do not fund address - - Possible values: `true`, `false` - * `--seed ` — Optional seed to use when generating seed phrase. Random otherwise * `-s`, `--as-secret` — Output the generated identity as a secret key - - Possible values: `true`, `false` - * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--hd-path ` — When generating a secret key, which hd_path should be used from the original seed_phrase * `-d`, `--default-seed` — Generate the default seed phrase. Useful for testing. Equivalent to --seed 0000000000000000 - - Possible values: `true`, `false` - * `--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 @@ -384,15 +330,9 @@ List identities ###### **Options:** * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `-l`, `--long` - Possible values: `true`, `false` - - ## `soroban config identity rm` @@ -408,9 +348,6 @@ Remove an identity ###### **Options:** * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -429,9 +366,6 @@ Given an identity return its private key * `--hd-path ` — If identity is a seed phrase use this hd path, default is 0 * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -489,9 +423,6 @@ Get Id of builtin Soroban Asset Contract. Deprecated, use `soroban contract id a * `--source-account ` — Account that signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -511,9 +442,6 @@ Deploy builtin Soroban Asset Contract * `--source-account ` — Account that signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--fee ` — fee amount for transaction, in stroops. 1 stroop = 0.0000001 xlm @@ -570,14 +498,8 @@ Generate a TypeScript / JavaScript package * `--wasm ` — Path to optional wasm binary * `--output-dir ` — Where to place generated project * `--overwrite` — Whether to overwrite output directory if it already exists - - Possible values: `true`, `false` - * `--contract-id ` — The contract ID/address on the network * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--rpc-url ` — RPC server endpoint * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server @@ -606,19 +528,10 @@ To view the commands that will be executed, without executing them, use the --pr Default value: `release` * `--features ` — Build with the list of features activated, space or comma separated * `--all-features` — Build with the all features activated - - Possible values: `true`, `false` - * `--no-default-features` — Build with the default feature not activated - - Possible values: `true`, `false` - * `--out-dir ` — Directory to copy wasm files to * `--print-commands-only` — Print commands to build without executing them - Possible values: `true`, `false` - - ## `soroban contract extend` @@ -633,9 +546,6 @@ If no keys are specified the contract itself is extended. * `--ledgers-to-extend ` — Number of ledgers to extend the entries * `--ttl-ledger-only` — Only print the new Time To Live ledger - - Possible values: `true`, `false` - * `--id ` — Contract ID to which owns the data entries. If no keys provided the Contract's instance will be extended * `--key ` — Storage key (symbols only) * `--key-xdr ` — Storage key (base64-encoded XDR) @@ -643,8 +553,6 @@ If no keys are specified the contract itself is extended. * `--wasm-hash ` — Path to Wasm file of contract code to extend * `--durability ` — Storage entry durability - Default value: `persistent` - Possible values: - `persistent`: Persistent @@ -657,9 +565,6 @@ If no keys are specified the contract itself is extended. * `--source-account ` — Account that signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--fee ` — fee amount for transaction, in stroops. 1 stroop = 0.0000001 xlm @@ -684,9 +589,6 @@ Deploy a wasm contract * `--source-account ` — Account that signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--fee ` — fee amount for transaction, in stroops. 1 stroop = 0.0000001 xlm @@ -695,9 +597,6 @@ Deploy a wasm contract Default value: `false` - Possible values: `true`, `false` - - ## `soroban contract fetch` @@ -711,9 +610,6 @@ Fetch a contract's Wasm binary * `--id ` — Contract ID to fetch * `-o`, `--out-file ` — Where to write output otherwise stdout is used * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--rpc-url ` — RPC server endpoint * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server @@ -749,9 +645,6 @@ Deploy builtin Soroban Asset Contract * `--source-account ` — Account that signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -771,9 +664,6 @@ Deploy normal Wasm Contract * `--source-account ` — Account that signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -822,9 +712,6 @@ Inspect a WASM file listing contract functions, meta, etc Pretty print of contract spec entries * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -843,9 +730,6 @@ Install a WASM file to the ledger without creating a contract instance * `--source-account ` — Account that signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--fee ` — fee amount for transaction, in stroops. 1 stroop = 0.0000001 xlm @@ -855,9 +739,6 @@ Install a WASM file to the ledger without creating a contract instance Default value: `false` - Possible values: `true`, `false` - - ## `soroban contract invoke` @@ -878,23 +759,12 @@ soroban contract invoke ... -- --help * `--id ` — Contract ID to invoke * `--cost` — Output the cost execution to stderr - - Possible values: `true`, `false` - -* `--instructions ` — Number of instructions to simulate -* `--is-view` — Do not sign and submit transaction - - Possible values: `true`, `false` - * `--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 signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--fee ` — fee amount for transaction, in stroops. 1 stroop = 0.0000001 xlm @@ -942,8 +812,6 @@ Print the current value of a contract-data ledger entry * `--wasm-hash ` — Path to Wasm file of contract code to extend * `--durability ` — Storage entry durability - Default value: `persistent` - Possible values: - `persistent`: Persistent @@ -956,9 +824,6 @@ Print the current value of a contract-data ledger entry * `--source-account ` — Account that signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -980,8 +845,6 @@ If no keys are specificed the contract itself is restored. * `--wasm-hash ` — Path to Wasm file of contract code to extend * `--durability ` — Storage entry durability - Default value: `persistent` - Possible values: - `persistent`: Persistent @@ -990,18 +853,12 @@ If no keys are specificed the contract itself is restored. * `--ledgers-to-extend ` — Number of ledgers to extend the entry * `--ttl-ledger-only` — Only print the new Time To Live ledger - - Possible values: `true`, `false` - * `--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 signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--fee ` — fee amount for transaction, in stroops. 1 stroop = 0.0000001 xlm @@ -1043,9 +900,6 @@ Watch the network for contract events Possible values: `all`, `contract`, `system` * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--rpc-url ` — RPC server endpoint * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server @@ -1084,17 +938,8 @@ Add a new identity (keypair, ledger, macOS keychain) ###### **Options:** * `--secret-key` — Add using secret_key Can provide with SOROBAN_SECRET_KEY - - Possible values: `true`, `false` - * `--seed-phrase` — Add using 12 word seed phrase to generate secret_key - - Possible values: `true`, `false` - * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -1113,9 +958,6 @@ Given an identity return its address (public key) * `--hd-path ` — If identity is a seed phrase use this hd path, default is 0 * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -1137,9 +979,6 @@ Fund an identity on a test network * `--network ` — Name of network to use from config * `--hd-path ` — If identity is a seed phrase use this hd path, default is 0 * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -1157,24 +996,12 @@ Generate a new identity with a seed phrase, currently 12 words ###### **Options:** * `--no-fund` — Do not fund address - - Possible values: `true`, `false` - * `--seed ` — Optional seed to use when generating seed phrase. Random otherwise * `-s`, `--as-secret` — Output the generated identity as a secret key - - Possible values: `true`, `false` - * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--hd-path ` — When generating a secret key, which hd_path should be used from the original seed_phrase * `-d`, `--default-seed` — Generate the default seed phrase. Useful for testing. Equivalent to --seed 0000000000000000 - - Possible values: `true`, `false` - * `--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 @@ -1190,15 +1017,9 @@ List identities ###### **Options:** * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `-l`, `--long` - Possible values: `true`, `false` - - ## `soroban keys rm` @@ -1214,9 +1035,6 @@ Remove an identity ###### **Options:** * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -1235,9 +1053,6 @@ Given an identity return its private key * `--hd-path ` — If identity is a seed phrase use this hd path, default is 0 * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -1283,9 +1098,6 @@ Deploy a token contract to wrap an existing Stellar classic asset for smart cont * `--source-account ` — Account that signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `--fee ` — fee amount for transaction, in stroops. 1 stroop = 0.0000001 xlm @@ -1308,9 +1120,6 @@ Compute the expected contract id for the given asset Deprecated, use `soroban co * `--source-account ` — Account that signs the final transaction. Alias `source`. Can be an identity (--source alice), a secret key (--source SC36…), or a seed phrase (--source "kite urban…"). Default: `identity generate --default-seed` * `--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 - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -1490,9 +1299,6 @@ Add a new network * `--rpc-url ` — RPC server endpoint * `--network-passphrase ` — Network passphrase to sign the transaction sent to the rpc server * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -1510,9 +1316,6 @@ Remove a network ###### **Options:** * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." @@ -1526,15 +1329,9 @@ List networks ###### **Options:** * `--global` — Use global config - - Possible values: `true`, `false` - * `--config-dir ` — Location of config directory, default is "." * `-l`, `--long` — Get more info about the networks - Possible values: `true`, `false` - - ## `soroban version`