Skip to content

Commit

Permalink
feat(cast): pretty print tx status in cast receipt (#7534)
Browse files Browse the repository at this point in the history
* feat(cast): pretty print tx status in `cast receipt`

* pretty status

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
  • Loading branch information
llllvvuu and mattsse authored Apr 9, 2024
1 parent 0df7fb1 commit 7bb2b20
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/common/src/fmt/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ impl UIfmt for [u8] {
}
}

pub fn pretty_status(status: bool) -> String {
if status { "1 (success)" } else { "0 (failed)" }.to_string()
}

impl UIfmt for AnyTransactionReceipt {
fn pretty(&self) -> String {
let Self {
Expand Down Expand Up @@ -205,7 +209,7 @@ blobGasUsed {}",
serde_json::to_string(&logs).unwrap(),
logs_bloom.pretty(),
state_root.pretty(),
status.pretty(),
pretty_status(*status),
transaction_hash.pretty(),
transaction_index.pretty(),
transaction_type,
Expand Down Expand Up @@ -445,7 +449,7 @@ pub fn get_pretty_tx_receipt_attr(
"logsBloom" | "logs_bloom" => Some(receipt.receipt.inner.inner.inner.logs_bloom.pretty()),
"root" | "stateRoot" | "state_root " => Some(receipt.receipt.state_root.pretty()),
"status" | "statusCode" | "status_code" => {
Some(receipt.receipt.inner.inner.inner.receipt.status.pretty())
Some(pretty_status(receipt.receipt.inner.inner.inner.receipt.status))
}
"transactionHash" | "transaction_hash" => Some(receipt.receipt.transaction_hash.pretty()),
"transactionIndex" | "transaction_index" => {
Expand Down

0 comments on commit 7bb2b20

Please sign in to comment.