Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
dd9abff
wtf
ahangsu Mar 30, 2022
d33e26c
update
ahangsu Mar 30, 2022
cd7632e
update to f-str
ahangsu Mar 31, 2022
a21ce2c
define void type
ahangsu Mar 31, 2022
480ece7
update instantiated computed type returnedType for ABI return in subr…
ahangsu Mar 31, 2022
ff0d275
minor
ahangsu Mar 31, 2022
6929922
update stuffs to help infer type annotation of return ABI
ahangsu Mar 31, 2022
c24e0bd
minor
ahangsu Mar 31, 2022
9e3989b
minor
ahangsu Mar 31, 2022
a1e138e
minor
ahangsu Mar 31, 2022
0d617ff
minor
ahangsu Mar 31, 2022
081bfb6
minor
ahangsu Mar 31, 2022
e8e481e
try my best to save stuffs
ahangsu Mar 31, 2022
bd29b95
Merge branch 'abi-subroutine' of github.com:algorand/pyteal into abi-…
ahangsu Mar 31, 2022
616968d
simplify decorator to single function
ahangsu Mar 31, 2022
12e3ee4
tear it down
ahangsu Mar 31, 2022
f6af8fa
minor
ahangsu Mar 31, 2022
fee70a6
sheeeesh emacs
ahangsu Mar 31, 2022
92b4db4
Merge branch 'feature/abi' into abi-subroutine
ahangsu Apr 1, 2022
41ba233
Merge branch 'feature/abi' into abi-subroutine
ahangsu Apr 12, 2022
f0101d0
updates
ahangsu Apr 12, 2022
1b5cd6a
Merge branch 'feature/abi' into abi-subroutine
ahangsu Apr 14, 2022
a2d9ea2
minor, renaming something
ahangsu Apr 14, 2022
91c87b7
new design, start over
ahangsu Apr 14, 2022
3fb7374
updates
ahangsu Apr 15, 2022
2e27f82
Merge branch 'feature/abi' into abi-subroutine
ahangsu Apr 21, 2022
cf3106d
abi fn wrapper for now
ahangsu Apr 23, 2022
6969622
Merge branch 'feature/abi' into abi-subroutine
ahangsu Apr 23, 2022
dec018f
minor
ahangsu Apr 23, 2022
54fe3bc
minor update on subroutine def
ahangsu Apr 24, 2022
4e5e1e5
minor fixes
ahangsu Apr 24, 2022
287ba71
minor fixes
ahangsu Apr 24, 2022
fa33095
changes
ahangsu Apr 25, 2022
43212b7
more constraint on void ret
ahangsu Apr 25, 2022
31cf527
update comment examples
ahangsu Apr 25, 2022
87c34d8
import from abi
ahangsu Apr 25, 2022
b0baea5
update some error msg and comments
ahangsu Apr 25, 2022
1c48d0c
testcases partial
ahangsu Apr 26, 2022
319b953
upgrade testscripts
ahangsu Apr 27, 2022
96f7ede
Bundle optional refactorings to subroutine.py (#308)
michaeldiamant Apr 29, 2022
79d787b
storing local changes
ahangsu May 2, 2022
ae7b552
Merge branch 'abi-subroutine' of github.com:algorand/pyteal into abi-…
ahangsu May 2, 2022
9422ea3
pr review partly
ahangsu May 2, 2022
02f442a
pr review partly
ahangsu May 2, 2022
c9ed2b2
update test script
ahangsu May 2, 2022
21447bb
Abi subroutine feature merge (#315)
tzaffi May 3, 2022
d43905e
Merge branch 'feature/abi' into abi-subroutine
ahangsu May 3, 2022
d0737ef
resolve conflicts
May 3, 2022
0e776a4
Merge branch 'abi-subroutine' of github.com:algorand/pyteal into abi-…
May 3, 2022
73b595f
lint
May 3, 2022
6557649
Merge branch 'feature/abi' into abi-subroutine
ahangsu May 3, 2022
7ace3fc
minor reconstruct
ahangsu May 3, 2022
1479959
Merge branch 'abi-subroutine' of github.com:algorand/pyteal into abi-…
May 3, 2022
386d57b
missing imports
May 3, 2022
939dea4
missing requirements from bad merge
May 3, 2022
87eafdd
Merge branch 'feature/abi' into abi-subroutine
ahangsu May 4, 2022
4512c96
Merge branch 'feature/abi' into abi-subroutine
ahangsu May 4, 2022
69d389b
cooperate with typespec n var def change
ahangsu May 4, 2022
5378983
Merge branch 'feature/abi' into abi-subroutine
ahangsu May 4, 2022
f42339d
update comments
ahangsu May 4, 2022
59226b2
some comments resolving?
ahangsu May 5, 2022
44003d6
trim
ahangsu May 5, 2022
9f13409
update some comments
ahangsu May 5, 2022
5941108
bring testcase back
ahangsu May 5, 2022
c161e22
restriction on output kwarg name
ahangsu May 5, 2022
d2caed3
stop ci! i am reformatting
ahangsu May 5, 2022
bba1709
simplify name constrain
ahangsu May 9, 2022
4c0858f
resolving comments
ahangsu May 9, 2022
dc2e060
Merge branch 'feature/abi' into abi-subroutine
ahangsu May 9, 2022
95caac5
Use deferred subroutine expression for ABI returns (#328)
jasonpaulos May 9, 2022
d21e281
Merge branch 'abi-subroutine' of github.com:algorand/pyteal into abi-…
ahangsu May 9, 2022
fad77c6
hack return from abi var
ahangsu May 9, 2022
aa6f858
a hack
ahangsu May 9, 2022
4c148f7
better returned type
ahangsu May 9, 2022
b35ce21
simplify
ahangsu May 9, 2022
5ae1fe6
Merge branch 'feature/abi' into abi-subroutine
ahangsu May 10, 2022
a0c6a42
add some compiler test
ahangsu May 10, 2022
a14f271
flake break no way
ahangsu May 10, 2022
365090c
PR comment resolve partial
ahangsu May 11, 2022
76acb31
polishing
ahangsu May 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyteal/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ from pyteal.errors import (
from pyteal.config import MAX_GROUP_SIZE, NUM_SLOTS

__all__ = [
"ABIReturnSubroutine",
"AccountParam",
"Add",
"Addr",
Expand Down
4 changes: 3 additions & 1 deletion pyteal/ast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
from pyteal.ast.substring import Substring, Extract, Suffix

# more ops
from pyteal.ast.naryexpr import NaryExpr, And, Add, Mul, Or, Concat
from pyteal.ast.naryexpr import NaryExpr, Add, And, Mul, Or, Concat
from pyteal.ast.widemath import WideRatio

# control flow
Expand All @@ -118,6 +118,7 @@
SubroutineDeclaration,
SubroutineCall,
SubroutineFnWrapper,
ABIReturnSubroutine,
)
from pyteal.ast.while_ import While
from pyteal.ast.for_ import For
Expand Down Expand Up @@ -242,6 +243,7 @@
"SubroutineDeclaration",
"SubroutineCall",
"SubroutineFnWrapper",
"ABIReturnSubroutine",
"ScratchIndex",
"ScratchLoad",
"ScratchSlot",
Expand Down
3 changes: 2 additions & 1 deletion pyteal/ast/abi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Address,
AddressLength,
)
from pyteal.ast.abi.type import TypeSpec, BaseType, ComputedValue
from pyteal.ast.abi.type import TypeSpec, BaseType, ComputedValue, ReturnedValue
from pyteal.ast.abi.bool import BoolTypeSpec, Bool
from pyteal.ast.abi.uint import (
UintTypeSpec,
Expand Down Expand Up @@ -47,6 +47,7 @@
"TypeSpec",
"BaseType",
"ComputedValue",
"ReturnedValue",
"BoolTypeSpec",
"Bool",
"UintTypeSpec",
Expand Down
39 changes: 38 additions & 1 deletion pyteal/ast/abi/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class ComputedValue(ABC, Generic[T]):
"""Represents an ABI Type whose value must be computed by an expression."""

@abstractmethod
def produced_type_spec(cls) -> TypeSpec:
def produced_type_spec(self) -> TypeSpec:
"""Get the ABI TypeSpec that this object produces."""
pass

Expand Down Expand Up @@ -182,3 +182,40 @@ def use(self, action: Callable[[T], Expr]) -> Expr:


ComputedValue.__module__ = "pyteal"


class ReturnedValue(ComputedValue):
def __init__(self, type_spec: TypeSpec, computation_expr: Expr):
from pyteal.ast.subroutine import SubroutineCall

self.type_spec = type_spec
if not isinstance(computation_expr, SubroutineCall):
raise TealInputError(
f"Expecting computation_expr to be SubroutineCall but get {type(computation_expr)}"
)
self.computation = computation_expr

def produced_type_spec(self) -> TypeSpec:
return self.type_spec

def store_into(self, output: BaseType) -> Expr:
if output.type_spec() != self.produced_type_spec():
raise TealInputError(
f"expected type_spec {self.produced_type_spec()} but get {output.type_spec()}"
)

declaration = self.computation.subroutine.get_declaration()

if declaration.deferred_expr is None:
raise TealInputError(
"ABI return subroutine must have deferred_expr to be not-None."
)
if declaration.deferred_expr.type_of() != output.type_spec().storage_type():
raise TealInputError(
f"ABI return subroutine deferred_expr is expected to be typed {output.type_spec().storage_type()}, "
f"but has type {declaration.deferred_expr.type_of()}."
)
return output.stored_value.slot.store(self.computation)


ReturnedValue.__module__ = "pyteal"
2 changes: 1 addition & 1 deletion pyteal/ast/abi/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def substringForDecoding(
*,
startIndex: Expr = None,
endIndex: Expr = None,
length: Expr = None
length: Expr = None,
) -> Expr:
"""A helper function for getting the substring to decode according to the rules of BaseType.decode."""
if length is not None and endIndex is not None:
Expand Down
Loading