You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FRAME: Simplify and extend pallets config definition by using the stabilized feature: associated type bounds #3743
traitFoo:Bar<B>{typeB:IsType<Bar::B> + Default;}traitBar{typeB;}fnf<T:Foo>(){// Do back and forth conversion between <T as Foo>::B and <T as Bar>::B}
1: simplify Config definition
So for pallets other than frame_system we no longer need the associated types: RuntimeEvent, RuntimeOrigin, RuntimeCall, etc...
Instead we should be able to modify the pallet Config trait definition like this:
#[pallet::config]
- pub trait Config: frame_system::Config {- /// Overarching event type.- type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;-+ pub trait Config: frame_system::Config<RuntimeEvent: From<Event<Self>>> {
/// The type in which the assets for swapping are measured.
type Balance: Balance;
2: extend Config definition
We should be able to add constraint on pallet dependencies way more easily without having to write where ... for each implementation block.
To illustrate we could have a pallet which depends on pallet_balances but requires at least u128 as currency type
changed the title [-]FRAME: Simplify and extend pallets config definition by using the stabilized associated type bounds[/-][+]FRAME: Simplify and extend pallets config definition by using the stabilized feature: associated type bounds[/+]on Mar 19, 2024
This looks like a good issue to tackle and get crazy on rust types and traits.
So essentially , we would have this syntax where we tight couple every pallet? @ggwpez@thiolliere
So essentially , we would have this syntax where we tight couple every pallet?
I think a good start would be to use it for one or two pallets as a proof-of-concept. For example as gui pointed out, in the RuntimeEvent or RuntimeCall types of a pallet config.
Best to start small with this so that we can quickly review it.
So essentially , we would have this syntax where we tight couple every pallet?
I think a good start would be to use it for one or two pallets as a proof-of-concept. For example as gui pointed out, in the RuntimeEvent or RuntimeCall types of a pallet config. Best to start small with this so that we can quickly review it.
I opened an initial PoC PR for RuntimeEvent as an associated type bound. I will be gradually tackling RuntimeCall and other where clauses if the above approach looks good
Activity
[-]FRAME: Simplify and extend pallets config definition by using the stabilized associated type bounds[/-][+]FRAME: Simplify and extend pallets config definition by using the stabilized feature: associated type bounds[/+]MrishoLukamba commentedon Mar 20, 2024
This looks like a good issue to tackle and get crazy on rust types and traits.
So essentially , we would have this syntax where we tight couple every pallet? @ggwpez @thiolliere
ggwpez commentedon Mar 20, 2024
I think a good start would be to use it for one or two pallets as a proof-of-concept. For example as gui pointed out, in the
RuntimeEventorRuntimeCalltypes of a pallet config.Best to start small with this so that we can quickly review it.
dastansam commentedon Jan 17, 2025
I opened an initial PoC PR for
RuntimeEventas an associated type bound. I will be gradually tacklingRuntimeCalland otherwhereclauses if the above approach looks good[FRAME] Simplify pallet config definition: remove `RuntimeEvent` asso…
[FRAME] Simplify pallet config definition: remove `RuntimeEvent` asso…