From 3e7fdfdcad5cf79097ce687873d121a4810fda8e Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 15 Apr 2022 12:51:46 -0400 Subject: [PATCH] cr --- pyteal/ast/abi/__init__.py | 3 ++- pyteal/ast/abi/address.py | 6 +++--- pyteal/ast/abi/address_test.py | 6 ++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pyteal/ast/abi/__init__.py b/pyteal/ast/abi/__init__.py index aa670ce4f..0dfefb026 100644 --- a/pyteal/ast/abi/__init__.py +++ b/pyteal/ast/abi/__init__.py @@ -1,5 +1,5 @@ from .string import String, StringTypeSpec -from .address import AddressTypeSpec, Address +from .address import AddressTypeSpec, Address, ADDRESS_LENGTH from .type import TypeSpec, BaseType, ComputedValue from .bool import BoolTypeSpec, Bool from .uint import ( @@ -38,6 +38,7 @@ "StringTypeSpec", "Address", "AddressTypeSpec", + "ADDRESS_LENGTH", "TypeSpec", "BaseType", "ComputedValue", diff --git a/pyteal/ast/abi/address.py b/pyteal/ast/abi/address.py index 83bf9682e..0a95ab6f7 100644 --- a/pyteal/ast/abi/address.py +++ b/pyteal/ast/abi/address.py @@ -2,12 +2,12 @@ from .uint import ByteTypeSpec from ..expr import Expr -address_length = 32 +ADDRESS_LENGTH = 32 class AddressTypeSpec(StaticArrayTypeSpec): def __init__(self) -> None: - super().__init__(ByteTypeSpec(), address_length) + super().__init__(ByteTypeSpec(), ADDRESS_LENGTH) def new_instance(self) -> "Address": return Address() @@ -21,7 +21,7 @@ def __str__(self) -> str: class Address(StaticArray): def __init__(self) -> None: - super().__init__(AddressTypeSpec(), address_length) + super().__init__(AddressTypeSpec(), ADDRESS_LENGTH) def type_spec(self) -> AddressTypeSpec: return AddressTypeSpec() diff --git a/pyteal/ast/abi/address_test.py b/pyteal/ast/abi/address_test.py index 345bb2b2e..e7267a7e8 100644 --- a/pyteal/ast/abi/address_test.py +++ b/pyteal/ast/abi/address_test.py @@ -1,5 +1,3 @@ -from .type_test import ContainerType - from ... import * options = CompileOptions(version=5) @@ -14,7 +12,7 @@ def test_AddressTypeSpec_is_dynamic(): def test_AddressTypeSpec_byte_length_static(): - assert (abi.AddressTypeSpec()).byte_length_static() == 32 + assert (abi.AddressTypeSpec()).byte_length_static() == abi.ADDRESS_LENGTH def test_AddressTypeSpec_new_instance(): @@ -47,7 +45,7 @@ def test_Address_decode(): from os import urandom value = abi.Address() - for value_to_set in [urandom(32) for x in range(10)]: + for value_to_set in [urandom(abi.ADDRESS_LENGTH) for x in range(10)]: expr = value.decode(Bytes(value_to_set)) assert expr.type_of() == TealType.none