Skip to content

Commit

Permalink
0.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
stechu committed May 6, 2020
1 parent 01d3a4a commit 5c22a45
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 30 deletions.
54 changes: 27 additions & 27 deletions pyteal/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class GlobalField(Enum):
class Tmpl(LeafExpr):

# default constrcutor
def __init__(self, tmpl_v:str):
def __init__(self, tmpl_v:str) -> None:
valid_tmpl(tmpl_v)
self.name = tmpl_v

Expand All @@ -139,7 +139,7 @@ def type_of(self):
class Addr(LeafExpr):

# default constructor
def __init__(self, address):
def __init__(self, address) -> None:
if isinstance(address, Tmpl):
self.address = address.name
else:
Expand All @@ -159,7 +159,7 @@ def type_of(self):
class Bytes(LeafExpr):

#default constructor
def __init__(self, base:str, byte_str):
def __init__(self, base:str, byte_str) -> None:
if base == "base32":
self.base = base
if isinstance(byte_str, Tmpl):
Expand Down Expand Up @@ -227,7 +227,7 @@ def type_of(self):
class Arg(LeafExpr):

# default constructor
def __init__(self, index:int):
def __init__(self, index:int) -> None:
if type(index) is not int:
raise TealInputError("invalid arg input type {}".format(
type(index)))
Expand Down Expand Up @@ -318,7 +318,7 @@ def type_of(self):
class Lt(BinaryExpr):

# default constructor
def __init__(self, left:Expr, right:Expr):
def __init__(self, left:Expr, right:Expr) -> None:
require_type(left.type_of(), TealType.uint64)
require_type(right.type_of(), TealType.uint64)
self.left = left
Expand All @@ -338,7 +338,7 @@ def type_of(self):
class Gt(BinaryExpr):

# default constructor
def __init__(self, left:Expr, right:Expr):
def __init__(self, left:Expr, right:Expr) -> None:
require_type(left.type_of(), TealType.uint64)
require_type(right.type_of(), TealType.uint64)
self.left = left
Expand All @@ -357,7 +357,7 @@ def type_of(self):
class Ge(BinaryExpr):

# default constructor
def __init__(self, left:Expr, right:Expr):
def __init__(self, left:Expr, right:Expr) -> None:
require_type(left.type_of(), TealType.uint64)
require_type(right.type_of(), TealType.uint64)
self.left = left
Expand All @@ -376,7 +376,7 @@ def type_of(self):
class Le(BinaryExpr):

# default constructor
def __init__(self, left:Expr, right:Expr):
def __init__(self, left:Expr, right:Expr) -> None:
require_type(left.type_of(), TealType.uint64)
require_type(right.type_of(), TealType.uint64)
self.left = left
Expand All @@ -396,7 +396,7 @@ def type_of(self):
class Eq(BinaryExpr):

# default constructor
def __init__(self, left:Expr, right:Expr):
def __init__(self, left:Expr, right:Expr) -> None:
# type checking
t1 = left.type_of()
t2 = right.type_of()
Expand All @@ -420,7 +420,7 @@ def type_of(self):
class Len(UnaryExpr):

# default constructor
def __init__(self, child:Expr):
def __init__(self, child:Expr) -> None:
require_type(child.type_of(), TealType.bytes)
self.child = child

Expand All @@ -438,7 +438,7 @@ def type_of(self):
class Txn(LeafExpr):

# default constructor
def __init__(self, field:TxnField):
def __init__(self, field:TxnField) -> None:
self.field = field

def __str__(self):
Expand Down Expand Up @@ -547,7 +547,7 @@ def type_of(self):
class Global(LeafExpr):

# default constructor
def __init__(self, field:GlobalField):
def __init__(self, field:GlobalField) -> None:
self.field = field

def __teal__(self):
Expand Down Expand Up @@ -584,7 +584,7 @@ def type_of(self):
class Ed25519Verify(NaryExpr):

# default constructor
def __init__(self, arg0:Expr, arg1:Expr, arg2:Expr):
def __init__(self, arg0:Expr, arg1:Expr, arg2:Expr) -> None:
require_type(arg0.type_of(), TealType.bytes)
require_type(arg1.type_of(), TealType.bytes)
require_type(arg2.type_of(), TealType.bytes)
Expand All @@ -608,7 +608,7 @@ def type_of(self):
class Gtxn(LeafExpr):

