Skip to content

Commit

Permalink
cli: print information about the mining status in contract state
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Sep 20, 2024
1 parent c85b0ae commit de9587a
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ use rgb::{
RgbDescr, RgbKeychain, RgbWallet, StateType, TransferParams, WalletError, WalletProvider,
XChain, XOutpoint, XWitnessId,
};
use rgbstd::persistence::StockError;
use rgbstd::interface::ContractIface;
use rgbstd::persistence::{MemContractState, StockError};
use rgbstd::{KnownState, OutputAssignment};
use seals::SecretSeal;
use serde_crate::{Deserialize, Serialize};
use strict_types::encoding::{FieldName, TypeName};
Expand Down Expand Up @@ -577,67 +579,57 @@ impl Exec for RgbArgs {
}

println!("\nOwned:");
fn witness<S: KnownState>(
allocation: &OutputAssignment<S>,
contract: &ContractIface<MemContract<&MemContractState>>,
) -> String {
allocation
.witness
.and_then(|w| contract.witness_info(w))
.map(|info| format!("{} ({})", info.id, info.ord))
.unwrap_or_else(|| s!("~"))
}
for owned in &contract.iface.assignments {
println!(" {}:", owned.name);
if let Ok(allocations) = contract.fungible(owned.name.clone(), &filter) {
for allocation in allocations {
let witness = allocation
.witness
.as_ref()
.map(XWitnessId::to_string)
.unwrap_or(s!("~"));
println!(
" value={}, utxo={}, witness={} {}",
allocation.state.value(),
allocation.seal,
witness,
witness(&allocation, &contract),
filter.comment(allocation.seal.to_outpoint())
);
}
}
if let Ok(allocations) = contract.data(owned.name.clone(), &filter) {
for allocation in allocations {
let witness = allocation
.witness
.as_ref()
.map(XWitnessId::to_string)
.unwrap_or(s!("~"));
println!(
" data={}, utxo={}, witness={} {}",
allocation.state,
allocation.seal,
witness,
witness(&allocation, &contract),
filter.comment(allocation.seal.to_outpoint())
);
}
}
if let Ok(allocations) = contract.attachments(owned.name.clone(), &filter) {
for allocation in allocations {
let witness = allocation
.witness
.as_ref()
.map(XWitnessId::to_string)
.unwrap_or(s!("~"));
println!(
" file={}, utxo={}, witness={} {}",
allocation.state,
allocation.seal,
witness,
witness(&allocation, &contract),
filter.comment(allocation.seal.to_outpoint())
);
}
}
if let Ok(allocations) = contract.rights(owned.name.clone(), &filter) {
for allocation in allocations {
let witness = allocation
.witness
.as_ref()
.map(XWitnessId::to_string)
.unwrap_or(s!("~"));
println!(
" utxo={}, witness={} {}",
allocation.seal,
witness,
witness(&allocation, &contract),
filter.comment(allocation.seal.to_outpoint())
);
}
Expand Down

0 comments on commit de9587a

Please sign in to comment.