-
Notifications
You must be signed in to change notification settings - Fork 107
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
Add auto-generated key methods for Events #1116
base: nightly
Are you sure you want to change the base?
Add auto-generated key methods for Events #1116
Conversation
Codecov Report
|
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 except for the create_get_key_string_impl
body. Just need to replace the format!("{:?}", inner)
call with inner.event_key()
and we should be good to go
get_key_string
method to the `<runtime>Event via an Event trait
get_key_string
method to the `<runtime>Event via an Event trait
|
Description
We want to use typed objects instead of the handwritten events in the codebase so that the event processes are less error-prone, and its easer/ more obvious for users to index these events.
For this purpose, in this PR, we:
Event
trait with methods anevent_key()
, which returns a given Event object's key, andget_all_event_keys()
, which returns all possible event keys for a module, and put this trait as a trait bound on theEvent
associated type on theModule
trait.Event
macro that derives theEvent
trait methods for a given enum.Event
macro that creates an enum that represents all possible events from all the modules toRuntimeEvent
.get_key_string
method to the<runtime>Event
enum generated by the (now called)RuntimeEvent
macro, which returns a given<Runtime>Event
's key.get_all_key_strings
method to the<runtime>Event
enum, which returns the key strings for all events in the runtime, spanning across all modules.Event
type fromrollup_interface
toLegacyEvent
to fix name clashing. TheLegacyEvent
will be completely removed in an upcoming PR as we move to a simplerEvent
flow.The diffs for the macro files are unfortunately bigger than necessary as the name
event.rs
was more appropriate for the new macro than the previousRuntimeEvent
macro.