Skip to content

Commit

Permalink
Merge branch 'release/1.22.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
algobarb committed Dec 6, 2022
2 parents 4c4969d + 5362aaf commit 94032f7
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 339 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 1.22.0

### Bugfixes
* BugFix: Fix incorrect reference to global schema by @barnjamin in https://github.com/algorand/java-algorand-sdk/pull/427
* Bug-Fix: parsing type strings for tuples containing static arrays of tuples by @ahangsu in https://github.com/algorand/java-algorand-sdk/pull/431
### Enhancements
* REST API: Add KV counts to NodeStatusResponse by @github-actions in https://github.com/algorand/java-algorand-sdk/pull/428
* Enhancement: Migrate v1 algod dependencies to v2 in cucumber tests by @ahangsu in https://github.com/algorand/java-algorand-sdk/pull/425
* Enhancement: Allowing zero length in static array by @ahangsu in https://github.com/algorand/java-algorand-sdk/pull/432


**Full Changelog**: https://github.com/algorand/java-algorand-sdk/compare/1.21.1...1.22.0

# 1.21.1

## What's Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Maven:
<dependency>
<groupId>com.algorand</groupId>
<artifactId>algosdk</artifactId>
<version>1.21.1</version>
<version>1.22.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.algorand</groupId>
<artifactId>algosdk</artifactId>
<version>1.21.1</version>
<version>1.22.0</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/com/algorand/algosdk/abi/ABIType.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ public static List<String> parseTupleContent(String str) {
return new ArrayList<>();

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

if (str.contains(",,"))
throw new IllegalArgumentException("parsing error: tuple content should not have consecutive commas");
Expand All @@ -118,8 +118,15 @@ else if (str.charAt(i) == ')') {
if (parenStack.isEmpty())
throw new IllegalArgumentException("parsing error: tuple parentheses are not balanced: " + str);
int leftParenIndex = parenStack.pop();
if (parenStack.isEmpty())
if (parenStack.isEmpty()) {
// iterate through the byte str, include all the bytes after closing round bracket, for array indicator
// increase the index until it meets comma, or end of string
int forwardIndex = i + 1;
while (forwardIndex < str.length() && str.charAt(forwardIndex) != ',')
forwardIndex++;
i = forwardIndex - 1;
parenSegments.add(new Segment(leftParenIndex, i));
}
}
}
if (!parenStack.isEmpty())
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/algorand/algosdk/abi/TypeArrayStatic.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public class TypeArrayStatic extends ABIType {
public final int length;

public TypeArrayStatic(ABIType elemType, int length) {
if (length < 1)
throw new IllegalArgumentException("static-array initialize failure: array length should be at least 1");
if (length < 0)
throw new IllegalArgumentException("static-array initialize failure: array length should be non-negative");
this.elemType = elemType;
this.length = length;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ public Transaction(
if (foreignAssets != null) this.foreignAssets = foreignAssets;
if (globalStateSchema != null) this.globalStateSchema = globalStateSchema;
if (applicationId != null) this.applicationId = applicationId;
if (localStateSchema != null) this.localStateSchema = globalStateSchema;
if (localStateSchema != null) this.localStateSchema = localStateSchema;
if (clearStateProgram != null) this.clearStateProgram = clearStateProgram;
if (extraPages != null) this.extraPages = extraPages;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public class NodeStatusResponse extends PathResponse {
@JsonProperty("catchpoint-processed-accounts")
public Long catchpointProcessedAccounts;

/**
* The number of key-values (KVs) from the current catchpoint that have been
* processed so far as part of the catchup
*/
@JsonProperty("catchpoint-processed-kvs")
public Long catchpointProcessedKvs;

/**
* The total number of accounts included in the current catchpoint
*/
Expand All @@ -40,13 +47,26 @@ public class NodeStatusResponse extends PathResponse {
@JsonProperty("catchpoint-total-blocks")
public Long catchpointTotalBlocks;

/**
* The total number of key-values (KVs) included in the current catchpoint
*/
@JsonProperty("catchpoint-total-kvs")
public Long catchpointTotalKvs;

/**
* The number of accounts from the current catchpoint that have been verified so
* far as part of the catchup
*/
@JsonProperty("catchpoint-verified-accounts")
public Long catchpointVerifiedAccounts;

/**
* The number of key-values (KVs) from the current catchpoint that have been
* verified so far as part of the catchup
*/
@JsonProperty("catchpoint-verified-kvs")
public Long catchpointVerifiedKvs;

/**
* CatchupTime in nanoseconds
*/
Expand Down Expand Up @@ -113,9 +133,12 @@ public boolean equals(Object o) {
if (!Objects.deepEquals(this.catchpoint, other.catchpoint)) return false;
if (!Objects.deepEquals(this.catchpointAcquiredBlocks, other.catchpointAcquiredBlocks)) return false;
if (!Objects.deepEquals(this.catchpointProcessedAccounts, other.catchpointProcessedAccounts)) return false;
if (!Objects.deepEquals(this.catchpointProcessedKvs, other.catchpointProcessedKvs)) return false;
if (!Objects.deepEquals(this.catchpointTotalAccounts, other.catchpointTotalAccounts)) return false;
if (!Objects.deepEquals(this.catchpointTotalBlocks, other.catchpointTotalBlocks)) return false;
if (!Objects.deepEquals(this.catchpointTotalKvs, other.catchpointTotalKvs)) return false;
if (!Objects.deepEquals(this.catchpointVerifiedAccounts, other.catchpointVerifiedAccounts)) return false;
if (!Objects.deepEquals(this.catchpointVerifiedKvs, other.catchpointVerifiedKvs)) return false;
if (!Objects.deepEquals(this.catchupTime, other.catchupTime)) return false;
if (!Objects.deepEquals(this.lastCatchpoint, other.lastCatchpoint)) return false;
if (!Objects.deepEquals(this.lastRound, other.lastRound)) return false;
Expand Down
50 changes: 49 additions & 1 deletion src/test/java/com/algorand/algosdk/abi/TestTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,54 @@ public void TestTypeFromStringValid() {
)
)
);
assertThat(ABIType.valueOf("(uint32,(uint64,bool)[10],byte)")).isEqualTo(
new TypeTuple(
Arrays.asList(
new TypeUint(32),
new TypeArrayStatic(
new TypeTuple(
Arrays.asList(
new TypeUint(64),
new TypeBool()
)
),
10),
new TypeByte()
)
)
);
assertThat(ABIType.valueOf("(uint32,byte,(uint64,bool)[10])")).isEqualTo(
new TypeTuple(
Arrays.asList(
new TypeUint(32),
new TypeByte(),
new TypeArrayStatic(
new TypeTuple(
Arrays.asList(
new TypeUint(64),
new TypeBool()
)
),
10)
)
)
);
assertThat(ABIType.valueOf("((uint64,bool)[10],uint32,byte)")).isEqualTo(
new TypeTuple(
Arrays.asList(
new TypeArrayStatic(
new TypeTuple(
Arrays.asList(
new TypeUint(64),
new TypeBool()
)
),
10),
new TypeUint(32),
new TypeByte()
)
)
);
}

@Test
Expand Down Expand Up @@ -266,7 +314,7 @@ public void TestTypeFromStringInvalid() {
"[][][]",
"stuff[]",
// static array
"ufixed32x10[0]",
"bool[01]",
"byte[10 ]",
"uint64[0x21]",
// tuple
Expand Down
Loading

0 comments on commit 94032f7

Please sign in to comment.