Skip to content

fix: correct dynamic array decoding in struct codegen#2272

Open
Dev10-sys wants to merge 2 commits intoLFDT-web3j:mainfrom
Dev10-sys:fix/struct-decode-final
Open

fix: correct dynamic array decoding in struct codegen#2272
Dev10-sys wants to merge 2 commits intoLFDT-web3j:mainfrom
Dev10-sys:fix/struct-decode-final

Conversation

@Dev10-sys
Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes an issue where structs containing dynamic arrays (like address[]) were failing to decode at runtime.

Where should the reviewer start?

SolidityFunctionWrapper.java

Why is it needed?

The generated struct constructors were missing the required type information for dynamic arrays.
Because of this, the ABI decoder could not determine the element type at runtime and threw an error during decoding.

What changed?

  • Applied @Parameterized only for dynamic array fields in struct constructors
  • Ensured static arrays and non-array fields are not affected
  • Fixed parameter generation to avoid incorrect or duplicate handling
  • Added a test (StructDynamicArrayDecodeTest) to verify:
    • dynamic arrays are correctly annotated
    • static arrays are not annotated
    • decoding works as expected

Result

Structs with dynamic arrays now decode correctly without runtime errors.

Fixes #2001

Signed-off-by: Dev10-sys <kalpanagola9897@gmail.com>
@Dev10-sys Dev10-sys force-pushed the fix/struct-decode-final branch from 03288ab to 5fe5c28 Compare April 21, 2026 19:47
Signed-off-by: Dev10-sys <dev10.sys@gmail.com>
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.

Generated wrapper around struct containing a address[] member can't be instantiated

1 participant