alloy-rs / core

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

[Bug] Simple getter not available on loaded artifact, yet available on equivalent embedded contract #658

Closed zerosnacks closed 3 months ago

zerosnacks commented 3 months ago

Component

syn-solidity

What version of Alloy are you on?

No response

Operating System

None

Describe the bug

It seems that when loading from an artifact the codegen does not correctly pick up the getter name and rather forces the ._0 unnamed getter.

https://github.com/alloy-rs/examples/blob/7e62ffba1e2a8360a133f6d5dde3ff4232a8bb06/examples/contracts/examples/deploy_from_artifact.rs#L52-L54

This is the expected behavior:

https://github.com/alloy-rs/examples/blob/7e62ffba1e2a8360a133f6d5dde3ff4232a8bb06/examples/contracts/examples/deploy_from_contract.rs#L62-L64

The bytecode and source code to generate the artifact are the exact same for both examples.

Artifact: https://github.com/alloy-rs/examples/blob/main/examples/contracts/examples/artifacts/Counter.json

DaniPopes commented 3 months ago

solc does not emit names in the return types of auto-generated getters

I added the logic myself in https://github.com/alloy-rs/core/pull/648

zerosnacks commented 3 months ago

solc does not emit names in the return types of auto-generated getters

I added the logic myself in #648

Ah I see, I'll add a note in the example as it can be confusing for the end user