mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +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
@@ -27,7 +27,7 @@ use frame_system::EnsureSignedBy;
|
||||
use pallet_ranked_collective::{EnsureRanked, Geometric, Rank, TallyOf, Votes};
|
||||
use sp_core::Get;
|
||||
use sp_runtime::{
|
||||
traits::{Convert, ReduceBy, TryMorphInto},
|
||||
traits::{Convert, ReduceBy, ReplaceWithDefault, TryMorphInto},
|
||||
BuildStorage, DispatchError,
|
||||
};
|
||||
type Class = Rank;
|
||||
@@ -137,12 +137,14 @@ impl pallet_ranked_collective::Config for Test {
|
||||
// Members can promote up to the rank of 2 below them.
|
||||
MapSuccess<EnsureRanked<Test, (), 2>, ReduceBy<ConstU16<2>>>,
|
||||
>;
|
||||
type AddOrigin = MapSuccess<Self::PromoteOrigin, ReplaceWithDefault<()>>;
|
||||
type DemoteOrigin = EitherOf<
|
||||
// Root can demote arbitrarily.
|
||||
frame_system::EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
|
||||
// Members can demote up to the rank of 3 below them.
|
||||
MapSuccess<EnsureRanked<Test, (), 3>, ReduceBy<ConstU16<3>>>,
|
||||
>;
|
||||
type RemoveOrigin = Self::DemoteOrigin;
|
||||
type ExchangeOrigin = EitherOf<
|
||||
// Root can exchange arbitrarily.
|
||||
frame_system::EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>,
|
||||
|
||||
Reference in New Issue
Block a user