-
Notifications
You must be signed in to change notification settings - Fork 0
/
SendZil.scilla
65 lines (55 loc) · 1.63 KB
/
SendZil.scilla
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
scilla_version 0
contract SendZil
()
field test_field : Uint256 = Uint256 0
field bool : Bool = True
field empty_bool : Option Bool = None {Bool}
field some_int : Option Int32 = let ten = Int32 10 in
Some {Int32} ten
field pair: Pair String Uint32 =
let s1 = "Hello" in
let num = Uint32 2 in
Pair {String Uint32} s1 num
field list : List Int32 =
let nil = Nil {Int32} in
let one = Int32 1 in
Cons {Int32} one nil
transition acceptZil ()
accept;
v <- _balance;
ev = {_eventname: "currentBalance"; value: v};
event ev
end
transition updateTestField (val : Uint256)
test_field := val
end
transition dontAcceptZil ()
v <- _balance;
ev = {_eventname: "currentBalance"; value: v};
event ev
end
(* See ZIL-5165 *)
transition fundUserWithTag( user : ByStr20, amount : Uint128)
msg = { _tag : "AddFunds"; _recipient : user ; _amount : amount };
no_msg = Nil {Message};
msgs = Cons {Message} msg no_msg;
send msgs
end
transition fundUser (user : ByStr20, amount : Uint128)
msg = { _tag : "" ; _recipient : user ; _amount : amount };
no_msg = Nil {Message};
msgs = Cons {Message} msg no_msg;
send msgs
end
transition fundContract (contract_address : ByStr20, amount : Uint128)
msg = { _tag : "acceptZil" ; _recipient : contract_address ; _amount : amount };
no_msg = Nil {Message};
msgs = Cons {Message} msg no_msg;
send msgs
end
transition callOtherContract (contract_address : ByStr20, tag : String, value : Uint256)
msg = { _tag : tag ; _recipient : contract_address ; _amount : Uint128 0 ; val: value};
no_msg = Nil {Message};
msgs = Cons {Message} msg no_msg;
send msgs
end