Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

decl_event! should generate only one struct/type #4288

Closed
@bkchr

Description

@bkchr

Currently decl_event! creates enum RawEvent and type Event = when you have a generic event, but for none-generic events it just generates enum Event.
This needs to be unified, aka just generate enum Event.

As rust automatic trait derives are somewhat broken, the macro will need to implementClone, PartialEq, Eq and RuntimeDebug on it's own. It is required that trait bound will not be put onto the generic parameter itself and instead it needs to be put onto the associated types, so something like this:

enum Event<T> {
    SomeEvent(T::Data),
}

has the following PartialEq bounds:

impl<T: Trait> PartialEq for Event<T> where T::Data: PartialEq

and not:

impl<T: Trait> PartialEq for Event<T> where T: PartialEq

parity-scale-codec does this already automatic and so derive(Encode, Decode) should work without any problems.

The code of the macro can be found here

Metadata

Metadata

Assignees

No one assigned

    Labels

    I7-refactorCode needs refactoring.Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.Z6-mentorAn easy task where a mentor is available. Please indicate in the issue who the mentor could be.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions