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

Commit

Permalink
feat(abigen): add provided derives for call and event enums (#721)
Browse files Browse the repository at this point in the history
* feat(abigen): add provided derives for call and event enums

* chore: update CHANGELOG
  • Loading branch information
mattsse authored Dec 20, 2021
1 parent c5ee58d commit 1f4ecc6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

## ethers-contract-abigen

- Add provided `event_derives` to call and event enums as well
[#721](https://github.com/gakonst/ethers-rs/pull/721).
- Implement snowtrace and polygonscan on par with the etherscan integration
[#666](https://github.com/gakonst/ethers-rs/pull/666).

Expand Down
8 changes: 5 additions & 3 deletions ethers-contract/ethers-contract-abigen/src/contract/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ impl Context {
.map(|e| expand_struct_name(e, self.event_aliases.get(&e.abi_signature()).cloned()))
.collect::<Vec<_>>();

let enum_name = self.expand_event_enum_name();

let ethers_core = ethers_core_crate();
let ethers_contract = ethers_contract_crate();

// use the same derives as for events
let derives = util::expand_derives(&self.event_derives);
let enum_name = self.expand_event_enum_name();

quote! {
#[derive(Debug, Clone, PartialEq, Eq, #ethers_contract::EthAbiType)]
#[derive(Debug, Clone, PartialEq, Eq, #ethers_contract::EthAbiType, #derives)]
pub enum #enum_name {
#(#variants(#variants)),*
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,14 @@ impl Context {
let ethers_core = ethers_core_crate();
let ethers_contract = ethers_contract_crate();

// use the same derives as for events
let derives = util::expand_derives(&self.event_derives);
let enum_name = self.expand_calls_enum_name();

Ok(quote! {
#struct_def_tokens

#[derive(Debug, Clone, PartialEq, Eq, #ethers_contract::EthAbiType)]
#[derive(Debug, Clone, PartialEq, Eq, #ethers_contract::EthAbiType, #derives)]
pub enum #enum_name {
#(#variant_names(#struct_names)),*
}
Expand Down

0 comments on commit 1f4ecc6

Please sign in to comment.