From d421660768c6ac84033501c19244088610244cba Mon Sep 17 00:00:00 2001 From: Hang Su Date: Thu, 9 Feb 2023 14:11:07 -0500 Subject: [PATCH 1/9] minor --- pyteal/ast/abi/tuple.py | 2 +- ...p_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v6.teal | 2 +- ...p_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v8.teal | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyteal/ast/abi/tuple.py b/pyteal/ast/abi/tuple.py index 21782af71..551cafe3f 100644 --- a/pyteal/ast/abi/tuple.py +++ b/pyteal/ast/abi/tuple.py @@ -200,7 +200,7 @@ def _index_tuple( return output.decode(encoded) # This is the last value in the tuple, so decode the substring from start_index to the end of # encoded - return output.decode(encoded, start_index=start_index) + # return output.decode(encoded, start_index=start_index) if offset == 0: # This is the first value in the tuple, so decode the substring from 0 with length length diff --git a/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v6.teal b/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v6.teal index 6e7ce0eb3..73a675b5a 100644 --- a/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v6.teal +++ b/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v6.teal @@ -25,7 +25,7 @@ int 5 extract_uint64 store 2 load 19 -extract 13 0 +extract 13 32 store 3 load 0 callsub arraycomplement_4 diff --git a/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v8.teal b/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v8.teal index c5580033b..d6a2e3e00 100644 --- a/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v8.teal +++ b/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v8.teal @@ -44,7 +44,7 @@ int 5 extract_uint64 store 2 frame_dig -1 -extract 13 0 +extract 13 32 store 3 load 0 callsub arraycomplement_4 From cae8721c73b2f6c001ccc962f5bed1a9d0630eaf Mon Sep 17 00:00:00 2001 From: Hang Su Date: Thu, 9 Feb 2023 14:50:59 -0500 Subject: [PATCH 2/9] changelog and unit test --- CHANGELOG.md | 2 ++ pyteal/ast/abi/tuple.py | 3 --- pyteal/ast/abi/tuple_test.py | 4 +++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b3618fee..5a16aab17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ## Fixed +* Fixed wrong encoding result in tuple get last item. ([#663](https://github.com/algorand/pyteal/pull/663)) + ## Changed # v0.22.0 diff --git a/pyteal/ast/abi/tuple.py b/pyteal/ast/abi/tuple.py index 551cafe3f..e68daea81 100644 --- a/pyteal/ast/abi/tuple.py +++ b/pyteal/ast/abi/tuple.py @@ -198,9 +198,6 @@ def _index_tuple( if offset == 0: # This is the first and only value in the tuple, so decode all of encoded return output.decode(encoded) - # This is the last value in the tuple, so decode the substring from start_index to the end of - # encoded - # return output.decode(encoded, start_index=start_index) if offset == 0: # This is the first value in the tuple, so decode the substring from 0 with length length diff --git a/pyteal/ast/abi/tuple_test.py b/pyteal/ast/abi/tuple_test.py index db7f2808f..dffe16f3d 100644 --- a/pyteal/ast/abi/tuple_test.py +++ b/pyteal/ast/abi/tuple_test.py @@ -330,7 +330,9 @@ class IndexTest(NamedTuple): IndexTest( types=[byte_t, tuple_t], typeIndex=1, - expected=lambda output: output.decode(encoded, start_index=pt.Int(1)), + expected=lambda output: output.decode( + encoded, start_index=pt.Int(1), length=pt.Int(1) + ), ), IndexTest( types=[tuple_t, byte_t], From f1b6ead595d236e6f76b8a78eb66aabe87244fed Mon Sep 17 00:00:00 2001 From: Hang Su Date: Thu, 9 Feb 2023 15:15:14 -0500 Subject: [PATCH 3/9] more testcase --- pyteal/ast/abi/tuple_test.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pyteal/ast/abi/tuple_test.py b/pyteal/ast/abi/tuple_test.py index dffe16f3d..1d629f923 100644 --- a/pyteal/ast/abi/tuple_test.py +++ b/pyteal/ast/abi/tuple_test.py @@ -373,6 +373,15 @@ class IndexTest(NamedTuple): encoded, start_index=pt.ExtractUint16(encoded, pt.Int(0)) ), ), + IndexTest( + types=[dynamic_array_t1, byte_t], + typeIndex=1, + expected=lambda output: output.decode( + encoded, + start_index=pt.Int(2), + length=pt.Int(1), + ), + ), IndexTest( types=[byte_t, dynamic_array_t1, byte_t], typeIndex=1, From b4b55f38edaaddfff1ff60c3fea65c0257fc1d77 Mon Sep 17 00:00:00 2001 From: Hang Su Date: Thu, 9 Feb 2023 15:45:28 -0500 Subject: [PATCH 4/9] integration testcase --- tests/compile_asserts.py | 4 +- tests/integration/abi_roundtrip_test.py | 1 + .../app_roundtrip_(byte[],byte[3])_v6.teal | 251 ++++++++++++++++ .../app_roundtrip_(byte[],byte[3])_v8.teal | 284 ++++++++++++++++++ 4 files changed, 538 insertions(+), 2 deletions(-) create mode 100644 tests/integration/teal/roundtrip/app_roundtrip_(byte[],byte[3])_v6.teal create mode 100644 tests/integration/teal/roundtrip/app_roundtrip_(byte[],byte[3])_v8.teal diff --git a/tests/compile_asserts.py b/tests/compile_asserts.py index 85d660818..1e1a2b28e 100644 --- a/tests/compile_asserts.py +++ b/tests/compile_asserts.py @@ -17,7 +17,7 @@ def compile_and_save(approval, version: int, test_name: str) -> tuple[Path, str, with open(tealdir / (name + ".teal"), "w") as f: f.write(compiled) print( - f"""Successfuly tested approval program <<{name}>> having + f"""Successfuly tested approval program <<{name}>> having compiled it into {len(compiled)} characters. See the results in: {tealdir} """ @@ -51,7 +51,7 @@ def assert_new_v_old(approve_func, version: int, test_name: str): tealdir, name, compiled = compile_and_save(approve_func, version, test_name) print( - f"""Compilation resulted in TEAL program of length {len(compiled)}. + f"""Compilation resulted in TEAL program of length {len(compiled)}. To view output SEE <{name}.teal> in ({tealdir}) --------------""" ) diff --git a/tests/integration/abi_roundtrip_test.py b/tests/integration/abi_roundtrip_test.py index feda75870..5e6447422 100644 --- a/tests/integration/abi_roundtrip_test.py +++ b/tests/integration/abi_roundtrip_test.py @@ -76,6 +76,7 @@ class NamedTupleInherit(abi.NamedTuple): abi.Tuple1[abi.Uint32], abi.Tuple1[abi.Uint64], abi.Tuple2[abi.Bool, abi.Byte], + abi.Tuple2[abi.DynamicBytes, abi.StaticBytes[Literal[3]]], abi.Tuple3[abi.Bool, abi.Uint64, abi.Uint32], abi.Tuple3[abi.Byte, abi.Bool, abi.Uint64], abi.Tuple3[abi.Uint8, abi.Byte, abi.Bool], diff --git a/tests/integration/teal/roundtrip/app_roundtrip_(byte[],byte[3])_v6.teal b/tests/integration/teal/roundtrip/app_roundtrip_(byte[],byte[3])_v6.teal new file mode 100644 index 000000000..016ef564e --- /dev/null +++ b/tests/integration/teal/roundtrip/app_roundtrip_(byte[],byte[3])_v6.teal @@ -0,0 +1,251 @@ +#pragma version 6 +txna ApplicationArgs 0 +store 3 +load 3 +callsub roundtripper_1 +store 2 +byte 0x151f7c75 +load 2 +concat +log +int 1 +return + +// tuple_complement +tuplecomplement_0: +store 8 +load 8 +load 8 +int 0 +extract_uint16 +dig 1 +len +substring3 +store 0 +load 8 +extract 2 3 +store 1 +load 0 +callsub arraycomplement_3 +store 0 +load 1 +callsub arraycomplement_5 +store 1 +load 0 +store 27 +load 27 +store 26 +int 5 +store 25 +load 25 +itob +extract 6 0 +load 1 +concat +load 26 +concat +store 9 +load 9 +retsub + +// round_tripper +roundtripper_1: +store 4 +load 4 +callsub tuplecomplement_0 +store 6 +load 6 +callsub tuplecomplement_0 +store 7 +load 4 +store 31 +load 31 +store 30 +int 6 +store 28 +load 28 +load 31 +len ++ +store 29 +load 29 +int 65536 +< +assert +load 28 +itob +extract 6 0 +load 6 +store 31 +load 30 +load 31 +concat +store 30 +load 29 +store 28 +load 28 +load 31 +len ++ +store 29 +load 29 +int 65536 +< +assert +load 28 +itob +extract 6 0 +concat +load 7 +store 31 +load 30 +load 31 +concat +store 30 +load 29 +store 28 +load 28 +itob +extract 6 0 +concat +load 30 +concat +store 5 +load 5 +retsub + +// numerical_comp +numericalcomp_2: +store 15 +int 255 +load 15 +- +store 16 +load 16 +int 256 +< +assert +load 16 +retsub + +// array_complement +arraycomplement_3: +store 10 +load 10 +int 1 +int 0 +* +int 2 ++ +getbyte +store 12 +load 10 +int 1 +int 1 +* +int 2 ++ +getbyte +store 13 +load 10 +int 1 +int 2 +* +int 2 ++ +getbyte +store 14 +load 12 +callsub numericalcomp_2 +store 12 +load 13 +callsub numericalcomp_2 +store 13 +load 14 +callsub numericalcomp_2 +store 14 +int 3 +store 17 +load 17 +itob +extract 6 0 +byte 0x00 +int 0 +load 12 +setbyte +byte 0x00 +int 0 +load 13 +setbyte +concat +byte 0x00 +int 0 +load 14 +setbyte +concat +concat +store 11 +load 11 +retsub + +// numerical_comp +numericalcomp_4: +store 23 +int 255 +load 23 +- +store 24 +load 24 +int 256 +< +assert +load 24 +retsub + +// array_complement +arraycomplement_5: +store 18 +load 18 +int 1 +int 0 +* +getbyte +store 20 +load 18 +int 1 +int 1 +* +getbyte +store 21 +load 18 +int 1 +int 2 +* +getbyte +store 22 +load 20 +callsub numericalcomp_4 +store 20 +load 21 +callsub numericalcomp_4 +store 21 +load 22 +callsub numericalcomp_4 +store 22 +byte 0x00 +int 0 +load 20 +setbyte +byte 0x00 +int 0 +load 21 +setbyte +concat +byte 0x00 +int 0 +load 22 +setbyte +concat +store 19 +load 19 +retsub \ No newline at end of file diff --git a/tests/integration/teal/roundtrip/app_roundtrip_(byte[],byte[3])_v8.teal b/tests/integration/teal/roundtrip/app_roundtrip_(byte[],byte[3])_v8.teal new file mode 100644 index 000000000..a3b3139c6 --- /dev/null +++ b/tests/integration/teal/roundtrip/app_roundtrip_(byte[],byte[3])_v8.teal @@ -0,0 +1,284 @@ +#pragma version 8 +txna ApplicationArgs 0 +store 3 +load 3 +callsub roundtripper_1 +store 2 +byte 0x151f7c75 +load 2 +concat +log +int 1 +return + +// tuple_complement +tuplecomplement_0: +proto 1 1 +byte "" +int 0 +dup +byte "" +dup +int 0 +dupn 13 +byte "" +dup +int 0 +byte "" +dup +int 0 +dupn 10 +byte "" +dup +int 0 +dup +byte "" +dup +frame_dig -1 +frame_dig -1 +int 0 +extract_uint16 +dig 1 +len +substring3 +store 0 +frame_dig -1 +extract 2 3 +store 1 +load 0 +callsub arraycomplement_3 +store 0 +load 1 +callsub arraycomplement_5 +store 1 +load 0 +frame_bury 40 +frame_dig 40 +frame_bury 39 +int 5 +frame_bury 37 +frame_dig 37 +itob +extract 6 0 +load 1 +concat +frame_dig 39 +concat +frame_bury 0 +retsub + +// round_tripper +roundtripper_1: +proto 1 1 +byte "" +dupn 2 +int 0 +dup +byte "" +dup +frame_dig -1 +callsub tuplecomplement_0 +frame_bury 1 +frame_dig 1 +callsub tuplecomplement_0 +frame_bury 2 +frame_dig -1 +frame_bury 6 +frame_dig 6 +frame_bury 5 +int 6 +frame_bury 3 +frame_dig 3 +frame_dig 6 +len ++ +frame_bury 4 +frame_dig 4 +int 65536 +< +assert +frame_dig 3 +itob +extract 6 0 +frame_dig 1 +frame_bury 6 +frame_dig 5 +frame_dig 6 +concat +frame_bury 5 +frame_dig 4 +frame_bury 3 +frame_dig 3 +frame_dig 6 +len ++ +frame_bury 4 +frame_dig 4 +int 65536 +< +assert +frame_dig 3 +itob +extract 6 0 +concat +frame_dig 2 +frame_bury 6 +frame_dig 5 +frame_dig 6 +concat +frame_bury 5 +frame_dig 4 +frame_bury 3 +frame_dig 3 +itob +extract 6 0 +concat +frame_dig 5 +concat +frame_bury 0 +retsub + +// numerical_comp +numericalcomp_2: +proto 1 1 +int 0 +int 255 +frame_dig -1 +- +frame_bury 0 +frame_dig 0 +int 256 +< +assert +retsub + +// array_complement +arraycomplement_3: +proto 1 1 +byte "" +int 0 +dupn 13 +byte "" +dup +int 0 +frame_dig -1 +int 1 +int 0 +* +int 2 ++ +getbyte +frame_bury 1 +frame_dig -1 +int 1 +int 1 +* +int 2 ++ +getbyte +frame_bury 2 +frame_dig -1 +int 1 +int 2 +* +int 2 ++ +getbyte +frame_bury 3 +frame_dig 1 +callsub numericalcomp_2 +frame_bury 1 +frame_dig 2 +callsub numericalcomp_2 +frame_bury 2 +frame_dig 3 +callsub numericalcomp_2 +frame_bury 3 +int 3 +frame_bury 17 +frame_dig 17 +itob +extract 6 0 +byte 0x00 +int 0 +frame_dig 1 +setbyte +byte 0x00 +int 0 +frame_dig 2 +setbyte +concat +byte 0x00 +int 0 +frame_dig 3 +setbyte +concat +concat +frame_bury 0 +retsub + +// numerical_comp +numericalcomp_4: +proto 1 1 +int 0 +int 255 +frame_dig -1 +- +frame_bury 0 +frame_dig 0 +int 256 +< +assert +retsub + +// array_complement +arraycomplement_5: +proto 1 1 +byte "" +int 0 +dupn 10 +byte "" +dup +frame_dig -1 +int 1 +int 0 +* +getbyte +frame_bury 1 +frame_dig -1 +int 1 +int 1 +* +getbyte +frame_bury 2 +frame_dig -1 +int 1 +int 2 +* +getbyte +frame_bury 3 +frame_dig 1 +callsub numericalcomp_4 +frame_bury 1 +frame_dig 2 +callsub numericalcomp_4 +frame_bury 2 +frame_dig 3 +callsub numericalcomp_4 +frame_bury 3 +byte 0x00 +int 0 +frame_dig 1 +setbyte +byte 0x00 +int 0 +frame_dig 2 +setbyte +concat +byte 0x00 +int 0 +frame_dig 3 +setbyte +concat +frame_bury 0 +retsub \ No newline at end of file From 6c55c4a1971440078cefa26e23426102e6edd13d Mon Sep 17 00:00:00 2001 From: Hang Su Date: Thu, 9 Feb 2023 15:49:25 -0500 Subject: [PATCH 5/9] combine tuple index decode logic --- pyteal/ast/abi/tuple.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pyteal/ast/abi/tuple.py b/pyteal/ast/abi/tuple.py index e68daea81..93d4d4325 100644 --- a/pyteal/ast/abi/tuple.py +++ b/pyteal/ast/abi/tuple.py @@ -194,12 +194,10 @@ def _index_tuple( start_index = Int(offset) length = Int(valueType.byte_length_static()) - if index + 1 == len(value_types): - if offset == 0: + if offset == 0: + if index + 1 == len(value_types): # This is the first and only value in the tuple, so decode all of encoded return output.decode(encoded) - - if offset == 0: # This is the first value in the tuple, so decode the substring from 0 with length length return output.decode(encoded, length=length) From eaf8c262e31602f5d6e07889a56d7de2eee313ef Mon Sep 17 00:00:00 2001 From: Hang Su Date: Thu, 9 Feb 2023 17:21:53 -0500 Subject: [PATCH 6/9] optimize for all static case --- pyteal/ast/abi/tuple.py | 9 +++++++-- pyteal/ast/abi/tuple_test.py | 4 +--- ...trip_(byte[4],(bool,bool),uint64,address)[]_7_v6.teal | 2 +- ...trip_(byte[4],(bool,bool),uint64,address)[]_7_v8.teal | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pyteal/ast/abi/tuple.py b/pyteal/ast/abi/tuple.py index 93d4d4325..f22c22d41 100644 --- a/pyteal/ast/abi/tuple.py +++ b/pyteal/ast/abi/tuple.py @@ -194,10 +194,15 @@ def _index_tuple( start_index = Int(offset) length = Int(valueType.byte_length_static()) - if offset == 0: - if index + 1 == len(value_types): + if index + 1 == len(value_types): + if offset == 0: # This is the first and only value in the tuple, so decode all of encoded return output.decode(encoded) + elif all(not x.is_dynamic() for x in value_types): + # This is the last element in tuple with all elements being static typed + return output.decode(encoded, start_index=start_index) + + if offset == 0: # This is the first value in the tuple, so decode the substring from 0 with length length return output.decode(encoded, length=length) diff --git a/pyteal/ast/abi/tuple_test.py b/pyteal/ast/abi/tuple_test.py index 1d629f923..1bc1754dd 100644 --- a/pyteal/ast/abi/tuple_test.py +++ b/pyteal/ast/abi/tuple_test.py @@ -330,9 +330,7 @@ class IndexTest(NamedTuple): IndexTest( types=[byte_t, tuple_t], typeIndex=1, - expected=lambda output: output.decode( - encoded, start_index=pt.Int(1), length=pt.Int(1) - ), + expected=lambda output: output.decode(encoded, start_index=pt.Int(1)), ), IndexTest( types=[tuple_t, byte_t], diff --git a/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v6.teal b/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v6.teal index 73a675b5a..6e7ce0eb3 100644 --- a/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v6.teal +++ b/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v6.teal @@ -25,7 +25,7 @@ int 5 extract_uint64 store 2 load 19 -extract 13 32 +extract 13 0 store 3 load 0 callsub arraycomplement_4 diff --git a/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v8.teal b/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v8.teal index d6a2e3e00..c5580033b 100644 --- a/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v8.teal +++ b/tests/integration/teal/roundtrip/app_roundtrip_(byte[4],(bool,bool),uint64,address)[]_7_v8.teal @@ -44,7 +44,7 @@ int 5 extract_uint64 store 2 frame_dig -1 -extract 13 32 +extract 13 0 store 3 load 0 callsub arraycomplement_4 From dda9b0ab9df704f4ae8ea1574bda0cfd0ddb6e97 Mon Sep 17 00:00:00 2001 From: Hang Su Date: Fri, 10 Feb 2023 10:11:33 -0500 Subject: [PATCH 7/9] f string --- pyteal/ast/abi/array_base.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pyteal/ast/abi/array_base.py b/pyteal/ast/abi/array_base.py index 7fdf51dc6..cd7fa1f1b 100644 --- a/pyteal/ast/abi/array_base.py +++ b/pyteal/ast/abi/array_base.py @@ -84,7 +84,7 @@ def decode( *, start_index: Expr | None = None, end_index: Expr | None = None, - length: Expr | None = None + length: Expr | None = None, ) -> Expr: """Decode a substring of the passed in encoded byte string and set it as this type's value. @@ -128,11 +128,7 @@ def set(self, values: Sequence[T]) -> Expr: for index, value in enumerate(values): if self.type_spec().value_type_spec() != value.type_spec(): raise TealInputError( - "Cannot assign type {} at index {} to {}".format( - value.type_spec(), - index, - self.type_spec().value_type_spec(), - ) + f"Cannot assign type {value.type_spec()} at index {index} to {self.type_spec().value_type_spec()}" ) encoded = _encode_tuple(values) From 7bc748d4c7c38adbc139443726c65637aa2449ad Mon Sep 17 00:00:00 2001 From: Hang Su Date: Fri, 10 Feb 2023 10:32:14 -0500 Subject: [PATCH 8/9] reasonable testcase of using static bytes that makes a difference from master --- pyteal/ast/abi/tuple_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyteal/ast/abi/tuple_test.py b/pyteal/ast/abi/tuple_test.py index 1bc1754dd..d134aa781 100644 --- a/pyteal/ast/abi/tuple_test.py +++ b/pyteal/ast/abi/tuple_test.py @@ -236,6 +236,7 @@ class IndexTest(NamedTuple): tuple_t = abi.TupleTypeSpec(abi.BoolTypeSpec(), abi.BoolTypeSpec()) dynamic_array_t1 = abi.DynamicArrayTypeSpec(abi.Uint64TypeSpec()) dynamic_array_t2 = abi.DynamicArrayTypeSpec(abi.Uint16TypeSpec()) + static_bytes_t = abi.StaticBytesTypeSpec(2) encoded = pt.Bytes("encoded") @@ -372,12 +373,12 @@ class IndexTest(NamedTuple): ), ), IndexTest( - types=[dynamic_array_t1, byte_t], + types=[dynamic_array_t1, static_bytes_t], typeIndex=1, expected=lambda output: output.decode( encoded, start_index=pt.Int(2), - length=pt.Int(1), + length=pt.Int(2), ), ), IndexTest( From 8fb2e33f8448ddd58668855a2a71df0982a7678b Mon Sep 17 00:00:00 2001 From: Hang Su Date: Fri, 10 Feb 2023 13:11:46 -0500 Subject: [PATCH 9/9] update testcase and some logic --- pyteal/ast/abi/tuple.py | 2 +- pyteal/ast/abi/tuple_test.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pyteal/ast/abi/tuple.py b/pyteal/ast/abi/tuple.py index f22c22d41..a671518f5 100644 --- a/pyteal/ast/abi/tuple.py +++ b/pyteal/ast/abi/tuple.py @@ -198,7 +198,7 @@ def _index_tuple( if offset == 0: # This is the first and only value in the tuple, so decode all of encoded return output.decode(encoded) - elif all(not x.is_dynamic() for x in value_types): + if all(not x.is_dynamic() for x in value_types): # This is the last element in tuple with all elements being static typed return output.decode(encoded, start_index=start_index) diff --git a/pyteal/ast/abi/tuple_test.py b/pyteal/ast/abi/tuple_test.py index d134aa781..c3aaf02f4 100644 --- a/pyteal/ast/abi/tuple_test.py +++ b/pyteal/ast/abi/tuple_test.py @@ -381,6 +381,14 @@ class IndexTest(NamedTuple): length=pt.Int(2), ), ), + IndexTest( + types=[static_bytes_t, static_bytes_t], + typeIndex=1, + expected=lambda output: output.decode( + encoded, + start_index=pt.Int(2), + ), + ), IndexTest( types=[byte_t, dynamic_array_t1, byte_t], typeIndex=1,