Skip to content

Commit

Permalink
nicer proposal action printout
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Sep 11, 2024
1 parent f28568e commit dbee4ec
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "encointer-client-notee"
authors = ["encointer.org <[email protected]>"]
edition = "2021"
#keep with node version. major, minor and patch
version = "1.14.2"
version = "1.14.3"

[dependencies]
# todo migrate to clap >=3 https://github.com/encointer/encointer-node/issues/107
Expand Down
21 changes: 20 additions & 1 deletion client/src/commands/encointer_democracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use encointer_node_notee_runtime::{AccountId, Balance, Hash};
use encointer_primitives::{
ceremonies::{CeremonyIndexType, CommunityCeremony, ReputationCountType},
common::{FromStr, PalletString},
communities::CommunityIdentifier,
democracy::{
Proposal, ProposalAccessPolicy, ProposalAction, ProposalIdType, ProposalState,
ReputationVec, Vote,
Expand Down Expand Up @@ -222,7 +223,18 @@ pub fn list_proposals(_args: &str, matches: &ArgMatches<'_>) -> Result<(), clap:
"Proposal id: {} (reputation commitment purpose id: {})",
*proposal_id, purpose_id
);
println!("🛠 action: {:?}", proposal.action);
let proposal_str = match &proposal.action {
ProposalAction::SetInactivityTimeout(timeout) =>
format!("Set inactivity timeout to {timeout}"),
ProposalAction::UpdateNominalIncome(cid, income) =>
format!("Update nominal income for {cid} to {income}"),
ProposalAction::Petition(maybecid, demand) =>
format!("Petition for {} demanding: {}", cid_or_global(maybecid), String::from_utf8_lossy(demand)),
ProposalAction::SpendNative(maybecid, to, amount) =>
format!("Spend Native from {} treasury to {to}, amount {amount}", cid_or_global(maybecid)),
_ => format!("{:?}", proposal.action),
};
println!("🛠 action: {:?}", proposal_str);
println!("▶️ started at: {}", start.format("%Y-%m-%d %H:%M:%S %Z").to_string());
println!(
"🏁 ends after: {}",
Expand Down Expand Up @@ -398,3 +410,10 @@ async fn get_relevant_electorate(
fn approval_threshold_percent(electorate: u128, turnout: u128) -> f64 {
100f64 / (1f64 + (turnout as f64 / electorate as f64).sqrt())
}

fn cid_or_global(maybecid: &Option<CommunityIdentifier>) -> String {
match maybecid {
Some(cid) => format!("{:?}", cid),
None => "global".into(),
}
}
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/encointer/encointer-node"
# * Align major and minor version with polkadot-sdk major.minor.
# * Bump patch version for new releases, and make it the release tag.
# * The client should follow this version.
version = "1.14.2"
version = "1.14.3"

[[bin]]
name = "encointer-node-notee"
Expand Down

0 comments on commit dbee4ec

Please sign in to comment.