-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(pallet-ranked-collective): added types #14577
base: master
Are you sure you want to change the base?
feat(pallet-ranked-collective): added types #14577
Conversation
New associated types(`AddOrigin` & `RemoveOrigin`) have been added to `Config`.
@@ -538,7 +545,7 @@ pub mod pallet { | |||
who: AccountIdLookupOf<T>, | |||
min_rank: Rank, | |||
) -> DispatchResultWithPostInfo { | |||
let max_rank = T::DemoteOrigin::ensure_origin(origin)?; | |||
let max_rank = T::RemoveOrigin::ensure_origin(origin)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function doc mentions AdminOrigin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -490,7 +497,7 @@ pub mod pallet { | |||
#[pallet::call_index(0)] | |||
#[pallet::weight(T::WeightInfo::add_member())] | |||
pub fn add_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult { | |||
let _ = T::PromoteOrigin::ensure_origin(origin)?; | |||
T::AddOrigin::ensure_origin(origin)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function docs needs to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. + Refresh docs to some other functions
/// maximum rank *from which* the removal may be. | ||
type RemoveOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Rank>; | ||
|
||
/// The origin required to promote a member. The success value indicates the | ||
/// maximum rank *to which* the promotion may be. | ||
type PromoteOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Rank>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it improve flexibility?
PromoteOrigin
returns the Rank
, if it returns 0, it can only add_member
.
Same with DemoteOrigin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AddOrigin
allows a chain to use a different (from the PromoteOrigin
) authority to add members. E.g., entering the ranked collective could be managed separately from promoting inside it. The same with the RemoveOrigin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can do the same with only PromoteOrigin
since it returns Rank
.
for your add origin the promote origin type will return rank 0
hence it can only add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In current impl where only PromoteOrigin
exists, one could add a dedicated origin with a 0 rank to the PromoteOrigin
to add new members. However, anyone who can promote can also add a new member in this case, not only our dedicated origin. So we can't express the setting where one can promote an existing member but can't add a new one.
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
The CI pipeline was cancelled due to failure one of the required jobs. |
This reverts commit e1f8af4.
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This PR added associated types(
AddOrigin
&RemoveOrigin
) toConfig
. 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.To achieve the backward compatibility, the users of the pallet can use the old type via the new morph:
Polkadot companion: paritytech/polkadot#7500
Cumulus companion: paritytech/cumulus#2881