web3j icon indicating copy to clipboard operation
web3j copied to clipboard

fixed FunctionEncoder for Array in Struct

Open SeongUgJung opened this issue 2 years ago • 3 comments

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?

  1. Check FooArrayInStruct in AbiV2TestFixture.java
  2. Check DynamicStruct.java & StaticStruct.java
  3. 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.

SeongUgJung avatar Jul 04 '22 16:07 SeongUgJung

~~checking build status~~ ✅ Done.

SeongUgJung avatar Jul 20 '22 12:07 SeongUgJung

Both StaticArray and DynamicArray have the same problem, there should be the same solution to it.

expect uint256[2][] but got staticarray2[]

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.

MiRaIOMeZaSu avatar Aug 11 '22 10:08 MiRaIOMeZaSu

any update?

probepark avatar Sep 13 '22 01:09 probepark

Due to #1738 merging, My PR is unnecessary anymore. So I closed it.

SeongUgJung avatar Oct 27 '22 05:10 SeongUgJung