From 5c49ed358ebe31f430ea4598b6d0d218db0c8c8c Mon Sep 17 00:00:00 2001 From: tonykwok1992 Date: Sun, 16 Jun 2024 16:38:11 +0800 Subject: [PATCH] separate array type handling Signed-off-by: tonykwok1992 --- .../codegen/SolidityFunctionWrapper.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java b/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java index 1127df072..2eeddf4e6 100644 --- a/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java +++ b/codegen/src/main/java/org/web3j/codegen/SolidityFunctionWrapper.java @@ -641,20 +641,34 @@ private List extractStructs( }) .forEach( namedType -> { - structMap.put( - namedType.flattenNamedType().structIdentifier(), namedType); + if (namedType.getType().startsWith("tuple[")) { + structMap.putIfAbsent( + namedType.flattenNamedType().structIdentifier(), namedType); + } else { + structMap.put(namedType.structIdentifier(), namedType); + } + extractNested(namedType).stream() .map(this::normalizeNamedType) .filter( nestedNamedStruct -> nestedNamedStruct.getType().startsWith("tuple")) .forEach( - nestedNamedType -> - structMap.put( + nestedNamedType -> { + if (nestedNamedType + .getType() + .startsWith("tuple[")) { + structMap.putIfAbsent( nestedNamedType .flattenNamedType() .structIdentifier(), - nestedNamedType)); + nestedNamedType); + } else { + structMap.put( + nestedNamedType.structIdentifier(), + nestedNamedType); + } + }); }); return structMap.values().stream()