@@ -33,7 +33,7 @@ interface JSONStructTypeDescription {
33
33
address : string ;
34
34
module : string ;
35
35
name : string ;
36
- type_args : string [ ] ;
36
+ type_args : JSONBaseType [ ] ;
37
37
}
38
38
39
39
interface JSONStructType {
@@ -882,10 +882,38 @@ function processInstructionIfMacro(
882
882
}
883
883
884
884
885
-
885
+ /**
886
+ * Converts a JSON trace compound type to a string representation.
887
+ * @param refPrefix prefix for the reference type.
888
+ * @param address address of the package.
889
+ * @param module name of the module.
890
+ * @param name name of the type.
891
+ * @param typeArgs type arguments of the compound type.
892
+ * @returns string representation of the compound type.
893
+ * */
894
+ function JSONCompoundTypeToString (
895
+ refPrefix : string ,
896
+ address : string ,
897
+ module : string ,
898
+ name : string ,
899
+ typeArgs : JSONBaseType [ ]
900
+ ) : string {
901
+ return refPrefix
902
+ + JSONTraceAddressToHexString ( address )
903
+ + '::'
904
+ + module
905
+ + '::'
906
+ + name
907
+ + ( typeArgs . length === 0
908
+ ? ''
909
+ : '<' + typeArgs . map ( ( t ) => JSONTraceTypeToString ( t ) ) . join ( ',' ) + '>' ) ;
910
+ }
886
911
887
912
/**
888
913
* Converts a JSON trace type to a string representation.
914
+ * @param baseType base type.
915
+ * @param refType reference type.
916
+ * @returns string representation of the type.
889
917
*/
890
918
function JSONTraceTypeToString ( baseType : JSONBaseType , refType ?: JSONTraceRefType ) : string {
891
919
const refPrefix = refType === JSONTraceRefType . Mut
@@ -898,19 +926,17 @@ function JSONTraceTypeToString(baseType: JSONBaseType, refType?: JSONTraceRefTyp
898
926
} else if ( 'vector' in baseType ) {
899
927
return refPrefix + `vector<${ JSONTraceTypeToString ( baseType . vector ) } >` ;
900
928
} else if ( 'struct' in baseType ) {
901
- return refPrefix
902
- + JSONTraceAddressToHexString ( baseType . struct . address )
903
- + "::"
904
- + baseType . struct . module
905
- + "::"
906
- + baseType . struct . name ;
929
+ return JSONCompoundTypeToString ( refPrefix ,
930
+ baseType . struct . address ,
931
+ baseType . struct . module ,
932
+ baseType . struct . name ,
933
+ baseType . struct . type_args ) ;
907
934
} else {
908
- return refPrefix
909
- + JSONTraceAddressToHexString ( baseType . address )
910
- + "::"
911
- + baseType . module
912
- + "::"
913
- + baseType . name ;
935
+ return JSONCompoundTypeToString ( refPrefix ,
936
+ baseType . address ,
937
+ baseType . module ,
938
+ baseType . name ,
939
+ baseType . type_args ) ;
914
940
}
915
941
}
916
942
0 commit comments