[FRAME] Make core-fellowship ans salary work for swapped members (#3156)

Fixup for https://github.com/paritytech/polkadot-sdk/pull/2587 to make
the `core-fellowship` crate work with swapped members.

Adds a `MemberSwappedHandler` to the `ranked-collective` pallet that are
implemented by `core-fellowship+salary`.
There is are exhaustive tests
[here](https://github.com/paritytech/polkadot-sdk/blob/72aa7ac17a0e5b16faab5d2992aa2db2e01b05d0/substrate/frame/core-fellowship/src/tests/integration.rs#L338)
and
[here](https://github.com/paritytech/polkadot-sdk/blob/ab3cdb05a5ebc1ff841f8dda67edef0ea40bbba5/substrate/frame/salary/src/tests/integration.rs#L224)
to check that adding member `1` is equivalent to adding member `0` and
then swapping.

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2024-01-31 17:29:48 +01:00
committed by GitHub
parent 6ea472ad5a
commit 07e55006ad
25 changed files with 795 additions and 69 deletions
@@ -113,7 +113,10 @@ impl pallet_ranked_collective::Config<AmbassadorCollectiveInstance> for Runtime
type ExchangeOrigin = ExchangeOrigin;
type Polls = AmbassadorReferenda;
type MinRankOfClass = sp_runtime::traits::Identity;
type MemberSwappedHandler = (crate::AmbassadorCore, crate::AmbassadorSalary);
type VoteWeight = pallet_ranked_collective::Linear;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkSetup = (crate::AmbassadorCore, crate::AmbassadorSalary);
}
parameter_types! {
@@ -141,7 +141,10 @@ impl pallet_ranked_collective::Config<FellowshipCollectiveInstance> for Runtime
EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Fellows>;
type Polls = FellowshipReferenda;
type MinRankOfClass = tracks::MinRankOfClass;
type MemberSwappedHandler = (crate::FellowshipCore, crate::FellowshipSalary);
type VoteWeight = pallet_ranked_collective::Geometric;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkSetup = (crate::FellowshipCore, crate::FellowshipSalary);
}
pub type FellowshipCoreInstance = pallet_core_fellowship::Instance1;