Browse Source

council - vote stake unlock conditioning move

ondratra 4 years ago
parent
commit
40c7d79110
2 changed files with 7 additions and 12 deletions
  1. 7 0
      runtime-modules/council/src/lib.rs
  2. 0 12
      runtime-modules/referendum/src/lib.rs

+ 7 - 0
runtime-modules/council/src/lib.rs

@@ -761,6 +761,13 @@ impl<T: Trait> ReferendumConnection<T> for Module<T> {
             return Ok(());
         }
 
+        // allow release for current cycle only in idle stage
+        if current_voting_cycle_id == vote.cycle_id
+            && !matches!(Stage::<T>::get().stage, CouncilStage::Idle)
+        {
+            return Err(Error::CantReleaseStakeNow);
+        }
+
         let voting_for_winner = CouncilMembers::<T>::get()
             .iter()
             .map(|council_member| council_member.membership_id)

+ 0 - 12
runtime-modules/referendum/src/lib.rs

@@ -833,18 +833,6 @@ impl<T: Trait<I>, I: Instance> EnsureChecks<T, I> {
 
         let cast_vote = Self::ensure_vote_exists(&account_id)?;
 
-        // get current cycle id
-        let current_cycle_id = match Stage::<T, I>::get() {
-            ReferendumStage::Voting(stage_data) => Some(stage_data.current_cycle_id),
-            ReferendumStage::Revealing(stage_data) => Some(stage_data.current_cycle_id),
-            _ => None,
-        };
-
-        // allow release only for past cycles
-        if current_cycle_id == Some(cast_vote.cycle_id) {
-            return Err(Error::UnstakingVoteInSameCycle);
-        }
-
         // ask runtime if stake can be released
         if !T::can_unlock_vote_stake(&cast_vote) {
             return Err(Error::UnstakingForbidden);