Skip to content

Commit

Permalink
close the voting round if the total votes are done (#269)
Browse files Browse the repository at this point in the history
* close the voting round if the total votes are done

* cargo fmt

---------

Co-authored-by: samelamin <[email protected]>
  • Loading branch information
mshankarrao and samelamin authored Nov 13, 2023
1 parent 834393a commit 445f8f6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ pub enum Subcommand {
Benchmark(frame_benchmarking_cli::BenchmarkCmd),

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

Expand Down
5 changes: 1 addition & 4 deletions pallets/fellowship/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion pallets/fellowship/src/tests/ensure_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ fn ensure_role_in_works() {
});
}


#[test]
fn ensure_role_in_works_with_rank() {
new_test_ext().execute_with(|| {
Expand Down
1 change: 0 additions & 1 deletion pallets/fellowship/src/tests/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::*;


// Saves a bit of typing.
pub(crate) fn add_to_fellowship_take_deposit(
who: &AccountIdOf<Test>,
Expand Down
13 changes: 10 additions & 3 deletions pallets/proposals/src/impls/pallet_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ impl<T: Config> Pallet<T> {
Ok::<(), DispatchError>(())
})?;

let funding_threshold: BalanceOf<T> =
T::PercentRequiredForVoteToPass::get().mul_floor(project.raised_funds);

let vote: Vote<BalanceOf<T>> =
MilestoneVotes::<T>::try_mutate(project_key, |vote_btree| {
if let Some(vote) = vote_btree.get_mut(&milestone_key) {
Expand All @@ -100,15 +103,19 @@ impl<T: Config> Pallet<T> {
} 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 {

This comment has been minimized.

Copy link
@f-gate

f-gate Nov 20, 2023

Member

This is an unsafe operation, use saturating_add please

Self::close_voting_round(project_key, user_has_voted_key)?;
Self::deposit_event(Event::MilestoneRejected(project_key, milestone_key));
}
Ok::<Vote<BalanceOf<T>>, DispatchError>(vote.clone())
} else {
Err(Error::<T>::VotingRoundNotStarted.into())
}
})?;

let funding_threshold: BalanceOf<T> =
T::PercentRequiredForVoteToPass::get().mul_floor(project.raised_funds);

Self::try_auto_finalise_milestone_voting(
project_key,
&vote,
Expand Down
4 changes: 1 addition & 3 deletions runtime/integration-tests/src/xcm_transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 445f8f6

Please sign in to comment.