1 | | - | {-# STDLIB_VERSION 6 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = 100000000 |
---|
7 | | - | |
---|
8 | | - | let c = 10 |
---|
9 | | - | |
---|
10 | | - | let d = 0 |
---|
11 | | - | |
---|
12 | | - | let e = 1 |
---|
13 | | - | |
---|
14 | | - | let f = makeString(["%s", "epochLength"], a) |
---|
15 | | - | |
---|
16 | | - | let g = makeString(["%s%s", "epochLength__new"], a) |
---|
17 | | - | |
---|
18 | | - | func h (i) = makeString(["%s%d", "epochLength", toString(i)], a) |
---|
19 | | - | |
---|
20 | | - | |
---|
21 | | - | let j = makeString(["%s", "currentEpoch"], a) |
---|
22 | | - | |
---|
23 | | - | let k = makeString(["%s", "maxDepth"], a) |
---|
24 | | - | |
---|
25 | | - | let l = makeString(["%s", "votingEmissionCandidateContract"], a) |
---|
26 | | - | |
---|
27 | | - | let m = makeString(["%s", "factoryContract"], a) |
---|
28 | | - | |
---|
29 | | - | let n = makeString(["%s", "boostingContract"], a) |
---|
30 | | - | |
---|
31 | | - | let o = makeString(["%s", "stakingContract"], a) |
---|
32 | | - | |
---|
33 | | - | let p = makeString(["%s", "finalizationStage"], a) |
---|
34 | | - | |
---|
35 | | - | let q = makeString(["%s", "nextPool"], a) |
---|
36 | | - | |
---|
37 | | - | let r = makeString(["%s", "nextUser"], a) |
---|
38 | | - | |
---|
39 | | - | let s = makeString(["%s", "startHeight"], a) |
---|
40 | | - | |
---|
41 | | - | let t = makeString(["%s", "currentEpochUi"], a) |
---|
42 | | - | |
---|
43 | | - | let u = makeString(["%s", "startHeightUi"], a) |
---|
44 | | - | |
---|
45 | | - | let v = makeString(["%s", "force"], a) |
---|
46 | | - | |
---|
47 | | - | func w (i) = makeString(["%s%d", "startHeight", toString(i)], a) |
---|
48 | | - | |
---|
49 | | - | |
---|
50 | | - | func x (i) = makeString(["%s%d", "finalized", toString(i)], a) |
---|
51 | | - | |
---|
52 | | - | |
---|
53 | | - | func y (z) = { |
---|
54 | | - | let A = z |
---|
55 | | - | let B = A._1 |
---|
56 | | - | let C = A._2 |
---|
57 | | - | makeString(["%s%s%s", "inList", B, C], a) |
---|
58 | | - | } |
---|
59 | | - | |
---|
60 | | - | |
---|
61 | | - | func D (E,i) = makeString(["%s%s%d", "used", toString(E), toString(i)], a) |
---|
62 | | - | |
---|
63 | | - | |
---|
64 | | - | func F (z,E,i) = { |
---|
65 | | - | let G = z |
---|
66 | | - | let B = G._1 |
---|
67 | | - | let C = G._2 |
---|
68 | | - | makeString(["%s%s%s%s%d", "vote", B, C, toString(E), toString(i)], a) |
---|
69 | | - | } |
---|
70 | | - | |
---|
71 | | - | |
---|
72 | | - | func H (z,i) = { |
---|
73 | | - | let I = z |
---|
74 | | - | let B = I._1 |
---|
75 | | - | let C = I._2 |
---|
76 | | - | makeString(["%s%s%s%d", "votingResult", B, C, toString(i)], a) |
---|
77 | | - | } |
---|
78 | | - | |
---|
79 | | - | |
---|
80 | | - | func J (z,i) = { |
---|
81 | | - | let K = z |
---|
82 | | - | let B = K._1 |
---|
83 | | - | let C = K._2 |
---|
84 | | - | makeString(["%s%s%s%d", "poolShare", B, C, toString(i)], a) |
---|
85 | | - | } |
---|
86 | | - | |
---|
87 | | - | |
---|
88 | | - | func L (i) = makeString(["%s%d", "totalVotes", toString(i)], a) |
---|
89 | | - | |
---|
90 | | - | |
---|
91 | | - | func M (E,N,O) = { |
---|
92 | | - | let P = makeString(["mandatory ", toString(E), ".", N, " is not defined"], "") |
---|
93 | | - | valueOrErrorMessage({ |
---|
94 | | - | let Q = O |
---|
95 | | - | if ($isInstanceOf(Q, "String")) |
---|
96 | | - | then { |
---|
97 | | - | let R = Q |
---|
98 | | - | getString(E, N) |
---|
99 | | - | } |
---|
100 | | - | else if ($isInstanceOf(Q, "Int")) |
---|
101 | | - | then { |
---|
102 | | - | let S = Q |
---|
103 | | - | getInteger(E, N) |
---|
104 | | - | } |
---|
105 | | - | else throw("invalid entry type") |
---|
106 | | - | }, P) |
---|
107 | | - | } |
---|
108 | | - | |
---|
109 | | - | |
---|
110 | | - | func T (E,N) = { |
---|
111 | | - | let U = M(E, N, "") |
---|
112 | | - | if ($isInstanceOf(U, "String")) |
---|
113 | | - | then U |
---|
114 | | - | else throw(($getType(U) + " couldn't be cast to String")) |
---|
115 | | - | } |
---|
116 | | - | |
---|
117 | | - | |
---|
118 | | - | func V (E,N) = { |
---|
119 | | - | let U = M(E, N, 0) |
---|
120 | | - | if ($isInstanceOf(U, "Int")) |
---|
121 | | - | then U |
---|
122 | | - | else throw(($getType(U) + " couldn't be cast to Int")) |
---|
123 | | - | } |
---|
124 | | - | |
---|
125 | | - | |
---|
126 | | - | func W (z) = ((z._1 + a) + z._2) |
---|
127 | | - | |
---|
128 | | - | |
---|
129 | | - | func X (R) = { |
---|
130 | | - | let Y = split(R, a) |
---|
131 | | - | if ((size(Y) == 2)) |
---|
132 | | - | then $Tuple2(Y[0], Y[1]) |
---|
133 | | - | else throw("invalid pool string") |
---|
134 | | - | } |
---|
135 | | - | |
---|
136 | | - | |
---|
137 | | - | func Z (B,C) = { |
---|
138 | | - | func aa (ab) = ("%s%s%s__mappings__baseAsset2internalId__" + ab) |
---|
139 | | - | |
---|
140 | | - | func ac (ad,ae) = (((("%d%d%s%s__" + toString(ad)) + "__") + toString(ae)) + "__mappings__poolAssets2PoolContract") |
---|
141 | | - | |
---|
142 | | - | func af (ag) = (("%s%s%s__" + ag) + "__mappings__poolContract2LpAsset") |
---|
143 | | - | |
---|
144 | | - | let ah = addressFromStringValue(T(this, m)) |
---|
145 | | - | let ai = V(ah, aa(B)) |
---|
146 | | - | let aj = V(ah, aa(C)) |
---|
147 | | - | let ag = T(ah, ac(ai, aj)) |
---|
148 | | - | let ak = T(ah, af(ag)) |
---|
149 | | - | ak |
---|
150 | | - | } |
---|
151 | | - | |
---|
152 | | - | |
---|
153 | | - | func al (z) = { |
---|
154 | | - | let am = z |
---|
155 | | - | let B = am._1 |
---|
156 | | - | let C = am._2 |
---|
157 | | - | let ah = addressFromStringValue(T(this, m)) |
---|
158 | | - | let U = invoke(ah, "checkWxEmissionPoolLabel", [B, C], nil) |
---|
159 | | - | if ($isInstanceOf(U, "Boolean")) |
---|
160 | | - | then U |
---|
161 | | - | else throw(($getType(U) + " couldn't be cast to Boolean")) |
---|
162 | | - | } |
---|
163 | | - | |
---|
164 | | - | |
---|
165 | | - | let an = "pools" |
---|
166 | | - | |
---|
167 | | - | func ao (z) = { |
---|
168 | | - | let ap = z |
---|
169 | | - | let B = ap._1 |
---|
170 | | - | let C = ap._2 |
---|
171 | | - | makeString(["votes", B, C], a) |
---|
172 | | - | } |
---|
173 | | - | |
---|
174 | | - | |
---|
175 | | - | func aq (ar) = { |
---|
176 | | - | let as = if ((ar == an)) |
---|
177 | | - | then "%s%s" |
---|
178 | | - | else "%s%s%s%s" |
---|
179 | | - | makeString([as, ar, "head"], a) |
---|
180 | | - | } |
---|
181 | | - | |
---|
182 | | - | |
---|
183 | | - | func at (ar) = { |
---|
184 | | - | let as = if ((ar == an)) |
---|
185 | | - | then "%s%s" |
---|
186 | | - | else "%s%s%s%s" |
---|
187 | | - | makeString([as, ar, "size"], a) |
---|
188 | | - | } |
---|
189 | | - | |
---|
190 | | - | |
---|
191 | | - | func au (ar,av) = { |
---|
192 | | - | let as = if ((ar == an)) |
---|
193 | | - | then "%s%s%s%s" |
---|
194 | | - | else "%s%s%s%s%s" |
---|
195 | | - | makeString([as, ar, av, "prev"], a) |
---|
196 | | - | } |
---|
197 | | - | |
---|
198 | | - | |
---|
199 | | - | func aw (ar,av) = { |
---|
200 | | - | let as = if ((ar == an)) |
---|
201 | | - | then "%s%s%s%s" |
---|
202 | | - | else "%s%s%s%s%s" |
---|
203 | | - | makeString([as, ar, av, "next"], a) |
---|
204 | | - | } |
---|
205 | | - | |
---|
206 | | - | |
---|
207 | | - | func ax (ar,av) = { |
---|
208 | | - | let ay = getString(this, aq(ar)) |
---|
209 | | - | let az = getString(this, au(ar, av)) |
---|
210 | | - | let aA = getString(this, aw(ar, av)) |
---|
211 | | - | if (if ((av == valueOrElse(ay, ""))) |
---|
212 | | - | then true |
---|
213 | | - | else (az != unit)) |
---|
214 | | - | then true |
---|
215 | | - | else (aA != unit) |
---|
216 | | - | } |
---|
217 | | - | |
---|
218 | | - | |
---|
219 | | - | func aB (ar,av) = { |
---|
220 | | - | let ay = getString(this, aq(ar)) |
---|
221 | | - | let aC = valueOrElse(getInteger(this, at(ar)), 0) |
---|
222 | | - | let aD = if (!(ax(ar, av))) |
---|
223 | | - | then true |
---|
224 | | - | else throw("Node exists") |
---|
225 | | - | if ((aD == aD)) |
---|
226 | | - | then (([IntegerEntry(at(ar), (aC + 1))] ++ (if ((ay != unit)) |
---|
227 | | - | then [StringEntry(aw(ar, av), value(ay)), StringEntry(au(ar, value(ay)), av)] |
---|
228 | | - | else nil)) ++ [StringEntry(aq(ar), av)]) |
---|
229 | | - | else throw("Strict value is not equal to itself.") |
---|
230 | | - | } |
---|
231 | | - | |
---|
232 | | - | |
---|
233 | | - | func aE (ar,av) = { |
---|
234 | | - | let ay = getString(this, aq(ar)) |
---|
235 | | - | let aC = valueOrElse(getInteger(this, at(ar)), 0) |
---|
236 | | - | let az = getString(this, au(ar, av)) |
---|
237 | | - | let aA = getString(this, aw(ar, av)) |
---|
238 | | - | ([IntegerEntry(at(ar), (aC - 1))] ++ (if (if ((az != unit)) |
---|
239 | | - | then (aA != unit) |
---|
240 | | - | else false) |
---|
241 | | - | then [StringEntry(aw(ar, value(az)), value(aA)), StringEntry(au(ar, value(aA)), value(az)), DeleteEntry(au(ar, av)), DeleteEntry(aw(ar, av))] |
---|
242 | | - | else if ((aA != unit)) |
---|
243 | | - | then [StringEntry(aq(ar), value(aA)), DeleteEntry(aw(ar, av)), DeleteEntry(au(ar, value(aA)))] |
---|
244 | | - | else if ((az != unit)) |
---|
245 | | - | then [DeleteEntry(au(ar, av)), DeleteEntry(aw(ar, value(az)))] |
---|
246 | | - | else if ((av == valueOrElse(ay, ""))) |
---|
247 | | - | then [DeleteEntry(aq(ar))] |
---|
248 | | - | else throw(((("invalid node: " + ar) + ".") + av)))) |
---|
249 | | - | } |
---|
250 | | - | |
---|
251 | | - | |
---|
252 | | - | func aF () = "%s__managerPublicKey" |
---|
253 | | - | |
---|
254 | | - | |
---|
255 | | - | func aG () = "%s__pendingManagerPublicKey" |
---|
256 | | - | |
---|
257 | | - | |
---|
258 | | - | func aH () = { |
---|
259 | | - | let Q = getString(aF()) |
---|
260 | | - | if ($isInstanceOf(Q, "String")) |
---|
261 | | - | then { |
---|
262 | | - | let aI = Q |
---|
263 | | - | fromBase58String(aI) |
---|
264 | | - | } |
---|
265 | | - | else if ($isInstanceOf(Q, "Unit")) |
---|
266 | | - | then unit |
---|
267 | | - | else throw("Match error") |
---|
268 | | - | } |
---|
269 | | - | |
---|
270 | | - | |
---|
271 | | - | func aJ () = { |
---|
272 | | - | let Q = getString(aG()) |
---|
273 | | - | if ($isInstanceOf(Q, "String")) |
---|
274 | | - | then { |
---|
275 | | - | let aI = Q |
---|
276 | | - | fromBase58String(aI) |
---|
277 | | - | } |
---|
278 | | - | else if ($isInstanceOf(Q, "Unit")) |
---|
279 | | - | then unit |
---|
280 | | - | else throw("Match error") |
---|
281 | | - | } |
---|
282 | | - | |
---|
283 | | - | |
---|
284 | | - | let aK = throw("Permission denied") |
---|
285 | | - | |
---|
286 | | - | func aL (aM) = if ((aM.caller == this)) |
---|
287 | | - | then true |
---|
288 | | - | else aK |
---|
289 | | - | |
---|
290 | | - | |
---|
291 | | - | func aN (aM) = { |
---|
292 | | - | let Q = aH() |
---|
293 | | - | if ($isInstanceOf(Q, "ByteVector")) |
---|
294 | | - | then { |
---|
295 | | - | let aO = Q |
---|
296 | | - | if ((aM.callerPublicKey == aO)) |
---|
297 | | - | then true |
---|
298 | | - | else aK |
---|
299 | | - | } |
---|
300 | | - | else if ($isInstanceOf(Q, "Unit")) |
---|
301 | | - | then aL(aM) |
---|
302 | | - | else throw("Match error") |
---|
303 | | - | } |
---|
304 | | - | |
---|
305 | | - | |
---|
306 | | - | @Callable(aM) |
---|
307 | | - | func setManager (aP) = { |
---|
308 | | - | let aQ = aN(aM) |
---|
309 | | - | if ((aQ == aQ)) |
---|
310 | | - | then { |
---|
311 | | - | let aR = fromBase58String(aP) |
---|
312 | | - | if ((aR == aR)) |
---|
313 | | - | then [StringEntry(aG(), aP)] |
---|
314 | | - | else throw("Strict value is not equal to itself.") |
---|
315 | | - | } |
---|
316 | | - | else throw("Strict value is not equal to itself.") |
---|
317 | | - | } |
---|
318 | | - | |
---|
319 | | - | |
---|
320 | | - | |
---|
321 | | - | @Callable(aM) |
---|
322 | | - | func confirmManager () = { |
---|
323 | | - | let aS = aJ() |
---|
324 | | - | let aT = if (isDefined(aS)) |
---|
325 | | - | then true |
---|
326 | | - | else throw("No pending manager") |
---|
327 | | - | if ((aT == aT)) |
---|
328 | | - | then { |
---|
329 | | - | let aU = if ((aM.callerPublicKey == value(aS))) |
---|
330 | | - | then true |
---|
331 | | - | else throw("You are not pending manager") |
---|
332 | | - | if ((aU == aU)) |
---|
333 | | - | then [StringEntry(aF(), toBase58String(value(aS))), DeleteEntry(aG())] |
---|
334 | | - | else throw("Strict value is not equal to itself.") |
---|
335 | | - | } |
---|
336 | | - | else throw("Strict value is not equal to itself.") |
---|
337 | | - | } |
---|
338 | | - | |
---|
339 | | - | |
---|
340 | | - | |
---|
341 | | - | @Callable(aM) |
---|
342 | | - | func getUserGwxAmountAtHeight (aV,aW) = { |
---|
343 | | - | let aX = valueOrErrorMessage(addressFromString(T(this, n)), "invalid boosting contract address") |
---|
344 | | - | $Tuple2(nil, { |
---|
345 | | - | let U = invoke(aX, "getUserGwxAmountAtHeightREADONLY", [aV, aW], nil) |
---|
346 | | - | if ($isInstanceOf(U, "Int")) |
---|
347 | | - | then U |
---|
348 | | - | else throw(($getType(U) + " couldn't be cast to Int")) |
---|
349 | | - | }) |
---|
350 | | - | } |
---|
351 | | - | |
---|
352 | | - | |
---|
353 | | - | |
---|
354 | | - | @Callable(aM) |
---|
355 | | - | func constructor (ah,aY,aZ,ba,bb) = { |
---|
356 | | - | let bc = [aN(aM), if ((addressFromString(ah) != unit)) |
---|
357 | | - | then true |
---|
358 | | - | else "invalid factory contract address", if ((addressFromString(aY) != unit)) |
---|
359 | | - | then true |
---|
360 | | - | else "invalid voting emission candidate contract address", if ((addressFromString(aZ) != unit)) |
---|
361 | | - | then true |
---|
362 | | - | else "invalid boosting contract address", if ((addressFromString(ba) != unit)) |
---|
363 | | - | then true |
---|
364 | | - | else "invalid staking contract address", if ((bb > 0)) |
---|
365 | | - | then true |
---|
366 | | - | else throw("invalid epoch length")] |
---|
367 | | - | if ((bc == bc)) |
---|
368 | | - | then $Tuple2([StringEntry(m, ah), StringEntry(l, aY), StringEntry(n, aZ), StringEntry(o, ba), IntegerEntry(f, bb)], unit) |
---|
369 | | - | else throw("Strict value is not equal to itself.") |
---|
370 | | - | } |
---|
371 | | - | |
---|
372 | | - | |
---|
373 | | - | |
---|
374 | | - | @Callable(aM) |
---|
375 | | - | func create (B,C) = { |
---|
376 | | - | let bc = [if ((toBase58String(aM.caller.bytes) == valueOrElse(getString(this, l), ""))) |
---|
377 | | - | then true |
---|
378 | | - | else aN(aM)] |
---|
379 | | - | if ((bc == bc)) |
---|
380 | | - | then { |
---|
381 | | - | let z = $Tuple2(B, C) |
---|
382 | | - | let bd = ([BooleanEntry(y(z), true)] ++ aB(an, W(z))) |
---|
383 | | - | let be = (getInteger(this, j) == unit) |
---|
384 | | - | let bf = if (be) |
---|
385 | | - | then { |
---|
386 | | - | let i = 0 |
---|
387 | | - | [IntegerEntry(j, i), IntegerEntry(w(i), height), IntegerEntry(s, height), IntegerEntry(t, i), IntegerEntry(u, height)] |
---|
388 | | - | } |
---|
389 | | - | else nil |
---|
390 | | - | $Tuple2((bd ++ bf), unit) |
---|
391 | | - | } |
---|
392 | | - | else throw("Strict value is not equal to itself.") |
---|
393 | | - | } |
---|
394 | | - | |
---|
395 | | - | |
---|
396 | | - | |
---|
397 | | - | @Callable(aM) |
---|
398 | | - | func vote (B,C,bg) = { |
---|
399 | | - | let z = $Tuple2(B, C) |
---|
400 | | - | let i = valueOrElse(getInteger(this, j), 0) |
---|
401 | | - | let bh = V(this, w(i)) |
---|
402 | | - | let bb = V(this, f) |
---|
403 | | - | let bi = (bh + bb) |
---|
404 | | - | let bj = getInteger(this, p) |
---|
405 | | - | let bk = valueOrElse(getInteger(this, D(aM.caller, i)), 0) |
---|
406 | | - | let bl = valueOrElse(getInteger(this, F(z, aM.caller, i)), 0) |
---|
407 | | - | let bm = valueOrElse(getInteger(this, H(z, i)), 0) |
---|
408 | | - | let bn = valueOrElse(getInteger(this, L(i)), 0) |
---|
409 | | - | let bo = { |
---|
410 | | - | let U = invoke(this, "getUserGwxAmountAtHeight", [toBase58String(aM.caller.bytes), bi], nil) |
---|
411 | | - | if ($isInstanceOf(U, "Int")) |
---|
412 | | - | then U |
---|
413 | | - | else throw(($getType(U) + " couldn't be cast to Int")) |
---|
414 | | - | } |
---|
415 | | - | let bp = (bo - bk) |
---|
416 | | - | let bq = (bl + bg) |
---|
417 | | - | let br = al(z) |
---|
418 | | - | let bc = [if ((getBoolean(y(z)) != unit)) |
---|
419 | | - | then true |
---|
420 | | - | else throw("invalid assets"), if ((bi > height)) |
---|
421 | | - | then true |
---|
422 | | - | else throw("invalid height"), if ((bj == unit)) |
---|
423 | | - | then true |
---|
424 | | - | else throw("finalization in progress"), if ((bo > 0)) |
---|
425 | | - | then true |
---|
426 | | - | else throw("you do not have gWX"), if (if ((bg > 0)) |
---|
427 | | - | then (bp >= bg) |
---|
428 | | - | else false) |
---|
429 | | - | then true |
---|
430 | | - | else throw("invalid amount"), if (br) |
---|
431 | | - | then true |
---|
432 | | - | else throw("pool hasn't WX_EMISSION label")] |
---|
433 | | - | if ((bc == bc)) |
---|
434 | | - | then { |
---|
435 | | - | let bs = ao(z) |
---|
436 | | - | let bt = toString(aM.caller) |
---|
437 | | - | let bu = if (ax(bs, bt)) |
---|
438 | | - | then nil |
---|
439 | | - | else aB(bs, bt) |
---|
440 | | - | $Tuple2(([IntegerEntry(D(aM.caller, i), (bk + bg)), IntegerEntry(F(z, aM.caller, i), bq), IntegerEntry(H(z, i), (bm + bg)), IntegerEntry(L(i), (bn + bg))] ++ bu), unit) |
---|
441 | | - | } |
---|
442 | | - | else throw("Strict value is not equal to itself.") |
---|
443 | | - | } |
---|
444 | | - | |
---|
445 | | - | |
---|
446 | | - | |
---|
447 | | - | @Callable(aM) |
---|
448 | | - | func cancelVote (B,C) = { |
---|
449 | | - | let z = $Tuple2(B, C) |
---|
450 | | - | let i = valueOrElse(getInteger(this, j), 0) |
---|
451 | | - | let bh = V(this, w(i)) |
---|
452 | | - | let bb = V(this, f) |
---|
453 | | - | let bi = (bh + bb) |
---|
454 | | - | let bj = getInteger(this, p) |
---|
455 | | - | let bk = valueOrElse(getInteger(this, D(aM.caller, i)), 0) |
---|
456 | | - | let bl = valueOrElse(getInteger(this, F(z, aM.caller, i)), 0) |
---|
457 | | - | let bm = valueOrElse(getInteger(this, H(z, i)), 0) |
---|
458 | | - | let bn = valueOrElse(getInteger(this, L(i)), 0) |
---|
459 | | - | let bc = [if ((getBoolean(y(z)) != unit)) |
---|
460 | | - | then true |
---|
461 | | - | else throw("invalid assets"), if ((bi > height)) |
---|
462 | | - | then true |
---|
463 | | - | else throw("invalid height"), if ((bj == unit)) |
---|
464 | | - | then true |
---|
465 | | - | else throw("finalization in progress"), if ((bl > 0)) |
---|
466 | | - | then true |
---|
467 | | - | else throw("no vote")] |
---|
468 | | - | if ((bc == bc)) |
---|
469 | | - | then { |
---|
470 | | - | let bs = ao(z) |
---|
471 | | - | let bt = toString(aM.caller) |
---|
472 | | - | $Tuple2(([IntegerEntry(D(aM.caller, i), max([(bk - bl), 0])), DeleteEntry(F(z, aM.caller, i)), IntegerEntry(H(z, i), (bm - bl)), IntegerEntry(L(i), (bn - bl))] ++ aE(bs, bt)), unit) |
---|
473 | | - | } |
---|
474 | | - | else throw("Strict value is not equal to itself.") |
---|
475 | | - | } |
---|
476 | | - | |
---|
477 | | - | |
---|
478 | | - | |
---|
479 | | - | @Callable(aM) |
---|
480 | | - | func setEpochLength (bv) = { |
---|
481 | | - | let bc = [aN(aM), if ((bv > 0)) |
---|
482 | | - | then true |
---|
483 | | - | else throw("invalid epoch length")] |
---|
484 | | - | if ((bc == bc)) |
---|
485 | | - | then $Tuple2([IntegerEntry(g, bv)], unit) |
---|
486 | | - | else throw("Strict value is not equal to itself.") |
---|
487 | | - | } |
---|
488 | | - | |
---|
489 | | - | |
---|
490 | | - | |
---|
491 | | - | @Callable(aM) |
---|
492 | | - | func setMaxDepth (bw) = { |
---|
493 | | - | let bc = [aN(aM), if ((bw > 0)) |
---|
494 | | - | then true |
---|
495 | | - | else throw("invalid max depth")] |
---|
496 | | - | if ((bc == bc)) |
---|
497 | | - | then $Tuple2([IntegerEntry(k, bw)], unit) |
---|
498 | | - | else throw("Strict value is not equal to itself.") |
---|
499 | | - | } |
---|
500 | | - | |
---|
501 | | - | |
---|
502 | | - | |
---|
503 | | - | @Callable(aM) |
---|
504 | | - | func processVoteINTERNAL (bx,bt) = { |
---|
505 | | - | let aQ = aL(aM) |
---|
506 | | - | if ((aQ == aQ)) |
---|
507 | | - | then { |
---|
508 | | - | let aV = valueOrErrorMessage(addressFromString(bt), ("processVoteINTERNAL: invalid user address " + bt)) |
---|
509 | | - | let i = V(this, j) |
---|
510 | | - | let by = (i - 1) |
---|
511 | | - | let bb = V(this, f) |
---|
512 | | - | let bh = V(this, w(i)) |
---|
513 | | - | let bi = (bh + bb) |
---|
514 | | - | let bz = V(this, w(by)) |
---|
515 | | - | let bA = V(this, h(by)) |
---|
516 | | - | let bB = (bz + bA) |
---|
517 | | - | let bC = if ((by >= 0)) |
---|
518 | | - | then true |
---|
519 | | - | else throw("processVoteINTERNAL: invalid previous epoch") |
---|
520 | | - | if ((bC == bC)) |
---|
521 | | - | then { |
---|
522 | | - | let z = X(bx) |
---|
523 | | - | let bD = z |
---|
524 | | - | let B = bD._1 |
---|
525 | | - | let C = bD._2 |
---|
526 | | - | let br = al(z) |
---|
527 | | - | let bo = { |
---|
528 | | - | let U = invoke(this, "getUserGwxAmountAtHeight", [bt, bi], nil) |
---|
529 | | - | if ($isInstanceOf(U, "Int")) |
---|
530 | | - | then U |
---|
531 | | - | else throw(($getType(U) + " couldn't be cast to Int")) |
---|
532 | | - | } |
---|
533 | | - | let bE = { |
---|
534 | | - | let U = invoke(this, "getUserGwxAmountAtHeight", [bt, bB], nil) |
---|
535 | | - | if ($isInstanceOf(U, "Int")) |
---|
536 | | - | then U |
---|
537 | | - | else throw(($getType(U) + " couldn't be cast to Int")) |
---|
538 | | - | } |
---|
539 | | - | let bn = valueOrElse(getInteger(L(i)), 0) |
---|
540 | | - | let bF = valueOrElse(getInteger(H(z, i)), 0) |
---|
541 | | - | let bG = valueOrErrorMessage(getInteger(F(z, aV, by)), (((("processVoteINTERNAL " + bx) + " ") + bt) + ": no previous vote")) |
---|
542 | | - | let bk = valueOrElse(getInteger(this, D(aV, i)), 0) |
---|
543 | | - | let bq = if ((bE > 0)) |
---|
544 | | - | then fraction(bG, bo, bE) |
---|
545 | | - | else 0 |
---|
546 | | - | let bH = if (if ((bq > 0)) |
---|
547 | | - | then br |
---|
548 | | - | else false) |
---|
549 | | - | then [IntegerEntry(F(z, aV, i), bq), IntegerEntry(L(i), (bn + bq)), IntegerEntry(H(z, i), (bF + bq)), IntegerEntry(D(aV, i), (bk + bq))] |
---|
550 | | - | else aE(ao(z), bt) |
---|
551 | | - | $Tuple2(bH, unit) |
---|
552 | | - | } |
---|
553 | | - | else throw("Strict value is not equal to itself.") |
---|
554 | | - | } |
---|
555 | | - | else throw("Strict value is not equal to itself.") |
---|
556 | | - | } |
---|
557 | | - | |
---|
558 | | - | |
---|
559 | | - | |
---|
560 | | - | @Callable(aM) |
---|
561 | | - | func processPoolINTERNAL (bx,bI) = { |
---|
562 | | - | let aQ = aL(aM) |
---|
563 | | - | if ((aQ == aQ)) |
---|
564 | | - | then { |
---|
565 | | - | let bJ = { |
---|
566 | | - | let bK = V(this, j) |
---|
567 | | - | if (bI) |
---|
568 | | - | then bK |
---|
569 | | - | else (bK - 1) |
---|
570 | | - | } |
---|
571 | | - | let bC = if ((bJ >= 0)) |
---|
572 | | - | then true |
---|
573 | | - | else throw("processPoolINTERNAL: invalid target epoch") |
---|
574 | | - | if ((bC == bC)) |
---|
575 | | - | then { |
---|
576 | | - | let z = X(bx) |
---|
577 | | - | let bL = z |
---|
578 | | - | let B = bL._1 |
---|
579 | | - | let C = bL._2 |
---|
580 | | - | let ba = addressFromStringValue(T(this, o)) |
---|
581 | | - | let ah = addressFromStringValue(T(this, m)) |
---|
582 | | - | let ak = Z(B, C) |
---|
583 | | - | let bM = { |
---|
584 | | - | let U = invoke(ba, "usersListTraversal", [ak], nil) |
---|
585 | | - | if ($isInstanceOf(U, "Boolean")) |
---|
586 | | - | then U |
---|
587 | | - | else throw(($getType(U) + " couldn't be cast to Boolean")) |
---|
588 | | - | } |
---|
589 | | - | if ((bM == bM)) |
---|
590 | | - | then if (bM) |
---|
591 | | - | then $Tuple2(nil, true) |
---|
592 | | - | else { |
---|
593 | | - | let br = al(z) |
---|
594 | | - | let bn = valueOrElse(getInteger(this, L(bJ)), 0) |
---|
595 | | - | let bF = valueOrElse(getInteger(this, H(z, bJ)), 0) |
---|
596 | | - | let bN = if (if ((bn == 0)) |
---|
597 | | - | then true |
---|
598 | | - | else !(br)) |
---|
599 | | - | then 0 |
---|
600 | | - | else fraction(bF, b, bn) |
---|
601 | | - | let bO = invoke(ah, "modifyWeight", [ak, bN], nil) |
---|
602 | | - | if ((bO == bO)) |
---|
603 | | - | then { |
---|
604 | | - | let bP = if (if (br) |
---|
605 | | - | then true |
---|
606 | | - | else bI) |
---|
607 | | - | then nil |
---|
608 | | - | else ([DeleteEntry(y(z))] ++ aE(an, bx)) |
---|
609 | | - | $Tuple2(([IntegerEntry(J(z, bJ), bN)] ++ bP), false) |
---|
610 | | - | } |
---|
611 | | - | else throw("Strict value is not equal to itself.") |
---|
612 | | - | } |
---|
613 | | - | else throw("Strict value is not equal to itself.") |
---|
614 | | - | } |
---|
615 | | - | else throw("Strict value is not equal to itself.") |
---|
616 | | - | } |
---|
617 | | - | else throw("Strict value is not equal to itself.") |
---|
618 | | - | } |
---|
619 | | - | |
---|
620 | | - | |
---|
621 | | - | |
---|
622 | | - | @Callable(aM) |
---|
623 | | - | func finalizeHelper () = { |
---|
624 | | - | let bI = valueOrElse(getBoolean(v), false) |
---|
625 | | - | let i = valueOrElse(getInteger(this, j), 0) |
---|
626 | | - | let bQ = (i - 1) |
---|
627 | | - | let bh = V(this, w(i)) |
---|
628 | | - | let bb = V(this, f) |
---|
629 | | - | let bi = (bh + bb) |
---|
630 | | - | let bj = getInteger(this, p) |
---|
631 | | - | if (if (if ((height >= bi)) |
---|
632 | | - | then (bj == unit) |
---|
633 | | - | else false) |
---|
634 | | - | then !(bI) |
---|
635 | | - | else false) |
---|
636 | | - | then { |
---|
637 | | - | let bR = (i + 1) |
---|
638 | | - | let bS = getInteger(this, g) |
---|
639 | | - | let bT = { |
---|
640 | | - | let Q = bS |
---|
641 | | - | if ($isInstanceOf(Q, "Int")) |
---|
642 | | - | then { |
---|
643 | | - | let bv = Q |
---|
644 | | - | [IntegerEntry(f, bv), DeleteEntry(g)] |
---|
645 | | - | } |
---|
646 | | - | else if ($isInstanceOf(Q, "Unit")) |
---|
647 | | - | then nil |
---|
648 | | - | else throw("Match error") |
---|
649 | | - | } |
---|
650 | | - | $Tuple2(([IntegerEntry(w(bR), height), IntegerEntry(s, height), IntegerEntry(j, bR), IntegerEntry(p, d), IntegerEntry(h(i), bb)] ++ bT), true) |
---|
651 | | - | } |
---|
652 | | - | else if (if (bI) |
---|
653 | | - | then (bj == unit) |
---|
654 | | - | else false) |
---|
655 | | - | then $Tuple2([IntegerEntry(p, e)], true) |
---|
656 | | - | else if ((bj == unit)) |
---|
657 | | - | then $Tuple2(nil, false) |
---|
658 | | - | else if ((bj == d)) |
---|
659 | | - | then { |
---|
660 | | - | let bU = getString(q) |
---|
661 | | - | let bV = getString(r) |
---|
662 | | - | let Q = bU |
---|
663 | | - | if ($isInstanceOf(Q, "Unit")) |
---|
664 | | - | then { |
---|
665 | | - | let bW = getString(aq(an)) |
---|
666 | | - | if ($isInstanceOf(bW, "Unit")) |
---|
667 | | - | then $Tuple2([IntegerEntry(p, e), DeleteEntry(q), DeleteEntry(r)], true) |
---|
668 | | - | else if ($isInstanceOf(bW, "String")) |
---|
669 | | - | then { |
---|
670 | | - | let bX = bW |
---|
671 | | - | $Tuple2([StringEntry(q, bX)], true) |
---|
672 | | - | } |
---|
673 | | - | else throw("Match error") |
---|
674 | | - | } |
---|
675 | | - | else if ($isInstanceOf(Q, "String")) |
---|
676 | | - | then { |
---|
677 | | - | let bx = Q |
---|
678 | | - | let z = X(bx) |
---|
679 | | - | let bY = { |
---|
680 | | - | let bW = bV |
---|
681 | | - | if ($isInstanceOf(bW, "Unit")) |
---|
682 | | - | then getString(aq(ao(z))) |
---|
683 | | - | else if ($isInstanceOf(bW, "String")) |
---|
684 | | - | then { |
---|
685 | | - | let bZ = bW |
---|
686 | | - | let ca = getString(aw(ao(z), bZ)) |
---|
687 | | - | if ((ca == ca)) |
---|
688 | | - | then { |
---|
689 | | - | let cb = invoke(this, "processVoteINTERNAL", [bx, bZ], nil) |
---|
690 | | - | if ((cb == cb)) |
---|
691 | | - | then ca |
---|
692 | | - | else throw("Strict value is not equal to itself.") |
---|
693 | | - | } |
---|
694 | | - | else throw("Strict value is not equal to itself.") |
---|
695 | | - | } |
---|
696 | | - | else throw("Match error") |
---|
697 | | - | } |
---|
698 | | - | let bW = bY |
---|
699 | | - | if ($isInstanceOf(bW, "Unit")) |
---|
700 | | - | then { |
---|
701 | | - | let cc = getString(aw(an, bx)) |
---|
702 | | - | let cd = cc |
---|
703 | | - | if ($isInstanceOf(cd, "Unit")) |
---|
704 | | - | then $Tuple2([IntegerEntry(p, e), DeleteEntry(q), DeleteEntry(r)], true) |
---|
705 | | - | else if ($isInstanceOf(cd, "String")) |
---|
706 | | - | then { |
---|
707 | | - | let aI = cd |
---|
708 | | - | $Tuple2([StringEntry(q, aI), DeleteEntry(r)], true) |
---|
709 | | - | } |
---|
710 | | - | else throw("Match error") |
---|
711 | | - | } |
---|
712 | | - | else if ($isInstanceOf(bW, "String")) |
---|
713 | | - | then { |
---|
714 | | - | let ce = bW |
---|
715 | | - | $Tuple2([StringEntry(r, ce)], true) |
---|
716 | | - | } |
---|
717 | | - | else throw("Match error") |
---|
718 | | - | } |
---|
719 | | - | else throw("Match error") |
---|
720 | | - | } |
---|
721 | | - | else if ((bj == e)) |
---|
722 | | - | then { |
---|
723 | | - | let bU = getString(q) |
---|
724 | | - | let Q = bU |
---|
725 | | - | if ($isInstanceOf(Q, "Unit")) |
---|
726 | | - | then { |
---|
727 | | - | let bW = getString(aq(an)) |
---|
728 | | - | if ($isInstanceOf(bW, "Unit")) |
---|
729 | | - | then { |
---|
730 | | - | let bH = if (bI) |
---|
731 | | - | then [DeleteEntry(p), DeleteEntry(v)] |
---|
732 | | - | else [DeleteEntry(p), BooleanEntry(x(bQ), true), IntegerEntry(t, i), IntegerEntry(u, bh)] |
---|
733 | | - | $Tuple2(bH, true) |
---|
734 | | - | } |
---|
735 | | - | else if ($isInstanceOf(bW, "String")) |
---|
736 | | - | then { |
---|
737 | | - | let cf = bW |
---|
738 | | - | $Tuple2([StringEntry(q, cf)], true) |
---|
739 | | - | } |
---|
740 | | - | else throw("Match error") |
---|
741 | | - | } |
---|
742 | | - | else if ($isInstanceOf(Q, "String")) |
---|
743 | | - | then { |
---|
744 | | - | let bx = Q |
---|
745 | | - | let cc = getString(aw(an, bx)) |
---|
746 | | - | if ((cc == cc)) |
---|
747 | | - | then { |
---|
748 | | - | let bM = { |
---|
749 | | - | let U = invoke(this, "processPoolINTERNAL", [bx, bI], nil) |
---|
750 | | - | if ($isInstanceOf(U, "Boolean")) |
---|
751 | | - | then U |
---|
752 | | - | else throw(($getType(U) + " couldn't be cast to Boolean")) |
---|
753 | | - | } |
---|
754 | | - | if ((bM == bM)) |
---|
755 | | - | then if (bM) |
---|
756 | | - | then $Tuple2(nil, true) |
---|
757 | | - | else { |
---|
758 | | - | let bW = cc |
---|
759 | | - | if ($isInstanceOf(bW, "Unit")) |
---|
760 | | - | then { |
---|
761 | | - | let bH = if (bI) |
---|
762 | | - | then [DeleteEntry(p), DeleteEntry(v), DeleteEntry(q)] |
---|
763 | | - | else [DeleteEntry(p), BooleanEntry(x(bQ), true), IntegerEntry(t, i), IntegerEntry(u, bh), DeleteEntry(q)] |
---|
764 | | - | $Tuple2(bH, true) |
---|
765 | | - | } |
---|
766 | | - | else if ($isInstanceOf(bW, "String")) |
---|
767 | | - | then { |
---|
768 | | - | let cf = bW |
---|
769 | | - | $Tuple2([StringEntry(q, cf)], true) |
---|
770 | | - | } |
---|
771 | | - | else throw("Match error") |
---|
772 | | - | } |
---|
773 | | - | else throw("Strict value is not equal to itself.") |
---|
774 | | - | } |
---|
775 | | - | else throw("Strict value is not equal to itself.") |
---|
776 | | - | } |
---|
777 | | - | else throw("Match error") |
---|
778 | | - | } |
---|
779 | | - | else throw("finalization is broken") |
---|
780 | | - | } |
---|
781 | | - | |
---|
782 | | - | |
---|
783 | | - | |
---|
784 | | - | @Callable(aM) |
---|
785 | | - | func finalizeWrapper (cg) = { |
---|
786 | | - | let ch = { |
---|
787 | | - | let U = invoke(this, "finalizeHelper", nil, nil) |
---|
788 | | - | if ($isInstanceOf(U, "Boolean")) |
---|
789 | | - | then U |
---|
790 | | - | else throw(($getType(U) + " couldn't be cast to Boolean")) |
---|
791 | | - | } |
---|
792 | | - | if ((ch == ch)) |
---|
793 | | - | then if (!(ch)) |
---|
794 | | - | then if ((cg == 0)) |
---|
795 | | - | then throw("Current voting is not over yet") |
---|
796 | | - | else $Tuple2(nil, unit) |
---|
797 | | - | else { |
---|
798 | | - | let ci = valueOrElse(getInteger(this, k), c) |
---|
799 | | - | if ((ci > cg)) |
---|
800 | | - | then { |
---|
801 | | - | let cj = invoke(this, "finalizeWrapper", [(cg + 1)], nil) |
---|
802 | | - | if ((cj == cj)) |
---|
803 | | - | then $Tuple2(nil, unit) |
---|
804 | | - | else throw("Strict value is not equal to itself.") |
---|
805 | | - | } |
---|
806 | | - | else $Tuple2(nil, unit) |
---|
807 | | - | } |
---|
808 | | - | else throw("Strict value is not equal to itself.") |
---|
809 | | - | } |
---|
810 | | - | |
---|
811 | | - | |
---|
812 | | - | |
---|
813 | | - | @Callable(aM) |
---|
814 | | - | func finalize () = { |
---|
815 | | - | let cj = invoke(this, "finalizeWrapper", [0], nil) |
---|
816 | | - | if ((cj == cj)) |
---|
817 | | - | then $Tuple2(nil, unit) |
---|
818 | | - | else throw("Strict value is not equal to itself.") |
---|
819 | | - | } |
---|
820 | | - | |
---|
821 | | - | |
---|
822 | | - | |
---|
823 | | - | @Callable(aM) |
---|
824 | | - | func containsNodeREADONLY (ar,av) = $Tuple2(nil, ax(ar, av)) |
---|
825 | | - | |
---|
826 | | - | |
---|
827 | | - | |
---|
828 | | - | @Callable(aM) |
---|
829 | | - | func insertNode (ar,av) = { |
---|
830 | | - | let aQ = aN(aM) |
---|
831 | | - | if ((aQ == aQ)) |
---|
832 | | - | then $Tuple2(aB(ar, av), unit) |
---|
833 | | - | else throw("Strict value is not equal to itself.") |
---|
834 | | - | } |
---|
835 | | - | |
---|
836 | | - | |
---|
837 | | - | |
---|
838 | | - | @Callable(aM) |
---|
839 | | - | func deleteNode (ar,av) = { |
---|
840 | | - | let aQ = aN(aM) |
---|
841 | | - | if ((aQ == aQ)) |
---|
842 | | - | then $Tuple2(aE(ar, av), unit) |
---|
843 | | - | else throw("Strict value is not equal to itself.") |
---|
844 | | - | } |
---|
845 | | - | |
---|
846 | | - | |
---|
847 | | - | @Verifier(ck) |
---|
848 | | - | func cl () = { |
---|
849 | | - | let cm = { |
---|
850 | | - | let Q = aH() |
---|
851 | | - | if ($isInstanceOf(Q, "ByteVector")) |
---|
852 | | - | then { |
---|
853 | | - | let aO = Q |
---|
854 | | - | aO |
---|
855 | | - | } |
---|
856 | | - | else if ($isInstanceOf(Q, "Unit")) |
---|
857 | | - | then ck.senderPublicKey |
---|
858 | | - | else throw("Match error") |
---|
859 | | - | } |
---|
860 | | - | sigVerify(ck.bodyBytes, ck.proofs[0], cm) |
---|
861 | | - | } |
---|
862 | | - | |
---|
| 1 | + | # no script |
---|