-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add tx hash command * docs * Update cmd/soroban-cli/src/commands/tx/mod.rs more detailed doc Co-authored-by: Willem Wyndham <[email protected]> * docs update * fix: use network only --------- Co-authored-by: Willem Wyndham <[email protected]>
- Loading branch information
1 parent
3fbf979
commit 2b19b7a
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::{commands::global, utils::transaction_hash}; | ||
use hex; | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
TxEnvelopeFromStdin(#[from] super::xdr::Error), | ||
#[error(transparent)] | ||
XdrToBase64(#[from] soroban_env_host::xdr::Error), | ||
#[error(transparent)] | ||
Config(#[from] super::super::network::Error), | ||
} | ||
|
||
// Command to return the transaction hash submitted to a network | ||
/// e.g. `cat file.txt | soroban tx hash` | ||
#[derive(Debug, clap::Parser, Clone, Default)] | ||
#[group(skip)] | ||
pub struct Cmd { | ||
#[clap(flatten)] | ||
pub network: super::super::network::Args, | ||
} | ||
|
||
impl Cmd { | ||
pub fn run(&self, global_args: &global::Args) -> Result<(), Error> { | ||
let tx = super::xdr::unwrap_envelope_v1(super::xdr::tx_envelope_from_stdin()?)?; | ||
let network = &self.network.get(&global_args.locator)?; | ||
println!( | ||
"{}", | ||
hex::encode(transaction_hash(&tx, &network.network_passphrase)?) | ||
); | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters