Skip to content

Commit

Permalink
cli: sort history
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Sep 20, 2024
1 parent 07c1b12 commit b36d00f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use rgb::persistence::{MemContract, StashReadProvider, Stock};
use rgb::resolvers::ContractIssueResolver;
use rgb::schema::SchemaId;
use rgb::validation::Validity;
use rgb::vm::RgbIsa;
use rgb::vm::{RgbIsa, WitnessOrd};
use rgb::{
BundleId, ContractId, DescriptorRgb, GenesisSeal, GraphSeal, Identity, OpId, OutputSeal,
RgbDescr, RgbKeychain, RgbWallet, StateType, TransferParams, WalletError, WalletProvider,
Expand Down Expand Up @@ -364,7 +364,8 @@ impl Exec for RgbArgs {
ControlFlow::Break(_) => return Ok(()),

Check warning on line 364 in cli/src/command.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/command.rs#L360-L364

Added lines #L360 - L364 were not covered by tests
},
};
let history = wallet.history(*contract_id, iface)?;
let mut history = wallet.history(*contract_id, iface)?;
history.sort_by_key(|op| op.witness.map(|w| w.ord).unwrap_or(WitnessOrd::Archived));
if *details {
println!("Operation\tValue\tState\tSeal\tWitness\tOpIds");
} else {
Expand All @@ -379,11 +380,11 @@ impl Exec for RgbArgs {
witness,
} in history

Check warning on line 381 in cli/src/command.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/command.rs#L375-L381

Added lines #L375 - L381 were not covered by tests
{
print!("{direction:<9}\t");
print!("{:9}\t", direction.to_string());
if let AllocatedState::Amount(amount) = state {
print!("{:>9}", amount.value());
print!("{: >9}", amount.value());
} else {
print!("{state}");
print!("{state:>9}");
}
if *details {
print!("\t{ty}");
Expand Down Expand Up @@ -582,7 +583,9 @@ impl Exec for RgbArgs {
Filter::WalletAll(rgb) if rgb.wallet().is_unspent(outpoint) => {
"-- unspent"

Check warning on line 584 in cli/src/command.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/command.rs#L582-L584

Added lines #L582 - L584 were not covered by tests
}
Filter::WalletAll(_) => "-- spent",
Filter::WalletAll(rgb) if rgb.wallet().has_outpoint(outpoint) => {
"-- spent"

Check warning on line 587 in cli/src/command.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/command.rs#L586-L587

Added lines #L586 - L587 were not covered by tests
}
_ => "-- third-party",

Check warning on line 589 in cli/src/command.rs

View check run for this annotation

Codecov / codecov/patch

cli/src/command.rs#L589

Added line #L589 was not covered by tests
}
}
Expand Down

0 comments on commit b36d00f

Please sign in to comment.