diff --git a/apps/src/lib/cli.rs b/apps/src/lib/cli.rs index eb3a5ffb31..c1ee3e3c7e 100644 --- a/apps/src/lib/cli.rs +++ b/apps/src/lib/cli.rs @@ -2241,11 +2241,11 @@ pub mod args { DATA_PATH_OPT.name, ]), ) - .arg( - PROPOSAL_VOTE - .def() - .about("The vote for the proposal. Either yay or nay (with optional memo).\nDefault vote: yay | nay\nPGF vote: yay $council1 $cap1 $council2 $cap2 ... | nay"), - ) + .arg(PROPOSAL_VOTE.def().about( + "The vote for the proposal. Either yay or nay (with \ + optional memo).\nDefault vote: yay | nay\nPGF vote: yay \ + $council1 $cap1 $council2 $cap2 ... | nay", + )) .arg( PROPOSAL_OFFLINE .def() diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index edba749e3c..d6fe3419ea 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -1788,9 +1788,9 @@ pub async fn query_bonded_stake(ctx: Context, args: args::QueryBondedStake) { }; let is_active = validator_set.active.contains(&weighted); if !is_active { - debug_assert!(validator_set - .inactive - .contains(&weighted)); + debug_assert!( + validator_set.inactive.contains(&weighted) + ); } println!( "Validator {} is {}, bonded stake: {}", diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index ddcb8e57a0..9a1705ea70 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -2042,10 +2042,12 @@ pub async fn submit_vote_proposal(mut ctx: Context, args: args::VoteProposal) { let proposal_type: ProposalType = rpc::query_storage_value(&client, &proposal_type_key) .await - .expect(&format!( - "Didn't find type of proposal id {} in storage", - proposal_id - )); + .unwrap_or_else(|| { + panic!( + "Didn't find type of proposal id {} in storage", + proposal_id + ) + }); if let ProposalVote::Yay(ref vote_type) = args.vote { if &proposal_type != vote_type { @@ -2055,23 +2057,29 @@ pub async fn submit_vote_proposal(mut ctx: Context, args: args::VoteProposal) { ); safe_exit(1); } else if let VoteType::PGFCouncil(set) = vote_type { - // Check that addresses proposed as council are established and are present in storage + // Check that addresses proposed as council are established and + // are present in storage for (address, _) in set { match address { Address::Established(_) => { - let vp_key = Key::validity_predicate(&address); + let vp_key = Key::validity_predicate(address); if !rpc::query_has_storage_key(&client, &vp_key) .await { - eprintln!("Proposed PGF council {} cannot be found in storage", address); + eprintln!( + "Proposed PGF council {} cannot be found \ + in storage", + address + ); safe_exit(1); } } _ => { eprintln!( - "PGF council vote contains a non-established address: {}", - address - ); + "PGF council vote contains a non-established \ + address: {}", + address + ); safe_exit(1); } } diff --git a/core/src/types/governance.rs b/core/src/types/governance.rs index 58b66fd480..0333ae1202 100644 --- a/core/src/types/governance.rs +++ b/core/src/types/governance.rs @@ -65,7 +65,7 @@ impl FromStr for ProposalVote { fn from_str(s: &str) -> Result { let splits = s.trim().split_ascii_whitespace(); - let mut iter = splits.clone().into_iter(); + let mut iter = splits.clone(); match iter.next() { Some(t) => match t { @@ -119,11 +119,10 @@ impl ProposalVote { /// Check if vote is of type default pub fn is_default_vote(&self) -> bool { - match self { - ProposalVote::Yay(VoteType::Default) => true, - ProposalVote::Nay => true, - _ => false, - } + matches!( + self, + ProposalVote::Yay(VoteType::Default) | ProposalVote::Nay + ) } } diff --git a/shared/src/ledger/native_vp/governance/mod.rs b/shared/src/ledger/native_vp/governance/mod.rs index a0ad8953e2..3bd03ae11c 100644 --- a/shared/src/ledger/native_vp/governance/mod.rs +++ b/shared/src/ledger/native_vp/governance/mod.rs @@ -204,7 +204,7 @@ where ) => { if let ProposalVote::Yay(vote_type) = vote { if proposal_type != vote_type { - //FIXME: technically this is needed only for Yay votes + // FIXME: technically this is needed only for Yay votes return Ok(false); } @@ -214,7 +214,8 @@ where for (address, _) in set { match address { Address::Established(_) => { - // Check that established address exists in storage + // Check that established address exists in + // storage let vp_key = Key::validity_predicate(&address); if !self.ctx.has_key_pre(&vp_key)? { diff --git a/tests/src/e2e/ledger_tests.rs b/tests/src/e2e/ledger_tests.rs index fc14f703b8..47feb4cd35 100644 --- a/tests/src/e2e/ledger_tests.rs +++ b/tests/src/e2e/ledger_tests.rs @@ -2789,7 +2789,8 @@ fn pgf_governance_proposal() -> Result<()> { client.assert_success(); // FIXME: test not 1/3 of total voting power (vote with just the delegator) - // FIXME: test majority when 1/3 of votes (vote with both BERTHA and validator 0 anche check that validtor 0 won) + // FIXME: test majority when 1/3 of votes (vote with both BERTHA and + // validator 0 anche check that validtor 0 won) // 12. Wait proposal grace and check proposal author funds let mut epoch = get_epoch(&test, &validator_one_rpc).unwrap();