-
Notifications
You must be signed in to change notification settings - Fork 0
/
contracts.py
46 lines (34 loc) · 1.26 KB
/
contracts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from pyteal import *
def approval_program():
i = ScratchVar(TealType.uint64)
# test = ScratchVar(TealType.bytes)
handle_noop = Seq([
Pop(Keccak256(Bytes("a"))),
Pop(Keccak256(Bytes("b"))),
Pop(Keccak256(Bytes("c"))),
Pop(Keccak256(Bytes("d"))),
If(Btoi(Txn.application_args[0])).Then(Seq([
Pop(Keccak256(Bytes("e"))),
Pop(Keccak256(Bytes("f"))),
]))
.Else(Seq([
# Pop(Keccak256(Bytes("g"))),
])
),
# test.store(Bytes("1")),
# For(i.store(Int(0)), i.load() < Int(4), i.store(i.load() + Int(1))).Do(
# Log(Keccak256(Itob(i.load())))
# ),
Approve()
])
program = Cond(
[Txn.application_id() == Int(0), Approve()],
[Txn.on_completion() == OnComplete.OptIn, Reject()],
[Txn.on_completion() == OnComplete.CloseOut, Reject()],
[Txn.on_completion() == OnComplete.UpdateApplication, Approve()],
[Txn.on_completion() == OnComplete.DeleteApplication, Reject()],
[Txn.on_completion() == OnComplete.NoOp, handle_noop]
)
return compileTeal(program, Mode.Application, version=5)
def clear_state_program():
return compileTeal(Approve(), Mode.Application, version=5)