-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix and test for duplicated fields (#680) #989
Fix and test for duplicated fields (#680) #989
Conversation
Thanks for the submission but I disagree with the approach. I don't think the issue is with web3j. It is more an issue of the naming convention from the Solidity developer. I think it is bad practice to have the same name with a different case for different variables. I would suggest that the Solidity code is modified e.g. |
I completely agree with you about the naming convention. |
fixes #680 |
@kostind thanks for taking a look - I did not understand the issue but with your code it is obvious :) I will get a colleague to review this and give their opinion. |
@iikirilov I'm happy to help :-) Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the more interesting question is as a user of web3j what do you expect to happen. Should we keep to the normal Java naming conventions or bend them to match Solidity?
Personally, I think we should keep the naming convention we have but throw a compile error when you have duplicates.
codegen/src/test/resources/solidity/duplicate/DuplicateFeild.sol
Outdated
Show resolved
Hide resolved
codegen/src/test/resources/solidity/duplicate/DuplicateFeild.sol
Outdated
Show resolved
Hide resolved
I usually avoid such situation with function/variable names. The only concern here if we need to interact with a smart contract which has already been deployed and can't be upgraded. |
I think that's the way to go with this.
That's true, I think what would be nice would be a halfway house between a fully generated wrapper and |
Did you mean that we can always build methods for working with duplicated functions by hand and don't use generated wrappers for them?
|
The problem is that |
With this PR I think we should prevent code generation for anything that will cause a clash. When clashes are found output a warning to the user. |
Thank you for your suggestions. |
Good point. Just to clarify the resolution is to successfully generate a wrapper without the duplicate fields (i.e. it must compile) and to output warnings on the command line for the user. |
@antonydenyer Thank you for the approval. |
What does this PR do?
Changes SolidityFunctionWrapper in order to don't use upper case for function names which will be duplicated.
Where should the reviewer start?
SolidityFunctionWrapper
SolidityFunctionWrapperGeneratorTest
Why is it needed?
To fix bug with code generation for contracts with duplicate fields.
Extra
Java class generated from DuplicateField contract will have the following constants:
FUNC_name
FUNC_DECIMALS
FUNC_Name
FUNC_NAME
FUNC_SYMBOL