Ankan
authored
closes https://github.com/paritytech/polkadot-sdk/issues/5742
Need to be backported to stable2503 release.
With the migration of staking accounts to [fungible
currency](https://github.com/paritytech/polkadot-sdk/pull/5501), we can
now allow pool users to stake directly and vice versa. This update
introduces a configurable filter mechanism to determine which accounts
can join a nomination pool.
## Example Usage
### 1. Allow any account to join a pool
To permit all accounts to join a nomination pool, use the `Nothing`
filter:
```rust
impl pallet_nomination_pools::Config for Runtime {
...
type Filter = Nothing;
}
```
### 2. Restrict direct stakers from joining a pool
To prevent direct stakers from joining a nomination pool, use
`pallet_staking::AllStakers`:
```rust
impl pallet_nomination_pools::Config for Runtime {
...
type Filter = pallet_staking::AllStakers<Runtime>;
}
```
### 3. Define a custom filter
For more granular control, you can define a custom filter:
```rust
struct MyCustomFilter<T: Config>(core::marker::PhantomData<T>);
impl<T: Config> Contains<T::AccountId> for MyCustomFilter<T> {
fn contains(account: &T::AccountId) -> bool {
todo!("Implement custom logic. Return `false` to allow the account to join a pool.")
}
}
```
---------
Co-authored-by:
Bastian Köcher <info@kchr.de>