web3j
web3j copied to clipboard
fixed FunctionEncoder for Array in Struct
What does this PR do?
Pre-condition : array in Struct
struct FooArrayInStruct {
uint256[] fooIntArray;
string[] fooStringArray;
bytes[] fooBytesArray;
}
Action : FunctionEncoder.buildMethodSignature(Function(FooArrayInStruct))
✅ Expected
{method-name}((uint256[],string[],bytes[]))
🟥 Actual
{method-name}((dynamicarray,dynamicarray,dynamicarray))
If array is wrapped in struct, the signature of parameter isn't converted proper type's array but dynamicarray or staticarray.
Where should the reviewer start?
- Check
FooArrayInStruct
inAbiV2TestFixture.java
- Check
DynamicStruct.java
&StaticStruct.java
- Check or run
DefaultFunctionEncoderTest.testArrayInStruct()
Why is it needed?
Oct 2021 (https://github.com/web3j/web3j/issues/1526) Dec 2021 (https://github.com/web3j/web3j/issues/1588), there was various reports but not fixed yet. I also faced same issue and found how to fix.
Please kindly consider and review. Hopefully merge into next release.
~~checking build status~~ ✅ Done.
Both StaticArray
and DynamicArray
have the same problem, there should be the same solution to it.
expect
uint256[2][]
but gotstaticarray2[]
When it comes to StaticArray0
or DynamicArray
contains nothing, just check the size of values in advance to see if should use getTypeAsString
or not.
any update?
Due to #1738 merging, My PR is unnecessary anymore. So I closed it.