Skip to content
Snippets Groups Projects
Commit 6476f268 authored by Gav's avatar Gav
Browse files

Introduce minimum deposit

parent e8d38add
No related merge requests found
......@@ -74,6 +74,7 @@ const PUBLIC_PROP_COUNT: &[u8] = b"dem:cou"; // PropIndex
const PUBLIC_PROPS: &[u8] = b"dem:pub"; // Vec<(PropIndex, Proposal)>
const DEPOSIT_OF: &[u8] = b"dem:dep:"; // PropIndex -> (Balance, Vec<AccountId>)
const LAUNCH_PERIOD: &[u8] = b"dem:lau"; // BlockNumber
const MINIMUM_DEPOSIT: &[u8] = b"dem:min"; // Balance
// referenda
const VOTING_PERIOD: &[u8] = b"dem:per"; // BlockNumber
......@@ -83,6 +84,12 @@ const REFERENDUM_INFO_OF: &[u8] = b"dem:pro:"; // ReferendumIndex -> (BlockNumbe
const VOTERS_FOR: &[u8] = b"dem:vtr:"; // ReferendumIndex -> Vec<AccountId>
const VOTE_OF: &[u8] = b"dem:vot:"; // (ReferendumIndex, AccountId) -> bool
/// The minimum amount to be used as a deposit for a public referendum proposal.
pub fn minimum_deposit() -> Balance {
storage::get(MINIMUM_DEPOSIT)
.expect("all core parameters of council module must be in place")
}
/// How often (in blocks) to check for new votes.
pub fn voting_period() -> BlockNumber {
storage::get(VOTING_PERIOD)
......@@ -159,6 +166,7 @@ pub mod public {
/// Propose a sensitive action to be taken.
pub fn propose(signed: &AccountId, proposal: &Proposal, value: Balance) {
assert!(value >= minimum_deposit());
let b = staking::balance(signed);
assert!(b >= value);
......@@ -321,7 +329,8 @@ mod tests {
twox_128(b"sta:vac").to_vec() => vec![].and(&3u64),
twox_128(b"sta:era").to_vec() => vec![].and(&1u64),
twox_128(LAUNCH_PERIOD).to_vec() => vec![].and(&1u64),
twox_128(VOTING_PERIOD).to_vec() => vec![].and(&1u64)
twox_128(VOTING_PERIOD).to_vec() => vec![].and(&1u64),
twox_128(MINIMUM_DEPOSIT).to_vec() => vec![].and(&1u64)
]
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment