1 | | - | {-# STDLIB_VERSION 3 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = base58'9UUaVVahBUyLHLQo4HNuQsRMKY9QBH43Grojkbdf4wG4' |
---|
5 | | - | |
---|
6 | | - | let b = "destination_wallet_address" |
---|
7 | | - | |
---|
8 | | - | let c = "btc" |
---|
9 | | - | |
---|
10 | | - | let d = "eth" |
---|
11 | | - | |
---|
12 | | - | let e = "waves" |
---|
13 | | - | |
---|
14 | | - | let f = "ltc" |
---|
15 | | - | |
---|
16 | | - | func g () = { |
---|
17 | | - | let h = getString(this, b) |
---|
18 | | - | if ($isInstanceOf(h, "String")) |
---|
19 | | - | then { |
---|
20 | | - | let i = h |
---|
21 | | - | if ((i == "")) |
---|
22 | | - | then throw("Destination wallet address cannot be empty") |
---|
23 | | - | else addressFromStringValue(i) |
---|
24 | | - | } |
---|
25 | | - | else throw("Destination wallet address undefined") |
---|
26 | | - | } |
---|
27 | | - | |
---|
28 | | - | |
---|
29 | | - | func j (k,l) = (((k + "_") + l) + "_canceled") |
---|
30 | | - | |
---|
31 | | - | |
---|
32 | | - | func m (k,l,n) = (((((k + "_player_") + l) + "_bet_") + n) + "_amount") |
---|
33 | | - | |
---|
34 | | - | |
---|
35 | | - | func o (k,l,n) = (((((k + "_player_") + l) + "_") + n) + "_share_sum") |
---|
36 | | - | |
---|
37 | | - | |
---|
38 | | - | func p (k) = (k + "_total_bet_amount") |
---|
39 | | - | |
---|
40 | | - | |
---|
41 | | - | func q (k,r) = (((k + "_") + toString(r)) + "_place_player_address") |
---|
42 | | - | |
---|
43 | | - | |
---|
44 | | - | func s (k,n) = (((k + "_") + n) + "_start_price") |
---|
45 | | - | |
---|
46 | | - | |
---|
47 | | - | func t (k,n) = (((k + "_") + n) + "_end_price") |
---|
48 | | - | |
---|
49 | | - | |
---|
50 | | - | func u (k,l) = { |
---|
51 | | - | let h = getBoolean(this, j(k, l)) |
---|
52 | | - | if ($isInstanceOf(h, "Boolean")) |
---|
53 | | - | then { |
---|
54 | | - | let i = h |
---|
55 | | - | i |
---|
56 | | - | } |
---|
57 | | - | else true |
---|
58 | | - | } |
---|
59 | | - | |
---|
60 | | - | |
---|
61 | | - | @Callable(v) |
---|
62 | | - | func setDestinationWallet (w) = if ((v.callerPublicKey != a)) |
---|
63 | | - | then throw("Only owner can call this method") |
---|
64 | | - | else if ((w == "")) |
---|
65 | | - | then throw("Address cannot be empty") |
---|
66 | | - | else WriteSet([DataEntry(b, w)]) |
---|
67 | | - | |
---|
68 | | - | |
---|
69 | | - | |
---|
70 | | - | @Callable(v) |
---|
71 | | - | func bet (k,x,y,z,A,B) = { |
---|
72 | | - | let C = toString(k) |
---|
73 | | - | let D = extract(v.payment) |
---|
74 | | - | let E = D.amount |
---|
75 | | - | let F = toBase58String(v.caller.bytes) |
---|
76 | | - | if (u(C, F)) |
---|
77 | | - | then throw("Your bet has been canceled, you cannot bet in this race anymore") |
---|
78 | | - | else { |
---|
79 | | - | let G = ((((((C + F) + toString(E)) + toString(x)) + toString(y)) + toString(z)) + toString(A)) |
---|
80 | | - | if (!(sigVerify(toBytes(G), B, a))) |
---|
81 | | - | then throw("Cannot verify signature") |
---|
82 | | - | else { |
---|
83 | | - | let H = { |
---|
84 | | - | let h = getInteger(this, p(C)) |
---|
85 | | - | if ($isInstanceOf(h, "Int")) |
---|
86 | | - | then { |
---|
87 | | - | let i = h |
---|
88 | | - | i |
---|
89 | | - | } |
---|
90 | | - | else 0 |
---|
91 | | - | } |
---|
92 | | - | let I = (H + E) |
---|
93 | | - | WriteSet([DataEntry(p(C), I), DataEntry(m(C, F, e), E), DataEntry(o(C, F, c), x), DataEntry(o(C, F, d), y), DataEntry(o(C, F, e), z), DataEntry(o(C, F, f), A)]) |
---|
94 | | - | } |
---|
95 | | - | } |
---|
96 | | - | } |
---|
97 | | - | |
---|
98 | | - | |
---|
99 | | - | |
---|
100 | | - | @Callable(v) |
---|
101 | | - | func cancelBet (k,B) = { |
---|
102 | | - | let C = toString(k) |
---|
103 | | - | let F = toBase58String(v.caller.bytes) |
---|
104 | | - | if (u(C, F)) |
---|
105 | | - | then throw("Bet already canceled") |
---|
106 | | - | else { |
---|
107 | | - | let G = ((toString(k) + F) + "cancel") |
---|
108 | | - | if (!(sigVerify(toBytes(G), B, a))) |
---|
109 | | - | then throw("Cannot verify signature") |
---|
110 | | - | else { |
---|
111 | | - | let J = p(C) |
---|
112 | | - | let K = getIntegerValue(this, m(C, F, e)) |
---|
113 | | - | let L = getIntegerValue(this, J) |
---|
114 | | - | let I = (L - K) |
---|
115 | | - | if ((0 > I)) |
---|
116 | | - | then throw("New state of total bet will be less than zero, state error") |
---|
117 | | - | else ScriptResult(WriteSet([DataEntry(j(C, F), true), DataEntry(J, I)]), TransferSet([ScriptTransfer(addressFromStringValue(F), K, unit)])) |
---|
118 | | - | } |
---|
119 | | - | } |
---|
120 | | - | } |
---|
121 | | - | |
---|
122 | | - | |
---|
123 | | - | |
---|
124 | | - | @Callable(v) |
---|
125 | | - | func endRace (M,N,O,P,Q,R,S,T,U,V,W,X) = if ((v.callerPublicKey != a)) |
---|
126 | | - | then throw("Only owner can call endRace") |
---|
127 | | - | else { |
---|
128 | | - | let C = toString(M) |
---|
129 | | - | let H = getIntegerValue(this, p(C)) |
---|
130 | | - | let Y = getIntegerValue(this, m(C, N, e)) |
---|
131 | | - | let Z = getIntegerValue(this, m(C, O, e)) |
---|
132 | | - | let aa = getIntegerValue(this, m(C, P, e)) |
---|
133 | | - | let ab = (Y * 2) |
---|
134 | | - | let ac = ((Z * 3) / 2) |
---|
135 | | - | let ad = aa |
---|
136 | | - | let ae = (H - ((ab + ac) + ad)) |
---|
137 | | - | if ((0 >= ae)) |
---|
138 | | - | then throw("Commission must be greater than zero, state error") |
---|
139 | | - | else { |
---|
140 | | - | let af = wavesBalance(this) |
---|
141 | | - | let ag = (af - ae) |
---|
142 | | - | if ((0 > ag)) |
---|
143 | | - | then throw("Not enough funds in core account") |
---|
144 | | - | else ScriptResult(WriteSet([DataEntry(q(C, 1), N), DataEntry(q(C, 2), O), DataEntry(q(C, 3), P), DataEntry(s(C, c), Q), DataEntry(t(C, c), R), DataEntry(s(C, d), S), DataEntry(t(C, d), T), DataEntry(s(C, e), U), DataEntry(t(C, e), V), DataEntry(s(C, f), W), DataEntry(t(C, f), X)]), TransferSet([ScriptTransfer(addressFromStringValue(N), ab, unit), ScriptTransfer(addressFromStringValue(O), ac, unit), ScriptTransfer(addressFromStringValue(P), ad, unit), ScriptTransfer(g(), ae, unit)])) |
---|
145 | | - | } |
---|
146 | | - | } |
---|
147 | | - | |
---|
148 | | - | |
---|
| 1 | + | # no script |
---|