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

abigen! fails for functions with same name, different args #543

Closed
odyslam opened this issue Oct 30, 2021 · 7 comments · Fixed by #545
Closed

abigen! fails for functions with same name, different args #543

odyslam opened this issue Oct 30, 2021 · 7 comments · Fixed by #545
Labels
bug Something isn't working

Comments

@odyslam
Copy link
Contributor

odyslam commented Oct 30, 2021

Version

ethers v0.5.3 (https://github.com/gakonst/ethers-rs#5ab0b7e0)

Platform
Darwin odys-mbp-68.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64

Description

  • abigen! fails to handle multiple functions that have the same name but different arguments
  • It fails in a non-consistent manner. The first example works, the second produces an error:
log(address)
log(string, string)
log(string)
log(string, string)
log(string)

Error

error: Function with same name and parameter types defined twice: log
  --> evm-adapters/src/sputnik/cheatcodes/mod.rs:72:5
   |
72 | /     r#"[
73 | |             log(string, string)
74 | |             log(string)
75 | |     ]"#,
   | |_______^


Code

ethers::contract::abigen!(
    ConsoleLog,
    r#"[
            log(address)
            log(string, string)
            log(string)
    ]"#,
);

pub use ConsoleLogCalls;

The above is needed so that we can port console.log functionality to dapptools-rs.

@odyslam odyslam added the bug Something isn't working label Oct 30, 2021
@mattsse
Copy link
Collaborator

mattsse commented Oct 30, 2021

that's somewhat related to #530
In this case we should just enumerate them when we derive the rust idents like,
log0, log1, log2 etc

@odyslam
Copy link
Contributor Author

odyslam commented Oct 30, 2021

@mattsse out of curiosity, why it breaks if I remove log(address)?

@mattsse
Copy link
Collaborator

mattsse commented Oct 30, 2021

interesting will have to take a look

@odyslam
Copy link
Contributor Author

odyslam commented Oct 31, 2021

@mattsse interestingly, as you can see from dapptools-rs#128, the abigen creates the following associated functions:
log
logwith
logwithand

So, it somewhat handles the repeated name.

If you give me a pointer, I would happily take a stab at it.

@mattsse
Copy link
Collaborator

mattsse commented Oct 31, 2021

this should be fixed with #545 , could you check?

@odyslam
Copy link
Contributor Author

odyslam commented Oct 31, 2021

@mattsse trying, recent ethers-rs commit broke Solc in dapptools-rs, so I have to figure that out first in order to compile again.

@gakonst
Copy link
Owner

gakonst commented Oct 31, 2021

I think this issue is resolved, we will fix the compilation issue in dapptools-rs separately, and then we can resume the console.sol work there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants