moonbase_runtime/governance/
referenda.rs

1// Copyright 2019-2025 PureStake Inc.
2// This file is part of Moonbeam.
3
4// Moonbeam is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Moonbeam is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Moonbeam.  If not, see <http://www.gnu.org/licenses/>.
16
17//! # Gov2 config
18//! Includes runtime configs for these substrate pallets:
19//! 1. pallet-conviction-voting
20//! 2. pallet-whitelist
21//! 3. pallet-referenda
22
23use super::moonbase_weights;
24use super::*;
25use crate::currency::*;
26use frame_support::traits::{EitherOf, MapSuccess};
27use frame_system::EnsureRootWithSuccess;
28use sp_runtime::traits::Replace;
29
30parameter_types! {
31	pub const VoteLockingPeriod: BlockNumber = 1 * DAYS;
32}
33
34impl pallet_conviction_voting::Config for Runtime {
35	type WeightInfo = moonbase_weights::pallet_conviction_voting::WeightInfo<Runtime>;
36	type RuntimeEvent = RuntimeEvent;
37	type Currency = Balances;
38	type Polls = Referenda;
39	type MaxTurnout = frame_support::traits::TotalIssuanceOf<Balances, Self::AccountId>;
40	// Maximum number of concurrent votes an account may have
41	type MaxVotes = ConstU32<20>;
42	// Minimum period of vote locking
43	type VoteLockingPeriod = VoteLockingPeriod;
44	type BlockNumberProvider = System;
45	type VotingHooks = ();
46}
47
48parameter_types! {
49	pub const AlarmInterval: BlockNumber = 1;
50	pub const SubmissionDeposit: Balance = 10 * UNIT * SUPPLY_FACTOR;
51	pub const UndecidingTimeout: BlockNumber = 21 * DAYS;
52}
53
54pub type GeneralAdminOrRoot = EitherOf<EnsureRoot<AccountId>, origins::GeneralAdmin>;
55
56/// The policy allows for Root, GeneralAdmin or FastGeneralAdmin.
57pub type FastGeneralAdminOrRoot =
58	EitherOf<EnsureRoot<AccountId>, EitherOf<origins::GeneralAdmin, origins::FastGeneralAdmin>>;
59
60impl custom_origins::Config for Runtime {}
61
62// The purpose of this pallet is to queue calls to be dispatched as by root later => the Dispatch
63// origin corresponds to the Gov2 Whitelist track.
64impl pallet_whitelist::Config for Runtime {
65	type WeightInfo = moonbase_weights::pallet_whitelist::WeightInfo<Runtime>;
66	type RuntimeEvent = RuntimeEvent;
67	type RuntimeCall = RuntimeCall;
68	type WhitelistOrigin = EitherOf<
69		EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
70		MapSuccess<
71			pallet_collective::EnsureProportionAtLeast<
72				Self::AccountId,
73				OpenTechCommitteeInstance,
74				5,
75				9,
76			>,
77			Replace<ConstU16<6>>,
78		>,
79	>;
80	type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<Self::AccountId>, WhitelistedCaller>;
81	type Preimages = Preimage;
82}
83
84impl pallet_referenda::Config for Runtime {
85	type WeightInfo = moonbase_weights::pallet_referenda::WeightInfo<Runtime>;
86	type RuntimeCall = RuntimeCall;
87	type RuntimeEvent = RuntimeEvent;
88	type Scheduler = Scheduler;
89	type Currency = Balances;
90	type SubmitOrigin = frame_system::EnsureSigned<AccountId>;
91	type CancelOrigin = EitherOf<EnsureRoot<Self::AccountId>, ReferendumCanceller>;
92	type KillOrigin = EitherOf<EnsureRoot<Self::AccountId>, ReferendumKiller>;
93	type Slash = Treasury;
94	type Votes = pallet_conviction_voting::VotesOf<Runtime>;
95	type Tally = pallet_conviction_voting::TallyOf<Runtime>;
96	type SubmissionDeposit = SubmissionDeposit;
97	type MaxQueued = ConstU32<100>;
98	type UndecidingTimeout = UndecidingTimeout;
99	type AlarmInterval = AlarmInterval;
100	type Tracks = TracksInfo;
101	type Preimages = Preimage;
102	type BlockNumberProvider = System;
103}