From 445f8f6193afc78cec17e1d83f2ca53663d93822 Mon Sep 17 00:00:00 2001 From: Evolution Date: Mon, 13 Nov 2023 11:22:31 -0500 Subject: [PATCH] close the voting round if the total votes are done (#269) * close the voting round if the total votes are done * cargo fmt --------- Co-authored-by: samelamin --- node/src/cli.rs | 4 ++-- pallets/fellowship/src/impls.rs | 5 +---- pallets/fellowship/src/tests/ensure_role.rs | 1 - pallets/fellowship/src/tests/test_utils.rs | 1 - pallets/proposals/src/impls/pallet_impls.rs | 13 ++++++++++--- runtime/integration-tests/src/xcm_transfers.rs | 4 +--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/node/src/cli.rs b/node/src/cli.rs index 6346c8eb..26140b21 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -37,8 +37,8 @@ pub enum Subcommand { Benchmark(frame_benchmarking_cli::BenchmarkCmd), /// Try-runtime has migrated to a standalone - /// [CLI](). The subcommand exists as a stub and - /// deprecation notice. It will be removed entirely some time after Janurary 2024. + /// [CLI](). The subcommand exists as a stub and + /// deprecation notice. It will be removed entirely some time after Janurary 2024. TryRuntime, } diff --git a/pallets/fellowship/src/impls.rs b/pallets/fellowship/src/impls.rs index 8a106df8..b8b5d8fd 100644 --- a/pallets/fellowship/src/impls.rs +++ b/pallets/fellowship/src/impls.rs @@ -3,10 +3,7 @@ use crate::*; use common_traits::MaybeConvert; use frame_support::{ensure, traits::Get}; use orml_traits::MultiReservableCurrency; -use sp_runtime::{ - traits::BadOrigin, - DispatchError, -}; +use sp_runtime::{traits::BadOrigin, DispatchError}; use sp_std::{vec, vec::Vec}; /// Ensure that a account is of a given role. /// Used in other pallets like an ensure origin. diff --git a/pallets/fellowship/src/tests/ensure_role.rs b/pallets/fellowship/src/tests/ensure_role.rs index 144ce6f3..2e1a7dfd 100644 --- a/pallets/fellowship/src/tests/ensure_role.rs +++ b/pallets/fellowship/src/tests/ensure_role.rs @@ -27,7 +27,6 @@ fn ensure_role_in_works() { }); } - #[test] fn ensure_role_in_works_with_rank() { new_test_ext().execute_with(|| { diff --git a/pallets/fellowship/src/tests/test_utils.rs b/pallets/fellowship/src/tests/test_utils.rs index 766f5bd0..c78a6919 100644 --- a/pallets/fellowship/src/tests/test_utils.rs +++ b/pallets/fellowship/src/tests/test_utils.rs @@ -1,6 +1,5 @@ use super::*; - // Saves a bit of typing. pub(crate) fn add_to_fellowship_take_deposit( who: &AccountIdOf, diff --git a/pallets/proposals/src/impls/pallet_impls.rs b/pallets/proposals/src/impls/pallet_impls.rs index 33c59203..d368c307 100644 --- a/pallets/proposals/src/impls/pallet_impls.rs +++ b/pallets/proposals/src/impls/pallet_impls.rs @@ -92,6 +92,9 @@ impl Pallet { Ok::<(), DispatchError>(()) })?; + let funding_threshold: BalanceOf = + T::PercentRequiredForVoteToPass::get().mul_floor(project.raised_funds); + let vote: Vote> = MilestoneVotes::::try_mutate(project_key, |vote_btree| { if let Some(vote) = vote_btree.get_mut(&milestone_key) { @@ -100,15 +103,19 @@ impl Pallet { } else { vote.nay = vote.nay.saturating_add(contribution_amount); } + + //check if the everyone has voted and its still less than the + // funding threshold just reject it + if vote.yay + vote.nay == project.raised_funds && vote.yay < funding_threshold { + Self::close_voting_round(project_key, user_has_voted_key)?; + Self::deposit_event(Event::MilestoneRejected(project_key, milestone_key)); + } Ok::>, DispatchError>(vote.clone()) } else { Err(Error::::VotingRoundNotStarted.into()) } })?; - let funding_threshold: BalanceOf = - T::PercentRequiredForVoteToPass::get().mul_floor(project.raised_funds); - Self::try_auto_finalise_milestone_voting( project_key, &vote, diff --git a/runtime/integration-tests/src/xcm_transfers.rs b/runtime/integration-tests/src/xcm_transfers.rs index 1d0492da..c6f14e7b 100644 --- a/runtime/integration-tests/src/xcm_transfers.rs +++ b/runtime/integration-tests/src/xcm_transfers.rs @@ -27,9 +27,7 @@ use crate::kusama_test_net::{ use crate::setup::{ksm_amount, mgx_amount, native_amount, PARA_ID_DEVELOPMENT, PARA_ID_SIBLING}; use common_runtime::Balance; use common_types::{CurrencyId, FundingType, TreasuryOrigin}; -use imbue_kusama_runtime::{ - OrmlTokens, Runtime as R, RuntimeOrigin, XTokens, -}; +use imbue_kusama_runtime::{OrmlTokens, Runtime as R, RuntimeOrigin, XTokens}; use orml_traits::MultiCurrency; use pallet_proposals::traits::RefundHandler;