Skip to content

Commit 3b7c139

Browse files
Add recovered address to cast decode transaction #10247 (#10252)
* Update args.rs * Update lib.rs * Update opts.rs * Update args.rs * Update lib.rs * Update args.rs * Update opts.rs * Update opts.rs * Update opts.rs * Update opts.rs * rustfmt --------- Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
1 parent 623f852 commit 3b7c139

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/cast/src/args.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{
33
traces::identifier::SignaturesIdentifier,
44
Cast, SimpleCast,
55
};
6+
use alloy_consensus::transaction::Recovered;
67
use alloy_dyn_abi::{DynSolValue, ErrorExt, EventExt};
78
use alloy_primitives::{eip191_hash_message, hex, keccak256, Address, B256};
89
use alloy_provider::Provider;
@@ -698,7 +699,12 @@ pub async fn run_command(args: CastArgs) -> Result<()> {
698699
let tx = stdin::unwrap_line(tx)?;
699700
let tx = SimpleCast::decode_raw_transaction(&tx)?;
700701

701-
sh_println!("{}", serde_json::to_string_pretty(&tx)?)?
702+
if let Ok(signer) = tx.recover_signer() {
703+
let recovered = Recovered::new_unchecked(tx, signer);
704+
sh_println!("{}", serde_json::to_string_pretty(&recovered)?)?;
705+
} else {
706+
sh_println!("{}", serde_json::to_string_pretty(&tx)?)?;
707+
}
702708
}
703709
CastSubcommand::DecodeEof { eof } => {
704710
let eof = stdin::unwrap_line(eof)?;

0 commit comments

Comments
 (0)