Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Allowing zero length in static array #432

Merged
merged 8 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .test-env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configs for testing repo download:
SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing"
SDK_TESTING_BRANCH="master"
SDK_TESTING_BRANCH="zero-length"
ahangsu marked this conversation as resolved.
Show resolved Hide resolved
SDK_TESTING_HARNESS="test-harness"

INSTALL_ONLY=0
Expand Down
2 changes: 1 addition & 1 deletion 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]*)]$");
ahangsu marked this conversation as resolved.
Show resolved Hide resolved
private static final Pattern ufixedPattern = Pattern.compile("^ufixed(?<size>[1-9][\\d]*)x(?<precision>[1-9][\\d]*)$");

/**
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
2 changes: 1 addition & 1 deletion src/test/java/com/algorand/algosdk/abi/TestTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public void TestTypeFromStringInvalid() {
"[][][]",
"stuff[]",
// static array
"ufixed32x10[0]",
"bool[01]",
bbroder-algo marked this conversation as resolved.
Show resolved Hide resolved
"byte[10 ]",
"uint64[0x21]",
// tuple
Expand Down