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

Structs arrays support #1321

Merged
merged 41 commits into from
Jan 8, 2021

Conversation

rach-id
Copy link
Contributor

@rach-id rach-id commented Dec 31, 2020

What does this PR do?

Adds support for:

  • Arrays of structs
  • Multiple structs returns

Where should the reviewer start?

Abi encoder/decoder and check the encoding formal specification

Why is it needed?

More and more users are using structs in their Solidity smart contracts

@rach-id rach-id marked this pull request as draft December 31, 2020 02:26
@iikirilov-wmt
Copy link

test coverage looks good - needs a spotless apply

@rach-id
Copy link
Contributor Author

rach-id commented Dec 31, 2020

Still needs more encoding tests with different functions and also codegen module update to generate arrays of structs code.

@rach-id
Copy link
Contributor Author

rach-id commented Jan 4, 2021

Limitation

@xaviarias xaviarias merged commit 87d2446 into hyperledger-web3j:master Jan 8, 2021
rach-id added a commit to rach-id/web3j that referenced this pull request Dec 10, 2021
* adds structs arrays fixtures to AbiV2TestFixture

* Adds necessary AbiV2 functions for testing

* Adds Abi Decoder tests

* Adds Structs array + multiple structs returns decoder

* fixes String padded length size

* adds type name return for structs when getting simple name

* Adds structs encoder tests

* Adds structs encoder

* adds struct type to AbiTypes

* imports cleanup

* spotless

* Utils refactor

* fix array of structs creation by the decoder

* fix structs array encoding

* imports fix

* add support for array of structs wrapper generation

* make the convert to native function support arrays of structs

* add getTypeAsString java doc

* fix getTypeAsString to support structs arrays

* add encoder structs array tests

* add codegen structs array wrapper generation test

* cosmetics

* spotless + cosmetics

* suppress warnings + remove unnecessary sout

* suppress warnings + remove unnecessary sout

* update ComplexStorage.sol to use arrays of structs

* cosmetics

* fixes dynamic byte arrays prefixed their length encoding in structs.

* structs dynamic values tweak + add tests for dynamic struct containing dynamic bytes array

* fixes encoding of array strings + adds tests

* fixes byte types padded length

* cosmetics

* spotless

* fix isParametrizedTypeStaticStruct

* remove unnecessary function

* fixes dynamic type in static array + adds tests

* adds more encoder tests

* fixes static array with static struct decoder

* adds static/dynamic array with static struct encoder test

* suppress warnings + java docs + cosmetics

* javadocs + spotless
@874341642
Copy link

874341642 commented Jun 12, 2022

What does this PR do?

Adds support for:


abi

"outputs": [{
"components": [ {
"internalType": "uint256[]",
"name": "blocks",
"type": "uint256[]"
}],
"internalType": "struct Mining.PlayerWork",
"name": "",
"type": "tuple"
}]

java

public PlayerWork(DynamicArray< Uint256 > blocks) {
super(blocks);
}

Error info

java.lang.UnsupportedOperationException: Array types must be wrapped in a TypeReference

Bug?Bug?Bug?Bug?Bug?Bug?Bug?Bug?

@rach-id
Copy link
Contributor Author

rach-id commented Jun 12, 2022

@874341642 Please open a new issue with this case, and provide more information on solidity version, compiler used etc.
I personally don't think I will have time to pick this up in upcoming months. But, if somebody else did, I would be happy to provide context and review.

@rach-id rach-id deleted the structs_arrays_support branch June 12, 2022 03:26
@874341642
Copy link

The tuple contains arrays, what do I need to do to solve this problem?

@874341642 Please open a new issue with this case, and provide more information on solidity version, compiler used etc. I personally don't think I will have time to pick this up in upcoming months. But, if somebody else did, I would be happy to provide context and review.

The tuple contains arrays, what do I need to do to solve this problem?

@874341642
Copy link

@874341642 Please open a new issue with this case, and provide more information on solidity version, compiler used etc. I personally don't think I will have time to pick this up in upcoming months. But, if somebody else did, I would be happy to provide context and review.

Please help me

@tonghoang196
Copy link

tonghoang196 commented Oct 29, 2022

when is this included in the new version? I am using this dependency

<dependency>
    <groupId>org.web3j</groupId>
    <artifactId>core</artifactId>
    <version>4.9.4</version>
</dependency>

and web3j version: Version: 1.4.2, still have error Unsupported type encountered: tuple

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.

5 participants