Skip to content

Commit 94032f7

Browse files
committed
Merge branch 'release/1.22.0'
2 parents 4c4969d + 5362aaf commit 94032f7

File tree

13 files changed

+227
-339
lines changed

13 files changed

+227
-339
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# 1.22.0
2+
3+
### Bugfixes
4+
* BugFix: Fix incorrect reference to global schema by @barnjamin in https://github.com/algorand/java-algorand-sdk/pull/427
5+
* Bug-Fix: parsing type strings for tuples containing static arrays of tuples by @ahangsu in https://github.com/algorand/java-algorand-sdk/pull/431
6+
### Enhancements
7+
* REST API: Add KV counts to NodeStatusResponse by @github-actions in https://github.com/algorand/java-algorand-sdk/pull/428
8+
* Enhancement: Migrate v1 algod dependencies to v2 in cucumber tests by @ahangsu in https://github.com/algorand/java-algorand-sdk/pull/425
9+
* Enhancement: Allowing zero length in static array by @ahangsu in https://github.com/algorand/java-algorand-sdk/pull/432
10+
11+
12+
**Full Changelog**: https://github.com/algorand/java-algorand-sdk/compare/1.21.1...1.22.0
13+
114
# 1.21.1
215

316
## What's Changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Maven:
1919
<dependency>
2020
<groupId>com.algorand</groupId>
2121
<artifactId>algosdk</artifactId>
22-
<version>1.21.1</version>
22+
<version>1.22.0</version>
2323
</dependency>
2424
```
2525

pom.xml

+1-1
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.21.1</version>
7+
<version>1.22.0</version>
88
<packaging>jar</packaging>
99

1010
<name>${project.groupId}:${project.artifactId}</name>

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public abstract class ABIType {
1111
public static final int ABI_DYNAMIC_HEAD_BYTE_LEN = 2;
12-
private static final Pattern staticArrayPattern = Pattern.compile("^(?<elemT>[a-z\\d\\[\\](),]+)\\[(?<len>[1-9][\\d]*)]$");
12+
private static final Pattern staticArrayPattern = Pattern.compile("^(?<elemT>[a-z\\d\\[\\](),]+)\\[(?<len>0|[1-9][\\d]*)]$");
1313
private static final Pattern ufixedPattern = Pattern.compile("^ufixed(?<size>[1-9][\\d]*)x(?<precision>[1-9][\\d]*)$");
1414

1515
/**
@@ -103,7 +103,7 @@ public static List<String> parseTupleContent(String str) {
103103
return new ArrayList<>();
104104

105105
if (str.startsWith(",") || str.endsWith(","))
106-
throw new IllegalArgumentException("parsing error: tuple content should not start with comma");
106+
throw new IllegalArgumentException("parsing error: tuple content should not start or end with comma");
107107

108108
if (str.contains(",,"))
109109
throw new IllegalArgumentException("parsing error: tuple content should not have consecutive commas");
@@ -118,8 +118,15 @@ else if (str.charAt(i) == ')') {
118118
if (parenStack.isEmpty())
119119
throw new IllegalArgumentException("parsing error: tuple parentheses are not balanced: " + str);
120120
int leftParenIndex = parenStack.pop();
121-
if (parenStack.isEmpty())
121+
if (parenStack.isEmpty()) {
122+
// iterate through the byte str, include all the bytes after closing round bracket, for array indicator
123+
// increase the index until it meets comma, or end of string
124+
int forwardIndex = i + 1;
125+
while (forwardIndex < str.length() && str.charAt(forwardIndex) != ',')
126+
forwardIndex++;
127+
i = forwardIndex - 1;
122128
parenSegments.add(new Segment(leftParenIndex, i));
129+
}
123130
}
124131
}
125132
if (!parenStack.isEmpty())

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public class TypeArrayStatic extends ABIType {
77
public final int length;
88

99
public TypeArrayStatic(ABIType elemType, int length) {
10-
if (length < 1)
11-
throw new IllegalArgumentException("static-array initialize failure: array length should be at least 1");
10+
if (length < 0)
11+
throw new IllegalArgumentException("static-array initialize failure: array length should be non-negative");
1212
this.elemType = elemType;
1313
this.length = length;
1414
}

src/main/java/com/algorand/algosdk/transaction/Transaction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ public Transaction(
948948
if (foreignAssets != null) this.foreignAssets = foreignAssets;
949949
if (globalStateSchema != null) this.globalStateSchema = globalStateSchema;
950950
if (applicationId != null) this.applicationId = applicationId;
951-
if (localStateSchema != null) this.localStateSchema = globalStateSchema;
951+
if (localStateSchema != null) this.localStateSchema = localStateSchema;
952952
if (clearStateProgram != null) this.clearStateProgram = clearStateProgram;
953953
if (extraPages != null) this.extraPages = extraPages;
954954
}

src/main/java/com/algorand/algosdk/v2/client/model/NodeStatusResponse.java

+23
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ public class NodeStatusResponse extends PathResponse {
2727
@JsonProperty("catchpoint-processed-accounts")
2828
public Long catchpointProcessedAccounts;
2929

30+
/**
31+
* The number of key-values (KVs) from the current catchpoint that have been
32+
* processed so far as part of the catchup
33+
*/
34+
@JsonProperty("catchpoint-processed-kvs")
35+
public Long catchpointProcessedKvs;
36+
3037
/**
3138
* The total number of accounts included in the current catchpoint
3239
*/
@@ -40,13 +47,26 @@ public class NodeStatusResponse extends PathResponse {
4047
@JsonProperty("catchpoint-total-blocks")
4148
public Long catchpointTotalBlocks;
4249

50+
/**
51+
* The total number of key-values (KVs) included in the current catchpoint
52+
*/
53+
@JsonProperty("catchpoint-total-kvs")
54+
public Long catchpointTotalKvs;
55+
4356
/**
4457
* The number of accounts from the current catchpoint that have been verified so
4558
* far as part of the catchup
4659
*/
4760
@JsonProperty("catchpoint-verified-accounts")
4861
public Long catchpointVerifiedAccounts;
4962

63+
/**
64+
* The number of key-values (KVs) from the current catchpoint that have been
65+
* verified so far as part of the catchup
66+
*/
67+
@JsonProperty("catchpoint-verified-kvs")
68+
public Long catchpointVerifiedKvs;
69+
5070
/**
5171
* CatchupTime in nanoseconds
5272
*/
@@ -113,9 +133,12 @@ public boolean equals(Object o) {
113133
if (!Objects.deepEquals(this.catchpoint, other.catchpoint)) return false;
114134
if (!Objects.deepEquals(this.catchpointAcquiredBlocks, other.catchpointAcquiredBlocks)) return false;
115135
if (!Objects.deepEquals(this.catchpointProcessedAccounts, other.catchpointProcessedAccounts)) return false;
136+
if (!Objects.deepEquals(this.catchpointProcessedKvs, other.catchpointProcessedKvs)) return false;
116137
if (!Objects.deepEquals(this.catchpointTotalAccounts, other.catchpointTotalAccounts)) return false;
117138
if (!Objects.deepEquals(this.catchpointTotalBlocks, other.catchpointTotalBlocks)) return false;
139+
if (!Objects.deepEquals(this.catchpointTotalKvs, other.catchpointTotalKvs)) return false;
118140
if (!Objects.deepEquals(this.catchpointVerifiedAccounts, other.catchpointVerifiedAccounts)) return false;
141+
if (!Objects.deepEquals(this.catchpointVerifiedKvs, other.catchpointVerifiedKvs)) return false;
119142
if (!Objects.deepEquals(this.catchupTime, other.catchupTime)) return false;
120143
if (!Objects.deepEquals(this.lastCatchpoint, other.lastCatchpoint)) return false;
121144
if (!Objects.deepEquals(this.lastRound, other.lastRound)) return false;

src/test/java/com/algorand/algosdk/abi/TestTypes.java

+49-1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,54 @@ public void TestTypeFromStringValid() {
238238
)
239239
)
240240
);
241+
assertThat(ABIType.valueOf("(uint32,(uint64,bool)[10],byte)")).isEqualTo(
242+
new TypeTuple(
243+
Arrays.asList(
244+
new TypeUint(32),
245+
new TypeArrayStatic(
246+
new TypeTuple(
247+
Arrays.asList(
248+
new TypeUint(64),
249+
new TypeBool()
250+
)
251+
),
252+
10),
253+
new TypeByte()
254+
)
255+
)
256+
);
257+
assertThat(ABIType.valueOf("(uint32,byte,(uint64,bool)[10])")).isEqualTo(
258+
new TypeTuple(
259+
Arrays.asList(
260+
new TypeUint(32),
261+
new TypeByte(),
262+
new TypeArrayStatic(
263+
new TypeTuple(
264+
Arrays.asList(
265+
new TypeUint(64),
266+
new TypeBool()
267+
)
268+
),
269+
10)
270+
)
271+
)
272+
);
273+
assertThat(ABIType.valueOf("((uint64,bool)[10],uint32,byte)")).isEqualTo(
274+
new TypeTuple(
275+
Arrays.asList(
276+
new TypeArrayStatic(
277+
new TypeTuple(
278+
Arrays.asList(
279+
new TypeUint(64),
280+
new TypeBool()
281+
)
282+
),
283+
10),
284+
new TypeUint(32),
285+
new TypeByte()
286+
)
287+
)
288+
);
241289
}
242290

243291
@Test
@@ -266,7 +314,7 @@ public void TestTypeFromStringInvalid() {
266314
"[][][]",
267315
"stuff[]",
268316
// static array
269-
"ufixed32x10[0]",
317+
"bool[01]",
270318
"byte[10 ]",
271319
"uint64[0x21]",
272320
// tuple

0 commit comments

Comments
 (0)