Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Merge #848
Browse files Browse the repository at this point in the history
848: Problem: Client CLI does not show transaction type in history r=tomtau a=devashishdxt

Solution: Show transaction type in history. This addresses a part of #846

Sample output after this change:
```
+------------------------------------------------------------------+--------+----------------------+-----+------------------+--------------+--------------------------------+
| Transaction ID                                                   | In/Out | Amount               | Fee | Transaction Type | Block Height | Block Time                     |
+------------------------------------------------------------------+--------+----------------------+-----+------------------+--------------+--------------------------------+
| cc88d0ca2cbcd6ce167a6db426f40c3da034deb5b4e4f09e5ec01f39af80c0ea | IN     | 24999999999.99999703 |   - | Withdraw         |           92 | 2020-01-07T10:14:17.764748000Z |
+------------------------------------------------------------------+--------+----------------------+-----+------------------+--------------+--------------------------------+
```

Co-authored-by: Devashish Dixit <devashish@crypto.com>
  • Loading branch information
bors[bot] and devashishdxt authored Jan 8, 2020
2 parents f07117b + 204f658 commit 4053a2d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion client-cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ pub enum Command {
)]
disable_fast_forward: bool,
#[structopt(
name = "block_height_ensure",
name = "block-height-ensure",
long,
default_value = "50",
help = "Number of block height to rollback the utxos in pending transactions"
)]
block_height_ensure: u64,
Expand Down Expand Up @@ -431,6 +432,7 @@ impl Command {
Cell::new("In/Out", bold),
Cell::new("Amount", bold),
Cell::new("Fee", bold),
Cell::new("Transaction Type", bold),
Cell::new("Block Height", bold),
Cell::new("Block Time", bold),
]));
Expand Down Expand Up @@ -464,6 +466,7 @@ impl Command {
.unwrap_or_else(|| "-".to_owned()),
right_justify,
),
Cell::new(&change.transaction_type, Default::default()),
Cell::new(&change.block_height, right_justify),
Cell::new(&change.block_time, Default::default()),
]));
Expand Down
12 changes: 12 additions & 0 deletions client-core/src/types/transaction_change.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Types for tracking balance change in a wallet
use std::fmt;
use std::ops::Add;
use std::str::FromStr;

Expand Down Expand Up @@ -79,6 +80,17 @@ pub enum TransactionType {
Deposit,
}

impl fmt::Display for TransactionType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TransactionType::Transfer => write!(f, "Transfer"),
TransactionType::Withdraw => write!(f, "Withdraw"),
TransactionType::Unbond => write!(f, "Unbond"),
TransactionType::Deposit => write!(f, "Deposit"),
}
}
}

/// Balance change a transaction has caused
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, Encode, Decode)]
#[serde(tag = "kind")]
Expand Down
2 changes: 1 addition & 1 deletion client-rpc/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct Options {
)]
pub batch_size: usize,
#[structopt(
name = "block_height_ensure",
name = "block-height-ensure",
long,
default_value = "50",
help = "Number of block height to rollback the utxos in the pending transactions"
Expand Down

0 comments on commit 4053a2d

Please sign in to comment.