From fa81388ac54fecabc52f796b2281258c3750f0b1 Mon Sep 17 00:00:00 2001 From: Jason Paulos Date: Thu, 21 Dec 2023 14:47:12 -0500 Subject: [PATCH] Add box ops --- pyteal/__init__.pyi | 2 + pyteal/ast/__init__.py | 4 + pyteal/ast/box.py | 108 ++++++++++++- pyteal/ast/box_test.py | 80 ++++++++-- pyteal/ir/ops.py | 348 +++++++++++++++++++++-------------------- 5 files changed, 358 insertions(+), 184 deletions(-) diff --git a/pyteal/__init__.pyi b/pyteal/__init__.pyi index 6d0e65680..02dfedb36 100644 --- a/pyteal/__init__.pyi +++ b/pyteal/__init__.pyi @@ -76,6 +76,8 @@ __all__ = [ "BoxLen", "BoxPut", "BoxReplace", + "BoxResize", + "BoxSplice", "Break", "Btoi", "Bytes", diff --git a/pyteal/ast/__init__.py b/pyteal/ast/__init__.py index 587e8ed1d..94595768e 100644 --- a/pyteal/ast/__init__.py +++ b/pyteal/ast/__init__.py @@ -36,9 +36,11 @@ from pyteal.ast.acct import AccountParam, AccountParamObject from pyteal.ast.box import ( BoxCreate, + BoxResize, BoxDelete, BoxExtract, BoxReplace, + BoxSplice, BoxLen, BoxGet, BoxPut, @@ -212,8 +214,10 @@ "BitwiseXor", "Block", "BoxCreate", + "BoxResize", "BoxDelete", "BoxExtract", + "BoxSplice", "BoxGet", "BoxLen", "BoxPut", diff --git a/pyteal/ast/box.py b/pyteal/ast/box.py index 119f7f24e..3e37cd604 100644 --- a/pyteal/ast/box.py +++ b/pyteal/ast/box.py @@ -49,6 +49,49 @@ def has_return(self): BoxCreate.__module__ = "pyteal" +class BoxResize(Expr): + """Resize an existing box. + + If the new size is larger than the old size, zero bytes will be added to the end of the box. + If the new size is smaller than the old size, the box will be truncated from the end. + """ + + def __init__(self, name: Expr, size: Expr) -> None: + """ + Args: + name: The key used to reference this box. Must evaluate to a bytes. + size: The new number of bytes to reserve for this box. Must evaluate to a uint64. + """ + + super().__init__() + require_type(name, TealType.bytes) + require_type(size, TealType.uint64) + self.name = name + self.size = size + + def __teal__(self, options: "CompileOptions"): + verifyProgramVersion( + minVersion=Op.box_resize.min_version, + version=options.version, + msg=f"{Op.box_resize} unavailable", + ) + return TealBlock.FromOp( + options, TealOp(self, Op.box_resize), self.name, self.size + ) + + def __str__(self): + return f"(box_resize {self.name} {self.size})" + + def type_of(self): + return TealType.none + + def has_return(self): + return False + + +BoxResize.__module__ = "pyteal" + + class BoxDelete(Expr): """Deletes a box given its name.""" @@ -83,7 +126,10 @@ def has_return(self): class BoxReplace(Expr): - """Replaces bytes in a box given its name, start index, and value.""" + """Replaces bytes in a box given its name, start index, and value. + + Also see BoxSplice. + """ def __init__(self, name: Expr, start: Expr, value: Expr) -> None: """ @@ -165,6 +211,66 @@ def has_return(self): BoxExtract.__module__ = "pyteal" +class BoxSplice(Expr): + """Splice content into a box.""" + + def __init__( + self, name: Expr, start: Expr, length: Expr, new_content: Expr + ) -> None: + """ + Replaces the range of bytes from `start` through `start + length` with `new_content`. + + Recall that boxes are constant length, so this operation will not change the length of the + box. Instead content may be adjusted as so: + * If the length of the new content is less than `length`, zero bytes will be added to the + end of the box to make up the difference. + * If the length of the new content is greater than `length`, bytes will be truncated from + the end of the box to make up the difference. + + Args: + name: The name of the box to modify. Must evaluate to bytes. + start: The byte index into the box to start writing. Must evaluate to uint64. + length: The length of the bytes to be replaced. Must evaluate to uint64. + new_content: The new content to write into the box. Must evaluate to bytes. + """ + super().__init__() + require_type(name, TealType.bytes) + require_type(start, TealType.uint64) + require_type(length, TealType.uint64) + require_type(new_content, TealType.bytes) + self.name = name + self.start = start + self.length = length + self.new_content = new_content + + def __teal__(self, options: "CompileOptions"): + verifyProgramVersion( + minVersion=Op.box_splice.min_version, + version=options.version, + msg=f"{Op.box_splice} unavailable", + ) + return TealBlock.FromOp( + options, + TealOp(self, Op.box_splice), + self.name, + self.start, + self.length, + self.new_content, + ) + + def __str__(self): + return f"(box_splice {self.name} {self.start} {self.length} {self.new_content})" + + def type_of(self): + return TealType.none + + def has_return(self): + return False + + +BoxSplice.__module__ = "pyteal" + + def BoxLen(name: Expr) -> MaybeValue: """ Get the byte length of the box specified by its name. diff --git a/pyteal/ast/box_test.py b/pyteal/ast/box_test.py index 008ffb580..7125f55e4 100644 --- a/pyteal/ast/box_test.py +++ b/pyteal/ast/box_test.py @@ -5,32 +5,38 @@ avm7Options = pt.CompileOptions(version=7) avm8Options = pt.CompileOptions(version=8) +avm10Options = pt.CompileOptions(version=10) -POSITIVE_TEST_CASES: list[Tuple[pt.Expr, pt.TealType]] = [ - (pt.BoxCreate(pt.Bytes("box"), pt.Int(10)), pt.TealType.uint64), - (pt.BoxDelete(pt.Bytes("box")), pt.TealType.uint64), - (pt.BoxExtract(pt.Bytes("box"), pt.Int(2), pt.Int(4)), pt.TealType.bytes), +POSITIVE_TEST_CASES: list[Tuple[int, pt.Expr, pt.TealType]] = [ + (8, pt.BoxCreate(pt.Bytes("box"), pt.Int(10)), pt.TealType.uint64), + (8, pt.BoxDelete(pt.Bytes("box")), pt.TealType.uint64), + (8, pt.BoxExtract(pt.Bytes("box"), pt.Int(2), pt.Int(4)), pt.TealType.bytes), ( + 8, pt.BoxReplace(pt.Bytes("box"), pt.Int(3), pt.Bytes("replace")), pt.TealType.none, ), - (pt.BoxLen(pt.Bytes("box")), pt.TealType.none), - (pt.BoxGet(pt.Bytes("box")), pt.TealType.none), - (pt.BoxPut(pt.Bytes("box"), pt.Bytes("goonery")), pt.TealType.none), + (8, pt.BoxLen(pt.Bytes("box")), pt.TealType.none), + (8, pt.BoxGet(pt.Bytes("box")), pt.TealType.none), + (8, pt.BoxPut(pt.Bytes("box"), pt.Bytes("goonery")), pt.TealType.none), + (10, pt.BoxResize(pt.Bytes("box"), pt.Int(16)), pt.TealType.none), + ( + 10, + pt.BoxSplice(pt.Bytes("box"), pt.Int(5), pt.Int(2), pt.Bytes("replacement")), + pt.TealType.none, + ), ] -@pytest.mark.parametrize("test_case, test_case_type", POSITIVE_TEST_CASES) -def test_compile_version_and_type(test_case, test_case_type): +@pytest.mark.parametrize("version, test_case, test_case_type", POSITIVE_TEST_CASES) +def test_compile_version_and_type(version, test_case, test_case_type): with pytest.raises(pt.TealInputError): - test_case.__teal__(avm7Options) + test_case.__teal__(pt.CompileOptions(version=version - 1)) - test_case.__teal__(avm8Options) + test_case.__teal__(pt.CompileOptions(version=version)) assert test_case.type_of() == test_case_type assert not test_case.has_return() - return - INVALID_TEST_CASES: list[Tuple[list[pt.Expr], type | Callable[..., pt.MaybeValue]]] = [ ([pt.Bytes("box"), pt.Bytes("ten")], pt.BoxCreate), @@ -41,6 +47,12 @@ def test_compile_version_and_type(test_case, test_case_type): ([pt.Int(12)], pt.BoxLen), ([pt.Int(45)], pt.BoxGet), ([pt.Bytes("box"), pt.Int(123)], pt.BoxPut), + ([pt.Int(1), pt.Int(2)], pt.BoxResize), + ([pt.Bytes("box"), pt.Bytes("b")], pt.BoxResize), + ([pt.Bytes("box"), pt.Int(123), pt.Int(456), pt.Int(7)], pt.BoxSplice), + ([pt.Bytes("box"), pt.Int(123), pt.Bytes("456"), pt.Bytes("x")], pt.BoxSplice), + ([pt.Bytes("box"), pt.Bytes("123"), pt.Int(456), pt.Bytes("x")], pt.BoxSplice), + ([pt.Int(8), pt.Int(123), pt.Int(456), pt.Bytes("x")], pt.BoxSplice), ] @@ -69,6 +81,25 @@ def test_box_create_compile(): assert expected == actual +def test_box_resize_compile(): + name_arg: pt.Expr = pt.Bytes("eineName") + size_arg: pt.Expr = pt.Int(10) + expr: pt.Expr = pt.BoxResize(name_arg, size_arg) + + expected = pt.TealSimpleBlock( + [ + pt.TealOp(name_arg, pt.Op.byte, '"eineName"'), + pt.TealOp(size_arg, pt.Op.int, 10), + pt.TealOp(expr, pt.Op.box_resize), + ] + ) + actual, _ = expr.__teal__(avm10Options) + actual.addIncoming() + actual = pt.TealBlock.NormalizeBlocks(actual) + + assert expected == actual + + def test_box_delete_compile(): name_arg: pt.Expr = pt.Bytes("eineName") expr: pt.Expr = pt.BoxDelete(name_arg) @@ -125,6 +156,29 @@ def test_box_replace(): assert expected == actual +def test_box_splice(): + name_arg: pt.Expr = pt.Bytes("eineName") + srt_arg: pt.Expr = pt.Int(10) + len_arg: pt.Expr = pt.Int(17) + replace_arg: pt.Expr = pt.Bytes("replace-str") + expr: pt.Expr = pt.BoxSplice(name_arg, srt_arg, len_arg, replace_arg) + + expected = pt.TealSimpleBlock( + [ + pt.TealOp(name_arg, pt.Op.byte, '"eineName"'), + pt.TealOp(srt_arg, pt.Op.int, 10), + pt.TealOp(len_arg, pt.Op.int, 17), + pt.TealOp(replace_arg, pt.Op.byte, '"replace-str"'), + pt.TealOp(expr, pt.Op.box_splice), + ] + ) + actual, _ = expr.__teal__(avm10Options) + actual.addIncoming() + actual = pt.TealBlock.NormalizeBlocks(actual) + + assert expected == actual + + def test_box_length(): name_arg: pt.Expr = pt.Bytes("eineName") expr: pt.MaybeValue = pt.BoxLen(name_arg) diff --git a/pyteal/ir/ops.py b/pyteal/ir/ops.py index 74f3663ac..26b5258e7 100644 --- a/pyteal/ir/ops.py +++ b/pyteal/ir/ops.py @@ -37,177 +37,185 @@ def min_version(self) -> int: # fmt: off # meta - comment = OpType("//", Mode.Signature | Mode.Application, 0) + comment = OpType("//", Mode.Signature | Mode.Application, 0) # avm - err = OpType("err", Mode.Signature | Mode.Application, 2) - sha256 = OpType("sha256", Mode.Signature | Mode.Application, 2) - keccak256 = OpType("keccak256", Mode.Signature | Mode.Application, 2) - sha512_256 = OpType("sha512_256", Mode.Signature | Mode.Application, 2) - ed25519verify = OpType("ed25519verify", Mode.Signature | Mode.Application, 2) - add = OpType("+", Mode.Signature | Mode.Application, 2) - minus = OpType("-", Mode.Signature | Mode.Application, 2) - div = OpType("/", Mode.Signature | Mode.Application, 2) - mul = OpType("*", Mode.Signature | Mode.Application, 2) - lt = OpType("<", Mode.Signature | Mode.Application, 2) - gt = OpType(">", Mode.Signature | Mode.Application, 2) - le = OpType("<=", Mode.Signature | Mode.Application, 2) - ge = OpType(">=", Mode.Signature | Mode.Application, 2) - logic_and = OpType("&&", Mode.Signature | Mode.Application, 2) - logic_or = OpType("||", Mode.Signature | Mode.Application, 2) - eq = OpType("==", Mode.Signature | Mode.Application, 2) - neq = OpType("!=", Mode.Signature | Mode.Application, 2) - logic_not = OpType("!", Mode.Signature | Mode.Application, 2) - len = OpType("len", Mode.Signature | Mode.Application, 2) - itob = OpType("itob", Mode.Signature | Mode.Application, 2) - btoi = OpType("btoi", Mode.Signature | Mode.Application, 2) - mod = OpType("%", Mode.Signature | Mode.Application, 2) - bitwise_or = OpType("|", Mode.Signature | Mode.Application, 2) - bitwise_and = OpType("&", Mode.Signature | Mode.Application, 2) - bitwise_xor = OpType("^", Mode.Signature | Mode.Application, 2) - bitwise_not = OpType("~", Mode.Signature | Mode.Application, 2) - mulw = OpType("mulw", Mode.Signature | Mode.Application, 2) - addw = OpType("addw", Mode.Signature | Mode.Application, 2) - intcblock = OpType("intcblock", Mode.Signature | Mode.Application, 2) - intc = OpType("intc", Mode.Signature | Mode.Application, 2) - intc_0 = OpType("intc_0", Mode.Signature | Mode.Application, 2) - intc_1 = OpType("intc_1", Mode.Signature | Mode.Application, 2) - intc_2 = OpType("intc_2", Mode.Signature | Mode.Application, 2) - intc_3 = OpType("intc_3", Mode.Signature | Mode.Application, 2) - int = OpType("int", Mode.Signature | Mode.Application, 2) - bytecblock = OpType("bytecblock", Mode.Signature | Mode.Application, 2) - bytec = OpType("bytec", Mode.Signature | Mode.Application, 2) - bytec_0 = OpType("bytec_0", Mode.Signature | Mode.Application, 2) - bytec_1 = OpType("bytec_1", Mode.Signature | Mode.Application, 2) - bytec_2 = OpType("bytec_2", Mode.Signature | Mode.Application, 2) - bytec_3 = OpType("bytec_3", Mode.Signature | Mode.Application, 2) - byte = OpType("byte", Mode.Signature | Mode.Application, 2) - addr = OpType("addr", Mode.Signature | Mode.Application, 2) - method_signature = OpType("method", Mode.Signature | Mode.Application, 2) - arg = OpType("arg", Mode.Signature, 2) - txn = OpType("txn", Mode.Signature | Mode.Application, 2) - global_ = OpType("global", Mode.Signature | Mode.Application, 2) - gtxn = OpType("gtxn", Mode.Signature | Mode.Application, 2) - load = OpType("load", Mode.Signature | Mode.Application, 2) - store = OpType("store", Mode.Signature | Mode.Application, 2) - txna = OpType("txna", Mode.Signature | Mode.Application, 2) - gtxna = OpType("gtxna", Mode.Signature | Mode.Application, 2) - bnz = OpType("bnz", Mode.Signature | Mode.Application, 2) - bz = OpType("bz", Mode.Signature | Mode.Application, 2) - b = OpType("b", Mode.Signature | Mode.Application, 2) - return_ = OpType("return", Mode.Signature | Mode.Application, 2) - pop = OpType("pop", Mode.Signature | Mode.Application, 2) - dup = OpType("dup", Mode.Signature | Mode.Application, 2) - dup2 = OpType("dup2", Mode.Signature | Mode.Application, 2) - concat = OpType("concat", Mode.Signature | Mode.Application, 2) - substring = OpType("substring", Mode.Signature | Mode.Application, 2) - substring3 = OpType("substring3", Mode.Signature | Mode.Application, 2) - balance = OpType("balance", Mode.Application, 2) - app_opted_in = OpType("app_opted_in", Mode.Application, 2) - app_local_get = OpType("app_local_get", Mode.Application, 2) - app_local_get_ex = OpType("app_local_get_ex", Mode.Application, 2) - app_global_get = OpType("app_global_get", Mode.Application, 2) - app_global_get_ex = OpType("app_global_get_ex", Mode.Application, 2) - app_local_put = OpType("app_local_put", Mode.Application, 2) - app_global_put = OpType("app_global_put", Mode.Application, 2) - app_local_del = OpType("app_local_del", Mode.Application, 2) - app_global_del = OpType("app_global_del", Mode.Application, 2) - asset_holding_get = OpType("asset_holding_get", Mode.Application, 2) - asset_params_get = OpType("asset_params_get", Mode.Application, 2) - gtxns = OpType("gtxns", Mode.Signature | Mode.Application, 3) - gtxnsa = OpType("gtxnsa", Mode.Signature | Mode.Application, 3) - assert_ = OpType("assert", Mode.Signature | Mode.Application, 3) - dig = OpType("dig", Mode.Signature | Mode.Application, 3) - swap = OpType("swap", Mode.Signature | Mode.Application, 3) - select = OpType("select", Mode.Signature | Mode.Application, 3) - getbit = OpType("getbit", Mode.Signature | Mode.Application, 3) - setbit = OpType("setbit", Mode.Signature | Mode.Application, 3) - getbyte = OpType("getbyte", Mode.Signature | Mode.Application, 3) - setbyte = OpType("setbyte", Mode.Signature | Mode.Application, 3) - min_balance = OpType("min_balance", Mode.Application, 3) - pushbytes = OpType("pushbytes", Mode.Signature | Mode.Application, 3) - pushint = OpType("pushint", Mode.Signature | Mode.Application, 3) - shl = OpType("shl", Mode.Signature | Mode.Application, 4) - shr = OpType("shr", Mode.Signature | Mode.Application, 4) - sqrt = OpType("sqrt", Mode.Signature | Mode.Application, 4) - bitlen = OpType("bitlen", Mode.Signature | Mode.Application, 4) - exp = OpType("exp", Mode.Signature | Mode.Application, 4) - divmodw = OpType("divmodw", Mode.Signature | Mode.Application, 4) - expw = OpType("expw", Mode.Signature | Mode.Application, 4) - b_add = OpType("b+", Mode.Signature | Mode.Application, 4) - b_minus = OpType("b-", Mode.Signature | Mode.Application, 4) - b_div = OpType("b/", Mode.Signature | Mode.Application, 4) - b_mul = OpType("b*", Mode.Signature | Mode.Application, 4) - b_lt = OpType("b<", Mode.Signature | Mode.Application, 4) - b_gt = OpType("b>", Mode.Signature | Mode.Application, 4) - b_le = OpType("b<=", Mode.Signature | Mode.Application, 4) - b_ge = OpType("b>=", Mode.Signature | Mode.Application, 4) - b_eq = OpType("b==", Mode.Signature | Mode.Application, 4) - b_neq = OpType("b!=", Mode.Signature | Mode.Application, 4) - b_mod = OpType("b%", Mode.Signature | Mode.Application, 4) - b_or = OpType("b|", Mode.Signature | Mode.Application, 4) - b_and = OpType("b&", Mode.Signature | Mode.Application, 4) - b_xor = OpType("b^", Mode.Signature | Mode.Application, 4) - b_not = OpType("b~", Mode.Signature | Mode.Application, 4) - bzero = OpType("bzero", Mode.Signature | Mode.Application, 4) - gload = OpType("gload", Mode.Application, 4) - gloads = OpType("gloads", Mode.Application, 4) - gaid = OpType("gaid", Mode.Application, 4) - gaids = OpType("gaids", Mode.Application, 4) - callsub = OpType("callsub", Mode.Signature | Mode.Application, 4) - retsub = OpType("retsub", Mode.Signature | Mode.Application, 4) - ecdsa_verify = OpType("ecdsa_verify", Mode.Signature | Mode.Application, 5) - ecdsa_pk_decompress = OpType("ecdsa_pk_decompress", Mode.Signature | Mode.Application, 5) - ecdsa_pk_recover = OpType("ecdsa_pk_recover", Mode.Signature | Mode.Application, 5) - loads = OpType("loads", Mode.Signature | Mode.Application, 5) - stores = OpType("stores", Mode.Signature | Mode.Application, 5) - cover = OpType("cover", Mode.Signature | Mode.Application, 5) - uncover = OpType("uncover", Mode.Signature | Mode.Application, 5) - extract = OpType("extract", Mode.Signature | Mode.Application, 5) - extract3 = OpType("extract3", Mode.Signature | Mode.Application, 5) - extract_uint16 = OpType("extract_uint16", Mode.Signature | Mode.Application, 5) - extract_uint32 = OpType("extract_uint32", Mode.Signature | Mode.Application, 5) - extract_uint64 = OpType("extract_uint64", Mode.Signature | Mode.Application, 5) - app_params_get = OpType("app_params_get", Mode.Application, 5) - log = OpType("log", Mode.Application, 5) - itxn_begin = OpType("itxn_begin", Mode.Application, 5) - itxn_field = OpType("itxn_field", Mode.Application, 5) - itxn_submit = OpType("itxn_submit", Mode.Application, 5) - itxn = OpType("itxn", Mode.Application, 5) - itxna = OpType("itxna", Mode.Application, 5) - txnas = OpType("txnas", Mode.Signature | Mode.Application, 5) - gtxnas = OpType("gtxnas", Mode.Signature | Mode.Application, 5) - gtxnsas = OpType("gtxnsas", Mode.Signature | Mode.Application, 5) - args = OpType("args", Mode.Signature, 5) - bsqrt = OpType("bsqrt", Mode.Signature | Mode.Application, 6) - divw = OpType("divw", Mode.Signature | Mode.Application, 6) - itxn_next = OpType("itxn_next", Mode.Application, 6) - itxnas = OpType("itxnas", Mode.Application, 6) - gitxn = OpType("gitxn", Mode.Application, 6) - gitxna = OpType("gitxna", Mode.Application, 6) - gitxnas = OpType("gitxnas", Mode.Application, 6) - gloadss = OpType("gloadss", Mode.Application, 6) - acct_params_get = OpType("acct_params_get", Mode.Application, 6) - replace2 = OpType("replace2", Mode.Signature | Mode.Application, 7) - replace3 = OpType("replace3", Mode.Signature | Mode.Application, 7) - base64_decode = OpType("base64_decode", Mode.Signature | Mode.Application, 7) - json_ref = OpType("json_ref", Mode.Signature | Mode.Application, 7) - ed25519verify_bare = OpType("ed25519verify_bare", Mode.Signature | Mode.Application, 7) - sha3_256 = OpType("sha3_256", Mode.Signature | Mode.Application, 7) - vrf_verify = OpType("vrf_verify", Mode.Signature | Mode.Application, 7) - block = OpType("block", Mode.Signature | Mode.Application, 7) - box_create = OpType("box_create", Mode.Application, 8) - box_extract = OpType("box_extract", Mode.Application, 8) - box_replace = OpType("box_replace", Mode.Application, 8) - box_del = OpType("box_del", Mode.Application, 8) - box_len = OpType("box_len", Mode.Application, 8) - box_get = OpType("box_get", Mode.Application, 8) - box_put = OpType("box_put", Mode.Application, 8) - popn = OpType("popn", Mode.Signature | Mode.Application, 8) - dupn = OpType("dupn", Mode.Signature | Mode.Application, 8) - bury = OpType("bury", Mode.Signature | Mode.Application, 8) - frame_dig = OpType("frame_dig", Mode.Signature | Mode.Application, 8) - frame_bury = OpType("frame_bury", Mode.Signature | Mode.Application, 8) - proto = OpType("proto", Mode.Signature | Mode.Application, 8) + err = OpType("err", Mode.Signature | Mode.Application, 2) + sha256 = OpType("sha256", Mode.Signature | Mode.Application, 2) + keccak256 = OpType("keccak256", Mode.Signature | Mode.Application, 2) + sha512_256 = OpType("sha512_256", Mode.Signature | Mode.Application, 2) + ed25519verify = OpType("ed25519verify", Mode.Signature | Mode.Application, 2) + add = OpType("+", Mode.Signature | Mode.Application, 2) + minus = OpType("-", Mode.Signature | Mode.Application, 2) + div = OpType("/", Mode.Signature | Mode.Application, 2) + mul = OpType("*", Mode.Signature | Mode.Application, 2) + lt = OpType("<", Mode.Signature | Mode.Application, 2) + gt = OpType(">", Mode.Signature | Mode.Application, 2) + le = OpType("<=", Mode.Signature | Mode.Application, 2) + ge = OpType(">=", Mode.Signature | Mode.Application, 2) + logic_and = OpType("&&", Mode.Signature | Mode.Application, 2) + logic_or = OpType("||", Mode.Signature | Mode.Application, 2) + eq = OpType("==", Mode.Signature | Mode.Application, 2) + neq = OpType("!=", Mode.Signature | Mode.Application, 2) + logic_not = OpType("!", Mode.Signature | Mode.Application, 2) + len = OpType("len", Mode.Signature | Mode.Application, 2) + itob = OpType("itob", Mode.Signature | Mode.Application, 2) + btoi = OpType("btoi", Mode.Signature | Mode.Application, 2) + mod = OpType("%", Mode.Signature | Mode.Application, 2) + bitwise_or = OpType("|", Mode.Signature | Mode.Application, 2) + bitwise_and = OpType("&", Mode.Signature | Mode.Application, 2) + bitwise_xor = OpType("^", Mode.Signature | Mode.Application, 2) + bitwise_not = OpType("~", Mode.Signature | Mode.Application, 2) + mulw = OpType("mulw", Mode.Signature | Mode.Application, 2) + addw = OpType("addw", Mode.Signature | Mode.Application, 2) + intcblock = OpType("intcblock", Mode.Signature | Mode.Application, 2) + intc = OpType("intc", Mode.Signature | Mode.Application, 2) + intc_0 = OpType("intc_0", Mode.Signature | Mode.Application, 2) + intc_1 = OpType("intc_1", Mode.Signature | Mode.Application, 2) + intc_2 = OpType("intc_2", Mode.Signature | Mode.Application, 2) + intc_3 = OpType("intc_3", Mode.Signature | Mode.Application, 2) + int = OpType("int", Mode.Signature | Mode.Application, 2) + bytecblock = OpType("bytecblock", Mode.Signature | Mode.Application, 2) + bytec = OpType("bytec", Mode.Signature | Mode.Application, 2) + bytec_0 = OpType("bytec_0", Mode.Signature | Mode.Application, 2) + bytec_1 = OpType("bytec_1", Mode.Signature | Mode.Application, 2) + bytec_2 = OpType("bytec_2", Mode.Signature | Mode.Application, 2) + bytec_3 = OpType("bytec_3", Mode.Signature | Mode.Application, 2) + byte = OpType("byte", Mode.Signature | Mode.Application, 2) + addr = OpType("addr", Mode.Signature | Mode.Application, 2) + method_signature = OpType("method", Mode.Signature | Mode.Application, 2) + arg = OpType("arg", Mode.Signature, 2) + txn = OpType("txn", Mode.Signature | Mode.Application, 2) + global_ = OpType("global", Mode.Signature | Mode.Application, 2) + gtxn = OpType("gtxn", Mode.Signature | Mode.Application, 2) + load = OpType("load", Mode.Signature | Mode.Application, 2) + store = OpType("store", Mode.Signature | Mode.Application, 2) + txna = OpType("txna", Mode.Signature | Mode.Application, 2) + gtxna = OpType("gtxna", Mode.Signature | Mode.Application, 2) + bnz = OpType("bnz", Mode.Signature | Mode.Application, 2) + bz = OpType("bz", Mode.Signature | Mode.Application, 2) + b = OpType("b", Mode.Signature | Mode.Application, 2) + return_ = OpType("return", Mode.Signature | Mode.Application, 2) + pop = OpType("pop", Mode.Signature | Mode.Application, 2) + dup = OpType("dup", Mode.Signature | Mode.Application, 2) + dup2 = OpType("dup2", Mode.Signature | Mode.Application, 2) + concat = OpType("concat", Mode.Signature | Mode.Application, 2) + substring = OpType("substring", Mode.Signature | Mode.Application, 2) + substring3 = OpType("substring3", Mode.Signature | Mode.Application, 2) + balance = OpType("balance", Mode.Application, 2) + app_opted_in = OpType("app_opted_in", Mode.Application, 2) + app_local_get = OpType("app_local_get", Mode.Application, 2) + app_local_get_ex = OpType("app_local_get_ex", Mode.Application, 2) + app_global_get = OpType("app_global_get", Mode.Application, 2) + app_global_get_ex = OpType("app_global_get_ex", Mode.Application, 2) + app_local_put = OpType("app_local_put", Mode.Application, 2) + app_global_put = OpType("app_global_put", Mode.Application, 2) + app_local_del = OpType("app_local_del", Mode.Application, 2) + app_global_del = OpType("app_global_del", Mode.Application, 2) + asset_holding_get = OpType("asset_holding_get", Mode.Application, 2) + asset_params_get = OpType("asset_params_get", Mode.Application, 2) + gtxns = OpType("gtxns", Mode.Signature | Mode.Application, 3) + gtxnsa = OpType("gtxnsa", Mode.Signature | Mode.Application, 3) + assert_ = OpType("assert", Mode.Signature | Mode.Application, 3) + dig = OpType("dig", Mode.Signature | Mode.Application, 3) + swap = OpType("swap", Mode.Signature | Mode.Application, 3) + select = OpType("select", Mode.Signature | Mode.Application, 3) + getbit = OpType("getbit", Mode.Signature | Mode.Application, 3) + setbit = OpType("setbit", Mode.Signature | Mode.Application, 3) + getbyte = OpType("getbyte", Mode.Signature | Mode.Application, 3) + setbyte = OpType("setbyte", Mode.Signature | Mode.Application, 3) + min_balance = OpType("min_balance", Mode.Application, 3) + pushbytes = OpType("pushbytes", Mode.Signature | Mode.Application, 3) + pushint = OpType("pushint", Mode.Signature | Mode.Application, 3) + shl = OpType("shl", Mode.Signature | Mode.Application, 4) + shr = OpType("shr", Mode.Signature | Mode.Application, 4) + sqrt = OpType("sqrt", Mode.Signature | Mode.Application, 4) + bitlen = OpType("bitlen", Mode.Signature | Mode.Application, 4) + exp = OpType("exp", Mode.Signature | Mode.Application, 4) + divmodw = OpType("divmodw", Mode.Signature | Mode.Application, 4) + expw = OpType("expw", Mode.Signature | Mode.Application, 4) + b_add = OpType("b+", Mode.Signature | Mode.Application, 4) + b_minus = OpType("b-", Mode.Signature | Mode.Application, 4) + b_div = OpType("b/", Mode.Signature | Mode.Application, 4) + b_mul = OpType("b*", Mode.Signature | Mode.Application, 4) + b_lt = OpType("b<", Mode.Signature | Mode.Application, 4) + b_gt = OpType("b>", Mode.Signature | Mode.Application, 4) + b_le = OpType("b<=", Mode.Signature | Mode.Application, 4) + b_ge = OpType("b>=", Mode.Signature | Mode.Application, 4) + b_eq = OpType("b==", Mode.Signature | Mode.Application, 4) + b_neq = OpType("b!=", Mode.Signature | Mode.Application, 4) + b_mod = OpType("b%", Mode.Signature | Mode.Application, 4) + b_or = OpType("b|", Mode.Signature | Mode.Application, 4) + b_and = OpType("b&", Mode.Signature | Mode.Application, 4) + b_xor = OpType("b^", Mode.Signature | Mode.Application, 4) + b_not = OpType("b~", Mode.Signature | Mode.Application, 4) + bzero = OpType("bzero", Mode.Signature | Mode.Application, 4) + gload = OpType("gload", Mode.Application, 4) + gloads = OpType("gloads", Mode.Application, 4) + gaid = OpType("gaid", Mode.Application, 4) + gaids = OpType("gaids", Mode.Application, 4) + callsub = OpType("callsub", Mode.Signature | Mode.Application, 4) + retsub = OpType("retsub", Mode.Signature | Mode.Application, 4) + ecdsa_verify = OpType("ecdsa_verify", Mode.Signature | Mode.Application, 5) + ecdsa_pk_decompress = OpType("ecdsa_pk_decompress", Mode.Signature | Mode.Application, 5) + ecdsa_pk_recover = OpType("ecdsa_pk_recover", Mode.Signature | Mode.Application, 5) + loads = OpType("loads", Mode.Signature | Mode.Application, 5) + stores = OpType("stores", Mode.Signature | Mode.Application, 5) + cover = OpType("cover", Mode.Signature | Mode.Application, 5) + uncover = OpType("uncover", Mode.Signature | Mode.Application, 5) + extract = OpType("extract", Mode.Signature | Mode.Application, 5) + extract3 = OpType("extract3", Mode.Signature | Mode.Application, 5) + extract_uint16 = OpType("extract_uint16", Mode.Signature | Mode.Application, 5) + extract_uint32 = OpType("extract_uint32", Mode.Signature | Mode.Application, 5) + extract_uint64 = OpType("extract_uint64", Mode.Signature | Mode.Application, 5) + app_params_get = OpType("app_params_get", Mode.Application, 5) + log = OpType("log", Mode.Application, 5) + itxn_begin = OpType("itxn_begin", Mode.Application, 5) + itxn_field = OpType("itxn_field", Mode.Application, 5) + itxn_submit = OpType("itxn_submit", Mode.Application, 5) + itxn = OpType("itxn", Mode.Application, 5) + itxna = OpType("itxna", Mode.Application, 5) + txnas = OpType("txnas", Mode.Signature | Mode.Application, 5) + gtxnas = OpType("gtxnas", Mode.Signature | Mode.Application, 5) + gtxnsas = OpType("gtxnsas", Mode.Signature | Mode.Application, 5) + args = OpType("args", Mode.Signature, 5) + bsqrt = OpType("bsqrt", Mode.Signature | Mode.Application, 6) + divw = OpType("divw", Mode.Signature | Mode.Application, 6) + itxn_next = OpType("itxn_next", Mode.Application, 6) + itxnas = OpType("itxnas", Mode.Application, 6) + gitxn = OpType("gitxn", Mode.Application, 6) + gitxna = OpType("gitxna", Mode.Application, 6) + gitxnas = OpType("gitxnas", Mode.Application, 6) + gloadss = OpType("gloadss", Mode.Application, 6) + acct_params_get = OpType("acct_params_get", Mode.Application, 6) + replace2 = OpType("replace2", Mode.Signature | Mode.Application, 7) + replace3 = OpType("replace3", Mode.Signature | Mode.Application, 7) + base64_decode = OpType("base64_decode", Mode.Signature | Mode.Application, 7) + json_ref = OpType("json_ref", Mode.Signature | Mode.Application, 7) + ed25519verify_bare = OpType("ed25519verify_bare", Mode.Signature | Mode.Application, 7) + sha3_256 = OpType("sha3_256", Mode.Signature | Mode.Application, 7) + vrf_verify = OpType("vrf_verify", Mode.Signature | Mode.Application, 7) + block = OpType("block", Mode.Signature | Mode.Application, 7) + box_create = OpType("box_create", Mode.Application, 8) + box_extract = OpType("box_extract", Mode.Application, 8) + box_replace = OpType("box_replace", Mode.Application, 8) + box_del = OpType("box_del", Mode.Application, 8) + box_len = OpType("box_len", Mode.Application, 8) + box_get = OpType("box_get", Mode.Application, 8) + box_put = OpType("box_put", Mode.Application, 8) + popn = OpType("popn", Mode.Signature | Mode.Application, 8) + dupn = OpType("dupn", Mode.Signature | Mode.Application, 8) + bury = OpType("bury", Mode.Signature | Mode.Application, 8) + frame_dig = OpType("frame_dig", Mode.Signature | Mode.Application, 8) + frame_bury = OpType("frame_bury", Mode.Signature | Mode.Application, 8) + proto = OpType("proto", Mode.Signature | Mode.Application, 8) + box_splice = OpType("box_splice", Mode.Application, 10) + box_resize = OpType("box_resize", Mode.Application, 10) + ec_add = OpType("ec_add", Mode.Signature | Mode.Application, 10) + ec_scalar_mul = OpType("ec_scalar_mul", Mode.Signature | Mode.Application, 10) + ec_pairing_check = OpType("ec_pairing_check", Mode.Signature | Mode.Application, 10) + ec_multi_scalar_mul = OpType("ec_multi_scalar_mul", Mode.Signature | Mode.Application, 10) + ec_subgroup_check = OpType("ec_subgroup_check", Mode.Signature | Mode.Application, 10) + ec_map_to = OpType("ec_map_to", Mode.Signature | Mode.Application, 10) # fmt: on