feat(abigen): add provided derives for call and event enums (#721)

* feat(abigen): add provided derives for call and event enums

* chore: update CHANGELOG
This commit is contained in:
Matthias Seitz 2021-12-20 22:24:21 +01:00 committed by GitHub
parent c5ee58d13d
commit 1f4ecc6e75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -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).

View File

@ -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)),*
}

View File

@ -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)),*
}