Skip to content

Commit

Permalink
Enhancement: allowing zero length static array (algorand#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangsu committed Nov 29, 2022
1 parent cd91a9a commit 72f2789
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions algosdk/abi/array_static_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class ArrayStaticType(ABIType):
"""

def __init__(self, arg_type: ABIType, array_len: int) -> None:
if array_len < 1:
if array_len < 0:
raise error.ABITypeError(
"static array length must be a positive integer: {}".format(
"static array length {} must be a non-negative integer".format(
array_len
)
)
Expand Down
2 changes: 1 addition & 1 deletion algosdk/abi/base_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Globals
ABI_LENGTH_SIZE = 2 # We use 2 bytes to encode the length of a dynamic element
UFIXED_REGEX = r"^ufixed([1-9][\d]*)x([1-9][\d]*)$"
STATIC_ARRAY_REGEX = r"^([a-z\d\[\](),]+)\[([1-9][\d]*)]$"
STATIC_ARRAY_REGEX = r"^([a-z\d\[\](),]+)\[(0|[1-9][\d]*)]$"


class ABIType(ABC):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_type_from_string_invalid(self):
"[][][]",
"stuff[]",
# static array
"ufixed32x10[0]",
"bool[01]",
"byte[10 ]",
"uint64[0x21]",
# tuple
Expand Down

0 comments on commit 72f2789

Please sign in to comment.