Skip to content

Commit 445f8f6

Browse files
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 <[email protected]>
1 parent 834393a commit 445f8f6

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

node/src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub enum Subcommand {
3737
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
3838

3939
/// Try-runtime has migrated to a standalone
40-
/// [CLI](<https://github.com/paritytech/try-runtime-cli>). The subcommand exists as a stub and
41-
/// deprecation notice. It will be removed entirely some time after Janurary 2024.
40+
/// [CLI](<https://github.com/paritytech/try-runtime-cli>). The subcommand exists as a stub and
41+
/// deprecation notice. It will be removed entirely some time after Janurary 2024.
4242
TryRuntime,
4343
}
4444

pallets/fellowship/src/impls.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use crate::*;
33
use common_traits::MaybeConvert;
44
use frame_support::{ensure, traits::Get};
55
use orml_traits::MultiReservableCurrency;
6-
use sp_runtime::{
7-
traits::BadOrigin,
8-
DispatchError,
9-
};
6+
use sp_runtime::{traits::BadOrigin, DispatchError};
107
use sp_std::{vec, vec::Vec};
118
/// Ensure that a account is of a given role.
129
/// Used in other pallets like an ensure origin.

pallets/fellowship/src/tests/ensure_role.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ fn ensure_role_in_works() {
2727
});
2828
}
2929

30-
3130
#[test]
3231
fn ensure_role_in_works_with_rank() {
3332
new_test_ext().execute_with(|| {

pallets/fellowship/src/tests/test_utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use super::*;
22

3-
43
// Saves a bit of typing.
54
pub(crate) fn add_to_fellowship_take_deposit(
65
who: &AccountIdOf<Test>,

pallets/proposals/src/impls/pallet_impls.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ impl<T: Config> Pallet<T> {
9292
Ok::<(), DispatchError>(())
9393
})?;
9494

95+
let funding_threshold: BalanceOf<T> =
96+
T::PercentRequiredForVoteToPass::get().mul_floor(project.raised_funds);
97+
9598
let vote: Vote<BalanceOf<T>> =
9699
MilestoneVotes::<T>::try_mutate(project_key, |vote_btree| {
97100
if let Some(vote) = vote_btree.get_mut(&milestone_key) {
@@ -100,15 +103,19 @@ impl<T: Config> Pallet<T> {
100103
} else {
101104
vote.nay = vote.nay.saturating_add(contribution_amount);
102105
}
106+
107+
//check if the everyone has voted and its still less than the
108+
// funding threshold just reject it
109+
if vote.yay + vote.nay == project.raised_funds && vote.yay < funding_threshold {
110+
Self::close_voting_round(project_key, user_has_voted_key)?;
111+
Self::deposit_event(Event::MilestoneRejected(project_key, milestone_key));
112+
}
103113
Ok::<Vote<BalanceOf<T>>, DispatchError>(vote.clone())
104114
} else {
105115
Err(Error::<T>::VotingRoundNotStarted.into())
106116
}
107117
})?;
108118

109-
let funding_threshold: BalanceOf<T> =
110-
T::PercentRequiredForVoteToPass::get().mul_floor(project.raised_funds);
111-
112119
Self::try_auto_finalise_milestone_voting(
113120
project_key,
114121
&vote,

runtime/integration-tests/src/xcm_transfers.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ use crate::kusama_test_net::{
2727
use crate::setup::{ksm_amount, mgx_amount, native_amount, PARA_ID_DEVELOPMENT, PARA_ID_SIBLING};
2828
use common_runtime::Balance;
2929
use common_types::{CurrencyId, FundingType, TreasuryOrigin};
30-
use imbue_kusama_runtime::{
31-
OrmlTokens, Runtime as R, RuntimeOrigin, XTokens,
32-
};
30+
use imbue_kusama_runtime::{OrmlTokens, Runtime as R, RuntimeOrigin, XTokens};
3331
use orml_traits::MultiCurrency;
3432
use pallet_proposals::traits::RefundHandler;
3533

0 commit comments

Comments
 (0)