From 5f0f9bcf04ca7762775e49cb5425a64977a36408 Mon Sep 17 00:00:00 2001 From: "Thomas M. DuBuisson" Date: Wed, 20 Nov 2024 08:48:05 -0800 Subject: [PATCH 1/6] Add tx hash at the top of the send command --- cmd/soroban-cli/src/commands/tx/send.rs | 11 +++++++++++ flake.nix | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-cli/src/commands/tx/send.rs b/cmd/soroban-cli/src/commands/tx/send.rs index 22fbc860a..7eb5e547d 100644 --- a/cmd/soroban-cli/src/commands/tx/send.rs +++ b/cmd/soroban-cli/src/commands/tx/send.rs @@ -1,5 +1,6 @@ use async_trait::async_trait; use soroban_rpc::GetTransactionResponse; +use crate::utils::transaction_hash; use crate::{ commands::{global, NetworkRunnable}, @@ -56,6 +57,16 @@ impl NetworkRunnable for Cmd { }; let client = network.rpc_client()?; let tx_env = super::xdr::tx_envelope_from_stdin()?; + match super::xdr::unwrap_envelope_v1(tx_env.clone()).map(|tx| transaction_hash(&tx, &network.network_passphrase)) { + Ok(Ok(hash)) => { + println!( + "Transaction Hash: {}", + hex::encode(hash) + ); + } + _ => { + } + } Ok(client.send_transaction_polling(&tx_env).await?) } } diff --git a/flake.nix b/flake.nix index 0a30ea556..8e5ace887 100644 --- a/flake.nix +++ b/flake.nix @@ -36,8 +36,8 @@ }; cargoLock.outputHashes = { - # The only git+https dependency in Cargo.lock - "stellar-rpc-client-21.4.0" = "sha256-ue7Ynux9YaDP3f/XkHz2OPd2g0iCX5R0yS5SaVHEYxQ"; + # This is needed for any git+https dependency in Cargo.lock + # "somepackage-1.2.3" = "sha256-somehash"; }; doCheck = false; From b100ab305f29158e60ff29e085a9d530d40cabc8 Mon Sep 17 00:00:00 2001 From: "Thomas M. DuBuisson" Date: Wed, 20 Nov 2024 09:00:42 -0800 Subject: [PATCH 2/6] Obey quiet --- cmd/soroban-cli/src/commands/tx/send.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/soroban-cli/src/commands/tx/send.rs b/cmd/soroban-cli/src/commands/tx/send.rs index 7eb5e547d..7f74dd3a9 100644 --- a/cmd/soroban-cli/src/commands/tx/send.rs +++ b/cmd/soroban-cli/src/commands/tx/send.rs @@ -47,7 +47,7 @@ impl NetworkRunnable for Cmd { type Result = GetTransactionResponse; async fn run_against_rpc_server( &self, - _: Option<&global::Args>, + globals: Option<&global::Args>, config: Option<&config::Args>, ) -> Result { let network = if let Some(config) = config { @@ -59,10 +59,12 @@ impl NetworkRunnable for Cmd { let tx_env = super::xdr::tx_envelope_from_stdin()?; match super::xdr::unwrap_envelope_v1(tx_env.clone()).map(|tx| transaction_hash(&tx, &network.network_passphrase)) { Ok(Ok(hash)) => { - println!( - "Transaction Hash: {}", - hex::encode(hash) - ); + if !globals.map_or(false, |g| g.quiet) { + println!( + "Transaction Hash: {}", + hex::encode(hash) + ); + } } _ => { } From d51bd7a7098717e931ac700890c350113eb0d795 Mon Sep 17 00:00:00 2001 From: "Thomas M. DuBuisson" Date: Wed, 20 Nov 2024 09:09:34 -0800 Subject: [PATCH 3/6] Fmt --- cmd/soroban-cli/src/commands/tx/send.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/soroban-cli/src/commands/tx/send.rs b/cmd/soroban-cli/src/commands/tx/send.rs index 7f74dd3a9..5f17dd5f0 100644 --- a/cmd/soroban-cli/src/commands/tx/send.rs +++ b/cmd/soroban-cli/src/commands/tx/send.rs @@ -57,17 +57,15 @@ impl NetworkRunnable for Cmd { }; let client = network.rpc_client()?; let tx_env = super::xdr::tx_envelope_from_stdin()?; - match super::xdr::unwrap_envelope_v1(tx_env.clone()).map(|tx| transaction_hash(&tx, &network.network_passphrase)) { + match super::xdr::unwrap_envelope_v1(tx_env.clone()) + .map(|tx| transaction_hash(&tx, &network.network_passphrase)) + { Ok(Ok(hash)) => { - if !globals.map_or(false, |g| g.quiet) { - println!( - "Transaction Hash: {}", - hex::encode(hash) - ); + if !globals.map_or(false, |g| g.quiet){ + println!( "Transaction Hash: {}", hex::encode(hash)); } } - _ => { - } + _ => {} } Ok(client.send_transaction_polling(&tx_env).await?) } From 975ccc5a8280678aef64286eef1fb168bcbf045e Mon Sep 17 00:00:00 2001 From: "Thomas M. DuBuisson" Date: Wed, 20 Nov 2024 09:16:47 -0800 Subject: [PATCH 4/6] fmt fmt fmt --- cmd/soroban-cli/src/commands/tx/send.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/soroban-cli/src/commands/tx/send.rs b/cmd/soroban-cli/src/commands/tx/send.rs index 5f17dd5f0..b410cf1f3 100644 --- a/cmd/soroban-cli/src/commands/tx/send.rs +++ b/cmd/soroban-cli/src/commands/tx/send.rs @@ -1,6 +1,6 @@ +use crate::utils::transaction_hash; use async_trait::async_trait; use soroban_rpc::GetTransactionResponse; -use crate::utils::transaction_hash; use crate::{ commands::{global, NetworkRunnable}, @@ -58,11 +58,11 @@ impl NetworkRunnable for Cmd { let client = network.rpc_client()?; let tx_env = super::xdr::tx_envelope_from_stdin()?; match super::xdr::unwrap_envelope_v1(tx_env.clone()) - .map(|tx| transaction_hash(&tx, &network.network_passphrase)) + .map(|tx| transaction_hash(&tx, &network.network_passphrase)) { Ok(Ok(hash)) => { - if !globals.map_or(false, |g| g.quiet){ - println!( "Transaction Hash: {}", hex::encode(hash)); + if !globals.map_or(false, |g| g.quiet) { + println!("Transaction Hash: {}", hex::encode(hash)); } } _ => {} From 5c88412d4aae2b70763b5c7e5b02c89a44bf67db Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Thu, 21 Nov 2024 13:02:15 -0800 Subject: [PATCH 5/6] tweak --- cmd/soroban-cli/src/commands/tx/send.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/soroban-cli/src/commands/tx/send.rs b/cmd/soroban-cli/src/commands/tx/send.rs index b410cf1f3..c35f21dc1 100644 --- a/cmd/soroban-cli/src/commands/tx/send.rs +++ b/cmd/soroban-cli/src/commands/tx/send.rs @@ -61,7 +61,7 @@ impl NetworkRunnable for Cmd { .map(|tx| transaction_hash(&tx, &network.network_passphrase)) { Ok(Ok(hash)) => { - if !globals.map_or(false, |g| g.quiet) { + if !globals.is_some_and(|g| g.quiet) { println!("Transaction Hash: {}", hex::encode(hash)); } } From d450320afeb88702342dbb748c7ce68e2513af0c Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Thu, 21 Nov 2024 13:31:43 -0800 Subject: [PATCH 6/6] Use print instead, so the json output continues to be valid. --- cmd/soroban-cli/src/commands/tx/send.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/soroban-cli/src/commands/tx/send.rs b/cmd/soroban-cli/src/commands/tx/send.rs index c35f21dc1..1e542eb6f 100644 --- a/cmd/soroban-cli/src/commands/tx/send.rs +++ b/cmd/soroban-cli/src/commands/tx/send.rs @@ -1,4 +1,4 @@ -use crate::utils::transaction_hash; +use crate::{print::Print, utils::transaction_hash}; use async_trait::async_trait; use soroban_rpc::GetTransactionResponse; @@ -57,16 +57,14 @@ impl NetworkRunnable for Cmd { }; let client = network.rpc_client()?; let tx_env = super::xdr::tx_envelope_from_stdin()?; - match super::xdr::unwrap_envelope_v1(tx_env.clone()) + + if let Ok(Ok(hash)) = super::xdr::unwrap_envelope_v1(tx_env.clone()) .map(|tx| transaction_hash(&tx, &network.network_passphrase)) { - Ok(Ok(hash)) => { - if !globals.is_some_and(|g| g.quiet) { - println!("Transaction Hash: {}", hex::encode(hash)); - } - } - _ => {} + let print = Print::new(globals.map_or(false, |g| g.quiet)); + print.infoln(format!("Transaction Hash: {}", hex::encode(hash))); } + Ok(client.send_transaction_polling(&tx_env).await?) } }