web3j
web3j copied to clipboard
Conflict for Events with same name for generated abi
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
- Open Compound's etherscan link controller contract
- Copy abi and bin codes to 2 files.
- 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
- etherscan references
@ShawnWu0x investigating this
Any updates on this? Also encountering the same issue in https://github.com/lukso-network/lsp-smart-contracts/pull/469
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>() {}));
;