Skip to content

Commit b79ae34

Browse files
committed
Merge branch 'release/1.11.0-beta-2'
2 parents 88d88b0 + 7ae8485 commit b79ae34

File tree

18 files changed

+621
-158
lines changed

18 files changed

+621
-158
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.11.0-beta-2
2+
- Support Foreign objects as ABI arguments (#283)
3+
- Upgrade `jackson` packages to resolve PRs on vulnerability (#281)
4+
15
# 1.11.0-beta-1
26
- ABI Interaction Support for JAVA SDK (#268)
37
- Bug fix for `logs` on `PendingTransactionResponse` (#275)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Maven:
2323
<dependency>
2424
<groupId>com.algorand</groupId>
2525
<artifactId>algosdk</artifactId>
26-
<version>1.11.0-beta-1</version>
26+
<version>1.11.0-beta-2</version>
2727
</dependency>
2828
```
2929

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.algorand</groupId>
66
<artifactId>algosdk</artifactId>
7-
<version>1.11.0-beta-1</version>
7+
<version>1.11.0-beta-2</version>
88
<packaging>jar</packaging>
99

1010
<name>${project.groupId}:${project.artifactId}</name>
@@ -55,17 +55,17 @@
5555
<dependency>
5656
<groupId>com.fasterxml.jackson.core</groupId>
5757
<artifactId>jackson-annotations</artifactId>
58-
<version>2.9.9</version>
58+
<version>2.10.0</version>
5959
</dependency>
6060
<dependency>
6161
<groupId>com.fasterxml.jackson.core</groupId>
6262
<artifactId>jackson-core</artifactId>
63-
<version>2.9.9</version>
63+
<version>2.10.0</version>
6464
</dependency>
6565
<dependency>
6666
<groupId>com.fasterxml.jackson.core</groupId>
6767
<artifactId>jackson-databind</artifactId>
68-
<version>2.9.9.3</version>
68+
<version>2.10.5.1</version>
6969
</dependency>
7070
<dependency>
7171
<groupId>com.google.code.gson</groupId>

src/main/java/com/algorand/algosdk/abi/ABIType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package com.algorand.algosdk.abi;
22

33
import java.lang.reflect.Array;
4-
import java.util.*;
4+
import java.util.Arrays;
5+
import java.util.List;
6+
import java.util.ArrayList;
7+
import java.util.ArrayDeque;
58
import java.util.regex.Matcher;
69
import java.util.regex.Pattern;
710

src/main/java/com/algorand/algosdk/abi/Contract.java

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.fasterxml.jackson.annotation.JsonInclude;
66
import com.fasterxml.jackson.annotation.JsonProperty;
77

8+
import java.util.HashMap;
9+
import java.util.Map;
810
import java.util.ArrayList;
911
import java.util.List;
1012
import java.util.Objects;
@@ -13,19 +15,23 @@
1315
public class Contract {
1416
@JsonProperty("name")
1517
public String name;
16-
@JsonProperty("appId")
17-
public Integer appId;
18+
@JsonProperty("desc")
19+
public String description;
20+
@JsonProperty("networks")
21+
public Map<String, NetworkInfo> networks = new HashMap<>();
1822
@JsonProperty("methods")
1923
public List<Method> methods = new ArrayList<>();
2024

2125
@JsonCreator
2226
public Contract(
2327
@JsonProperty("name") String name,
24-
@JsonProperty("appId") Integer appId,
28+
@JsonProperty("desc") String description,
29+
@JsonProperty("networks") Map<String, NetworkInfo> networks,
2530
@JsonProperty("methods") List<Method> methods
2631
) {
2732
this.name = Objects.requireNonNull(name, "name must not be null");
28-
this.appId = Objects.requireNonNull(appId, "name must not be null");
33+
this.description = description;
34+
if (networks != null) this.networks = networks;
2935
if (methods != null) this.methods = methods;
3036
}
3137

@@ -35,8 +41,13 @@ public String getName() {
3541
}
3642

3743
@JsonIgnore
38-
public Integer getAppId() {
39-
return this.appId;
44+
public String getDescription() {
45+
return this.description;
46+
}
47+
48+
@JsonIgnore
49+
public NetworkInfo getNetworkInfo(String genesisHash) {
50+
return this.networks.get(genesisHash);
4051
}
4152

4253
@JsonIgnore
@@ -48,6 +59,25 @@ public Method getMethodByIndex(int index) {
4859
public boolean equals(Object o) {
4960
if (o == null || getClass() != o.getClass()) return false;
5061
Contract contract = (Contract) o;
51-
return Objects.equals(name, contract.name) && Objects.equals(appId, contract.appId) && Objects.equals(methods, contract.methods);
62+
return Objects.equals(name, contract.name) && Objects.equals(methods, contract.methods) &&
63+
Objects.equals(description, contract.description) && Objects.equals(networks, contract.networks);
64+
}
65+
66+
@JsonInclude(JsonInclude.Include.NON_NULL)
67+
static public class NetworkInfo {
68+
@JsonProperty("appID")
69+
public Long appID;
70+
71+
@JsonCreator
72+
public NetworkInfo(@JsonProperty("appID") Long appID) {
73+
this.appID = Objects.requireNonNull(appID, "appID must not be null");
74+
}
75+
76+
@Override
77+
public boolean equals(Object o) {
78+
if (o == null || o.getClass() != getClass()) return false;
79+
NetworkInfo other = (NetworkInfo) o;
80+
return Objects.equals(appID, other.appID);
81+
}
5282
}
5383
}

src/main/java/com/algorand/algosdk/abi/Interface.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@
1313
public class Interface {
1414
@JsonProperty("name")
1515
public String name;
16+
@JsonProperty("desc")
17+
public String description;
1618
@JsonProperty("methods")
1719
public List<Method> methods = new ArrayList<>();
1820

1921
@JsonCreator
2022
public Interface(
2123
@JsonProperty("name") String name,
24+
@JsonProperty("desc") String description,
2225
@JsonProperty("methods") List<Method> methods
2326
) {
2427
this.name = Objects.requireNonNull(name, "name must not be null");
28+
this.description = description;
2529
if (methods != null) this.methods = methods;
2630
}
2731

@@ -30,6 +34,11 @@ public String getName() {
3034
return this.name;
3135
}
3236

37+
@JsonIgnore
38+
public String getDescription() {
39+
return this.description;
40+
}
41+
3342
@JsonIgnore
3443
public Method getMethodByIndex(int index) {
3544
return this.methods.get(index);

src/main/java/com/algorand/algosdk/abi/Method.java

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,55 @@
1111
import java.nio.charset.StandardCharsets;
1212
import java.security.MessageDigest;
1313
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;
1522

1623
@JsonInclude(JsonInclude.Include.NON_NULL)
1724
public 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

src/main/java/com/algorand/algosdk/account/Account.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,7 @@ public int hashCode() {
695695
}
696696

697697
@Override
698-
public SignedTransaction[] signTxnGroup(Transaction[] txnGroup, int[] indicesToSign)
699-
throws Exception {
698+
public SignedTransaction[] signTxnGroup(Transaction[] txnGroup, int[] indicesToSign) throws Exception {
700699
SignedTransaction[] sTxn = new SignedTransaction[indicesToSign.length];
701700
for (int i = 0; i < indicesToSign.length; i++)
702701
sTxn[i] = self.signTransaction(txnGroup[indicesToSign[i]]);

0 commit comments

Comments
 (0)