From 62ce556cfb54f085a43f3de7da2e5a6f3a996a72 Mon Sep 17 00:00:00 2001 From: "Thomas M. DuBuisson" Date: Thu, 21 Nov 2024 14:00:56 -0800 Subject: [PATCH] Add tx hash at the top of the send command (#1747) Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Co-authored-by: Nando Vieira --- cmd/soroban-cli/src/commands/tx/send.rs | 11 ++++++++++- flake.nix | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/soroban-cli/src/commands/tx/send.rs b/cmd/soroban-cli/src/commands/tx/send.rs index 22fbc860a..1e542eb6f 100644 --- a/cmd/soroban-cli/src/commands/tx/send.rs +++ b/cmd/soroban-cli/src/commands/tx/send.rs @@ -1,3 +1,4 @@ +use crate::{print::Print, utils::transaction_hash}; use async_trait::async_trait; use soroban_rpc::GetTransactionResponse; @@ -46,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 { @@ -56,6 +57,14 @@ impl NetworkRunnable for Cmd { }; let client = network.rpc_client()?; let tx_env = super::xdr::tx_envelope_from_stdin()?; + + if let Ok(Ok(hash)) = super::xdr::unwrap_envelope_v1(tx_env.clone()) + .map(|tx| transaction_hash(&tx, &network.network_passphrase)) + { + 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?) } } 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;