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

decl_event! should generate only one struct/type #4288

Closed
bkchr opened this issue Dec 4, 2019 · 7 comments
Closed

decl_event! should generate only one struct/type #4288

bkchr opened this issue Dec 4, 2019 · 7 comments
Labels
I7-refactor Code needs refactoring. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.
Milestone

Comments

@bkchr
Copy link
Member

bkchr commented Dec 4, 2019

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

@bkchr bkchr added I7-refactor Code needs refactoring. Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. labels Dec 4, 2019
@bkchr bkchr added this to the Ideas milestone Dec 4, 2019
@jakubadamw jakubadamw removed their assignment Jul 28, 2020
@herou
Copy link

herou commented Sep 3, 2020

@bkchr Can I work on this ticket?

@bkchr
Copy link
Member Author

bkchr commented Sep 3, 2020

@herou theoretically yes, but this will probably be solved by #6877 anyway.

@herou
Copy link

herou commented Sep 3, 2020

@bkchr any other issue which you offer mentorship?

@bkchr
Copy link
Member Author

bkchr commented Sep 3, 2020

@herou what is your background? What kind of tasks are you searching for?

@herou
Copy link

herou commented Sep 3, 2020

@bkchr I am a mobile developer (Java), recently (6 months) learning rust, substrate, and blockchain to get my feet into.

@bkchr
Copy link
Member Author

bkchr commented Sep 4, 2020

Maybe this one: paritytech/polkadot-sdk#369 ?

@thiolliere
Copy link
Contributor

Fixed by #6877

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I7-refactor Code needs refactoring. Z2-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.
Projects
None yet
Development

No branches or pull requests

4 participants