sovereign-sdk
sovereign-sdk copied to clipboard
Add auto-generated key methods for Events
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:
- Added an
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. - Added an
Event
macro that derives theEvent
trait methods for a given enum. - Renamed the original
Event
macro that creates an enum that represents all possible events from all the modules toRuntimeEvent
. - Added a
get_key_string
method to the<runtime>Event
enum generated by the (now called)RuntimeEvent
macro, which returns a given<Runtime>Event
's key. - Added a
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. - Renamed the legacy
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 previous RuntimeEvent
macro.
Codecov Report
Merging #1116 (c711860) into nightly (5d61e35) will increase coverage by
0.0%
. The diff coverage is91.5%
.
Files | Coverage Δ | |
---|---|---|
full-node/db/sov-db/src/ledger_db/mod.rs | 90.8% <ø> (ø) |
|
full-node/db/sov-db/src/schema/tables.rs | 85.0% <ø> (ø) |
|
full-node/db/sov-db/src/schema/types.rs | 80.7% <100.0%> (ø) |
|
full-node/sov-ledger-rpc/src/client.rs | 100.0% <ø> (ø) |
|
...ions/integration-tests/src/nested_modules/tests.rs | 100.0% <100.0%> (ø) |
|
...ule-system/sov-modules-api/src/state/scratchpad.rs | 88.1% <100.0%> (ø) |
|
module-system/sov-modules-macros/src/lib.rs | 100.0% <100.0%> (ø) |
|
...ule-system/sov-modules-macros/src/runtime_event.rs | 100.0% <100.0%> (ø) |
|
rollup-interface/src/node/rpc/mod.rs | 89.2% <ø> (ø) |
|
rollup-interface/src/state_machine/stf.rs | 85.7% <ø> (ø) |
|
... and 4 more |
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.