Skip to content

Commit

Permalink
Deprecate *_TEAL_VERSION in favor of *_PROGRAM_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtzmn committed Jul 13, 2022
1 parent 56aa075 commit 3454808
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
6 changes: 6 additions & 0 deletions pyteal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
MAX_TEAL_VERSION,
MIN_TEAL_VERSION,
DEFAULT_TEAL_VERSION,
MAX_PROGRAM_VERSION,
MIN_PROGRAM_VERSION,
DEFAULT_PROGRAM_VERSION,
CompileOptions,
compileTeal,
OptimizeOptions,
Expand All @@ -27,6 +30,9 @@
"MAX_TEAL_VERSION",
"MIN_TEAL_VERSION",
"DEFAULT_TEAL_VERSION",
"MAX_PROGRAM_VERSION",
"MIN_PROGRAM_VERSION",
"DEFAULT_PROGRAM_VERSION",
"CompileOptions",
"compileTeal",
"OptimizeOptions",
Expand Down
6 changes: 6 additions & 0 deletions pyteal/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ from pyteal.compiler import (
MAX_TEAL_VERSION,
MIN_TEAL_VERSION,
DEFAULT_TEAL_VERSION,
MAX_PROGRAM_VERSION,
MIN_PROGRAM_VERSION,
DEFAULT_PROGRAM_VERSION,
CompileOptions,
compileTeal,
OptimizeOptions,
Expand Down Expand Up @@ -67,6 +70,7 @@ __all__ = [
"Concat",
"Cond",
"Continue",
"DEFAULT_PROGRAM_VERSION",
"DEFAULT_TEAL_VERSION",
"Div",
"Divw",
Expand Down Expand Up @@ -115,7 +119,9 @@ __all__ = [
"Log",
"Lt",
"MAX_GROUP_SIZE",
"MAX_PROGRAM_VERSION",
"MAX_TEAL_VERSION",
"MIN_PROGRAM_VERSION",
"MIN_TEAL_VERSION",
"MaybeValue",
"MethodSignature",
Expand Down
6 changes: 6 additions & 0 deletions pyteal/compiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
MAX_TEAL_VERSION,
MIN_TEAL_VERSION,
DEFAULT_TEAL_VERSION,
MAX_PROGRAM_VERSION,
MIN_PROGRAM_VERSION,
DEFAULT_PROGRAM_VERSION,
CompileOptions,
compileTeal,
)
Expand All @@ -12,6 +15,9 @@
"MAX_TEAL_VERSION",
"MIN_TEAL_VERSION",
"DEFAULT_TEAL_VERSION",
"MAX_PROGRAM_VERSION",
"MIN_PROGRAM_VERSION",
"DEFAULT_PROGRAM_VERSION",
"CompileOptions",
"compileTeal",
"OptimizeOptions",
Expand Down
22 changes: 15 additions & 7 deletions pyteal/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,25 @@
)
from pyteal.compiler.constants import createConstantBlocks

MAX_TEAL_VERSION = 6
MIN_TEAL_VERSION = 2
DEFAULT_TEAL_VERSION = MIN_TEAL_VERSION
MAX_PROGRAM_VERSION = 6
MIN_PROGRAM_VERSION = 2
DEFAULT_PROGRAM_VERSION = MIN_PROGRAM_VERSION


"""Deprecated. Use MAX_PROGRAM_VERSION instead."""
MAX_TEAL_VERSION = MAX_PROGRAM_VERSION
"""Deprecated. Use MIN_PROGRAM_VERSION instead."""
MIN_TEAL_VERSION = MIN_PROGRAM_VERSION
"""Deprecated. Use DEFAULT_PROGRAM_VERSION instead."""
DEFAULT_TEAL_VERSION = DEFAULT_PROGRAM_VERSION


class CompileOptions:
def __init__(
self,
*,
mode: Mode = Mode.Signature,
version: int = DEFAULT_TEAL_VERSION,
version: int = DEFAULT_PROGRAM_VERSION,
optimize: OptimizeOptions = None,
) -> None:
self.mode = mode
Expand Down Expand Up @@ -192,7 +200,7 @@ def compileTeal(
ast: Expr,
mode: Mode,
*,
version: int = DEFAULT_TEAL_VERSION,
version: int = DEFAULT_PROGRAM_VERSION,
assembleConstants: bool = False,
optimize: OptimizeOptions = None,
) -> str:
Expand All @@ -219,12 +227,12 @@ def compileTeal(
TealInternalError: if an internal error is encounter during compilation.
"""
if (
not (MIN_TEAL_VERSION <= version <= MAX_TEAL_VERSION)
not (MIN_PROGRAM_VERSION <= version <= MAX_PROGRAM_VERSION)
or type(version) is not int
):
raise TealInputError(
"Unsupported program version: {}. Excepted an integer in the range [{}, {}]".format(
version, MIN_TEAL_VERSION, MAX_TEAL_VERSION
version, MIN_PROGRAM_VERSION, MAX_PROGRAM_VERSION
)
)

Expand Down

0 comments on commit 3454808

Please sign in to comment.