Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tx hash at the top of the send command #1747

Merged
merged 8 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cmd/soroban-cli/src/commands/tx/send.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::{print::Print, utils::transaction_hash};
use async_trait::async_trait;
use soroban_rpc::GetTransactionResponse;

Expand Down Expand Up @@ -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<Self::Result, Self::Error> {
let network = if let Some(config) = config {
Expand All @@ -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?)
}
}
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading