mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Ranked collective Add+Remove origins (#3212)
Superseeds https://github.com/paritytech/polkadot-sdk/pull/1245 This PR is a migration of the https://github.com/paritytech/substrate/pull/14577. The PR added associated types (`AddOrigin` & `RemoveOrigin`) to `Config`. It allows you to decouple types and areas of responsibility, since at the moment the same types are responsible for adding and promoting(removing and demoting). This will improve the flexibility of the pallet configuration. ``` /// The origin required to add a member. type AddOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = ()>; /// The origin required to remove a member. The success value indicates the /// maximum rank *from which* the removal may be. type RemoveOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Rank>; ``` To achieve the backward compatibility, the users of the pallet can use the old type via the new morph: ``` type AddOrigin = MapSuccess<Self::PromoteOrigin, Ignore>; type RemoveOrigin = Self::DemoteOrigin; ``` --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: PraetorP <praetorian281@gmail.com> Co-authored-by: Pavel Orlov <45266194+PraetorP@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7df1ae3b81
commit
c552fb5495
@@ -40,7 +40,7 @@ use origins::pallet_origins::{
|
||||
EnsureAmbassadorsVoice, EnsureAmbassadorsVoiceFrom, EnsureHeadAmbassadorsVoice, Origin,
|
||||
};
|
||||
use sp_core::ConstU128;
|
||||
use sp_runtime::traits::{CheckedReduceBy, ConstU16, ConvertToValue, Replace};
|
||||
use sp_runtime::traits::{CheckedReduceBy, ConstU16, ConvertToValue, Replace, ReplaceWithDefault};
|
||||
use xcm::prelude::*;
|
||||
use xcm_builder::{AliasesIntoAccountId32, PayOverXcm};
|
||||
|
||||
@@ -108,8 +108,10 @@ pub type ExchangeOrigin = EitherOf<EnsureRootWithSuccess<AccountId, ConstU16<655
|
||||
impl pallet_ranked_collective::Config<AmbassadorCollectiveInstance> for Runtime {
|
||||
type WeightInfo = weights::pallet_ranked_collective_ambassador_collective::WeightInfo<Runtime>;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type AddOrigin = MapSuccess<Self::PromoteOrigin, ReplaceWithDefault<()>>;
|
||||
type PromoteOrigin = PromoteOrigin;
|
||||
type DemoteOrigin = DemoteOrigin;
|
||||
type RemoveOrigin = Self::DemoteOrigin;
|
||||
type ExchangeOrigin = ExchangeOrigin;
|
||||
type Polls = AmbassadorReferenda;
|
||||
type MinRankOfClass = sp_runtime::traits::Identity;
|
||||
|
||||
@@ -113,12 +113,17 @@ impl pallet_ranked_collective::Config<FellowshipCollectiveInstance> for Runtime
|
||||
type WeightInfo = weights::pallet_ranked_collective_fellowship_collective::WeightInfo<Runtime>;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
// Promotions and the induction of new members are serviced by `FellowshipCore` pallet instance.
|
||||
type PromoteOrigin = frame_system::EnsureNever<pallet_ranked_collective::Rank>;
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
type AddOrigin = frame_system::EnsureNever<()>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type AddOrigin = frame_system::EnsureRoot<Self::AccountId>;
|
||||
|
||||
// The maximum value of `u16` set as a success value for the root to ensure the benchmarks will
|
||||
// pass.
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
type PromoteOrigin = frame_system::EnsureNever<pallet_ranked_collective::Rank>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type PromoteOrigin = EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>;
|
||||
|
||||
// Demotion is by any of:
|
||||
@@ -127,6 +132,7 @@ impl pallet_ranked_collective::Config<FellowshipCollectiveInstance> for Runtime
|
||||
//
|
||||
// The maximum value of `u16` set as a success value for the root to ensure the benchmarks will
|
||||
// pass.
|
||||
type RemoveOrigin = Self::DemoteOrigin;
|
||||
type DemoteOrigin = EitherOf<
|
||||
EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
|
||||
MapSuccess<
|
||||
|
||||
Reference in New Issue
Block a user