Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict for Events with same name for generated abi #1781

Open
ShawnWu0x opened this issue Sep 28, 2022 · 3 comments
Open

Conflict for Events with same name for generated abi #1781

ShawnWu0x opened this issue Sep 28, 2022 · 3 comments
Labels
bug A bug in behaviour or functionality

Comments

@ShawnWu0x
Copy link

Bug_title

In Solidity, the events may have same names, but with different parameters.
Such as Compound's controller contract

There are 2 ActionPaused events with different parameters.

/// @notice Emitted when an action is paused globally
    event ActionPaused(string action, bool pauseState);

    /// @notice Emitted when an action is paused on a market
    event ActionPaused(CToken cToken, string action, bool pauseState);

If we generate the Java file with web3jgen for it, there will be 2 global parameters with name ACTIONPAUSED_EVENT in the generated JAVA file.
This is not allowed in Java.

public static final Event ACTIONPAUSED_EVENT = new Event("ActionPaused", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Bool>() {}));
    ;

    public static final Event ACTIONPAUSED_EVENT = new Event("ActionPaused", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Bool>() {}));
    ;

Steps To Reproduce

  1. Open Compound's etherscan link controller contract
  2. Copy abi and bin codes to 2 files.
  3. Run web3j generate solidity -a abc.abi -b abc.bin -o ./ -p abi
  • -a is abi file
  • -b is bin file
  • -o is the directory where generate the file
  • -p is the package of java file

Expected behavior

The generated java file should has no ERROR.

Actual behavior

The generated java file built failed with ERROR.

Environment

  • Web3j core 4.8.7
  • Java 1.8
  • MacOS

Additional context

@ShawnWu0x ShawnWu0x added the bug A bug in behaviour or functionality label Sep 28, 2022
@mohamedelshami mohamedelshami pinned this issue Oct 21, 2022
@mohamedelshami
Copy link
Contributor

@ShawnWu0x investigating this

@CJ42
Copy link

CJ42 commented Feb 13, 2023

Any updates on this? Also encountering the same issue in lukso-network/lsp-smart-contracts#469

@mattiamonari
Copy link
Contributor

How would you like to have the name of duplicated event @CJ42? I'm currently working on it.

It is possible to create in the wrapper a 'numbered list', e.g. :

public static final Event ACTIONPAUSED_EVENT = new Event("ActionPaused", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Bool>() {}));
    ;

    public static final Event ACTIONPAUSED_EVENT_1 = new Event("ActionPaused", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Bool>() {}));
    ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug in behaviour or functionality
Projects
None yet
Development

No branches or pull requests

4 participants