moonriver_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::*;
24use crate::currency::*;
25use frame_support::traits::{EitherOf, MapSuccess};
26use frame_system::EnsureRootWithSuccess;
27use sp_runtime::traits::Replace;
28
29parameter_types! {
30	pub const VoteLockingPeriod: BlockNumber = 1 * DAYS;
31}
32
33impl pallet_conviction_voting::Config for Runtime {
34	type WeightInfo = moonriver_weights::pallet_conviction_voting::WeightInfo<Runtime>;
35	type RuntimeEvent = RuntimeEvent;
36	type Currency = Balances;
37	type Polls = Referenda;
38	type MaxTurnout = frame_support::traits::TotalIssuanceOf<Balances, Self::AccountId>;
39	// Maximum number of concurrent votes an account may have
40	type MaxVotes = ConstU32<20>;
41	// Minimum period of vote locking
42	type VoteLockingPeriod = VoteLockingPeriod;
43	type BlockNumberProvider = System;
44	type VotingHooks = ();
45}
46
47parameter_types! {
48	pub const AlarmInterval: BlockNumber = 1;
49	pub const SubmissionDeposit: Balance = 10 * MOVR * SUPPLY_FACTOR;
50	pub const UndecidingTimeout: BlockNumber = 21 * DAYS;
51}
52
53// Origin for general admin or root
54pub type GeneralAdminOrRoot = EitherOf<EnsureRoot<AccountId>, origins::GeneralAdmin>;
55/// The policy allows for Root, GeneralAdmin or FastGeneralAdmin.
56pub type FastGeneralAdminOrRoot =
57	EitherOf<EnsureRoot<AccountId>, EitherOf<origins::GeneralAdmin, origins::FastGeneralAdmin>>;
58
59impl custom_origins::Config for Runtime {}
60
61// The purpose of this pallet is to queue calls to be dispatched as by root later => the Dispatch
62// origin corresponds to the Gov2 Whitelist track.
63impl pallet_whitelist::Config for Runtime {
64	type WeightInfo = moonriver_weights::pallet_whitelist::WeightInfo<Runtime>;
65	type RuntimeEvent = RuntimeEvent;
66	type RuntimeCall = RuntimeCall;
67	type WhitelistOrigin = EitherOf<
68		EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
69		MapSuccess<
70			pallet_collective::EnsureProportionAtLeast<
71				Self::AccountId,
72				OpenTechCommitteeInstance,
73				5,
74				9,
75			>,
76			Replace<ConstU16<6>>,
77		>,
78	>;
79	type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<Self::AccountId>, WhitelistedCaller>;
80	type Preimages = Preimage;
81}
82
83impl pallet_referenda::Config for Runtime {
84	type WeightInfo = moonriver_weights::pallet_referenda::WeightInfo<Runtime>;
85	type RuntimeCall = RuntimeCall;
86	type RuntimeEvent = RuntimeEvent;
87	type Scheduler = Scheduler;
88	type Currency = Balances;
89	type SubmitOrigin = frame_system::EnsureSigned<AccountId>;
90	type CancelOrigin = EitherOf<EnsureRoot<Self::AccountId>, ReferendumCanceller>;
91	type KillOrigin = EitherOf<EnsureRoot<Self::AccountId>, ReferendumKiller>;
92	type Slash = Treasury;
93	type Votes = pallet_conviction_voting::VotesOf<Runtime>;
94	type Tally = pallet_conviction_voting::TallyOf<Runtime>;
95	type SubmissionDeposit = SubmissionDeposit;
96	type MaxQueued = ConstU32<100>;
97	type UndecidingTimeout = UndecidingTimeout;
98	type AlarmInterval = AlarmInterval;
99	type Tracks = TracksInfo;
100	type Preimages = Preimage;
101	type BlockNumberProvider = System;
102}