mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Fellowship: Voters can initiate proposals on their votable tracks (#2725)
* Voters can initiate proposals on their tracks in Fellowship * Bump * Remove it_builds * Docs
This commit is contained in:
+24
-13
@@ -19,28 +19,28 @@
|
|||||||
pub(crate) mod migration;
|
pub(crate) mod migration;
|
||||||
mod origins;
|
mod origins;
|
||||||
mod tracks;
|
mod tracks;
|
||||||
use cumulus_primitives_core::Junction::GeneralIndex;
|
|
||||||
use frame_system::EnsureNever;
|
|
||||||
pub use origins::{
|
|
||||||
pallet_origins as pallet_fellowship_origins, Architects, EnsureCanPromoteTo, EnsureCanRetainAt,
|
|
||||||
EnsureFellowship, Fellows, Masters, Members,
|
|
||||||
};
|
|
||||||
use xcm_builder::{AliasesIntoAccountId32, LocatableAssetId, PayOverXcm};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
constants, impls::ToParentTreasury, weights, AccountId, Balance, Balances, FellowshipReferenda,
|
constants, impls::ToParentTreasury, weights, AccountId, Balance, Balances, FellowshipReferenda,
|
||||||
GovernanceLocation, PolkadotTreasuryAccount, Preimage, Runtime, RuntimeCall, RuntimeEvent,
|
GovernanceLocation, PolkadotTreasuryAccount, Preimage, Runtime, RuntimeCall, RuntimeEvent,
|
||||||
Scheduler, DAYS,
|
RuntimeOrigin, Scheduler, DAYS,
|
||||||
};
|
};
|
||||||
|
use cumulus_primitives_core::Junction::GeneralIndex;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
parameter_types,
|
parameter_types,
|
||||||
traits::{EitherOf, EitherOfDiverse, MapSuccess},
|
traits::{EitherOf, EitherOfDiverse, MapSuccess, OriginTrait, TryWithMorphedArg},
|
||||||
};
|
};
|
||||||
|
use frame_system::EnsureNever;
|
||||||
|
pub use origins::{
|
||||||
|
pallet_origins as pallet_fellowship_origins, Architects, EnsureCanPromoteTo, EnsureCanRetainAt,
|
||||||
|
EnsureFellowship, Fellows, Masters, Members, ToVoice,
|
||||||
|
};
|
||||||
|
use pallet_ranked_collective::EnsureOfRank;
|
||||||
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
|
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
|
||||||
use polkadot_runtime_constants::{time::HOURS, xcm::body::FELLOWSHIP_ADMIN_INDEX};
|
use polkadot_runtime_constants::{time::HOURS, xcm::body::FELLOWSHIP_ADMIN_INDEX};
|
||||||
use sp_core::{ConstU128, ConstU32};
|
use sp_core::{ConstU128, ConstU32};
|
||||||
use sp_runtime::traits::{AccountIdConversion, ConstU16, ConvertToValue, Replace};
|
use sp_runtime::traits::{AccountIdConversion, ConstU16, ConvertToValue, Replace, TakeFirst};
|
||||||
use xcm::latest::BodyId;
|
use xcm::latest::BodyId;
|
||||||
|
use xcm_builder::{AliasesIntoAccountId32, LocatableAssetId, PayOverXcm};
|
||||||
|
|
||||||
/// The Fellowship members' ranks.
|
/// The Fellowship members' ranks.
|
||||||
pub mod ranks {
|
pub mod ranks {
|
||||||
@@ -74,8 +74,19 @@ impl pallet_referenda::Config<FellowshipReferendaInstance> for Runtime {
|
|||||||
type Scheduler = Scheduler;
|
type Scheduler = Scheduler;
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
// Fellows can submit proposals.
|
// Fellows can submit proposals.
|
||||||
type SubmitOrigin =
|
type SubmitOrigin = EitherOf<
|
||||||
pallet_ranked_collective::EnsureMember<Runtime, FellowshipCollectiveInstance, 3>;
|
pallet_ranked_collective::EnsureMember<Runtime, FellowshipCollectiveInstance, 3>,
|
||||||
|
MapSuccess<
|
||||||
|
TryWithMorphedArg<
|
||||||
|
RuntimeOrigin,
|
||||||
|
<RuntimeOrigin as OriginTrait>::PalletsOrigin,
|
||||||
|
ToVoice,
|
||||||
|
EnsureOfRank<Runtime, FellowshipCollectiveInstance>,
|
||||||
|
(AccountId, u16),
|
||||||
|
>,
|
||||||
|
TakeFirst,
|
||||||
|
>,
|
||||||
|
>;
|
||||||
type CancelOrigin = Architects;
|
type CancelOrigin = Architects;
|
||||||
type KillOrigin = Masters;
|
type KillOrigin = Masters;
|
||||||
type Slash = ToParentTreasury<PolkadotTreasuryAccount, ReferendaPalletAccount, Runtime>;
|
type Slash = ToParentTreasury<PolkadotTreasuryAccount, ReferendaPalletAccount, Runtime>;
|
||||||
|
|||||||
+41
@@ -35,22 +35,31 @@ pub mod pallet_origins {
|
|||||||
#[pallet::origin]
|
#[pallet::origin]
|
||||||
pub enum Origin {
|
pub enum Origin {
|
||||||
/// Origin aggregated through weighted votes of those with rank 1 or above; `Success` is 1.
|
/// Origin aggregated through weighted votes of those with rank 1 or above; `Success` is 1.
|
||||||
|
/// Aka the "voice" of all Members.
|
||||||
Members,
|
Members,
|
||||||
/// Origin aggregated through weighted votes of those with rank 2 or above; `Success` is 2.
|
/// Origin aggregated through weighted votes of those with rank 2 or above; `Success` is 2.
|
||||||
|
/// Aka the "voice" of members at least II Dan.
|
||||||
Fellowship2Dan,
|
Fellowship2Dan,
|
||||||
/// Origin aggregated through weighted votes of those with rank 3 or above; `Success` is 3.
|
/// Origin aggregated through weighted votes of those with rank 3 or above; `Success` is 3.
|
||||||
|
/// Aka the "voice" of all Fellows.
|
||||||
Fellows,
|
Fellows,
|
||||||
/// Origin aggregated through weighted votes of those with rank 4 or above; `Success` is 4.
|
/// Origin aggregated through weighted votes of those with rank 4 or above; `Success` is 4.
|
||||||
|
/// Aka the "voice" of members at least IV Dan.
|
||||||
Architects,
|
Architects,
|
||||||
/// Origin aggregated through weighted votes of those with rank 5 or above; `Success` is 5.
|
/// Origin aggregated through weighted votes of those with rank 5 or above; `Success` is 5.
|
||||||
|
/// Aka the "voice" of members at least V Dan.
|
||||||
Fellowship5Dan,
|
Fellowship5Dan,
|
||||||
/// Origin aggregated through weighted votes of those with rank 6 or above; `Success` is 6.
|
/// Origin aggregated through weighted votes of those with rank 6 or above; `Success` is 6.
|
||||||
|
/// Aka the "voice" of members at least VI Dan.
|
||||||
Fellowship6Dan,
|
Fellowship6Dan,
|
||||||
/// Origin aggregated through weighted votes of those with rank 7 or above; `Success` is 7.
|
/// Origin aggregated through weighted votes of those with rank 7 or above; `Success` is 7.
|
||||||
|
/// Aka the "voice" of all Masters.
|
||||||
Masters,
|
Masters,
|
||||||
/// Origin aggregated through weighted votes of those with rank 8 or above; `Success` is 8.
|
/// Origin aggregated through weighted votes of those with rank 8 or above; `Success` is 8.
|
||||||
|
/// Aka the "voice" of members at least VIII Dan.
|
||||||
Fellowship8Dan,
|
Fellowship8Dan,
|
||||||
/// Origin aggregated through weighted votes of those with rank 9 or above; `Success` is 9.
|
/// Origin aggregated through weighted votes of those with rank 9 or above; `Success` is 9.
|
||||||
|
/// Aka the "voice" of members at least IX Dan.
|
||||||
Fellowship9Dan,
|
Fellowship9Dan,
|
||||||
|
|
||||||
/// Origin aggregated through weighted votes of those with rank 3 or above when voting on
|
/// Origin aggregated through weighted votes of those with rank 3 or above when voting on
|
||||||
@@ -92,6 +101,38 @@ pub mod pallet_origins {
|
|||||||
PromoteTo6Dan,
|
PromoteTo6Dan,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Origin {
|
||||||
|
/// Returns the rank that the origin `self` speaks for, or `None` if it doesn't speak for
|
||||||
|
/// any.
|
||||||
|
///
|
||||||
|
/// `Some` will be returned only for the first 9 elements of [Origin].
|
||||||
|
pub fn as_voice(&self) -> Option<pallet_ranked_collective::Rank> {
|
||||||
|
Some(match &self {
|
||||||
|
Origin::Members => ranks::DAN_1,
|
||||||
|
Origin::Fellowship2Dan => ranks::DAN_2,
|
||||||
|
Origin::Fellows => ranks::DAN_3,
|
||||||
|
Origin::Architects => ranks::DAN_4,
|
||||||
|
Origin::Fellowship5Dan => ranks::DAN_5,
|
||||||
|
Origin::Fellowship6Dan => ranks::DAN_6,
|
||||||
|
Origin::Masters => ranks::DAN_7,
|
||||||
|
Origin::Fellowship8Dan => ranks::DAN_8,
|
||||||
|
Origin::Fellowship9Dan => ranks::DAN_9,
|
||||||
|
_ => return None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A `TryMorph` implementation which is designed to convert an aggregate `RuntimeOrigin`
|
||||||
|
/// value into the Fellowship voice it represents if it is a Fellowship pallet origin an
|
||||||
|
/// appropriate variant. See also [Origin::as_voice].
|
||||||
|
pub struct ToVoice;
|
||||||
|
impl<'a, O: 'a + TryInto<&'a Origin>> sp_runtime::traits::TryMorph<O> for ToVoice {
|
||||||
|
type Outcome = pallet_ranked_collective::Rank;
|
||||||
|
fn try_morph(o: O) -> Result<pallet_ranked_collective::Rank, ()> {
|
||||||
|
o.try_into().ok().and_then(Origin::as_voice).ok_or(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! decl_unit_ensures {
|
macro_rules! decl_unit_ensures {
|
||||||
( $name:ident: $success_type:ty = $success:expr ) => {
|
( $name:ident: $success_type:ty = $success:expr ) => {
|
||||||
pub struct $name;
|
pub struct $name;
|
||||||
|
|||||||
Reference in New Issue
Block a user