-
Notifications
You must be signed in to change notification settings - Fork 982
Open
Labels
D2-substantialCan be fixed by an experienced coder with a working knowledge of the codebase.Can be fixed by an experienced coder with a working knowledge of the codebase.T1-FRAMEThis PR/Issue is related to core FRAME, the framework.This PR/Issue is related to core FRAME, the framework.
Description
Associated type bounds is stabilized: rust-lang/rust#122055
So we can do code like this:
#![feature(associated_type_bounds)]
trait Foo: Bar<B: Default> {
}
trait Bar {
type B;
}
fn f<T: Foo>() {
<<T as Bar>::B as Default>::default();
}
Instead of doing this:
trait Foo: Bar<B> {
type B: IsType<Bar::B> + Default;
}
trait Bar {
type B;
}
fn f<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
#[pallet::config]
pub trait Config: pallet_balances::Config<Balance: From<u128>> {
}
ggwpez, seadanda, maksimryndin, bkchr, gupnik and 3 morebkchr, gupnik, shawntabrizi, dastansam and PolkadotDom
Metadata
Metadata
Assignees
Labels
D2-substantialCan be fixed by an experienced coder with a working knowledge of the codebase.Can be fixed by an experienced coder with a working knowledge of the codebase.T1-FRAMEThis PR/Issue is related to core FRAME, the framework.This PR/Issue is related to core FRAME, the framework.
Type
Projects
Status
Backlog