Fix Codegen fails when trying to create wrapper from ABI compiled by …#2286
Open
DakshRJain737 wants to merge 1 commit intoLFDT-web3j:mainfrom
Open
Fix Codegen fails when trying to create wrapper from ABI compiled by …#2286DakshRJain737 wants to merge 1 commit intoLFDT-web3j:mainfrom
DakshRJain737 wants to merge 1 commit intoLFDT-web3j:mainfrom
Conversation
15734ce to
9ff9197
Compare
…truffle for T-REX 4.0.0+ Signed-off-by: daksh <dakshjain737@gmail.com>
9ff9197 to
30e432d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1925
What does this PR do?
Codegen fails when trying to create wrapper from ABI compiled by truffle for T-REX 4.0.0+. The root cause is in
createMappedParameterTypes()inSolidityFunctionWrapper.java, where the code blindly casts aTypeNametoClassNamewithout checking its actual type first. When the inner type argument is aParameterizedTypeName(which happens with nested arrays likeuint256[][]), the cast fails.Added an
instanceof ClassNameguard before the cast, and extracted the type argument into a variable to avoid redundant calls:If the type argument is not a
ClassName(i.e. it's a nested array), it correctly falls through to the existingelseblock which handlesParameterizedTypeNameproperly.Where should the reviewer start?
The reviewer must just look into the
codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.javafile.Why is it needed?
Because the code assumed every type inside an array is a simple type (
ClassName), but for nested arrays likeuint256[][], the inner type is itself another array (ParameterizedTypeName).Checklist