mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +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
@@ -17,7 +17,7 @@
|
||||
//! Elements of governance concerning the Rococo Fellowship.
|
||||
|
||||
use frame_support::traits::{MapSuccess, TryMapSuccess};
|
||||
use sp_runtime::traits::{CheckedReduceBy, ConstU16, Replace};
|
||||
use sp_runtime::traits::{CheckedReduceBy, ConstU16, Replace, ReplaceWithDefault};
|
||||
|
||||
use super::*;
|
||||
use crate::{CENTS, DAYS};
|
||||
@@ -315,6 +315,11 @@ pub type FellowshipCollectiveInstance = pallet_ranked_collective::Instance1;
|
||||
impl pallet_ranked_collective::Config<FellowshipCollectiveInstance> for Runtime {
|
||||
type WeightInfo = weights::pallet_ranked_collective::WeightInfo<Self>;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
// Adding is by any of:
|
||||
// - Root.
|
||||
// - the FellowshipAdmin origin.
|
||||
// - a Fellowship origin.
|
||||
type AddOrigin = MapSuccess<Self::PromoteOrigin, ReplaceWithDefault<()>>;
|
||||
// Promotion is by any of:
|
||||
// - Root can demote arbitrarily.
|
||||
// - the FellowshipAdmin origin (i.e. token holder referendum);
|
||||
@@ -326,6 +331,11 @@ impl pallet_ranked_collective::Config<FellowshipCollectiveInstance> for Runtime
|
||||
TryMapSuccess<origins::EnsureFellowship, CheckedReduceBy<ConstU16<1>>>,
|
||||
>,
|
||||
>;
|
||||
// Removing is by any of:
|
||||
// - Root can remove arbitrarily.
|
||||
// - the FellowshipAdmin origin (i.e. token holder referendum);
|
||||
// - a vote by the rank two above the current rank.
|
||||
type RemoveOrigin = Self::DemoteOrigin;
|
||||
// Demotion is by any of:
|
||||
// - Root can demote arbitrarily.
|
||||
// - the FellowshipAdmin origin (i.e. token holder referendum);
|
||||
|
||||
Reference in New Issue
Block a user