4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | @Callable(b) |
---|
7 | | - | func emitEvent (c,d,e,f,g,h,i) = { |
---|
8 | | - | let j = { |
---|
9 | | - | let k = parseBigInt(i) |
---|
10 | | - | if ($isInstanceOf(k, "BigInt")) |
---|
11 | | - | then { |
---|
12 | | - | let l = k |
---|
13 | | - | l |
---|
14 | | - | } |
---|
15 | | - | else if ($isInstanceOf(k, "Unit")) |
---|
16 | | - | then throw("incorrect amount") |
---|
17 | | - | else throw("Match error") |
---|
18 | | - | } |
---|
19 | | - | let m = { |
---|
20 | | - | let k = getInteger("EVENTS_LAST_IDX") |
---|
21 | | - | if ($isInstanceOf(k, "Int")) |
---|
22 | | - | then { |
---|
23 | | - | let l = k |
---|
24 | | - | l |
---|
25 | | - | } |
---|
26 | | - | else if ($isInstanceOf(k, "Unit")) |
---|
27 | | - | then 0 |
---|
28 | | - | else throw("Match error") |
---|
29 | | - | } |
---|
30 | | - | let n = makeString([toString(c), toString(d), toString(e), f, g, h, toString(j)], a) |
---|
31 | | - | $Tuple2([StringEntry(("EVENTS__" + toString(m)), n), IntegerEntry("EVENTS_LAST_IDX", (m + 1))], unit) |
---|
32 | | - | } |
---|
35 | | - | |
---|
36 | | - | @Callable(b) |
---|
37 | | - | func depositInsurance () = { |
---|
38 | | - | let o = if ((size(b.payments) != 1)) |
---|
39 | | - | then throw("no payment") |
---|
40 | | - | else if ((b.payments[0].assetId == unit)) |
---|
41 | | - | then throw("payment is not WAVES") |
---|
42 | | - | else if ((0 >= b.payments[0].amount)) |
---|
43 | | - | then throw("zero payment") |
---|
44 | | - | else unit |
---|
45 | | - | if ((o == o)) |
---|
46 | | - | then $Tuple2([IntegerEntry(("INSURANCE_FREE__" + toBase58String(b.caller.bytes)), b.payments[0].amount)], unit) |
---|
47 | | - | else throw("Strict value is not equal to itself.") |
---|
48 | | - | } |
---|
49 | | - | |
---|
50 | | - | |
---|
51 | | - | |
---|
52 | | - | @Callable(b) |
---|
53 | | - | func withdrawInsurance () = { |
---|
54 | | - | let p = { |
---|
55 | | - | let k = getInteger(("INSURANCE_FREE__" + toBase58String(b.caller.bytes))) |
---|
56 | | - | if ($isInstanceOf(k, "Int")) |
---|
57 | | - | then { |
---|
58 | | - | let l = k |
---|
59 | | - | if ((l > 0)) |
---|
60 | | - | then l |
---|
61 | | - | else throw("no free insurance") |
---|
62 | | - | } |
---|
63 | | - | else throw("no insurance") |
---|
64 | | - | } |
---|
65 | | - | $Tuple2([ScriptTransfer(b.caller, p, unit), IntegerEntry(("INSURANCE_FREE__" + toBase58String(b.caller.bytes)), 0)], unit) |
---|
66 | | - | } |
---|
67 | | - | |
---|
68 | | - | |
---|
69 | | - | @Verifier(q) |
---|
70 | | - | func r () = sigVerify(q.bodyBytes, q.proofs[0], q.senderPublicKey) |
---|