Skip to content

Commit 0561ab8

Browse files
committed
cargo fmt
1 parent 02008f9 commit 0561ab8

File tree

1 file changed

+41
-38
lines changed

1 file changed

+41
-38
lines changed

src/blockstack_cli.rs

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ extern crate blockstack_lib;
2424
use blockstack_lib::address::AddressHashMode;
2525
use blockstack_lib::burnchains::Address;
2626
use blockstack_lib::chainstate::stacks::{
27-
StacksAddress, StacksBlock, StacksPrivateKey, StacksPublicKey, StacksTransaction, StacksTransactionSigner,
28-
TokenTransferMemo, TransactionAuth, TransactionContractCall, TransactionPayload,
29-
TransactionSmartContract, TransactionSpendingCondition, TransactionVersion,
27+
StacksAddress, StacksBlock, StacksPrivateKey, StacksPublicKey, StacksTransaction,
28+
StacksTransactionSigner, TokenTransferMemo, TransactionAuth, TransactionContractCall,
29+
TransactionPayload, TransactionSmartContract, TransactionSpendingCondition, TransactionVersion,
3030
C32_ADDRESS_VERSION_MAINNET_SINGLESIG, C32_ADDRESS_VERSION_TESTNET_SINGLESIG,
3131
};
3232
use blockstack_lib::net::{Error as NetError, StacksMessageCodec};
33-
use blockstack_lib::util::{hash::hex_bytes, hash::to_hex, log, strings::StacksString, retry::LogReader};
33+
use blockstack_lib::util::{
34+
hash::hex_bytes, hash::to_hex, log, retry::LogReader, strings::StacksString,
35+
};
3436
use blockstack_lib::vm;
3537
use blockstack_lib::vm::{
3638
errors::{Error as ClarityError, RuntimeErrorType},
@@ -116,7 +118,8 @@ The addresses command calculates both the Bitcoin and Stacks addresses from a se
116118
If successful, this command outputs both the Bitcoin and Stacks addresses to stdout, formatted
117119
as JSON, and exits with code 0";
118120

119-
const DECODE_TRANSACTION_USAGE: &str = "blockstack-cli (options) decode-tx [transaction-hex-or-stdin]
121+
const DECODE_TRANSACTION_USAGE: &str =
122+
"blockstack-cli (options) decode-tx [transaction-hex-or-stdin]
120123
121124
The decode-tx command decodes a serialized Stacks transaction and prints it to stdout as JSON.
122125
The transaction, if given, must be a hex string. Alternatively, you may pass - instead, and the
@@ -532,29 +535,29 @@ fn get_addresses(args: &[String], version: TransactionVersion) -> Result<String,
532535

533536
fn decode_transaction(args: &[String], _version: TransactionVersion) -> Result<String, CliError> {
534537
if (args.len() >= 1 && args[0] == "-h") || args.len() != 1 {
535-
return Err(CliError::Message(format!("Usage: {}\n", DECODE_TRANSACTION_USAGE)));
538+
return Err(CliError::Message(format!(
539+
"Usage: {}\n",
540+
DECODE_TRANSACTION_USAGE
541+
)));
536542
}
537543

538-
let tx_str =
539-
if args[0] == "-" {
540-
// read from stdin
541-
let mut tx_str = Vec::new();
542-
io::stdin().read_to_end(&mut tx_str).expect("Failed to read transaction from stdin");
543-
tx_str
544-
}
545-
else {
546-
// given as a command-line arg
547-
hex_bytes(&args[0].clone())
548-
.expect("Failed to decode transaction: must be a hex string")
549-
};
544+
let tx_str = if args[0] == "-" {
545+
// read from stdin
546+
let mut tx_str = Vec::new();
547+
io::stdin()
548+
.read_to_end(&mut tx_str)
549+
.expect("Failed to read transaction from stdin");
550+
tx_str
551+
} else {
552+
// given as a command-line arg
553+
hex_bytes(&args[0].clone()).expect("Failed to decode transaction: must be a hex string")
554+
};
550555

551556
let mut cursor = io::Cursor::new(&tx_str);
552557
let mut debug_cursor = LogReader::from_reader(&mut cursor);
553558

554559
match StacksTransaction::consensus_deserialize(&mut debug_cursor) {
555-
Ok(tx) => {
556-
Ok(serde_json::to_string(&tx).expect("Failed to serialize transaction to JSON"))
557-
},
560+
Ok(tx) => Ok(serde_json::to_string(&tx).expect("Failed to serialize transaction to JSON")),
558561
Err(e) => {
559562
let mut ret = String::new();
560563
ret.push_str(&format!("Failed to decode transaction: {:?}\n", &e));
@@ -570,28 +573,28 @@ fn decode_transaction(args: &[String], _version: TransactionVersion) -> Result<S
570573

571574
fn decode_block(args: &[String], _version: TransactionVersion) -> Result<String, CliError> {
572575
if (args.len() >= 1 && args[0] == "-h") || args.len() != 1 {
573-
return Err(CliError::Message(format!("Usage: {}\n", DECODE_BLOCK_USAGE)));
574-
}
575-
let block_data =
576-
if args[0] == "-" {
577-
// read from stdin
578-
let mut block_str = Vec::new();
579-
io::stdin().read_to_end(&mut block_str).expect("Failed to read block from stdin");
580-
block_str
581-
}
582-
else {
583-
// given as a command-line arg
584-
hex_bytes(&args[0].clone())
585-
.expect("Failed to decode block: must be a hex string")
586-
};
576+
return Err(CliError::Message(format!(
577+
"Usage: {}\n",
578+
DECODE_BLOCK_USAGE
579+
)));
580+
}
581+
let block_data = if args[0] == "-" {
582+
// read from stdin
583+
let mut block_str = Vec::new();
584+
io::stdin()
585+
.read_to_end(&mut block_str)
586+
.expect("Failed to read block from stdin");
587+
block_str
588+
} else {
589+
// given as a command-line arg
590+
hex_bytes(&args[0].clone()).expect("Failed to decode block: must be a hex string")
591+
};
587592

588593
let mut cursor = io::Cursor::new(&block_data);
589594
let mut debug_cursor = LogReader::from_reader(&mut cursor);
590595

591596
match StacksBlock::consensus_deserialize(&mut debug_cursor) {
592-
Ok(block) => {
593-
Ok(serde_json::to_string(&block).expect("Failed to serialize block to JSON"))
594-
},
597+
Ok(block) => Ok(serde_json::to_string(&block).expect("Failed to serialize block to JSON")),
595598
Err(e) => {
596599
let mut ret = String::new();
597600
ret.push_str(&format!("Failed to decode block: {:?}\n", &e));

0 commit comments

Comments
 (0)