1 | | - | {-# STDLIB_VERSION 5 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | |
---|
5 | | - | |
---|
6 | | - | @Callable(a) |
---|
7 | | - | func deposit () = { |
---|
8 | | - | let b = if ((size(a.payments) > 0)) |
---|
9 | | - | then a.payments[0] |
---|
10 | | - | else throw("At least one payment expected") |
---|
11 | | - | let c = if (isDefined(b.assetId)) |
---|
12 | | - | then value(b.assetId) |
---|
13 | | - | else throw("Only WAVES payment accepted") |
---|
14 | | - | [IntegerEntry(toString(a.caller), b.amount)] |
---|
15 | | - | } |
---|
16 | | - | |
---|
17 | | - | |
---|
18 | | - | |
---|
19 | | - | @Callable(a) |
---|
20 | | - | func withdraw (d) = { |
---|
21 | | - | let e = toString(a.caller) |
---|
22 | | - | let f = valueOrErrorMessage(getInteger(this, e), "You don't have a deposit") |
---|
23 | | - | let g = if (if ((d > 0)) |
---|
24 | | - | then true |
---|
25 | | - | else (d > f)) |
---|
26 | | - | then d |
---|
27 | | - | else throw("Amount to withdraw must be more than 0 and less than current deposit") |
---|
28 | | - | if ((d == f)) |
---|
29 | | - | then [DeleteEntry(e)] |
---|
30 | | - | else [IntegerEntry(e, (f - d)), ScriptTransfer(a.caller, d, unit)] |
---|
31 | | - | } |
---|
32 | | - | |
---|
33 | | - | |
---|
34 | | - | |
---|
35 | | - | @Callable(a) |
---|
36 | | - | func allArgTypes (h,i,j,k,l) = { |
---|
37 | | - | let m = [1, 2, 3, 4, 5] |
---|
38 | | - | func n (o,p) = if ((p >= size(l))) |
---|
39 | | - | then o |
---|
40 | | - | else { |
---|
41 | | - | let q = toString(p) |
---|
42 | | - | (o :+ { |
---|
43 | | - | let r = l[p] |
---|
44 | | - | if ($isInstanceOf(r, "Boolean")) |
---|
45 | | - | then { |
---|
46 | | - | let s = r |
---|
47 | | - | BooleanEntry((q + "-bool"), s) |
---|
48 | | - | } |
---|
49 | | - | else if ($isInstanceOf(r, "ByteVector")) |
---|
50 | | - | then { |
---|
51 | | - | let s = r |
---|
52 | | - | BinaryEntry((q + "-bin"), s) |
---|
53 | | - | } |
---|
54 | | - | else if ($isInstanceOf(r, "Int")) |
---|
55 | | - | then { |
---|
56 | | - | let t = r |
---|
57 | | - | IntegerEntry((q + "-int"), t) |
---|
58 | | - | } |
---|
59 | | - | else if ($isInstanceOf(r, "String")) |
---|
60 | | - | then { |
---|
61 | | - | let u = r |
---|
62 | | - | StringEntry((q + "-str"), u) |
---|
63 | | - | } |
---|
64 | | - | else throw("Match error") |
---|
65 | | - | }) |
---|
66 | | - | } |
---|
67 | | - | |
---|
68 | | - | ([BooleanEntry("bool", h), BinaryEntry("bin", i), IntegerEntry("int", j), StringEntry("str", k)] ++ { |
---|
69 | | - | let v = m |
---|
70 | | - | let w = size(v) |
---|
71 | | - | let x = nil |
---|
72 | | - | func y (z,A) = if ((A >= w)) |
---|
73 | | - | then z |
---|
74 | | - | else n(z, v[A]) |
---|
75 | | - | |
---|
76 | | - | func B (z,A) = if ((A >= w)) |
---|
77 | | - | then z |
---|
78 | | - | else throw("List size exceeds 5") |
---|
79 | | - | |
---|
80 | | - | B(y(y(y(y(y(x, 0), 1), 2), 3), 4), 5) |
---|
81 | | - | }) |
---|
82 | | - | } |
---|
83 | | - | |
---|
84 | | - | |
---|
| 1 | + | # no script |
---|