-
Notifications
You must be signed in to change notification settings - Fork 0
/
brc.py
72 lines (64 loc) · 2.33 KB
/
brc.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from beaker import *
from pyteal import *
from typing import Final
class Blockrat(Application):
viewer: Final[ApplicationStateValue] = ApplicationStateValue(
stack_type=TealType.bytes,
default=Bytes(""),
descr="Address of the viewer",
)
geo_location: Final[ApplicationStateValue] = ApplicationStateValue(
stack_type=TealType.bytes,
default=Bytes(""),
descr="Geo Location Data",
)
# validation_code: Final[ApplicationStateValue] = ApplicationStateValue(
# stack_type=TealType.bytes,
# default=Bytes(""),
# descr="Validation Code In Hash"
# )
@create
def create(self):
return self.initialize_application_state()
@external(authorize=Authorize.only(Global.creator_address()))
def opt_into_asset(self, asset: abi.Asset):
return Seq(
InnerTxnBuilder.Execute(
{
TxnField.type_enum: TxnType.AssetTransfer,
TxnField.asset_receiver: Global.current_application_address(),
TxnField.xfer_asset: asset.asset_id(),
TxnField.asset_amount: Int(0),
TxnField.fee: Int(0),
}
),
)
@external(authorize=Authorize.only(Global.creator_address()))
def submission(self, asset:abi.Asset, viewer: abi.Account, geo: abi.String):
return Seq(
self.geo_location.set(geo.get()),
InnerTxnBuilder.Execute(
{
TxnField.type_enum: TxnType.AssetTransfer,
TxnField.asset_receiver: viewer.address(),
TxnField.xfer_asset: asset.asset_id(),
TxnField.asset_amount: Int(100),
TxnField.fee: Int(0),
}
),
)
@external
def claim_asset(self, asset: abi.Asset, recipient: abi.Account):
return Seq(
InnerTxnBuilder.Execute(
{
TxnField.type_enum: TxnType.AssetTransfer,
TxnField.fee: Int(0),
TxnField.xfer_asset: asset.asset_id(),
TxnField.asset_receiver: recipient.address(),
}
),
Approve()
)
blockrat_instance = Blockrat(version=8)
blockrat_instance.dump()