Skip to content
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

Incorrect wrapping of two-dimensional arrays #2087

Open
ApereLieZ opened this issue Aug 5, 2024 · 0 comments
Open

Incorrect wrapping of two-dimensional arrays #2087

ApereLieZ opened this issue Aug 5, 2024 · 0 comments
Labels
bug A bug in behaviour or functionality

Comments

@ApereLieZ
Copy link

Incorrect wrapping of two-dimensional arrays

Steps To Reproduce

  1. Define an ABI with a two-dimensional array:
{
    "internalType": "uint256[][]",
    "name": "results",
    "type": "uint256[][]"
}

Use the following Java class to wrap the data:

public RemoteCall<ProposalInfo> getInfo(BigInteger id) {
        final Function function = new Function(FUNC_INFO, Arrays.asList(new Uint256(id)), Arrays.asList(new TypeReference<ExampleStruct>() {
        }));
        return executeRemoteCallSingleValueReturn(function, ExampleStruct.class);
    }
...

public static class ExampleStruct extends DynamicStruct {
    ...
    public final DynamicArray<DynamicArray<Uint256>> results;

    public ProposalInfo(..., @Parameterized(type = Uint256.class) DynamicArray<DynamicArray<Uint256>> results) {
        super(..., results);
        ...
        this.results = results;
    }
}

Expected behavior

The results field should be of type DynamicArray<DynamicArray<Uint256>>, correctly representing a two-dimensional array of Uint256.

Actual behavior

The results field is incorrectly returned as DynamicArray<Uint256> instead of DynamicArray<DynamicArray<Uint256>>.

Environment

Describe the environment in which the issue occurs

  • Web3j 4.12.0
  • Java 17
  • Operating System (mac os)
@ApereLieZ ApereLieZ added the bug A bug in behaviour or functionality label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug in behaviour or functionality
Projects
None yet
Development

No branches or pull requests

1 participant