Skip to content

Commit c53f8c5

Browse files
authored
Vote locks for all reasons except RESERVE (#13914)
* Vote locks tip * except reserve * reason for delegate * fix tests --------- Co-authored-by: parity-processbot <>
1 parent 168a9ae commit c53f8c5

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/lib.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,12 @@ impl<T: Config> Pallet<T> {
13081308
})?;
13091309
// Extend the lock to `balance` (rather than setting it) since we don't know what other
13101310
// votes are in place.
1311-
T::Currency::extend_lock(DEMOCRACY_ID, who, vote.balance(), WithdrawReasons::TRANSFER);
1311+
T::Currency::extend_lock(
1312+
DEMOCRACY_ID,
1313+
who,
1314+
vote.balance(),
1315+
WithdrawReasons::except(WithdrawReasons::RESERVE),
1316+
);
13121317
ReferendumInfoOf::<T>::insert(ref_index, ReferendumInfo::Ongoing(status));
13131318
Ok(())
13141319
}
@@ -1454,7 +1459,12 @@ impl<T: Config> Pallet<T> {
14541459
let votes = Self::increase_upstream_delegation(&target, conviction.votes(balance));
14551460
// Extend the lock to `balance` (rather than setting it) since we don't know what other
14561461
// votes are in place.
1457-
T::Currency::extend_lock(DEMOCRACY_ID, &who, balance, WithdrawReasons::TRANSFER);
1462+
T::Currency::extend_lock(
1463+
DEMOCRACY_ID,
1464+
&who,
1465+
balance,
1466+
WithdrawReasons::except(WithdrawReasons::RESERVE),
1467+
);
14581468
Ok(votes)
14591469
})?;
14601470
Self::deposit_event(Event::<T>::Delegated { who, target });
@@ -1499,7 +1509,12 @@ impl<T: Config> Pallet<T> {
14991509
if lock_needed.is_zero() {
15001510
T::Currency::remove_lock(DEMOCRACY_ID, who);
15011511
} else {
1502-
T::Currency::set_lock(DEMOCRACY_ID, who, lock_needed, WithdrawReasons::TRANSFER);
1512+
T::Currency::set_lock(
1513+
DEMOCRACY_ID,
1514+
who,
1515+
lock_needed,
1516+
WithdrawReasons::except(WithdrawReasons::RESERVE),
1517+
);
15031518
}
15041519
}
15051520

src/tests/lock_voting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn nay(x: u8, balance: u64) -> AccountVote<u64> {
3434
}
3535

3636
fn the_lock(amount: u64) -> BalanceLock<u64> {
37-
BalanceLock { id: DEMOCRACY_ID, amount, reasons: pallet_balances::Reasons::Misc }
37+
BalanceLock { id: DEMOCRACY_ID, amount, reasons: pallet_balances::Reasons::All }
3838
}
3939

4040
#[test]

0 commit comments

Comments
 (0)