2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "_amount" |
---|
5 | | - | |
---|
6 | | - | let b = "_probability" |
---|
7 | | - | |
---|
8 | | - | let c = "_probability_decimal" |
---|
9 | | - | |
---|
10 | | - | let d = "_price" |
---|
11 | | - | |
---|
12 | | - | let e = "_lottery_prices" |
---|
13 | | - | |
---|
14 | | - | let f = "_lottery_asset_id" |
---|
15 | | - | |
---|
16 | | - | let g = "_count_prices" |
---|
17 | | - | |
---|
18 | | - | let h = "last_spin_random_hash" |
---|
19 | | - | |
---|
20 | | - | let i = "last_token_random_hash" |
---|
21 | | - | |
---|
22 | | - | let j = "3BKFQLeo5ExZ5Y1pt9Ftzsno7aRwzD96zoYVHP3tcLgV" |
---|
23 | | - | |
---|
24 | | - | let k = 14 |
---|
25 | | - | |
---|
26 | | - | func l (m) = { |
---|
27 | | - | let n = { |
---|
28 | | - | let o = getBinary(this, h) |
---|
29 | | - | if ($isInstanceOf(o, "ByteVector")) |
---|
30 | | - | then { |
---|
31 | | - | let p = o |
---|
32 | | - | p |
---|
33 | | - | } |
---|
34 | | - | else if ($isInstanceOf(o, "Unit")) |
---|
35 | | - | then base58'2ee4oFDYriWJ9EMeR' |
---|
36 | | - | else throw("Match error") |
---|
37 | | - | } |
---|
38 | | - | let q = (((((n + m.transactionId) + m.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) |
---|
39 | | - | sha256(q) |
---|
40 | | - | } |
---|
41 | | - | |
---|
42 | | - | |
---|
43 | | - | func r (m) = { |
---|
44 | | - | let s = { |
---|
45 | | - | let o = getBinary(this, i) |
---|
46 | | - | if ($isInstanceOf(o, "ByteVector")) |
---|
47 | | - | then { |
---|
48 | | - | let p = o |
---|
49 | | - | p |
---|
50 | | - | } |
---|
51 | | - | else if ($isInstanceOf(o, "Unit")) |
---|
52 | | - | then base58'4dD7osCQzvuXJdTiGfKvTwnKT' |
---|
53 | | - | else throw("Match error") |
---|
54 | | - | } |
---|
55 | | - | let q = (((((s + m.transactionId) + m.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) |
---|
56 | | - | sha256(q) |
---|
57 | | - | } |
---|
58 | | - | |
---|
59 | | - | |
---|
60 | | - | func t () = { |
---|
61 | | - | let u = getStringValue(this, e) |
---|
62 | | - | let v = take(u, (size(u) - 1)) |
---|
63 | | - | let w = split(v, ",") |
---|
64 | | - | w |
---|
65 | | - | } |
---|
66 | | - | |
---|
67 | | - | |
---|
68 | | - | func x (y,z) = { |
---|
69 | | - | let A = indexOf(y, ",") |
---|
70 | | - | if ((A == unit)) |
---|
71 | | - | then (z + ",") |
---|
72 | | - | else ((y + z) + ",") |
---|
73 | | - | } |
---|
74 | | - | |
---|
75 | | - | |
---|
76 | | - | func B (C,y) = { |
---|
77 | | - | let D = getIntegerValue(this, (y + b)) |
---|
78 | | - | let E = getIntegerValue(this, (y + c)) |
---|
79 | | - | let F = (E * 1000) |
---|
80 | | - | let G = (E % F) |
---|
81 | | - | let H = size(C) |
---|
82 | | - | if ((H == 1)) |
---|
83 | | - | then { |
---|
84 | | - | let I = C[0] |
---|
85 | | - | if ((F > G)) |
---|
86 | | - | then { |
---|
87 | | - | let J = y :: C |
---|
88 | | - | J |
---|
89 | | - | } |
---|
90 | | - | else C |
---|
91 | | - | } |
---|
92 | | - | else C |
---|
93 | | - | } |
---|
94 | | - | |
---|
95 | | - | |
---|
96 | | - | @Callable(K) |
---|
97 | | - | func updateprobability (L,M,N,O,P) = { |
---|
98 | | - | let y = toBase64String(r(K)) |
---|
99 | | - | let Q = if (!(isDefined(K.payment))) |
---|
100 | | - | then false |
---|
101 | | - | else true |
---|
102 | | - | let R = if ((P == "")) |
---|
103 | | - | then true |
---|
104 | | - | else false |
---|
105 | | - | let S = (M * N) |
---|
106 | | - | if ((Q == true)) |
---|
107 | | - | then { |
---|
108 | | - | let T = extract(K.payment) |
---|
109 | | - | let U = { |
---|
110 | | - | let o = T.assetId |
---|
111 | | - | if ($isInstanceOf(o, "ByteVector")) |
---|
112 | | - | then { |
---|
113 | | - | let V = o |
---|
114 | | - | toBase64String(V) |
---|
115 | | - | } |
---|
116 | | - | else if ($isInstanceOf(o, "Unit")) |
---|
117 | | - | then "" |
---|
118 | | - | else throw("Match error") |
---|
119 | | - | } |
---|
120 | | - | let W = T.amount |
---|
121 | | - | if ((U != P)) |
---|
122 | | - | then throw("Asset Id not matching with Payment Asset Id") |
---|
123 | | - | else if ((S > W)) |
---|
124 | | - | then throw("Not enough Asset Amount") |
---|
125 | | - | else { |
---|
126 | | - | let X = { |
---|
127 | | - | let o = getString(this, e) |
---|
128 | | - | if ($isInstanceOf(o, "String")) |
---|
129 | | - | then { |
---|
130 | | - | let V = o |
---|
131 | | - | V |
---|
132 | | - | } |
---|
133 | | - | else if ($isInstanceOf(o, "Unit")) |
---|
134 | | - | then "" |
---|
135 | | - | else throw("Match error") |
---|
136 | | - | } |
---|
137 | | - | let Y = indexOf(X, y) |
---|
138 | | - | let Z = { |
---|
139 | | - | let o = Y |
---|
140 | | - | if ($isInstanceOf(o, "Unit")) |
---|
141 | | - | then ((X + y) + ",") |
---|
142 | | - | else if ($isInstanceOf(o, "Int")) |
---|
143 | | - | then { |
---|
144 | | - | let aa = o |
---|
145 | | - | throw("Token is duplicated") |
---|
146 | | - | } |
---|
147 | | - | else throw("Match error") |
---|
148 | | - | } |
---|
149 | | - | let ab = { |
---|
150 | | - | let o = getInteger(this, g) |
---|
151 | | - | if ($isInstanceOf(o, "Int")) |
---|
152 | | - | then { |
---|
153 | | - | let V = o |
---|
154 | | - | V |
---|
155 | | - | } |
---|
156 | | - | else if ($isInstanceOf(o, "Unit")) |
---|
157 | | - | then 0 |
---|
158 | | - | else throw("Match error") |
---|
159 | | - | } |
---|
160 | | - | if ((k >= ab)) |
---|
161 | | - | then { |
---|
162 | | - | let ac = WriteSet([DataEntry((y + a), M), DataEntry((y + b), L), DataEntry((y + d), N), DataEntry(e, Z), DataEntry(g, (ab + 1)), DataEntry((y + c), O), DataEntry((y + f), P), DataEntry(i, y)]) |
---|
163 | | - | ScriptResult(ac, TransferSet(nil)) |
---|
164 | | - | } |
---|
165 | | - | else throw(("Lottery prices has reached maximum " + toString(k))) |
---|
166 | | - | } |
---|
167 | | - | } |
---|
168 | | - | else { |
---|
169 | | - | let ad = if (R) |
---|
170 | | - | then wavesBalance(this) |
---|
171 | | - | else assetBalance(this, fromBase64String(P)) |
---|
172 | | - | if ((S > ad)) |
---|
173 | | - | then throw("Not enough Asset Amount") |
---|
174 | | - | else { |
---|
175 | | - | let X = { |
---|
176 | | - | let o = getString(this, e) |
---|
177 | | - | if ($isInstanceOf(o, "String")) |
---|
178 | | - | then { |
---|
179 | | - | let V = o |
---|
180 | | - | V |
---|
181 | | - | } |
---|
182 | | - | else if ($isInstanceOf(o, "Unit")) |
---|
183 | | - | then "" |
---|
184 | | - | else throw("Match error") |
---|
185 | | - | } |
---|
186 | | - | let Y = indexOf(X, y) |
---|
187 | | - | let Z = { |
---|
188 | | - | let o = Y |
---|
189 | | - | if ($isInstanceOf(o, "Unit")) |
---|
190 | | - | then ((X + y) + ",") |
---|
191 | | - | else if ($isInstanceOf(o, "Int")) |
---|
192 | | - | then { |
---|
193 | | - | let aa = o |
---|
194 | | - | throw("Token is duplicated") |
---|
195 | | - | } |
---|
196 | | - | else throw("Match error") |
---|
197 | | - | } |
---|
198 | | - | let ab = { |
---|
199 | | - | let o = getInteger(this, g) |
---|
200 | | - | if ($isInstanceOf(o, "Int")) |
---|
201 | | - | then { |
---|
202 | | - | let V = o |
---|
203 | | - | V |
---|
204 | | - | } |
---|
205 | | - | else if ($isInstanceOf(o, "Unit")) |
---|
206 | | - | then 0 |
---|
207 | | - | else throw("Match error") |
---|
208 | | - | } |
---|
209 | | - | if ((k >= ab)) |
---|
210 | | - | then { |
---|
211 | | - | let ac = WriteSet([DataEntry((y + a), M), DataEntry((y + b), L), DataEntry((y + d), N), DataEntry(e, Z), DataEntry(g, (ab + 1)), DataEntry((y + c), O), DataEntry((y + f), P), DataEntry(i, y)]) |
---|
212 | | - | ScriptResult(ac, TransferSet(nil)) |
---|
213 | | - | } |
---|
214 | | - | else throw("Lottery prices has reached maximum 15") |
---|
215 | | - | } |
---|
216 | | - | } |
---|
217 | | - | } |
---|
218 | | - | |
---|
219 | | - | |
---|
220 | | - | |
---|
221 | | - | @Callable(K) |
---|
222 | | - | func startlotto () = { |
---|
223 | | - | let ae = toBase58String(K.caller.bytes) |
---|
224 | | - | let af = l(K) |
---|
225 | | - | let ab = { |
---|
226 | | - | let o = getInteger(this, g) |
---|
227 | | - | if ($isInstanceOf(o, "Int")) |
---|
228 | | - | then { |
---|
229 | | - | let V = o |
---|
230 | | - | V |
---|
231 | | - | } |
---|
232 | | - | else if ($isInstanceOf(o, "Unit")) |
---|
233 | | - | then 0 |
---|
234 | | - | else throw("Match error") |
---|
235 | | - | } |
---|
236 | | - | let ag = t() |
---|
237 | | - | let ah = toInt(af) |
---|
238 | | - | let ai = { |
---|
239 | | - | let aj = ag |
---|
240 | | - | let ak = size(aj) |
---|
241 | | - | let al = nil |
---|
242 | | - | if ((ak == 0)) |
---|
243 | | - | then al |
---|
244 | | - | else { |
---|
245 | | - | let am = B(al, aj[0]) |
---|
246 | | - | if ((ak == 1)) |
---|
247 | | - | then am |
---|
248 | | - | else { |
---|
249 | | - | let an = B(am, aj[1]) |
---|
250 | | - | if ((ak == 2)) |
---|
251 | | - | then an |
---|
252 | | - | else { |
---|
253 | | - | let ao = B(an, aj[2]) |
---|
254 | | - | if ((ak == 3)) |
---|
255 | | - | then ao |
---|
256 | | - | else { |
---|
257 | | - | let ap = B(ao, aj[3]) |
---|
258 | | - | if ((ak == 4)) |
---|
259 | | - | then ap |
---|
260 | | - | else { |
---|
261 | | - | let aq = B(ap, aj[4]) |
---|
262 | | - | if ((ak == 5)) |
---|
263 | | - | then aq |
---|
264 | | - | else { |
---|
265 | | - | let ar = B(aq, aj[5]) |
---|
266 | | - | if ((ak == 6)) |
---|
267 | | - | then ar |
---|
268 | | - | else { |
---|
269 | | - | let as = B(ar, aj[6]) |
---|
270 | | - | if ((ak == 7)) |
---|
271 | | - | then as |
---|
272 | | - | else { |
---|
273 | | - | let at = B(as, aj[7]) |
---|
274 | | - | if ((ak == 8)) |
---|
275 | | - | then at |
---|
276 | | - | else { |
---|
277 | | - | let au = B(at, aj[8]) |
---|
278 | | - | if ((ak == 9)) |
---|
279 | | - | then au |
---|
280 | | - | else { |
---|
281 | | - | let av = B(au, aj[9]) |
---|
282 | | - | if ((ak == 10)) |
---|
283 | | - | then av |
---|
284 | | - | else { |
---|
285 | | - | let aw = B(av, aj[10]) |
---|
286 | | - | if ((ak == 11)) |
---|
287 | | - | then aw |
---|
288 | | - | else { |
---|
289 | | - | let ax = B(aw, aj[11]) |
---|
290 | | - | if ((ak == 12)) |
---|
291 | | - | then ax |
---|
292 | | - | else { |
---|
293 | | - | let ay = B(ax, aj[12]) |
---|
294 | | - | if ((ak == 13)) |
---|
295 | | - | then ay |
---|
296 | | - | else { |
---|
297 | | - | let az = B(ay, aj[13]) |
---|
298 | | - | if ((ak == 14)) |
---|
299 | | - | then az |
---|
300 | | - | else { |
---|
301 | | - | let aA = B(az, aj[14]) |
---|
302 | | - | throw("List size exceed 14") |
---|
303 | | - | } |
---|
304 | | - | } |
---|
305 | | - | } |
---|
306 | | - | } |
---|
307 | | - | } |
---|
308 | | - | } |
---|
309 | | - | } |
---|
310 | | - | } |
---|
311 | | - | } |
---|
312 | | - | } |
---|
313 | | - | } |
---|
314 | | - | } |
---|
315 | | - | } |
---|
316 | | - | } |
---|
317 | | - | } |
---|
318 | | - | } |
---|
319 | | - | let aB = size(ai) |
---|
320 | | - | if ((aB == 0)) |
---|
321 | | - | then { |
---|
322 | | - | let aC = WriteSet(nil) |
---|
323 | | - | ScriptResult(aC, TransferSet(nil)) |
---|
324 | | - | } |
---|
325 | | - | else { |
---|
326 | | - | let y = ai[1] |
---|
327 | | - | let aD = getIntegerValue(this, (y + a)) |
---|
328 | | - | if ((aD == 0)) |
---|
329 | | - | then throw("Amount exceeded") |
---|
330 | | - | else { |
---|
331 | | - | let aE = (aD - 1) |
---|
332 | | - | let aF = getIntegerValue(this, (y + d)) |
---|
333 | | - | let aG = getStringValue(this, (y + f)) |
---|
334 | | - | if ((aE == 0)) |
---|
335 | | - | then { |
---|
336 | | - | let Z = { |
---|
337 | | - | let aH = ag |
---|
338 | | - | let aI = size(aH) |
---|
339 | | - | let aJ = y |
---|
340 | | - | if ((aI == 0)) |
---|
341 | | - | then aJ |
---|
342 | | - | else { |
---|
343 | | - | let aK = x(aJ, aH[0]) |
---|
344 | | - | if ((aI == 1)) |
---|
345 | | - | then aK |
---|
346 | | - | else { |
---|
347 | | - | let aL = x(aK, aH[1]) |
---|
348 | | - | if ((aI == 2)) |
---|
349 | | - | then aL |
---|
350 | | - | else { |
---|
351 | | - | let aM = x(aL, aH[2]) |
---|
352 | | - | if ((aI == 3)) |
---|
353 | | - | then aM |
---|
354 | | - | else { |
---|
355 | | - | let aN = x(aM, aH[3]) |
---|
356 | | - | if ((aI == 4)) |
---|
357 | | - | then aN |
---|
358 | | - | else { |
---|
359 | | - | let aO = x(aN, aH[4]) |
---|
360 | | - | if ((aI == 5)) |
---|
361 | | - | then aO |
---|
362 | | - | else { |
---|
363 | | - | let aP = x(aO, aH[5]) |
---|
364 | | - | if ((aI == 6)) |
---|
365 | | - | then aP |
---|
366 | | - | else { |
---|
367 | | - | let aQ = x(aP, aH[6]) |
---|
368 | | - | if ((aI == 7)) |
---|
369 | | - | then aQ |
---|
370 | | - | else { |
---|
371 | | - | let aR = x(aQ, aH[7]) |
---|
372 | | - | if ((aI == 8)) |
---|
373 | | - | then aR |
---|
374 | | - | else { |
---|
375 | | - | let aS = x(aR, aH[8]) |
---|
376 | | - | if ((aI == 9)) |
---|
377 | | - | then aS |
---|
378 | | - | else { |
---|
379 | | - | let aT = x(aS, aH[9]) |
---|
380 | | - | if ((aI == 10)) |
---|
381 | | - | then aT |
---|
382 | | - | else { |
---|
383 | | - | let aU = x(aT, aH[10]) |
---|
384 | | - | if ((aI == 11)) |
---|
385 | | - | then aU |
---|
386 | | - | else { |
---|
387 | | - | let aV = x(aU, aH[11]) |
---|
388 | | - | if ((aI == 12)) |
---|
389 | | - | then aV |
---|
390 | | - | else { |
---|
391 | | - | let aW = x(aV, aH[12]) |
---|
392 | | - | if ((aI == 13)) |
---|
393 | | - | then aW |
---|
394 | | - | else { |
---|
395 | | - | let aX = x(aW, aH[13]) |
---|
396 | | - | if ((aI == 14)) |
---|
397 | | - | then aX |
---|
398 | | - | else { |
---|
399 | | - | let aY = x(aX, aH[14]) |
---|
400 | | - | throw("List size exceed 14") |
---|
401 | | - | } |
---|
402 | | - | } |
---|
403 | | - | } |
---|
404 | | - | } |
---|
405 | | - | } |
---|
406 | | - | } |
---|
407 | | - | } |
---|
408 | | - | } |
---|
409 | | - | } |
---|
410 | | - | } |
---|
411 | | - | } |
---|
412 | | - | } |
---|
413 | | - | } |
---|
414 | | - | } |
---|
415 | | - | } |
---|
416 | | - | } |
---|
417 | | - | let aC = WriteSet([DataEntry(("winning_token_" + y), y), DataEntry((ae + "_wininning_address_"), ae), DataEntry(g, (ab - 1)), DataEntry(e, Z), DataEntry(h, ah)]) |
---|
418 | | - | if ((aG == "")) |
---|
419 | | - | then { |
---|
420 | | - | let aZ = TransferSet([ScriptTransfer(K.caller, aF, unit)]) |
---|
421 | | - | ScriptResult(aC, aZ) |
---|
422 | | - | } |
---|
423 | | - | else { |
---|
424 | | - | let aZ = TransferSet([ScriptTransfer(K.caller, aF, unit)]) |
---|
425 | | - | ScriptResult(aC, aZ) |
---|
426 | | - | } |
---|
427 | | - | } |
---|
428 | | - | else { |
---|
429 | | - | let aC = WriteSet([DataEntry((ae + "_winning_token_"), y), DataEntry((ae + "_wininning_address_"), ae), DataEntry((y + a), aE), DataEntry(h, ah)]) |
---|
430 | | - | if ((aG == "")) |
---|
431 | | - | then { |
---|
432 | | - | let aZ = TransferSet([ScriptTransfer(K.caller, aF, unit)]) |
---|
433 | | - | ScriptResult(aC, aZ) |
---|
434 | | - | } |
---|
435 | | - | else { |
---|
436 | | - | let aZ = TransferSet([ScriptTransfer(K.caller, aF, unit)]) |
---|
437 | | - | ScriptResult(aC, aZ) |
---|
438 | | - | } |
---|
439 | | - | } |
---|
440 | | - | } |
---|
441 | | - | } |
---|
442 | | - | } |
---|
443 | | - | |
---|
444 | | - | |
---|
445 | | - | @Verifier(ba) |
---|
446 | | - | func bb () = { |
---|
447 | | - | let o = ba |
---|
448 | | - | if ($isInstanceOf(o, "DataTransaction")) |
---|
449 | | - | then true |
---|
450 | | - | else if ($isInstanceOf(o, "SetScriptTransaction")) |
---|
451 | | - | then true |
---|
452 | | - | else sigVerify(ba.bodyBytes, ba.proofs[0], ba.senderPublicKey) |
---|
453 | | - | } |
---|
454 | | - | |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | match tx { |
---|
| 4 | + | case _ => |
---|
| 5 | + | true |
---|
| 6 | + | } |
---|