collectives_westend_runtime/secretary/
mod.rs1use crate::{xcm_config::FellowshipAdminBodyId, *};
22use frame_support::{
23 parameter_types,
24 traits::{tokens::GetSalary, EitherOf, MapSuccess, NoOpPoll, PalletInfoAccess},
25};
26use frame_system::{pallet_prelude::BlockNumberFor, EnsureRootWithSuccess};
27use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
28use sp_core::{ConstU128, ConstU32};
29use sp_runtime::traits::{ConstU16, ConvertToValue, Identity, Replace};
30use westend_runtime_constants::time::HOURS;
31
32#[cfg(feature = "runtime-benchmarks")]
33use crate::impls::benchmarks::OpenHrmpChannel;
34
35use xcm::prelude::*;
36use xcm_builder::{AliasesIntoAccountId32, PayOverXcm};
37
38use self::xcm_config::UsdtAssetHub;
39
40pub mod ranks {
42 use pallet_ranked_collective::Rank;
43
44 pub const SECRETARY_CANDIDATE: Rank = 0;
45 pub const SECRETARY: Rank = 1;
46}
47
48type ApproveOrigin = EitherOf<
54 EnsureRootWithSuccess<AccountId, ConstU16<65535>>,
55 EitherOf<
56 MapSuccess<
57 EnsureXcm<IsVoiceOfBody<GovernanceLocation, FellowshipAdminBodyId>>,
58 Replace<ConstU16<65535>>,
59 >,
60 MapSuccess<Fellows, Replace<ConstU16<65535>>>,
61 >,
62>;
63
64pub type SecretaryCollectiveInstance = pallet_ranked_collective::Instance3;
65
66impl pallet_ranked_collective::Config<SecretaryCollectiveInstance> for Runtime {
67 type WeightInfo = ();
68 type RuntimeEvent = RuntimeEvent;
69 type AddOrigin = ApproveOrigin;
70 type RemoveOrigin = ApproveOrigin;
71 type PromoteOrigin = ApproveOrigin;
72 type DemoteOrigin = ApproveOrigin;
73 type ExchangeOrigin = ApproveOrigin;
74 type Polls = NoOpPoll<BlockNumberFor<Runtime>>;
75 type MinRankOfClass = Identity;
76 type MemberSwappedHandler = crate::SecretarySalary;
77 type VoteWeight = pallet_ranked_collective::Geometric;
78 type MaxMemberCount = ();
79 #[cfg(feature = "runtime-benchmarks")]
80 type BenchmarkSetup = crate::SecretarySalary;
81}
82
83pub type SecretarySalaryInstance = pallet_salary::Instance3;
84
85parameter_types! {
86 pub SecretarySalaryInteriorLocation: InteriorLocation = PalletInstance(<crate::SecretarySalary as PalletInfoAccess>::index() as u8).into();
89}
90
91const USDT_UNITS: u128 = 1_000_000;
92
93pub type SecretarySalaryPaymaster = PayOverXcm<
95 SecretarySalaryInteriorLocation,
96 crate::xcm_config::XcmRouter,
97 crate::PolkadotXcm,
98 ConstU32<{ 6 * HOURS }>,
99 AccountId,
100 (),
101 ConvertToValue<UsdtAssetHub>,
102 AliasesIntoAccountId32<(), AccountId>,
103>;
104
105pub struct SalaryForRank;
106impl GetSalary<u16, AccountId, Balance> for SalaryForRank {
107 fn get_salary(rank: u16, _who: &AccountId) -> Balance {
108 if rank == 1 {
109 6666 * USDT_UNITS
110 } else {
111 0
112 }
113 }
114}
115
116impl pallet_salary::Config<SecretarySalaryInstance> for Runtime {
117 type WeightInfo = ();
118 type RuntimeEvent = RuntimeEvent;
119
120 #[cfg(not(feature = "runtime-benchmarks"))]
121 type Paymaster = SecretarySalaryPaymaster;
122 #[cfg(feature = "runtime-benchmarks")]
123 type Paymaster = crate::impls::benchmarks::PayWithEnsure<
124 SecretarySalaryPaymaster,
125 OpenHrmpChannel<ConstU32<1000>>,
126 >;
127 type Members = pallet_ranked_collective::Pallet<Runtime, SecretaryCollectiveInstance>;
128
129 #[cfg(not(feature = "runtime-benchmarks"))]
130 type Salary = SalaryForRank;
131 #[cfg(feature = "runtime-benchmarks")]
132 type Salary = frame_support::traits::tokens::ConvertRank<
133 crate::impls::benchmarks::RankToSalary<Balances>,
134 >;
135 type RegistrationPeriod = ConstU32<{ 15 * DAYS }>;
137 type PayoutPeriod = ConstU32<{ 15 * DAYS }>;
139 type Budget = ConstU128<{ 6666 * USDT_UNITS }>;
141}