Skip to content

Fix Codegen fails when trying to create wrapper from ABI compiled by …#2286

Open
DakshRJain737 wants to merge 1 commit intoLFDT-web3j:mainfrom
DakshRJain737:codegen-wrapper-fail
Open

Fix Codegen fails when trying to create wrapper from ABI compiled by …#2286
DakshRJain737 wants to merge 1 commit intoLFDT-web3j:mainfrom
DakshRJain737:codegen-wrapper-fail

Conversation

@DakshRJain737
Copy link
Copy Markdown

@DakshRJain737 DakshRJain737 commented May 2, 2026

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() in SolidityFunctionWrapper.java, where the code blindly casts a TypeName to ClassName without checking its actual type first. When the inner type argument is a ParameterizedTypeName (which happens with nested arrays like uint256[][]), the cast fails.

Added an instanceof ClassName guard before the cast, and extracted the type argument into a variable to avoid redundant calls:

TypeName firstTypeArg = typeNames.get(0);
if (firstTypeArg instanceof ClassName && structClassNameMap.values().stream()...)

If the type argument is not a ClassName (i.e. it's a nested array), it correctly falls through to the existing else block which handles ParameterizedTypeName properly.

Where should the reviewer start?

The reviewer must just look into the codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java file.

Why is it needed?

Because the code assumed every type inside an array is a simple type (ClassName), but for nested arrays like uint256[][], the inner type is itself another array (ParameterizedTypeName).

Checklist

  • I've read the contribution guidelines.
  • I've added tests (if applicable).
  • I've added a changelog entry if necessary.

…truffle for T-REX 4.0.0+

Signed-off-by: daksh <dakshjain737@gmail.com>
@DakshRJain737 DakshRJain737 force-pushed the codegen-wrapper-fail branch from 9ff9197 to 30e432d Compare May 2, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codegen fails when trying to create wrapper from ABI compiled by truffle for T-REX 4.0.0+

1 participant