1111import java .nio .charset .StandardCharsets ;
1212import java .security .MessageDigest ;
1313import java .security .NoSuchAlgorithmException ;
14- import java .util .*;
14+ import java .util .Collections ;
15+ import java .util .Set ;
16+ import java .util .Arrays ;
17+ import java .util .HashSet ;
18+ import java .util .ArrayList ;
19+ import java .util .ArrayDeque ;
20+ import java .util .List ;
21+ import java .util .Objects ;
1522
1623@ JsonInclude (JsonInclude .Include .NON_NULL )
1724public class Method {
1825 @ JsonIgnore
19- public static final Set <String > TxArgTypes = new HashSet <>(
20- Arrays .asList (
21- "txn" ,
22- Transaction .Type .Payment .toValue (),
23- Transaction .Type .KeyRegistration .toValue (),
24- Transaction .Type .AssetConfig .toValue (),
25- Transaction .Type .AssetTransfer .toValue (),
26- Transaction .Type .AssetFreeze .toValue (),
27- Transaction .Type .ApplicationCall .toValue ()
26+ public static final String TxAnyType = "txn" ;
27+
28+ @ JsonIgnore
29+ public static final Set <String > TxArgTypes = Collections .unmodifiableSet (
30+ new HashSet <>(
31+ Arrays .asList (
32+ TxAnyType ,
33+ Transaction .Type .Payment .toValue (),
34+ Transaction .Type .KeyRegistration .toValue (),
35+ Transaction .Type .AssetConfig .toValue (),
36+ Transaction .Type .AssetTransfer .toValue (),
37+ Transaction .Type .AssetFreeze .toValue (),
38+ Transaction .Type .ApplicationCall .toValue ()
39+ )
40+ )
41+ );
42+
43+ @ JsonIgnore
44+ public static final String RefTypeAccount = "account" ;
45+
46+ @ JsonIgnore
47+ public static final String RefTypeAsset = "asset" ;
48+
49+ @ JsonIgnore
50+ public static final String RefTypeApplication = "application" ;
51+
52+ @ JsonIgnore
53+ public static final Set <String > RefArgTypes = Collections .unmodifiableSet (
54+ new HashSet <>(
55+ Arrays .asList (RefTypeAccount , RefTypeAsset , RefTypeApplication )
2856 )
2957 );
3058
59+ static boolean isTxnArgOrForeignArrayArgs (String str ) {
60+ return TxArgTypes .contains (str ) || RefArgTypes .contains (str );
61+ }
62+
3163 @ JsonIgnore
3264 private static final String HASH_ALG = "SHA-512/256" ;
3365
@@ -38,7 +70,7 @@ public class Method {
3870 @ JsonProperty ("args" )
3971 public List <Arg > args = new ArrayList <>();
4072 @ JsonProperty ("returns" )
41- public Returns returns = new Returns ("void" , null );
73+ public Returns returns = new Returns (Returns . VoidRetType , null );
4274 @ JsonIgnore
4375 private int txnCallCount = 1 ;
4476
@@ -150,6 +182,9 @@ public boolean equals(Object o) {
150182
151183 @ JsonInclude (JsonInclude .Include .NON_DEFAULT )
152184 public static class Returns {
185+ @ JsonIgnore
186+ public static final String VoidRetType = "void" ;
187+
153188 @ JsonProperty ("type" )
154189 public String type ;
155190 @ JsonProperty ("desc" )
@@ -201,7 +236,7 @@ public Arg(
201236 this .name = name ;
202237 this .desc = desc ;
203238 String typeStr = Objects .requireNonNull (type , "type must not be null" );
204- this .parsedType = Method . TxArgTypes . contains (typeStr ) ? null : ABIType .valueOf (typeStr );
239+ this .parsedType = isTxnArgOrForeignArrayArgs (typeStr ) ? null : ABIType .valueOf (typeStr );
205240 this .type = typeStr ;
206241 }
207242
0 commit comments