Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat(abigen): include ethevent proc macro in abigen code gen workflow #232

Merged

Conversation

mattsse
Copy link
Collaborator

@mattsse mattsse commented Mar 16, 2021

This integrates the EthEvent trait in the abigen code generation process.

Motivation

The EthEvent makes the output of the abigen macro more consistent for events, and allows for generating further helper methods, as mentioned in #228.

Solution

Instead of generating the methods name, signature and abi_signature for each event provided in the ABI, the EthEvent trait is simply implemented via a #[derive(EthEvent)] during the abigen workflow. In addition all structs that are declared in the human readable abi are generated aswell. If a solidity event contains variables with solidity structs as tyoe , the generated rust struct variables have the corresponding rust. This has currently a limitation where the build fails if a solidity event has an array of a struct as input, however gakonst/ethabi#1 should remove this limitation.

Open Discussion

  • The generated event struct still use a Filter name suffix, I think this is not necessary and could be removed.
  • To use the EthEvent methods as before, an import of the EthEvent is required, right now the generated contract module does not pub EthEvent, which would be breaking as well as the minor change from &'static str to Cow<'static, str> in EthEvent::name and EthEvent::abi_signature, I'd think that is negligible.

@mattsse mattsse marked this pull request as ready for review March 16, 2021 18:07
@gakonst gakonst merged commit 57010c1 into gakonst:master Mar 16, 2021
@gakonst
Copy link
Owner

gakonst commented Mar 16, 2021

Merged, thank you. Supportive of removing the Filter suffix from the struct definition. I'll mark this as a BREAKING change in the next release, no problem otherwise.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants