Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
223 commits
Select commit Hold shift + click to select a range
c73a2d9
init commit
ahangsu Jan 25, 2022
897ff6a
minor
ahangsu Jan 25, 2022
90fcfef
minor
ahangsu Jan 25, 2022
01c114e
rm decorator
ahangsu Jan 26, 2022
46daf5c
update ABI router design, seems we are still working on previous design
ahangsu Jan 26, 2022
8ea2bcb
minor
ahangsu Jan 26, 2022
0208800
update condition parser here
ahangsu Jan 27, 2022
9adec41
skeleton for handler wrapping, need to tweak on subroutine to expose …
ahangsu Jan 27, 2022
3953180
module
ahangsu Jan 27, 2022
ed874fa
Merge branch 'master' into abi-router
ahangsu Jan 27, 2022
2bf75c3
use subroutine fn wrapper
ahangsu Jan 27, 2022
5115383
update dummy method return class
ahangsu Jan 28, 2022
2d1c6e3
unify ast construct way
ahangsu Jan 28, 2022
0f8be9e
minor
ahangsu Jan 28, 2022
92d3242
update notes for tasks and todos
ahangsu Feb 1, 2022
bb204bf
update handler wrapping for bare app call
ahangsu Feb 1, 2022
ea66a6f
minor
ahangsu Feb 1, 2022
09bd24c
update redirecting args to method registered
ahangsu Feb 1, 2022
dfbec9b
minor
ahangsu Feb 1, 2022
88a565f
minor
ahangsu Feb 1, 2022
8c54acc
update router src
ahangsu Feb 1, 2022
1d6fa03
update program node
ahangsu Feb 1, 2022
7d683c3
add questions in build prog
ahangsu Feb 1, 2022
28c3a46
update executing method branch
ahangsu Feb 1, 2022
0633c88
minor
ahangsu Feb 1, 2022
e5cbdc7
minor
ahangsu Feb 2, 2022
e8d54d8
minor
ahangsu Feb 2, 2022
52cd87c
hide other methods, set MethodAppArgNumLimit, keyword args on exposed…
ahangsu Feb 3, 2022
fb544fe
minor
ahangsu Feb 3, 2022
096d693
update notes
ahangsu Feb 3, 2022
26c3ea0
update
ahangsu Feb 8, 2022
541b707
add a default for no registered ast gen
ahangsu Feb 9, 2022
ad50f67
Merge branch 'master' into abi-router
ahangsu Feb 10, 2022
f959cba
update ast construction to conds
ahangsu Mar 1, 2022
2794fa4
need some documentations
ahangsu Mar 1, 2022
2f6408a
Merge branch 'feature/abi' into abi-router
ahangsu Mar 2, 2022
47e684c
move abi-router in abi dir
ahangsu Mar 2, 2022
0d2dfcd
minor
ahangsu Mar 3, 2022
50a15e2
Merge branch 'feature/abi' into abi-router
ahangsu Mar 3, 2022
af0edbb
Merge branch 'master' into feature/abi
ahangsu Mar 3, 2022
0f06507
Merge branch 'feature/abi' into abi-router
ahangsu Mar 3, 2022
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
ce425d3
Merge branch 'feature/abi' into abi-router
ahangsu Apr 7, 2022
aa938f9
update with latest abi impl
ahangsu Apr 7, 2022
80c4d50
minors
ahangsu Apr 7, 2022
79492e7
minor
ahangsu Apr 7, 2022
41ba233
Merge branch 'feature/abi' into abi-subroutine
ahangsu Apr 12, 2022
f0101d0
updates
ahangsu Apr 12, 2022
2c724be
Merge branch 'feature/abi' into abi-router
ahangsu Apr 14, 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
67831ff
merging feature/abi to abi-router (#305)
barnjamin Apr 28, 2022
a18c47d
Export Router (#306)
barnjamin Apr 28, 2022
8ff5cc8
Merge branch 'feature/abi' into abi-router
barnjamin Apr 28, 2022
5d78129
fix spacing issue
barnjamin Apr 28, 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
cdd1e73
Merge branch 'feature/abi' into abi-router
ahangsu May 6, 2022
a262e3d
squash merge abi subroutine atm, merge again after abi subroutine int…
ahangsu May 6, 2022
2690233
conform to pep8, reconstructing
ahangsu May 6, 2022
c0c37f8
update json generator
ahangsu May 6, 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
4706832
Merge branch 'abi-subroutine' into abi-router
ahangsu May 9, 2022
3416b75
Merge branch 'feature/abi' into abi-router
ahangsu May 11, 2022
0169078
updating wrap handler
ahangsu May 12, 2022
a04a897
change how to de-tuple args
ahangsu May 12, 2022
bc6b8dc
update checkbox
ahangsu May 12, 2022
5516d89
minor
ahangsu May 12, 2022
b8e8d1f
bug fixes
ahangsu May 12, 2022
16199ec
Method sig for router (#340)
barnjamin May 13, 2022
d8b7b3d
minor, renaming
ahangsu May 13, 2022
d911e42
minor
ahangsu May 13, 2022
6eded9f
Merge branch 'feature/abi' into abi-router
ahangsu May 13, 2022
179ac5d
simplify
ahangsu May 13, 2022
1e7d779
compiler test adding...
ahangsu May 13, 2022
377cb22
documentation
ahangsu May 16, 2022
407f3d1
start testcases
ahangsu May 16, 2022
9fbdfec
update router testcase
ahangsu May 16, 2022
b348c65
docstring tweak
ahangsu May 16, 2022
d95ae32
update testcases
ahangsu May 16, 2022
e8a43a7
update testcases
ahangsu May 16, 2022
19460c0
formatting
ahangsu May 16, 2022
fa28de4
branch cond testing
ahangsu May 17, 2022
9961c1a
router contract test
ahangsu May 17, 2022
95f90c7
subroutine branch wrapper bare call case tested
ahangsu May 17, 2022
8923ef5
more testcases to barecall
ahangsu May 17, 2022
3576223
minor, need to work on method call wrapper
ahangsu May 17, 2022
b8ea59a
half done on method call wrapper
ahangsu May 17, 2022
a940f5e
update on abi method wrapper with return
ahangsu May 17, 2022
648d075
detuple testcase
ahangsu May 17, 2022
7a1c456
compiler test need to see csp
ahangsu May 17, 2022
818e839
rm redundant type annotation
ahangsu May 17, 2022
5fc8610
more error msg
ahangsu May 17, 2022
8f73760
renaming
ahangsu May 18, 2022
c598217
renaming is_registrable -> is_abi_routable
ahangsu May 18, 2022
a1d2c21
reording imports, eliminate anti patterns
ahangsu May 18, 2022
a0a7648
remove anti-pattern
ahangsu May 18, 2022
4d2e57e
section it out
ahangsu May 18, 2022
e162275
non_empty_power_set -> power_set
ahangsu May 18, 2022
2dafe23
add conflict detection to protect AST from overshadowing
ahangsu May 18, 2022
11f4cff
error message
ahangsu May 18, 2022
241e7ee
shrinked commits on pr review
ahangsu May 19, 2022
9b1205a
add compile_program
ahangsu May 19, 2022
fca1fb3
Merge branch 'feature/abi' into abi-router
ahangsu May 19, 2022
912b16b
fixup subroutine testcase
ahangsu May 19, 2022
d28fdc6
remove method signature specifying, directly infer from ABIReturnSubr…
ahangsu May 19, 2022
e8b4765
remove method sign field, directly infer from ABIReturnSubroutine
ahangsu May 19, 2022
e350220
relaxation of bare app call arg num restriction
ahangsu May 19, 2022
0b63f78
add barecall class, api change following
ahangsu May 19, 2022
f198857
rename barecall to OnCompleteAction
ahangsu May 20, 2022
d5f75d3
remove outdated comments
ahangsu May 20, 2022
bf58a10
Merge branch 'feature/abi' into abi-router
ahangsu May 20, 2022
0dd7208
start changing router api
ahangsu May 20, 2022
89f137b
eliminate contradiction for oc and creation
ahangsu May 23, 2022
ecd2767
remove restriction on cond
ahangsu May 23, 2022
4e8efe2
new interface: add bare-calls on init, register method-call more fine…
ahangsu May 24, 2022
89ab167
documentation for new interface from last discussion
ahangsu May 24, 2022
0ecfd62
Merge branch 'feature/abi' into abi-router
ahangsu May 24, 2022
59c86d1
Refactor #170 to reduce visibility and mutation (#362)
michaeldiamant May 25, 2022
2d203ff
hide wrap handler method
ahangsu May 25, 2022
a99b964
Merge branch 'abi-router' of github.com:algorand/pyteal into abi-router
ahangsu May 25, 2022
2557efc
adding comment changes
ahangsu May 25, 2022
a65d66e
pr review partly
ahangsu May 25, 2022
f38caed
partition into two methods
ahangsu May 25, 2022
0f10534
hide all these methods
ahangsu May 25, 2022
2323920
arc4 compliant CallConfigs classmethod
ahangsu May 25, 2022
9cea65d
arc4 compliant CallConfigs documentation
ahangsu May 25, 2022
065a797
disclaimer comments
ahangsu May 25, 2022
f1bb613
Merge branch 'feature/abi' into abi-router
ahangsu May 25, 2022
e0dc4bd
update new abi return hash prefix
ahangsu May 26, 2022
34ee8dc
review comments partly
ahangsu May 26, 2022
94d618b
OnCompleteActions -> BareCallActions
ahangsu May 26, 2022
f7185b9
disclaimer change, rename CallConfigs -> MethodConfig
ahangsu May 26, 2022
2958bc0
disclaimer move to docstring
ahangsu May 26, 2022
6f386dd
better naming for naming prefix
ahangsu May 26, 2022
aa69b0f
new ast builder
ahangsu May 26, 2022
e7a49f1
review comments
ahangsu May 27, 2022
22cf520
An attempt to add decorator syntax to abi-router (#370)
ahangsu May 27, 2022
f66b7e4
minor fix
ahangsu May 27, 2022
c42da1e
per pr comment on on-complete-action
ahangsu May 27, 2022
c0af62e
eliminate potential issue
ahangsu May 27, 2022
78ca6fb
update call config testcase
ahangsu May 27, 2022
4aa69c6
add testcase for on complete action
ahangsu May 27, 2022
7df0996
per comments
ahangsu May 27, 2022
1753a94
Add a check in `method_signature` to disallow reference return types …
barnjamin May 31, 2022
5b9c547
add new compiler tests for router
ahangsu May 31, 2022
3a76144
fix one test for wrapping bare calls
ahangsu May 31, 2022
eee9545
comments fixing
ahangsu May 31, 2022
b2c025e
simplified oc-action post_init check
ahangsu May 31, 2022
c6019b0
naming variables
ahangsu May 31, 2022
5e41d13
comments
ahangsu May 31, 2022
197a9d3
comments
ahangsu May 31, 2022
2128874
Merge branch 'feature/abi' into abi-router
ahangsu May 31, 2022
dbffe61
testcase for method config update
ahangsu Jun 1, 2022
a3a8601
add router method only in clearstate prog
ahangsu Jun 1, 2022
f6ad9ad
closeout -> clearstate
ahangsu Jun 1, 2022
4e95c20
removing is_arc4_compliant
ahangsu Jun 1, 2022
00376a6
update add method handler and method interface
ahangsu Jun 1, 2022
c56d837
remove arc4_compliant
ahangsu Jun 1, 2022
c8ef39a
Add manual test for 15+ args in abi router (#375)
jasonpaulos Jun 1, 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
9 changes: 8 additions & 1 deletion pyteal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
TealInputError,
TealCompileError,
)
from pyteal.config import MAX_GROUP_SIZE, NUM_SLOTS
from pyteal.config import (
MAX_GROUP_SIZE,
NUM_SLOTS,
RETURN_HASH_PREFIX,
METHOD_ARG_NUM_CUTOFF,
)

# begin __all__
__all__ = (
Expand All @@ -37,6 +42,8 @@
"TealCompileError",
"MAX_GROUP_SIZE",
"NUM_SLOTS",
"RETURN_HASH_PREFIX",
"METHOD_ARG_NUM_CUTOFF",
]
)
# end __all__
14 changes: 13 additions & 1 deletion pyteal/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ from pyteal.errors import (
TealInputError,
TealCompileError,
)
from pyteal.config import MAX_GROUP_SIZE, NUM_SLOTS
from pyteal.config import (
MAX_GROUP_SIZE,
NUM_SLOTS,
RETURN_HASH_PREFIX,
METHOD_ARG_NUM_CUTOFF,
)

__all__ = [
"ABIReturnSubroutine",
Expand All @@ -38,6 +43,7 @@ __all__ = [
"AssetHolding",
"AssetParam",
"Balance",
"BareCallActions",
"BinaryExpr",
"BitLen",
"BitwiseAnd",
Expand All @@ -64,6 +70,7 @@ __all__ = [
"BytesSqrt",
"BytesXor",
"BytesZero",
"CallConfig",
"CompileOptions",
"Concat",
"Cond",
Expand Down Expand Up @@ -117,8 +124,10 @@ __all__ = [
"Lt",
"MAX_GROUP_SIZE",
"MAX_TEAL_VERSION",
"METHOD_ARG_NUM_CUTOFF",
"MIN_TEAL_VERSION",
"MaybeValue",
"MethodConfig",
"MethodSignature",
"MinBalance",
"Minus",
Expand All @@ -132,14 +141,17 @@ __all__ = [
"Nonce",
"Not",
"OnComplete",
"OnCompleteAction",
"Op",
"OpUp",
"OpUpMode",
"OptimizeOptions",
"Or",
"Pop",
"RETURN_HASH_PREFIX",
"Reject",
"Return",
"Router",
"ScratchIndex",
"ScratchLoad",
"ScratchSlot",
Expand Down
13 changes: 12 additions & 1 deletion pyteal/ast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
from pyteal.ast.break_ import Break
from pyteal.ast.continue_ import Continue


# misc
from pyteal.ast.scratch import (
ScratchIndex,
Expand All @@ -139,6 +138,13 @@
from pyteal.ast.multi import MultiValue
from pyteal.ast.opup import OpUp, OpUpMode
from pyteal.ast.ecdsa import EcdsaCurve, EcdsaVerify, EcdsaDecompress, EcdsaRecover
from pyteal.ast.router import (
Router,
CallConfig,
MethodConfig,
OnCompleteAction,
BareCallActions,
)

# abi
import pyteal.ast.abi as abi # noqa: I250
Expand Down Expand Up @@ -280,6 +286,11 @@
"For",
"Break",
"Continue",
"Router",
"CallConfig",
"MethodConfig",
"OnCompleteAction",
"BareCallActions",
"abi",
"EcdsaCurve",
"EcdsaVerify",
Expand Down
2 changes: 2 additions & 0 deletions pyteal/ast/abi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
make,
size_of,
type_spec_from_annotation,
contains_type_spec,
)

__all__ = [
Expand Down Expand Up @@ -103,4 +104,5 @@
"size_of",
"algosdk_from_annotation",
"algosdk_from_type_spec",
"contains_type_spec",
]
8 changes: 4 additions & 4 deletions pyteal/ast/abi/method_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pyteal.errors import TealInputError
from pyteal.ast import Expr, Log, Concat, Bytes
from pyteal.ir import TealBlock, TealSimpleBlock, Op
from pyteal.config import RETURN_METHOD_SELECTOR
from pyteal.config import RETURN_HASH_PREFIX

if TYPE_CHECKING:
from pyteal.compiler import CompileOptions
Expand All @@ -22,9 +22,9 @@ def __teal__(self, options: "CompileOptions") -> Tuple[TealBlock, TealSimpleBloc
raise TealInputError(
f"current version {options.version} is lower than log's min version {Op.log.min_version}"
)
return Log(
Concat(Bytes("base16", RETURN_METHOD_SELECTOR), self.arg.encode())
).__teal__(options)
return Log(Concat(Bytes(RETURN_HASH_PREFIX), self.arg.encode())).__teal__(
options
)

def __str__(self) -> str:
return f"(MethodReturn {self.arg.type_spec()})"
Expand Down
12 changes: 2 additions & 10 deletions pyteal/ast/abi/string.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, TypeVar, Sequence, cast
from typing import Union, Sequence, cast
from collections.abc import Sequence as CollectionSequence

from pyteal.ast.abi.uint import Byte
Expand All @@ -20,9 +20,6 @@ def encoded_string(s: Expr):
return Concat(Suffix(Itob(Len(s)), Int(6)), s)


T = TypeVar("T", bound=BaseType)


class StringTypeSpec(DynamicArrayTypeSpec):
def __init__(self) -> None:
super().__init__(ByteTypeSpec())
Expand Down Expand Up @@ -70,12 +67,7 @@ def set(

match value:
case ComputedValue():
if value.produced_type_spec() == StringTypeSpec():
return value.store_into(self)

raise TealInputError(
f"Got ComputedValue with type spec {value.produced_type_spec()}, expected StringTypeSpec"
)
return self._set_with_computed_type(value)
case BaseType():
if value.type_spec() == StringTypeSpec() or (
value.type_spec() == DynamicArrayTypeSpec(ByteTypeSpec())
Expand Down
25 changes: 24 additions & 1 deletion pyteal/ast/abi/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TypeVar, Any, Literal, get_origin, get_args, cast
from typing import Sequence, TypeVar, Any, Literal, get_origin, get_args, cast

import algosdk.abi

Expand Down Expand Up @@ -235,6 +235,29 @@ def type_spec_from_annotation(annotation: Any) -> TypeSpec:
T = TypeVar("T", bound=BaseType)


def contains_type_spec(ts: TypeSpec, targets: Sequence[TypeSpec]) -> bool:
from pyteal.ast.abi.array_dynamic import DynamicArrayTypeSpec
from pyteal.ast.abi.array_static import StaticArrayTypeSpec
from pyteal.ast.abi.tuple import TupleTypeSpec

stack: list[TypeSpec] = [ts]

while stack:
current = stack.pop()
if current in targets:
return True

match current:
case TupleTypeSpec():
stack.extend(current.value_type_specs())
case DynamicArrayTypeSpec():
stack.append(current.value_type_spec())
case StaticArrayTypeSpec():
stack.append(current.value_type_spec())

return False


def size_of(t: type[T]) -> int:
"""Get the size in bytes of an ABI type. Must be a static type"""

Expand Down
5 changes: 1 addition & 4 deletions pyteal/ast/return_.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ def __teal__(self, options: "CompileOptions"):
)
op = Op.return_

args = []
if self.value is not None:
args.append(self.value)

args = [] if self.value is None else [self.value]
return TealBlock.FromOp(options, TealOp(self, op), *args)

def __str__(self):
Expand Down
Loading