# default constructor
def __init__(self, index:int, field:TxnField):
def __init__(self, index:int, field:TxnField) -> None:
require_type(type(index), int)
if index < 0 or index >= MAX_GROUP_SIZE :
raise TealInputError("invalid Gtxn index {}, shoud [0, {})".format(
Expand Down Expand Up @@ -722,7 +722,7 @@ def type_of(self):
class If(NaryExpr):

#default constructor
def __init__(self, arg0:Expr, arg1:Expr, arg2:Expr):
def __init__(self, arg0:Expr, arg1:Expr, arg2:Expr) -> None:
require_type(arg0.type_of(), TealType.uint64)
require_type(arg2.type_of(), arg1.type_of())

Expand All @@ -748,7 +748,7 @@ def type_of(self):

class Add(BinaryExpr):

def __init__(self, left:Expr, right:Expr):
def __init__(self, left:Expr, right:Expr) -> None:
require_type(left.type_of(), TealType.uint64)
require_type(right.type_of(), TealType.uint64)
self.left = left
Expand All @@ -766,7 +766,7 @@ def type_of(self):

class Minus(BinaryExpr):

def __init__(self, left:Expr, right:Expr):
def __init__(self, left:Expr, right:Expr) -> None:
require_type(left.type_of(), TealType.uint64)
require_type(right.type_of(), TealType.uint64)
self.left = left
Expand All @@ -784,7 +784,7 @@ def type_of(self):

class Mul(BinaryExpr):

def __init__(self, left:Expr, right:Expr):
def __init__(self, left:Expr, right:Expr) -> None:
require_type(left.type_of(), TealType.uint64)
require_type(right.type_of(), TealType.uint64)
self.left = left
Expand All @@ -801,7 +801,7 @@ def type_of(self):

class Div(BinaryExpr):

def __init__(self, left:Expr, right:Expr):
def __init__(self, left:Expr, right:Expr) -> None:
require_type(left.type_of(), TealType.uint64)
require_type(right.type_of(), TealType.uint64)
self.left = left
Expand All @@ -819,7 +819,7 @@ def type_of(self):

class Mod(BinaryExpr):

def __init__(self, left:Expr, right:Expr):
def __init__(self, left:Expr, right:Expr) -> None:
require_type(left.type_of(), TealType.uint64)
require_type(right.type_of(), TealType.uint64)
self.left = left
Expand All @@ -838,7 +838,7 @@ def type_of(self):
class Btoi(UnaryExpr):

# default constructor
def __init__(self, child:Expr):
def __init__(self, child:Expr) -> None:
require_type(child.type_of(), TealType.bytes)
self.child = child

Expand All @@ -855,7 +855,7 @@ def type_of(self):
class Itob(UnaryExpr):

# default constructor
def __init__(self, child:Expr):
def __init__(self, child:Expr) -> None:
require_type(child.type_of(), TealType.uint64)
self.child = child

Expand All @@ -872,7 +872,7 @@ def type_of(self):
class Keccak256(UnaryExpr):

# default constructor
def __init__(self, child:Expr):
def __init__(self, child:Expr) -> None:
require_type(child.type_of(), TealType.bytes)
self.child = child

Expand All @@ -889,7 +889,7 @@ def type_of(self):
class Sha512_256(UnaryExpr):

# default constructor
def __init__(self, child:Expr):
def __init__(self, child:Expr) -> None:
require_type(child.type_of(), TealType.bytes)
self.child = child

Expand All @@ -906,7 +906,7 @@ def type_of(self):
class Sha256(UnaryExpr):

# default constructor
def __init__(self, child:Expr):
def __init__(self, child:Expr) -> None:
require_type(child.type_of(), TealType.bytes)
self.child = child

Expand All @@ -923,7 +923,7 @@ def type_of(self):
class Nonce(UnaryExpr):

#default constructor
def __init__(self, base:str, nonce:str, child:Expr):
def __init__(self, base:str, nonce:str, child:Expr) -> None:
self.child = child
self.nonce_bytes = Bytes(base, nonce)

Expand Down Expand Up @@ -992,7 +992,7 @@ def make_if(conds):
e = conds[0]
return If(e[0], e[1], make_if(conds[1:]))

desugared = make_ite(self.args)
desugared = make_if(self.args)
return desugared.__teal__()

def __str__(self):
Expand Down
2 changes: 1 addition & 1 deletion pyteal/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TealType(Enum):

class TealInternalError(Exception):

def __init__(self, message:str):
def __init__(self, message:str) -> None:
self.message = "Internal Error: {}".format(message)

def __str__(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name="pyteal", # Replace with your own username
version="0.5.3",
version="0.5.4",
author="Shumo Chu",
author_email="shumo.chu@gmail.com",
description="Algorand Smart Contracts in Python",
Expand Down
11 changes: 10 additions & 1 deletion tests/compile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,13 @@ def test_split():
&&"""

assert split.teal() == target



def test_cond():
cond1 = Txn.fee() < Int(2000)
cond2 = Txn.amount() > Int(5000)
cond3 = Txn.receiver() == Txn.sender()
core = Cond([Global.group_size()==Int(2), cond1],
[Global.group_size()==Int(3), cond2],
[Global.group_size()==Int(4), cond3])
core.teal()

0 comments on commit 5c22a45

Please sign in to comment.