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 static array #698

Merged
merged 4 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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"
SDK_TESTING_HARNESS="test-harness"

INSTALL_ONLY=0
Expand Down
6 changes: 3 additions & 3 deletions src/abi/abi_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface Segment {
right: number;
}

const staticArrayRegexp = /^([a-z\d[\](),]+)\[([1-9][\d]*)]$/;
const staticArrayRegexp = /^([a-z\d[\](),]+)\[(0|[1-9][\d]*)]$/;
const ufixedRegexp = /^ufixed([1-9][\d]*)x([1-9][\d]*)$/;

export type ABIValue =
Expand Down Expand Up @@ -414,9 +414,9 @@ export class ABIArrayStaticType extends ABIType {

constructor(argType: ABIType, arrayLength: number) {
super();
if (arrayLength < 1) {
if (arrayLength < 0) {
throw new Error(
`static array must have a length greater than 0: ${arrayLength}`
`static array must have a non negative length: ${arrayLength}`
);
}
this.childType = argType;
Expand Down
1 change: 0 additions & 1 deletion tests/10.ABI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ describe('ABI type checking', () => {
'[][][]',
'stuff[]',
// static array
'ufixed32x10[0]',
'byte[10 ]',
'uint64[0x21]',
// tuple
Expand Down