11
11
import java .nio .charset .StandardCharsets ;
12
12
import java .security .MessageDigest ;
13
13
import 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 ;
15
22
16
23
@ JsonInclude (JsonInclude .Include .NON_NULL )
17
24
public class Method {
18
25
@ 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 )
28
56
)
29
57
);
30
58
59
+ static boolean isTxnArgOrForeignArrayArgs (String str ) {
60
+ return TxArgTypes .contains (str ) || RefArgTypes .contains (str );
61
+ }
62
+
31
63
@ JsonIgnore
32
64
private static final String HASH_ALG = "SHA-512/256" ;
33
65
@@ -38,7 +70,7 @@ public class Method {
38
70
@ JsonProperty ("args" )
39
71
public List <Arg > args = new ArrayList <>();
40
72
@ JsonProperty ("returns" )
41
- public Returns returns = new Returns ("void" , null );
73
+ public Returns returns = new Returns (Returns . VoidRetType , null );
42
74
@ JsonIgnore
43
75
private int txnCallCount = 1 ;
44
76
@@ -150,6 +182,9 @@ public boolean equals(Object o) {
150
182
151
183
@ JsonInclude (JsonInclude .Include .NON_DEFAULT )
152
184
public static class Returns {
185
+ @ JsonIgnore
186
+ public static final String VoidRetType = "void" ;
187
+
153
188
@ JsonProperty ("type" )
154
189
public String type ;
155
190
@ JsonProperty ("desc" )
@@ -201,7 +236,7 @@ public Arg(
201
236
this .name = name ;
202
237
this .desc = desc ;
203
238
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 );
205
240
this .type = typeStr ;
206
241
}
207
242
0 commit comments