From c7c4cd59d271c8175f1744aaa289b752172742df Mon Sep 17 00:00:00 2001 From: "zhanxin.xu" <1329576606@qq.com> Date: Wed, 13 Sep 2023 16:16:09 +0800 Subject: [PATCH 1/3] Fix: buildStructTypes --- .../java/org/web3j/codegen/SolidityFunctionWrapper.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java b/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java index a329d66a6..76e2f3063 100644 --- a/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java +++ b/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java @@ -500,6 +500,15 @@ private List buildStructTypes(final List functionDefini } else { nativeTypeName = buildTypeName(type, useJavaPrimitiveTypes); typeName = getWrapperType(nativeTypeName); + if(type.contains("[")) { + annotationSpec = + AnnotationSpec.builder(Parameterized.class) + .addMember( + "type", + "$T.class", + TypeReference.makeTypeReference(type.substring(0,type.indexOf('['))).getClassType()) + .build(); + } } builder.addField(typeName, component.getName(), Modifier.PUBLIC); constructorBuilder.addParameter(typeName, component.getName()); From 80c0370d3ec55809deacb7e98c5d38a8ebbf2217 Mon Sep 17 00:00:00 2001 From: "zhanxin.xu" <1329576606@qq.com> Date: Wed, 13 Sep 2023 16:58:16 +0800 Subject: [PATCH 2/3] Fix: buildStructTypes --- .../java/org/web3j/codegen/SolidityFunctionWrapper.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java b/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java index 76e2f3063..d451fba18 100644 --- a/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java +++ b/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java @@ -500,13 +500,16 @@ private List buildStructTypes(final List functionDefini } else { nativeTypeName = buildTypeName(type, useJavaPrimitiveTypes); typeName = getWrapperType(nativeTypeName); - if(type.contains("[")) { + if (type.contains("[")) { annotationSpec = AnnotationSpec.builder(Parameterized.class) .addMember( "type", "$T.class", - TypeReference.makeTypeReference(type.substring(0,type.indexOf('['))).getClassType()) + TypeReference.makeTypeReference( + type.substring( + 0, type.indexOf('['))) + .getClassType()) .build(); } } From 044b8a2141d63979c0f80d250f1edd99bc28d447 Mon Sep 17 00:00:00 2001 From: "zhanxin.xu" <1329576606@qq.com> Date: Wed, 13 Sep 2023 17:07:53 +0800 Subject: [PATCH 3/3] Fix: buildStructTypes --- .../solidity/arraysinstruct/build/java/ArraysInStruct.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codegen/src/test/resources/solidity/arraysinstruct/build/java/ArraysInStruct.java b/codegen/src/test/resources/solidity/arraysinstruct/build/java/ArraysInStruct.java index a87b287db..9468b4373 100644 --- a/codegen/src/test/resources/solidity/arraysinstruct/build/java/ArraysInStruct.java +++ b/codegen/src/test/resources/solidity/arraysinstruct/build/java/ArraysInStruct.java @@ -19,6 +19,7 @@ import org.web3j.abi.datatypes.generated.Int256; import org.web3j.abi.datatypes.generated.StaticArray5; import org.web3j.abi.datatypes.generated.Uint256; +import org.web3j.abi.datatypes.reflection.Parameterized; import org.web3j.crypto.Credentials; import org.web3j.protocol.Web3j; import org.web3j.protocol.core.RemoteFunctionCall; @@ -209,7 +210,7 @@ public Entity(byte[] bytesField, byte[] extraData, List stringArrayField this.addressArrayFieldStatic = addressArrayFieldStatic; } - public Entity(DynamicBytes bytesField, Bytes32 extraData, DynamicArray stringArrayField, DynamicArray bytesArrayField, DynamicArray bytes2ArrayField, DynamicArray bytes32ArrayField, DynamicArray unitArrayField, DynamicArray unit256ArrayField, DynamicArray boolField, DynamicArray intArrayField, DynamicArray
addressArrayField, StaticArray5 stringArrayFieldStatic, StaticArray5 bytesArrayFieldStatic, StaticArray5 bytes2ArrayFieldStatic, StaticArray5 bytes32ArrayFieldStatic, StaticArray5 unitArrayFieldStatic, StaticArray5 unit256ArrayFieldStatic, StaticArray5 boolFieldStatic, StaticArray5 intArrayFieldStatic, StaticArray5
addressArrayFieldStatic) { + public Entity(DynamicBytes bytesField, Bytes32 extraData, @Parameterized(type = Utf8String.class) DynamicArray stringArrayField, @Parameterized(type = DynamicBytes.class) DynamicArray bytesArrayField, @Parameterized(type = Bytes2.class) DynamicArray bytes2ArrayField, @Parameterized(type = Bytes32.class) DynamicArray bytes32ArrayField, @Parameterized(type = Uint256.class) DynamicArray unitArrayField, @Parameterized(type = Uint256.class) DynamicArray unit256ArrayField, @Parameterized(type = Bool.class) DynamicArray boolField, @Parameterized(type = Int256.class) DynamicArray intArrayField, @Parameterized(type = Address.class) DynamicArray
addressArrayField, @Parameterized(type = Utf8String.class) StaticArray5 stringArrayFieldStatic, @Parameterized(type = DynamicBytes.class) StaticArray5 bytesArrayFieldStatic, @Parameterized(type = Bytes2.class) StaticArray5 bytes2ArrayFieldStatic, @Parameterized(type = Bytes32.class) StaticArray5 bytes32ArrayFieldStatic, @Parameterized(type = Uint256.class) StaticArray5 unitArrayFieldStatic, @Parameterized(type = Uint256.class) StaticArray5 unit256ArrayFieldStatic, @Parameterized(type = Bool.class) StaticArray5 boolFieldStatic, @Parameterized(type = Int256.class) StaticArray5 intArrayFieldStatic, @Parameterized(type = Address.class) StaticArray5
addressArrayFieldStatic) { super(bytesField, extraData, stringArrayField, bytesArrayField, bytes2ArrayField, bytes32ArrayField, unitArrayField, unit256ArrayField, boolField, intArrayField, addressArrayField, stringArrayFieldStatic, bytesArrayFieldStatic, bytes2ArrayFieldStatic, bytes32ArrayFieldStatic, unitArrayFieldStatic, unit256ArrayFieldStatic, boolFieldStatic, intArrayFieldStatic, addressArrayFieldStatic); this.bytesField = bytesField.getValue(); this.extraData = extraData.getValue();