runtime_eden/
pallets_governance.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 * This file is part of the Nodle Chain distributed at https://github.com/NodleCode/chain
 * Copyright (C) 2020-2022  Nodle International
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

use crate::RuntimeBlockWeights;
use crate::{constants, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, TechnicalCommittee};
use frame_support::pallet_prelude::Weight;
use frame_support::{parameter_types, traits::EitherOfDiverse, PalletId};
use frame_system::{EnsureNever, EnsureRoot};
use primitives::{AccountId, BlockNumber};
pub use sp_runtime::Perbill;

parameter_types! {
	pub const CompanyReservePalletId: PalletId = PalletId(*b"py/resrv"); // 5EYCAe5ijiYfha9GzQDgPVtUCYDY9B8ZgcyiANL2L34crMoR
}

impl pallet_reserve::Config<pallet_reserve::Instance1> for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type Currency = pallet_balances::Pallet<Runtime>;
	type ExternalOrigin = MoreThanHalfOfTechComm;
	type RuntimeCall = RuntimeCall;
	type PalletId = CompanyReservePalletId;
	type WeightInfo = crate::weights::pallet_reserve_company_reserve::WeightInfo<Runtime>;
}

parameter_types! {
	pub const InternationalReservePalletId: PalletId = PalletId(*b"py/rvint"); // 5EYCAe5ijiYfi6GQAEPSHYDwvw4CkyGtPTS52BjLh42GygSv
}

impl pallet_reserve::Config<pallet_reserve::Instance2> for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type Currency = pallet_balances::Pallet<Runtime>;
	type ExternalOrigin = MoreThanHalfOfTechComm;
	type RuntimeCall = RuntimeCall;
	type PalletId = InternationalReservePalletId;
	type WeightInfo = crate::weights::pallet_reserve_international_reserve::WeightInfo<Runtime>;
}

parameter_types! {
	pub const UsaReservePalletId: PalletId = PalletId(*b"py/rvusa"); // 5EYCAe5ijiYfi6MEfWpZC3nJ38KFZ9EQSFpsj9mgYgTtVNri
}

impl pallet_reserve::Config<pallet_reserve::Instance3> for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type Currency = pallet_balances::Pallet<Runtime>;
	type ExternalOrigin = MoreThanHalfOfTechComm;
	type RuntimeCall = RuntimeCall;
	type PalletId = UsaReservePalletId;
	type WeightInfo = crate::weights::pallet_reserve_usa_reserve::WeightInfo<Runtime>;
}

parameter_types! {
	pub const DaoReservePalletId: PalletId = PalletId(*b"py/nddao"); // 5EYCAe5ijiYfABcws2T5dgN35iWYaWwvh8wPgbZaBKRRpMzV
}

impl pallet_reserve::Config<pallet_reserve::Instance4> for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type Currency = pallet_balances::Pallet<Runtime>;
	// as of now nobody can spend this, later, we need to map this to the
	// correct governance origin.
	type ExternalOrigin = EnsureNever<AccountId>;
	type RuntimeCall = RuntimeCall;
	type PalletId = DaoReservePalletId;
	type WeightInfo = crate::weights::pallet_reserve_dao_reserve::WeightInfo<Runtime>;
}

parameter_types! {
	pub const MotionDuration: BlockNumber = 2 * constants::DAYS;
	pub const MaxProposals: u32 = 100;
	pub const MaxMembers: u32 = 50;
	pub MaxCollectivesProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;

}

pub type MoreThanHalfOfTechComm =
	pallet_collective::EnsureProportionMoreThan<AccountId, pallet_collective::Instance1, 1, 2>;
pub type EnsureRootOrMoreThanHalfOfTechComm = EitherOfDiverse<EnsureRoot<AccountId>, MoreThanHalfOfTechComm>;
impl pallet_collective::Config<pallet_collective::Instance1> for Runtime {
	type RuntimeOrigin = RuntimeOrigin;
	type Proposal = RuntimeCall;
	type RuntimeEvent = RuntimeEvent;
	type MotionDuration = MotionDuration;
	type MaxProposals = MaxProposals;
	type WeightInfo = crate::weights::pallet_collective::WeightInfo<Runtime>;
	type MaxMembers = MaxMembers;
	type DefaultVote = pallet_collective::PrimeDefaultVote;
	type SetMembersOrigin = EnsureRootOrMoreThanHalfOfTechComm;
	type MaxProposalWeight = MaxCollectivesProposalWeight;
}

impl pallet_membership::Config<pallet_membership::Instance3> for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type AddOrigin = MoreThanHalfOfTechComm;
	type RemoveOrigin = MoreThanHalfOfTechComm;
	type SwapOrigin = MoreThanHalfOfTechComm;
	type ResetOrigin = MoreThanHalfOfTechComm;
	type PrimeOrigin = MoreThanHalfOfTechComm;
	type MembershipInitialized = TechnicalCommittee;
	type MembershipChanged = TechnicalCommittee;
	type MaxMembers = MaxMembers;
	type WeightInfo = crate::weights::pallet_membership_technical_membership::WeightInfo<Runtime>;
}

impl pallet_mandate::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type RuntimeCall = RuntimeCall;
	type ExternalOrigin = MoreThanHalfOfTechComm;
}