-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathtest19.liq
More file actions
57 lines (50 loc) · 1.41 KB
/
test19.liq
File metadata and controls
57 lines (50 loc) · 1.41 KB
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
type storage = {
key : key;
hash : bytes;
c : address;
}
let%init storage : storage = {
key = 0x0085b1e4560f47f089d7b97aabcf46937a4c137a9c3f96f73f20c83621694e36d5;
hash = 0xabcdef;
c = KT1LLcCCB9Fr1hrkGzfdiJ9u3ZajbdckBFrF%default;
}
contract PlusOne = struct
type storage = int
type t = A | B
let%init init_storage (x : bool) (y : int) = if x = false then 0 else y
let%entry default (_ : unit) s =
[], s + 1
end
let%entry default
(sign : signature)
storage =
let x = PlusOne.A in
begin match x with
| PlusOne.B -> failwith ()
| _ -> () end;
let c = Contract.self () in
let key_hash = Crypto.hash_key storage.key in
if key_hash = tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx then
Current.failwith ();
if key_hash =
Crypto.hash_key edpkuTXkJDGcFd5nh6VvMz8phXxU3Bi7h6hqgywNFi1vZTfQNnS1RV then
Current.failwith ();
let delegate = Some key_hash in
let spendable = Crypto.check storage.key sign storage.hash in
let amount = Current.amount () in
let amount = match amount / 2p with
None -> Current.failwith () (* not possible *)
| Some qr -> qr
in
let delegatable = false in
let _cocococ = [%handle PlusOne.default] storage.c in
let _op1 = Self.default sign ~amount:0tz in
let c_op, c_addr =
Contract.create
~delegate
~amount:amount.(0)
~storage:9
(contract PlusOne)
in
let storage = storage.c <- c_addr in
( [c_op], storage )