diff --git a/Cargo.lock b/Cargo.lock index ad1f0c73b4..42b9af85c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1198,6 +1198,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "ecdsa" version = "0.16.7" @@ -4250,6 +4256,30 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.39", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -4330,7 +4360,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ba64dc259185fdb8dfea7ab0418292743251efba80c9b20e88afc83c17b2593" dependencies = [ "slip10", - "stellar-strkey 0.0.8", + "stellar-strkey", "thiserror", "tiny-bip39", ] @@ -4366,6 +4396,17 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330f01ce65a3a5fe59a60c82f3c9a024b573b8a6e875bd233fe5f934e71d54e3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "serde_json" version = "1.0.108" @@ -4642,9 +4683,9 @@ dependencies = [ [[package]] name = "soroban-builtin-sdk-macros" -version = "21.0.1" +version = "21.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1593481b51c9a2a98b0ff60ba2256796d4dfa8005f7ce237257acee175cf48b" +checksum = "084aab008009e712c445a9d7eab837a86559a6c2341f30bc4f33e9b258947688" dependencies = [ "itertools 0.11.0", "proc-macro2", @@ -4707,7 +4748,7 @@ dependencies = [ "soroban-spec-tools", "soroban-spec-typescript", "stellar-rpc-client", - "stellar-strkey 0.0.8", + "stellar-strkey", "stellar-xdr", "strsim 0.10.0", "strum 0.17.1", @@ -4732,9 +4773,9 @@ dependencies = [ [[package]] name = "soroban-env-common" -version = "21.0.1" +version = "21.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff8c73721c0464eb8f0de7893637bd16512d3fe45143b4197b75e298988d67d" +checksum = "c16ee889fe99d6828bf3ffac00c84382793c31d62682401dbfa3e1b512f0c542" dependencies = [ "arbitrary", "crate-git-revision 0.0.6", @@ -4751,9 +4792,9 @@ dependencies = [ [[package]] name = "soroban-env-guest" -version = "21.0.1" +version = "21.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f39b60d7a8467e52ffb7863efba4b3ea3947aa028af8d88f4f5a76bb2909d8" +checksum = "95e591a15e488e66d3edd4be044fc4ffea438945f022c27129e933275744666f" dependencies = [ "soroban-env-common", "static_assertions", @@ -4761,9 +4802,9 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "21.0.1" +version = "21.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52bd39ea66b834e6e89981affd8b8ba58e450d3964d2a589e1a6a716bca12d77" +checksum = "4b73f48ae8081ecfb6c0d56c67f139c52cb6d5b6800d5e1adb9eef8e14a155b9" dependencies = [ "backtrace", "curve25519-dalek 4.1.2", @@ -4788,15 +4829,15 @@ dependencies = [ "soroban-env-common", "soroban-wasmi", "static_assertions", - "stellar-strkey 0.0.8", + "stellar-strkey", "wasmparser 0.116.1", ] [[package]] name = "soroban-env-macros" -version = "21.0.1" +version = "21.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fa76ebee7f29000d92792deccee1f670f4048422ad1a35e686a4654fb65f285" +checksum = "06d0581e3aba14892ee0ce63788f3d3e5d9eb1ab18906a9b7c66d77dae9e9fea" dependencies = [ "itertools 0.11.0", "proc-macro2", @@ -4813,9 +4854,9 @@ version = "21.0.0-rc.1" [[package]] name = "soroban-ledger-snapshot" -version = "21.0.1-preview.1" +version = "21.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b71878a8a3db38d5da6fa42d48d055b7937ef9ae608ffcb23f9589aa7989f10" +checksum = "07d02fc89d3a0e49776cdc35609719ddc5635ff61751b37d5577a06cc4b592ea" dependencies = [ "serde", "serde_json", @@ -4827,9 +4868,9 @@ dependencies = [ [[package]] name = "soroban-sdk" -version = "21.0.1-preview.1" +version = "21.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85dc6c199238c4150027034e3cfc383d9c64274292c8dc19bae598e843431356" +checksum = "1460cfdb31c0a1a7b93a35573fb9f794244a196224f8bf94cd235e4d29d8563d" dependencies = [ "arbitrary", "bytes-lit", @@ -4842,14 +4883,14 @@ dependencies = [ "soroban-env-host", "soroban-ledger-snapshot", "soroban-sdk-macros", - "stellar-strkey 0.0.8", + "stellar-strkey", ] [[package]] name = "soroban-sdk-macros" -version = "21.0.1-preview.1" +version = "21.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c503bf0d43499884aa22877e7f293b19882c2088dcd3f00b01eb21b4c65001" +checksum = "a164fe430678986174b9872c6f82c23d73e74d3c6820800979af19c455c0bb70" dependencies = [ "crate-git-revision 0.0.6", "darling", @@ -4867,9 +4908,9 @@ dependencies = [ [[package]] name = "soroban-spec" -version = "21.0.1-preview.1" +version = "21.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4138300450ad75817954070b1cf32422b236410f937205e9f47e44114fd82fe9" +checksum = "6eeac587846418ecb0c73e9b05a9719559bccfc05da941d328eb3f8f8664c11a" dependencies = [ "base64 0.13.1", "stellar-xdr", @@ -4893,9 +4934,9 @@ dependencies = [ [[package]] name = "soroban-spec-rust" -version = "21.0.1-preview.1" +version = "21.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b230255799160fbcf36986f96f506cca671d96541f015546e9f74e99efdedb6" +checksum = "57c179749d655418a01d6d46d5dd08c024ed2e6ee68689430144195ba2f42ca8" dependencies = [ "prettyplease", "proc-macro2", @@ -4918,7 +4959,7 @@ dependencies = [ "serde_json", "soroban-env-host", "soroban-spec", - "stellar-strkey 0.0.8", + "stellar-strkey", "stellar-xdr", "thiserror", "tokio", @@ -4965,7 +5006,7 @@ dependencies = [ "soroban-spec", "soroban-spec-tools", "stellar-rpc-client", - "stellar-strkey 0.0.8", + "stellar-strkey", "thiserror", "tokio", "toml 0.8.13", @@ -4976,9 +5017,9 @@ dependencies = [ [[package]] name = "soroban-token-sdk" -version = "21.0.1-preview.1" +version = "21.1.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ac1fe2457ed64e3ba18482b8375264c17340644ea485d0debce129e5cfb50f" +checksum = "61ce5410a2c201229755713f35f4bba041a201058d1084f0bcdfbca87bad1a9b" dependencies = [ "soroban-sdk", ] @@ -5055,7 +5096,7 @@ dependencies = [ "soroban-env-host", "soroban-spec", "stellar-rpc-client", - "stellar-strkey 0.0.8", + "stellar-strkey", "stellar-xdr", "testcontainers", "thiserror", @@ -5065,12 +5106,11 @@ dependencies = [ [[package]] name = "stellar-rpc-client" -version = "21.0.1" +version = "21.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fefdc91d3cda13e6e324f0c03e42126582b7ff7149da7a0ec792820bb11fb75f" +checksum = "e5fed71587e14c36c47089090f7c2b45cd5ffd3ca0cadbdb4e25cc8407b481dc" dependencies = [ "clap", - "ed25519-dalek 2.0.0", "hex", "http 1.1.0", "itertools 0.10.5", @@ -5080,10 +5120,7 @@ dependencies = [ "serde-aux", "serde_json", "sha2 0.10.8", - "soroban-env-host", - "soroban-sdk", - "soroban-spec", - "stellar-strkey 0.0.7", + "stellar-strkey", "stellar-xdr", "termcolor", "termcolor_output", @@ -5092,16 +5129,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "stellar-strkey" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0689070126ca7f2effc2c5726584446db52190f0cef043c02eb4040a711c11" -dependencies = [ - "base32", - "thiserror", -] - [[package]] name = "stellar-strkey" version = "0.0.8" @@ -5115,9 +5142,9 @@ dependencies = [ [[package]] name = "stellar-xdr" -version = "21.0.1" +version = "21.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88e716110d5e050e528820217f84d4667e166ced841ba48d074152d4ad4ab884" +checksum = "ec43c9c5ae7ec7b6ac9e263b6d5b9e3781aa05ba3a1c05f6e70701c5c6600665" dependencies = [ "arbitrary", "base64 0.13.1", @@ -5125,10 +5152,11 @@ dependencies = [ "crate-git-revision 0.0.6", "escape-bytes", "hex", + "schemars", "serde", "serde_json", "serde_with", - "stellar-strkey 0.0.8", + "stellar-strkey", "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index 09b7daad2a..23be775124 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,16 +15,16 @@ version = "21.0.0-rc.1" rust-version = "1.74.0" [workspace.dependencies.soroban-env-host] -version = "=21.0.1" +version = "=21.1.0" [workspace.dependencies.soroban-simulation] -version = "=21.0.1-preview.1" +version = "21.1.0" [workspace.dependencies.soroban-spec] -version = "=21.0.1-preview.1" +version = "=21.1.0-rc.1" [workspace.dependencies.soroban-spec-rust] -version = "=21.0.1-preview.1" +version = "=21.1.0-rc.1" [workspace.dependencies.soroban-spec-json] version = "=21.0.0-rc.1" @@ -39,13 +39,13 @@ version = "21.0.0-rc.1" path = "./cmd/crates/soroban-spec-tools" [workspace.dependencies.soroban-sdk] -version = "=21.0.1-preview.1" +version = "=21.1.0-rc.1" [workspace.dependencies.soroban-token-sdk] -version = "=21.0.1-preview.1" +version = "=21.1.0-rc.1" [workspace.dependencies.soroban-ledger-snapshot] -version = "=21.0.1-preview.1" +version = "=21.1.0-rc.1" [workspace.dependencies.soroban-cli] version = "=21.0.0-rc.1" @@ -53,10 +53,10 @@ path = "cmd/soroban-cli" [workspace.dependencies.soroban-rpc] package = "stellar-rpc-client" -version = "=21.0.1" +version = "21.3.0" [workspace.dependencies.stellar-xdr] -version = "=21.0.1" +version = "21.1.0" default-features = true [workspace.dependencies] diff --git a/cmd/soroban-cli/src/commands/config/mod.rs b/cmd/soroban-cli/src/commands/config/mod.rs index d9f4d72941..516149959e 100644 --- a/cmd/soroban-cli/src/commands/config/mod.rs +++ b/cmd/soroban-cli/src/commands/config/mod.rs @@ -6,9 +6,9 @@ use serde::{Deserialize, Serialize}; use soroban_rpc::Client; use stellar_strkey::Strkey; -use crate::xdr::{MuxedAccount, SequenceNumber, Transaction, TransactionEnvelope, Uint256}; use crate::{ - signer::{LocalKey, Stellar}, + signer::{self, LocalKey, Stellar}, + xdr::{MuxedAccount, SequenceNumber, Transaction, TransactionEnvelope, Uint256}, Pwd, }; @@ -32,6 +32,8 @@ pub enum Error { Config(#[from] locator::Error), #[error(transparent)] Rpc(#[from] soroban_rpc::Error), + #[error(transparent)] + Signer(#[from] signer::Error), } #[derive(Debug, clap::Args, Clone, Default)] @@ -58,11 +60,7 @@ impl Args { Ok(key.key_pair(self.hd_path)?) } - - pub async fn sign_with_local_key( - &self, - tx: Transaction, - ) -> Result { + pub async fn sign_with_local_key(&self, tx: Transaction) -> Result { let signer = LocalKey::new(self.key_pair()?, false); self.sign(&signer, tx).await } @@ -84,6 +82,20 @@ impl Args { .unwrap()) } + pub async fn sign_soroban_authorizations( + &self, + signer: &impl Stellar, + tx: Transaction, + ) -> Result, Error> { + let network = self.get_network()?; + let client = Client::new(&network.rpc_url)?; + let latest_ledger = client.get_latest_ledger().await?.sequence; + let seq_num = latest_ledger + 60; // ~ 5 min + Ok(signer + .sign_soroban_authorizations(&tx, seq_num, &network.network_passphrase) + .await?) + } + pub fn account(&self, account_str: &str) -> Result { if let Ok(secret) = self.locator.read_identity(account_str) { Ok(secret) diff --git a/cmd/soroban-cli/src/commands/contract/deploy/asset.rs b/cmd/soroban-cli/src/commands/contract/deploy/asset.rs index 2f78a0dd62..e912d2b981 100644 --- a/cmd/soroban-cli/src/commands/contract/deploy/asset.rs +++ b/cmd/soroban-cli/src/commands/contract/deploy/asset.rs @@ -118,13 +118,13 @@ impl NetworkRunnable for Cmd { if self.fee.build_only { return Ok(TxnResult::Txn(tx)); } - let txn = client.create_assembled_transaction(&tx).await?; - let txn = self.fee.apply_to_assembled_txn(txn); + let txn = client.simulate_and_assemble_transaction(&tx).await?; + let txn = self.fee.apply_to_assembled_txn(txn).transaction().clone(); if self.fee.sim_only { - return Ok(TxnResult::Txn(txn.transaction().clone())); + return Ok(TxnResult::Txn(txn)); } let get_txn_resp = client - .send_assembled_transaction(txn, &key, &[], network_passphrase, None, None) + .send_transaction_polling(&self.config.sign_with_local_key(txn).await?) .await? .try_into()?; if args.map_or(true, |a| !a.no_cache) { diff --git a/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs b/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs index b901b0ce5e..4e04cd275e 100644 --- a/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs +++ b/cmd/soroban-cli/src/commands/contract/deploy/wasm.rs @@ -188,13 +188,13 @@ impl NetworkRunnable for Cmd { return Ok(TxnResult::Txn(txn)); } - let txn = client.create_assembled_transaction(&txn).await?; - let txn = self.fee.apply_to_assembled_txn(txn); + let txn = client.simulate_and_assemble_transaction(&txn).await?; + let txn = self.fee.apply_to_assembled_txn(txn).transaction().clone(); if self.fee.sim_only { - return Ok(TxnResult::Txn(txn.transaction().clone())); + return Ok(TxnResult::Txn(txn)); } let get_txn_resp = client - .send_assembled_transaction(txn, &key, &[], &network.network_passphrase, None, None) + .send_transaction_polling(&self.config.sign_with_local_key(txn).await?) .await? .try_into()?; if global_args.map_or(true, |a| !a.no_cache) { diff --git a/cmd/soroban-cli/src/commands/contract/extend.rs b/cmd/soroban-cli/src/commands/contract/extend.rs index 544fdde3de..4d7350565e 100644 --- a/cmd/soroban-cli/src/commands/contract/extend.rs +++ b/cmd/soroban-cli/src/commands/contract/extend.rs @@ -171,8 +171,9 @@ impl NetworkRunnable for Cmd { if self.fee.build_only { return Ok(TxnResult::Txn(tx)); } + let tx = client.simulate_and_assemble_transaction(&tx).await?.transaction().clone(); let res = client - .prepare_and_send_transaction(&tx, &key, &[], &network.network_passphrase, None, None) + .send_transaction_polling(&config.sign_with_local_key(tx).await?) .await?; if args.map_or(true, |a| !a.no_cache) { data::write(res.clone().try_into()?, &network.rpc_uri()?)?; diff --git a/cmd/soroban-cli/src/commands/contract/install.rs b/cmd/soroban-cli/src/commands/contract/install.rs index 39b0397927..d7ebef16d3 100644 --- a/cmd/soroban-cli/src/commands/contract/install.rs +++ b/cmd/soroban-cli/src/commands/contract/install.rs @@ -164,14 +164,14 @@ impl NetworkRunnable for Cmd { } } let txn = client - .create_assembled_transaction(&tx_without_preflight) + .simulate_and_assemble_transaction(&tx_without_preflight) .await?; - let txn = self.fee.apply_to_assembled_txn(txn); + let txn = self.fee.apply_to_assembled_txn(txn).transaction().clone(); if self.fee.sim_only { - return Ok(TxnResult::Txn(txn.transaction().clone())); + return Ok(TxnResult::Txn(txn)); } let txn_resp = client - .send_assembled_transaction(txn, &key, &[], &network.network_passphrase, None, None) + .send_transaction_polling(&self.config.sign_with_local_key(txn).await?) .await?; if args.map_or(true, |a| !a.no_cache) { data::write(txn_resp.clone().try_into().unwrap(), &network.rpc_uri()?)?; diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 37b06514d7..93d01a6d83 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -13,17 +13,14 @@ use heck::ToKebabCase; use soroban_env_host::{ xdr::{ self, Hash, HostFunction, InvokeContractArgs, InvokeHostFunctionOp, LedgerEntryData, - LedgerFootprint, Limits, Memo, MuxedAccount, Operation, OperationBody, Preconditions, - PublicKey, ScAddress, ScSpecEntry, ScSpecFunctionV0, ScSpecTypeDef, ScVal, ScVec, - SequenceNumber, SorobanAuthorizationEntry, SorobanResources, String32, StringM, - Transaction, TransactionExt, Uint256, VecM, WriteXdr, + Limits, Memo, MuxedAccount, Operation, OperationBody, Preconditions, PublicKey, ScAddress, + ScSpecEntry, ScSpecFunctionV0, ScSpecTypeDef, ScVal, ScVec, SequenceNumber, String32, + StringM, Transaction, TransactionExt, Uint256, VecM, WriteXdr, }, HostError, }; -use soroban_env_host::xdr::{ - AccountEntry, AccountEntryExt, AccountId, DiagnosticEvent, Thresholds, -}; +use soroban_env_host::xdr::{AccountEntry, AccountEntryExt, AccountId, Thresholds}; use soroban_spec::read::FromWasmError; use stellar_strkey::DecodeError; @@ -34,6 +31,7 @@ use super::super::{ use crate::commands::txn_result::{TxnEnvelopeResult, TxnResult}; use crate::commands::NetworkRunnable; use crate::get_spec::{self, get_remote_contract_spec}; +use crate::signer::LocalKey; use crate::{ commands::{config::data, global, network}, rpc, Pwd, @@ -320,15 +318,14 @@ impl NetworkRunnable for Cmd { global_args: Option<&global::Args>, config: Option<&config::Args>, ) -> Result, Error> { - let unwrap_config = config.unwrap_or(&self.config); - let network = unwrap_config.get_network()?; + let config = config.unwrap_or(&self.config); + let network = config.get_network()?; tracing::trace!(?network); let contract_id = self.contract_id()?; let spec_entries = self.spec_entries()?; if let Some(spec_entries) = &spec_entries { // For testing wasm arg parsing - let _ = - self.build_host_function_parameters(contract_id, spec_entries, unwrap_config)?; + let _ = self.build_host_function_parameters(contract_id, spec_entries, config)?; } let client = rpc::Client::new(&network.rpc_url)?; let account_details = if self.is_view { @@ -337,7 +334,7 @@ impl NetworkRunnable for Cmd { client .verify_network_passphrase(Some(&network.network_passphrase)) .await?; - let key = unwrap_config.key_pair()?; + let key = config.key_pair()?; // Get the account sequence number let public_strkey = @@ -349,17 +346,17 @@ impl NetworkRunnable for Cmd { let spec_entries = get_remote_contract_spec( &contract_id, - &unwrap_config.locator, - &unwrap_config.network, + &config.locator, + &config.network, global_args, - config, + Some(config), ) .await .map_err(Error::from)?; // Get the ledger footprint let (function, spec, host_function_params, signers) = - self.build_host_function_parameters(contract_id, &spec_entries, unwrap_config)?; + self.build_host_function_parameters(contract_id, &spec_entries, config)?; let tx = build_invoke_contract_tx( host_function_params.clone(), sequence + 1, @@ -369,7 +366,7 @@ impl NetworkRunnable for Cmd { if self.fee.build_only { return Ok(TxnResult::Txn(tx)); } - let txn = client.create_assembled_transaction(&tx).await?; + let txn = client.simulate_and_assemble_transaction(&tx).await?; let txn = self.fee.apply_to_assembled_txn(txn); if self.fee.sim_only { return Ok(TxnResult::Txn(txn.transaction().clone())); @@ -381,21 +378,20 @@ impl NetworkRunnable for Cmd { let (return_value, events) = if self.is_view() { (sim_res.results()?[0].xdr.clone(), sim_res.events()?) } else { - let global::Args { - verbose, - very_verbose, - no_cache, - .. - } = global_args.cloned().unwrap_or_default(); + let global::Args { no_cache, .. } = global_args.cloned().unwrap_or_default(); + // Need to sign all auth entries + let mut txn = txn.transaction().clone(); + for signer in signers.into_iter().map(|key| LocalKey::new(key, false)) { + if let Some(tx) = config + .sign_soroban_authorizations(&signer, txn.clone()) + .await? + { + txn = tx; + } + } + // let txn = self.config.sign_with_local_key(tx) let res = client - .send_assembled_transaction( - txn, - &unwrap_config.key_pair()?, - &signers, - &network.network_passphrase, - Some(log_events), - (verbose || very_verbose || self.fee.cost).then_some(log_resources), - ) + .send_transaction_polling(&config.sign_with_local_key(txn).await?) .await?; if !no_cache { data::write(res.clone().try_into()?, &network.rpc_uri()?)?; @@ -425,19 +421,19 @@ fn default_account_entry() -> AccountEntry { } } -fn log_events( - footprint: &LedgerFootprint, - auth: &[VecM], - events: &[DiagnosticEvent], -) { - crate::log::auth(auth); - crate::log::diagnostic_events(events, tracing::Level::TRACE); - crate::log::footprint(footprint); -} - -fn log_resources(resources: &SorobanResources) { - crate::log::cost(resources); -} +// fn log_events( +// footprint: &LedgerFootprint, +// auth: &[VecM], +// events: &[DiagnosticEvent], +// ) { +// crate::log::auth(auth); +// crate::log::diagnostic_events(events, tracing::Level::TRACE); +// crate::log::footprint(footprint); +// } + +// fn log_resources(resources: &SorobanResources) { +// crate::log::cost(resources); +// } pub fn output_to_string( spec: &Spec, diff --git a/cmd/soroban-cli/src/commands/contract/restore.rs b/cmd/soroban-cli/src/commands/contract/restore.rs index ad824d34e4..e38a45b311 100644 --- a/cmd/soroban-cli/src/commands/contract/restore.rs +++ b/cmd/soroban-cli/src/commands/contract/restore.rs @@ -174,7 +174,7 @@ impl NetworkRunnable for Cmd { return Ok(TxnResult::Txn(tx)); } let res = client - .prepare_and_send_transaction(&tx, &key, &[], &network.network_passphrase, None, None) + .send_transaction_polling(&config.sign_with_local_key(tx).await?) .await?; if args.map_or(true, |a| !a.no_cache) { data::write(res.clone().try_into()?, &network.rpc_uri()?)?; diff --git a/cmd/soroban-cli/src/fee.rs b/cmd/soroban-cli/src/fee.rs index ab057a587b..698d66007b 100644 --- a/cmd/soroban-cli/src/fee.rs +++ b/cmd/soroban-cli/src/fee.rs @@ -17,10 +17,10 @@ pub struct Args { /// Number of instructions to simulate #[arg(long, help_heading = HEADING_RPC)] pub instructions: Option, - /// Build the transaction only write the base64 xdr to stdout + /// Build the transaction and only write the base64 xdr to stdout #[arg(long, help_heading = HEADING_RPC)] pub build_only: bool, - /// Simulation the transaction only write the base64 xdr to stdout + /// Simulate the transaction and only write the base64 xdr to stdout #[arg(long, help_heading = HEADING_RPC, conflicts_with = "build_only")] pub sim_only: bool, } diff --git a/cmd/soroban-cli/src/get_spec.rs b/cmd/soroban-cli/src/get_spec.rs index e0d5edb9a2..e21722794b 100644 --- a/cmd/soroban-cli/src/get_spec.rs +++ b/cmd/soroban-cli/src/get_spec.rs @@ -28,6 +28,8 @@ pub enum Error { Network(#[from] network::Error), #[error(transparent)] Config(#[from] config::Error), + #[error(transparent)] + ContractSpec(#[from] contract_spec::Error), } /// @@ -60,13 +62,15 @@ pub async fn get_remote_contract_spec( // Get the contract spec entries based on the executable type Ok(match executable { ContractExecutable::Wasm(hash) => { - let hash = hash.to_string(); - if let Ok(entries) = data::read_spec(&hash) { + let hash_str = hash.to_string(); + if let Ok(entries) = data::read_spec(&hash_str) { entries } else { - let res = client.get_remote_contract_spec(contract_id).await?; + let raw_wasm = client.get_remote_wasm_from_hash(hash).await?; + let res = contract_spec::Spec::new(&raw_wasm)?; + let res = res.spec; if global_args.map_or(true, |a| !a.no_cache) { - data::write_spec(&hash, &res)?; + data::write_spec(&hash_str, &res)?; } res }