alloy-rs / core

High-performance, well-tested & documented core libraries for Ethereum, in Rust
https://alloy.rs
Apache License 2.0
763 stars 137 forks source link

[Bug] cannot derive Clone with sol macro from an ABI #617

Closed erikreppel closed 4 months ago

erikreppel commented 4 months ago

Component

contract

What version of Alloy are you on?

alloy v0.1.0 (https://github.com/alloy-rs/alloy?rev=bbef8de#bbef8de3)

Operating System

macOS (Apple Silicon)

Describe the bug

(from discussion in telegram channel) The sol macro using an abi file. The sol macro seems to automatically add #[derive(Clone)] to SolStructs and errors, but not to SolEvents, so trying to derive Clone when using an abi as input breaks because of conflicting implementations of Clone on SolStructs and errors.

telegram-cloud-document-1-5012973626165560801 telegram-cloud-document-1-5012973626165560803

telegram-cloud-document-1-5012973626165560806

telegram-cloud-document-1-5012973626165560806

prestwich commented 4 months ago

quickest resolution would be to add a clone derive to the code in expand/event.rs

erikreppel commented 4 months ago

@prestwich not sure if its just this easy https://github.com/alloy-rs/core/pull/616

prestwich commented 4 months ago

yeah, that should do it. we need to release cc @DaniPopes

this is technically a breaking change but given the nature of the issue, basically no one would've actually hand implemented clone for these things

prestwich commented 4 months ago

As follow up, we should probably make sure that we're completely consistent across all generated types

DaniPopes commented 4 months ago

Fix released in 0.7.2.