Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require a minimum rank of 1 for communities to vote on the Root track #374

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pallets/communities-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub mod pallet {
maybe_track_info.unwrap_or_else(|| Self::default_tack(community_name)),
community_origin.into_caller(),
)?;
// Induct community at Kreivo Governance with rank 1
// Induct community at Kreivo Governance with rank 0
T::RankedCollective::induct(&community_account)?;

Self::deposit_event(Event::<T>::CommunityRegistered { id: community_id });
Expand Down
8 changes: 0 additions & 8 deletions runtime/kreivo/src/collective/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@ use super::*;

use frame_system::EnsureSigned;
use pallet_ranked_collective::{TallyOf, Votes};
use parachains_common::kusama::currency::QUID;
use sp_core::ConstU128;

pub type KreivoTracksInstance = pallet_referenda_tracks::Instance1;
pub type KreivoReferendaInstance = pallet_referenda::Instance1;

parameter_types! {
pub const AlarmInterval: BlockNumber = 1;
pub const SubmissionDeposit: Balance = QUID;
pub const UndecidingTimeout: BlockNumber = 14 * DAYS;
}

impl pallet_referenda::Config<KreivoReferendaInstance> for Runtime {
type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type Scheduler = Scheduler;
type Currency = Balances;
// Communities can submit proposals.
type SubmitOrigin = EnsureSigned<AccountId>;
type CancelOrigin = EnsureRoot<AccountId>;
type KillOrigin = EnsureRoot<AccountId>;
Expand Down
11 changes: 10 additions & 1 deletion runtime/kreivo/src/collective/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
use super::*;

use frame_system::EnsureRootWithSuccess;
use pallet_ranked_collective::Rank;
use sp_core::ConstU16;
use sp_runtime::traits::Convert;

pub mod governance;
pub mod tracks;

pub struct AtLeastRank<const R: Rank>;
impl<const R: Rank, T> Convert<T, Rank> for AtLeastRank<R> {
fn convert(_track: T) -> Rank {
R
}
}

pub type KreivoCollectiveInstance = pallet_ranked_collective::Instance1;
impl pallet_ranked_collective::Config<KreivoCollectiveInstance> for Runtime {
type WeightInfo = pallet_ranked_collective::weights::SubstrateWeight<Self>;
Expand All @@ -22,6 +31,6 @@ impl pallet_ranked_collective::Config<KreivoCollectiveInstance> for Runtime {
type DemoteOrigin = EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>;

type Polls = KreivoReferenda;
type MinRankOfClass = ();
type MinRankOfClass = AtLeastRank<1>;
type VoteWeight = pallet_ranked_collective::Linear;
}