-
Notifications
You must be signed in to change notification settings - Fork 823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FRAME] Simplify pallet config definition: remove RuntimeEvent
associated type
#7229
base: master
Are you sure you want to change the base?
[FRAME] Simplify pallet config definition: remove RuntimeEvent
associated type
#7229
Conversation
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.
Ty for doing this!
RuntimeEvent
as an associated type boundRuntimeEvent
associated type
@bkchr bunch of CI is failing because they treat the |
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.
Looks good to me, after the suggestion, and also a few comments
/// | ||
/// ```rs | ||
/// pub trait Config: frame_system::Config { | ||
/// ``` |
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.
As a note personally I would always bound the supertrait: frame_system::Config<RuntimeEvent: From<Event>>
, always, except if there is the flag is_frame_system
.
If user wants to write it, he can do, then it will still compile fine.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7cfad8342293e593a0c8041cd4b5a958
But this is also ok.
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.
thanks for this tip, really helpful)
@bkchr I replaced with proc macro warning but now I have to put the #[frame_support::pallet]
#[allow(deprecated)]
pub mod pallet { but this way it would take a big span and we could ignore other deprecation warnings as well. Putting |
You need to detect the |
…o feat/runtime-event-associated-type-bound
85171bc
to
cf1d716
Compare
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.
macro is now always auto inserting system supertrait with a RuntimeEvent
bound if it detects the valid #[pallet::event]
and simply ignoring the deprecated RuntimeEvent
. it now looks bit different and much smaller than the initial PR, so I guess reviewing from scratch would be easier)
@gui1117
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.
Some minor comments, then it looks good to me.
part of #3743
Motivation
This PR removes the need for defining
RuntimeEvent
in theConfig
trait of a pallet. It uses associated type bound feature under the hood to make sure thatEvent
of the pallet is convertible to the aggregated runtime event typeframe_system::RuntimeEvent
.This is an initial PR for
RuntimeEvent
type and will be followed with other types, e.gRuntimeCall
. As a demo, example pallets' config definition is updated to use this feature.With this change, we can do this:
instead of this:
The latter will emit deprecation warnings and is redundant.
polkadot address: 16FqwPZ8GRC5U5D4Fu7W33nA55ZXzXGWHwmbnE1eT6pxuqcT