Skip to content

Commit

Permalink
Merge pull request hyperledger-web3j#1962 from 1329576606/master
Browse files Browse the repository at this point in the history
FIx generateJavaFiles ArrayInStruct
  • Loading branch information
gtebrean authored Sep 19, 2023
2 parents 2a2da15 + 18758b2 commit e0b4b1e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,18 @@ private List<TypeSpec> buildStructTypes(final List<AbiDefinition> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -209,7 +210,7 @@ public Entity(byte[] bytesField, byte[] extraData, List<String> stringArrayField
this.addressArrayFieldStatic = addressArrayFieldStatic;
}

public Entity(DynamicBytes bytesField, Bytes32 extraData, DynamicArray<Utf8String> stringArrayField, DynamicArray<DynamicBytes> bytesArrayField, DynamicArray<Bytes2> bytes2ArrayField, DynamicArray<Bytes32> bytes32ArrayField, DynamicArray<Uint256> unitArrayField, DynamicArray<Uint256> unit256ArrayField, DynamicArray<Bool> boolField, DynamicArray<Int256> intArrayField, DynamicArray<Address> addressArrayField, StaticArray5<Utf8String> stringArrayFieldStatic, StaticArray5<DynamicBytes> bytesArrayFieldStatic, StaticArray5<Bytes2> bytes2ArrayFieldStatic, StaticArray5<Bytes32> bytes32ArrayFieldStatic, StaticArray5<Uint256> unitArrayFieldStatic, StaticArray5<Uint256> unit256ArrayFieldStatic, StaticArray5<Bool> boolFieldStatic, StaticArray5<Int256> intArrayFieldStatic, StaticArray5<Address> addressArrayFieldStatic) {
public Entity(DynamicBytes bytesField, Bytes32 extraData, @Parameterized(type = Utf8String.class) DynamicArray<Utf8String> stringArrayField, @Parameterized(type = DynamicBytes.class) DynamicArray<DynamicBytes> bytesArrayField, @Parameterized(type = Bytes2.class) DynamicArray<Bytes2> bytes2ArrayField, @Parameterized(type = Bytes32.class) DynamicArray<Bytes32> bytes32ArrayField, @Parameterized(type = Uint256.class) DynamicArray<Uint256> unitArrayField, @Parameterized(type = Uint256.class) DynamicArray<Uint256> unit256ArrayField, @Parameterized(type = Bool.class) DynamicArray<Bool> boolField, @Parameterized(type = Int256.class) DynamicArray<Int256> intArrayField, @Parameterized(type = Address.class) DynamicArray<Address> addressArrayField, @Parameterized(type = Utf8String.class) StaticArray5<Utf8String> stringArrayFieldStatic, @Parameterized(type = DynamicBytes.class) StaticArray5<DynamicBytes> bytesArrayFieldStatic, @Parameterized(type = Bytes2.class) StaticArray5<Bytes2> bytes2ArrayFieldStatic, @Parameterized(type = Bytes32.class) StaticArray5<Bytes32> bytes32ArrayFieldStatic, @Parameterized(type = Uint256.class) StaticArray5<Uint256> unitArrayFieldStatic, @Parameterized(type = Uint256.class) StaticArray5<Uint256> unit256ArrayFieldStatic, @Parameterized(type = Bool.class) StaticArray5<Bool> boolFieldStatic, @Parameterized(type = Int256.class) StaticArray5<Int256> intArrayFieldStatic, @Parameterized(type = Address.class) StaticArray5<Address> 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();
Expand Down

0 comments on commit e0b4b1e

Please sign in to comment.