1 | | - | {-# STDLIB_VERSION 6 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "" |
---|
5 | | - | |
---|
6 | | - | let b = "__" |
---|
7 | | - | |
---|
8 | | - | let c = ":" |
---|
9 | | - | |
---|
10 | | - | let d = 500000 |
---|
11 | | - | |
---|
12 | | - | let e = "https://forum.neutrino.at/" |
---|
13 | | - | |
---|
14 | | - | let f = 250 |
---|
15 | | - | |
---|
16 | | - | let g = 250 |
---|
17 | | - | |
---|
18 | | - | let h = 1209600000 |
---|
19 | | - | |
---|
20 | | - | let i = 1000000 |
---|
21 | | - | |
---|
22 | | - | let j = 1000000000 |
---|
23 | | - | |
---|
24 | | - | let k = 1000000000 |
---|
25 | | - | |
---|
26 | | - | let l = 7200000 |
---|
27 | | - | |
---|
28 | | - | let m = 5400000 |
---|
29 | | - | |
---|
30 | | - | let n = 111 |
---|
31 | | - | |
---|
32 | | - | let o = 1 |
---|
33 | | - | |
---|
34 | | - | let p = 2 |
---|
35 | | - | |
---|
36 | | - | let q = 3 |
---|
37 | | - | |
---|
38 | | - | let r = 4 |
---|
39 | | - | |
---|
40 | | - | let s = 5 |
---|
41 | | - | |
---|
42 | | - | let t = 6 |
---|
43 | | - | |
---|
44 | | - | let u = 7 |
---|
45 | | - | |
---|
46 | | - | let v = 8 |
---|
47 | | - | |
---|
48 | | - | let w = 9 |
---|
49 | | - | |
---|
50 | | - | let x = 10 |
---|
51 | | - | |
---|
52 | | - | let y = 11 |
---|
53 | | - | |
---|
54 | | - | let z = 1 |
---|
55 | | - | |
---|
56 | | - | let A = 2 |
---|
57 | | - | |
---|
58 | | - | let B = 3 |
---|
59 | | - | |
---|
60 | | - | let C = 4 |
---|
61 | | - | |
---|
62 | | - | let D = 5 |
---|
63 | | - | |
---|
64 | | - | let E = 6 |
---|
65 | | - | |
---|
66 | | - | let F = 7 |
---|
67 | | - | |
---|
68 | | - | let G = 8 |
---|
69 | | - | |
---|
70 | | - | func H (I,J) = valueOrErrorMessage(getString(I, J), makeString(["mandatory ", toString(I), ".", J, " is not defined"], "")) |
---|
71 | | - | |
---|
72 | | - | |
---|
73 | | - | func K (J,L) = valueOrElse(getInteger(this, J), L) |
---|
74 | | - | |
---|
75 | | - | |
---|
76 | | - | let M = 1 |
---|
77 | | - | |
---|
78 | | - | let N = 2 |
---|
79 | | - | |
---|
80 | | - | let O = 3 |
---|
81 | | - | |
---|
82 | | - | let P = 4 |
---|
83 | | - | |
---|
84 | | - | let Q = 5 |
---|
85 | | - | |
---|
86 | | - | let R = 6 |
---|
87 | | - | |
---|
88 | | - | let S = 7 |
---|
89 | | - | |
---|
90 | | - | let T = 8 |
---|
91 | | - | |
---|
92 | | - | let U = 9 |
---|
93 | | - | |
---|
94 | | - | let V = 10 |
---|
95 | | - | |
---|
96 | | - | let W = 11 |
---|
97 | | - | |
---|
98 | | - | let X = 12 |
---|
99 | | - | |
---|
100 | | - | let Y = 13 |
---|
101 | | - | |
---|
102 | | - | func Z () = "%s%s__config__controlAddress" |
---|
103 | | - | |
---|
104 | | - | |
---|
105 | | - | func aa () = "%s__controlConfig" |
---|
106 | | - | |
---|
107 | | - | |
---|
108 | | - | func ab (ac) = split_4C(H(ac, aa()), b) |
---|
109 | | - | |
---|
110 | | - | |
---|
111 | | - | func ad (ae,af) = valueOrErrorMessage(addressFromString(ae[af]), ("Control cfg doesn't contain address at index " + toString(af))) |
---|
112 | | - | |
---|
113 | | - | |
---|
114 | | - | let ag = addressFromStringValue(valueOrElse(getString(this, Z()), "3N4NS7d4Jo9a6F14LiFUKKYVdUkkf2eP4Zx")) |
---|
115 | | - | |
---|
116 | | - | let ae = ab(ag) |
---|
117 | | - | |
---|
118 | | - | let ah = ad(ae, M) |
---|
119 | | - | |
---|
120 | | - | let ai = ad(ae, W) |
---|
121 | | - | |
---|
122 | | - | let aj = ad(ae, V) |
---|
123 | | - | |
---|
124 | | - | func ak () = "%s__lastBase58Proposal" |
---|
125 | | - | |
---|
126 | | - | |
---|
127 | | - | func al (am) = ("%s%s__quorumRequired__" + am) |
---|
128 | | - | |
---|
129 | | - | |
---|
130 | | - | func an () = "%s__paymentRequired" |
---|
131 | | - | |
---|
132 | | - | |
---|
133 | | - | func ao () = "%s__gNsbtRequired" |
---|
134 | | - | |
---|
135 | | - | |
---|
136 | | - | func ap () = "%s__proposalId" |
---|
137 | | - | |
---|
138 | | - | |
---|
139 | | - | func aq () = "%s__firstProposalId" |
---|
140 | | - | |
---|
141 | | - | |
---|
142 | | - | func ar () = "%s__updateVersion" |
---|
143 | | - | |
---|
144 | | - | |
---|
145 | | - | func as (at) = ("%s%d__proposalStatusData__" + toString(at)) |
---|
146 | | - | |
---|
147 | | - | |
---|
148 | | - | func au (at) = ("%s%d__proposalData__" + toString(at)) |
---|
149 | | - | |
---|
150 | | - | |
---|
151 | | - | func av (at,aw) = makeString(["%s%d%d", "votesByOpt", toString(at), toString(aw)], b) |
---|
152 | | - | |
---|
153 | | - | |
---|
154 | | - | func ax (at,ay) = makeString(["%s%d%s", "votesByUser", toString(at), ay], b) |
---|
155 | | - | |
---|
156 | | - | |
---|
157 | | - | func az (at,ay) = makeString(["%s%d%s", "optionByUser", toString(at), ay], b) |
---|
158 | | - | |
---|
159 | | - | |
---|
160 | | - | func aA () = "%s__applyInProgress" |
---|
161 | | - | |
---|
162 | | - | |
---|
163 | | - | func aB (aC) = ("%s%d__proposalIdByTopicId__" + toString(aC)) |
---|
164 | | - | |
---|
165 | | - | |
---|
166 | | - | func aD (ay) = ("%s%s_userGnsbtReleaseTime__" + ay) |
---|
167 | | - | |
---|
168 | | - | |
---|
169 | | - | func aE (at) = ("%s%d__numVoters__" + toString(at)) |
---|
170 | | - | |
---|
171 | | - | |
---|
172 | | - | func aF () = "%s%s%s__stats__avg__uniqueVoters" |
---|
173 | | - | |
---|
174 | | - | |
---|
175 | | - | func aG () = "%s%s%s__stats__avg__gnsbtVoted" |
---|
176 | | - | |
---|
177 | | - | |
---|
178 | | - | func aH () = "%s%s__stats__uniqueAuthors" |
---|
179 | | - | |
---|
180 | | - | |
---|
181 | | - | func aI (aJ) = ("%s%s__numProposalsByAuthor__" + aJ) |
---|
182 | | - | |
---|
183 | | - | |
---|
184 | | - | func aK (aL) = ("%s%d__applyHistory__" + toString(aL)) |
---|
185 | | - | |
---|
186 | | - | |
---|
187 | | - | func aM (aN) = { |
---|
188 | | - | let aO = aN |
---|
189 | | - | if ($isInstanceOf(aO, "List[Any]")) |
---|
190 | | - | then { |
---|
191 | | - | let aP = aO |
---|
192 | | - | aP |
---|
193 | | - | } |
---|
194 | | - | else throw("fail to cast into List[Any]") |
---|
195 | | - | } |
---|
196 | | - | |
---|
197 | | - | |
---|
198 | | - | func aQ (aN) = { |
---|
199 | | - | let aO = aN |
---|
200 | | - | if ($isInstanceOf(aO, "Int")) |
---|
201 | | - | then { |
---|
202 | | - | let aR = aO |
---|
203 | | - | aR |
---|
204 | | - | } |
---|
205 | | - | else throw("fail to cast into Int") |
---|
206 | | - | } |
---|
207 | | - | |
---|
208 | | - | |
---|
209 | | - | func aS (aT,aU,aV,aW,aX,aY,aZ,ba) = makeString(["%b%d%d%d%b%d%b%s", toString(aT), toString(aU), toString(aV), toString(aW), toString(aX), toString(aY), toString(aZ), ba], b) |
---|
210 | | - | |
---|
211 | | - | |
---|
212 | | - | func bb (bc,am,bd,be,bf,bg,bh,bi,bj,bk,bl) = makeString(["%s%s%s%s%s%d%d%d%s%d%s", bc, am, bd, be, bf, toString(bg), toString(bh), toString(bi), bj, toString(bk), bl], b) |
---|
213 | | - | |
---|
214 | | - | |
---|
215 | | - | func bm (bn) = if ((size(bn) > 20)) |
---|
216 | | - | then throw(("Too many transactions: " + toString(size(bn)))) |
---|
217 | | - | else { |
---|
218 | | - | func bo (bp,bq) = if ((size(fromBase58String(bq)) != 32)) |
---|
219 | | - | then throw(("Wrong txId: " + bq)) |
---|
220 | | - | else if ((bp == "")) |
---|
221 | | - | then bq |
---|
222 | | - | else ((bp + c) + bq) |
---|
223 | | - | |
---|
224 | | - | let br = bn |
---|
225 | | - | let bs = size(br) |
---|
226 | | - | let bt = "" |
---|
227 | | - | func bu (bv,bw) = if ((bw >= bs)) |
---|
228 | | - | then bv |
---|
229 | | - | else bo(bv, br[bw]) |
---|
230 | | - | |
---|
231 | | - | func bx (bv,bw) = if ((bw >= bs)) |
---|
232 | | - | then bv |
---|
233 | | - | else throw("List size exceeds 20") |
---|
234 | | - | |
---|
235 | | - | bx(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bt, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
236 | | - | } |
---|
237 | | - | |
---|
238 | | - | |
---|
239 | | - | let by = 0 |
---|
240 | | - | |
---|
241 | | - | let bz = 1 |
---|
242 | | - | |
---|
243 | | - | func bA (bB) = { |
---|
244 | | - | let bC = if (isDefined(addressFromString(bB))) |
---|
245 | | - | then invoke(aj, "updateVotingPower", [bB], nil) |
---|
246 | | - | else unit |
---|
247 | | - | if ((bC == bC)) |
---|
248 | | - | then { |
---|
249 | | - | let bD = aM(invoke(ai, "gnsbtInfoSYSREADONLY", [bB, 0, 0], nil)) |
---|
250 | | - | let bE = aM(bD[2]) |
---|
251 | | - | let bF = aQ(bE[2]) |
---|
252 | | - | let bG = aQ(bE[3]) |
---|
253 | | - | let bH = aQ(bD[9]) |
---|
254 | | - | let bI = aQ(bD[6]) |
---|
255 | | - | [(bG + bI), (bF + bH)] |
---|
256 | | - | } |
---|
257 | | - | else throw("Strict value is not equal to itself.") |
---|
258 | | - | } |
---|
259 | | - | |
---|
260 | | - | |
---|
261 | | - | func bJ (bK) = if ((value(indexOf(bK, e)) != 0)) |
---|
262 | | - | then throw("Invalid url") |
---|
263 | | - | else if ((size(bK) > g)) |
---|
264 | | - | then throw("Url too long!") |
---|
265 | | - | else { |
---|
266 | | - | let aC = valueOrErrorMessage(parseInt(drop(bK, (value(lastIndexOf(bK, "/")) + 1))), "Wrong topicId") |
---|
267 | | - | let bL = getInteger(aB(aC)) |
---|
268 | | - | if (isDefined(bL)) |
---|
269 | | - | then throw(("Voting with such forum link is already registered by id=" + toString(value(bL)))) |
---|
270 | | - | else aC |
---|
271 | | - | } |
---|
272 | | - | |
---|
273 | | - | |
---|
274 | | - | func bM (bN,bc,am,bd,be,bf,bh,bi,bO,bn,bP) = if ((bN.assetId != unit)) |
---|
275 | | - | then throw("Allowed WAVES payment only!") |
---|
276 | | - | else { |
---|
277 | | - | let bQ = K(an(), j) |
---|
278 | | - | if ((bQ > bN.amount)) |
---|
279 | | - | then throw(("Payment attached should be at least " + toString(bQ))) |
---|
280 | | - | else { |
---|
281 | | - | let aC = bJ(be) |
---|
282 | | - | if ((bf == "")) |
---|
283 | | - | then throw("Title is empty") |
---|
284 | | - | else if ((size(bf) > f)) |
---|
285 | | - | then throw("Too long title") |
---|
286 | | - | else { |
---|
287 | | - | let bg = lastBlock.timestamp |
---|
288 | | - | if ((bg > bh)) |
---|
289 | | - | then throw(((("votingStartTime=" + toString(bh)) + " < proposalTime=") + toString(bg))) |
---|
290 | | - | else if ((bh > bi)) |
---|
291 | | - | then throw(((("votingEndTime=" + toString(bi)) + " < votingStartTime=") + toString(bh))) |
---|
292 | | - | else if (((bi - bh) > h)) |
---|
293 | | - | then throw(((("Voting period exceeds max: " + toString((bi - bh))) + " > ") + toString(h))) |
---|
294 | | - | else { |
---|
295 | | - | let bj = if ((am == "IDEA")) |
---|
296 | | - | then "" |
---|
297 | | - | else bm(bn) |
---|
298 | | - | if ((1 >= size(bP))) |
---|
299 | | - | then throw("Too few choices to vote") |
---|
300 | | - | else { |
---|
301 | | - | let bR = bA(bd) |
---|
302 | | - | let bS = bR[by] |
---|
303 | | - | let bT = bR[bz] |
---|
304 | | - | let bU = K(ao(), k) |
---|
305 | | - | if ((bU > bT)) |
---|
306 | | - | then throw((("You need at least " + toString(bU)) + " gNsbt to create voting")) |
---|
307 | | - | else { |
---|
308 | | - | let bV = invoke(ah, "acceptWaves", nil, [bN]) |
---|
309 | | - | if ((bV == bV)) |
---|
310 | | - | then { |
---|
311 | | - | let bW = K(al(am), d) |
---|
312 | | - | let bk = fraction(bW, bS, i) |
---|
313 | | - | let at = (K(ap(), 0) + 1) |
---|
314 | | - | let bX = (K(aI(bd), 0) + 1) |
---|
315 | | - | let bY = (K(aH(), 0) + (if ((bX == 1)) |
---|
316 | | - | then 1 |
---|
317 | | - | else 0)) |
---|
318 | | - | let bZ = makeString(bP, c) |
---|
319 | | - | let ca = getInteger(ak()) |
---|
320 | | - | let cb = if ((ca != unit)) |
---|
321 | | - | then nil |
---|
322 | | - | else [IntegerEntry(ak(), (at - 1))] |
---|
323 | | - | $Tuple2(([IntegerEntry(ap(), at), IntegerEntry(aB(aC), at), StringEntry(as(at), aS(false, 0, 0, 0, false, bi, false, "ACTIVE")), StringEntry(au(at), bb(bc, am, bd, toBase16String(toBytes(be)), toBase16String(toBytes(bf)), bg, bh, bi, bj, bk, bZ)), IntegerEntry(aI(bd), bX), IntegerEntry(aH(), bY)] ++ cb), bc) |
---|
324 | | - | } |
---|
325 | | - | else throw("Strict value is not equal to itself.") |
---|
326 | | - | } |
---|
327 | | - | } |
---|
328 | | - | } |
---|
329 | | - | } |
---|
330 | | - | } |
---|
331 | | - | } |
---|
332 | | - | |
---|
333 | | - | |
---|
334 | | - | func cc (at,bP,cd,ce,cf,cg,ch) = { |
---|
335 | | - | func ci (bp,cj) = { |
---|
336 | | - | let af = value(indexOf(bP, cj)) |
---|
337 | | - | let ck = if (cd) |
---|
338 | | - | then if ((af == cg)) |
---|
339 | | - | then ch |
---|
340 | | - | else K(av(at, af), 0) |
---|
341 | | - | else if ((af == value(ce))) |
---|
342 | | - | then cf |
---|
343 | | - | else if ((af == cg)) |
---|
344 | | - | then ch |
---|
345 | | - | else K(av(at, af), 0) |
---|
346 | | - | if ((bp._2 > ck)) |
---|
347 | | - | then bp |
---|
348 | | - | else $Tuple2(af, ck) |
---|
349 | | - | } |
---|
350 | | - | |
---|
351 | | - | let br = bP |
---|
352 | | - | let bs = size(br) |
---|
353 | | - | let bt = $Tuple2(0, 0) |
---|
354 | | - | func bu (bv,bw) = if ((bw >= bs)) |
---|
355 | | - | then bv |
---|
356 | | - | else ci(bv, br[bw]) |
---|
357 | | - | |
---|
358 | | - | func bx (bv,bw) = if ((bw >= bs)) |
---|
359 | | - | then bv |
---|
360 | | - | else throw("List size exceeds 10") |
---|
361 | | - | |
---|
362 | | - | bx(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bt, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) |
---|
363 | | - | } |
---|
364 | | - | |
---|
365 | | - | |
---|
366 | | - | func cl (cm,cn,co,cp) = makeString(["%b%d%d%d%b%d%b%s", toString(cn), toString(co._1), toString(co._2), toString(cp), cm[D], cm[E], cm[F], cm[G]], b) |
---|
367 | | - | |
---|
368 | | - | |
---|
369 | | - | func cq (cm) = makeString(["%b%d%d%d%b%d%b%s", cm[z], cm[A], cm[B], cm[C], "true", cm[E], cm[F], cm[G]], b) |
---|
370 | | - | |
---|
371 | | - | |
---|
372 | | - | func cr (cs,bf,bK,at) = { |
---|
373 | | - | let bS = bA("")[by] |
---|
374 | | - | let ct = 500000 |
---|
375 | | - | StringEntry(aK(lastBlock.timestamp), makeString(["%d%d%d%s%s%d", toString(cs), toString(bS), toString(ct), bf, bK, toString(at)], b)) |
---|
376 | | - | } |
---|
377 | | - | |
---|
378 | | - | |
---|
379 | | - | @Callable(aR) |
---|
380 | | - | func constructorV1 (cu,cv,cw,cx,cy) = if ((aR.caller != this)) |
---|
381 | | - | then throw("Permission denied") |
---|
382 | | - | else [StringEntry(Z(), cu), IntegerEntry(ao(), cv), IntegerEntry(an(), cw), IntegerEntry(al("IDEA"), cx), IntegerEntry(al("UPDATE"), cy)] |
---|
383 | | - | |
---|
384 | | - | |
---|
385 | | - | |
---|
386 | | - | @Callable(aR) |
---|
387 | | - | func castVote (at,cz) = { |
---|
388 | | - | let cA = toString(aR.caller) |
---|
389 | | - | let cB = split(H(this, as(at)), b) |
---|
390 | | - | if ((cB[F] == "true")) |
---|
391 | | - | then throw("Voting is canceled by team") |
---|
392 | | - | else { |
---|
393 | | - | let cC = split(H(this, au(at)), b) |
---|
394 | | - | let cD = parseIntValue(cC[u]) |
---|
395 | | - | let cE = parseIntValue(cC[v]) |
---|
396 | | - | let cF = lastBlock.timestamp |
---|
397 | | - | if ((cD > cF)) |
---|
398 | | - | then throw("Voting not started yet") |
---|
399 | | - | else if ((cF >= cE)) |
---|
400 | | - | then throw("Voting already finished") |
---|
401 | | - | else { |
---|
402 | | - | let cG = split(cC[y], c) |
---|
403 | | - | let cH = size(cG) |
---|
404 | | - | if ((1 >= cH)) |
---|
405 | | - | then throw("Too few choices to vote") |
---|
406 | | - | else if ((cz >= cH)) |
---|
407 | | - | then throw(("Unknown choice! Must be 0.." + toString((cH - 1)))) |
---|
408 | | - | else { |
---|
409 | | - | let bR = bA(cA) |
---|
410 | | - | let cI = bR[bz] |
---|
411 | | - | if ((0 >= cI)) |
---|
412 | | - | then throw("no gnsbt to vote") |
---|
413 | | - | else { |
---|
414 | | - | let bS = bR[by] |
---|
415 | | - | let ce = getInteger(az(at, cA)) |
---|
416 | | - | let cJ = if (!(isDefined(ce))) |
---|
417 | | - | then 0 |
---|
418 | | - | else K(ax(at, cA), 0) |
---|
419 | | - | let cK = if (isDefined(ce)) |
---|
420 | | - | then K(av(at, value(ce)), 0) |
---|
421 | | - | else 0 |
---|
422 | | - | let cL = K(av(at, cz), 0) |
---|
423 | | - | let cM = parseIntValue(cB[C]) |
---|
424 | | - | let cN = if (!(isDefined(ce))) |
---|
425 | | - | then 0 |
---|
426 | | - | else ((cK - cJ) + (if ((value(ce) == cz)) |
---|
427 | | - | then cI |
---|
428 | | - | else 0)) |
---|
429 | | - | let ch = if (if (isDefined(ce)) |
---|
430 | | - | then (value(ce) == cz) |
---|
431 | | - | else false) |
---|
432 | | - | then cN |
---|
433 | | - | else (cL + cI) |
---|
434 | | - | let cO = ((cM - cJ) + cI) |
---|
435 | | - | let cP = (cO >= parseIntValue(cC[x])) |
---|
436 | | - | let cQ = K(aE(at), 0) |
---|
437 | | - | let cR = K(aF(), 0) |
---|
438 | | - | let cS = ((getIntegerValue(ap()) - valueOrElse(getInteger(aq()), n)) + 1) |
---|
439 | | - | let cT = if ((cJ == 0)) |
---|
440 | | - | then 1 |
---|
441 | | - | else 0 |
---|
442 | | - | let cU = (cR + fraction(cT, i, cS)) |
---|
443 | | - | let cV = K(aG(), 0) |
---|
444 | | - | let cW = (cV + ((cI - cJ) / cS)) |
---|
445 | | - | let cd = if (!(isDefined(ce))) |
---|
446 | | - | then true |
---|
447 | | - | else (value(ce) == cz) |
---|
448 | | - | let cf = if (cd) |
---|
449 | | - | then nil |
---|
450 | | - | else [IntegerEntry(av(at, value(ce)), cN)] |
---|
451 | | - | let cX = cc(at, cG, cd, ce, cN, cz, ch) |
---|
452 | | - | let cY = max([cE, K(aD(cA), 0)]) |
---|
453 | | - | $Tuple2(([IntegerEntry(az(at, cA), cz), IntegerEntry(ax(at, cA), cI), IntegerEntry(av(at, cz), ch), IntegerEntry(aE(at), (cQ + cT)), IntegerEntry(aD(cA), cY), IntegerEntry(aF(), cU), IntegerEntry(aG(), cW), StringEntry(as(at), cl(cB, cP, cX, cO))] ++ cf), unit) |
---|
454 | | - | } |
---|
455 | | - | } |
---|
456 | | - | } |
---|
457 | | - | } |
---|
458 | | - | } |
---|
459 | | - | |
---|
460 | | - | |
---|
461 | | - | |
---|
462 | | - | @Callable(aR) |
---|
463 | | - | func initiateIdeaVoting (be,bf,bh,bi,bP) = if ((size(aR.payments) != 1)) |
---|
464 | | - | then throw("Exactly one payment required") |
---|
465 | | - | else if ((size(bP) != 2)) |
---|
466 | | - | then throw("Exactly 2 option ['NO', 'YES'] are expected") |
---|
467 | | - | else if ((bP[0] != "NO")) |
---|
468 | | - | then throw("Option NO should be the first") |
---|
469 | | - | else if ((bP[1] != "YES")) |
---|
470 | | - | then throw("Option YES should be the second") |
---|
471 | | - | else bM(value(aR.payments[0]), toBase58String(aR.transactionId), "IDEA", toString(aR.caller), be, bf, bh, bi, "PENDING", nil, bP) |
---|
472 | | - | |
---|
473 | | - | |
---|
474 | | - | |
---|
475 | | - | @Callable(aR) |
---|
476 | | - | func initiateUpdateVoting (be,bf,bh,bi,bn) = if ((size(aR.payments) != 1)) |
---|
477 | | - | then throw("Exactly one payment required") |
---|
478 | | - | else if ((1 > size(bn))) |
---|
479 | | - | then throw("Transactions list is empty") |
---|
480 | | - | else if ((aR.caller != this)) |
---|
481 | | - | then throw("not authorized") |
---|
482 | | - | else bM(value(aR.payments[0]), toBase58String(aR.transactionId), "UPDATE", toString(aR.caller), be, bf, bh, bi, "PENDING", bn, ["NO", "YES"]) |
---|
483 | | - | |
---|
484 | | - | |
---|
485 | | - | |
---|
486 | | - | @Callable(aR) |
---|
487 | | - | func cancelVoting (at) = if ((aR.caller != this)) |
---|
488 | | - | then throw("not authorized") |
---|
489 | | - | else { |
---|
490 | | - | let cZ = H(this, as(at)) |
---|
491 | | - | let da = ((take(cZ, value(lastIndexOf(cZ, b))) + b) + "true") |
---|
492 | | - | $Tuple2([StringEntry(as(at), da)], unit) |
---|
493 | | - | } |
---|
494 | | - | |
---|
495 | | - | |
---|
496 | | - | |
---|
497 | | - | @Callable(aR) |
---|
498 | | - | func applyUpdate (at) = { |
---|
499 | | - | let cC = split(H(this, au(at)), b) |
---|
500 | | - | let cE = parseIntValue(cC[v]) |
---|
501 | | - | let cF = lastBlock.timestamp |
---|
502 | | - | if ((cE > cF)) |
---|
503 | | - | then throw("Voting is not finished yet") |
---|
504 | | - | else if (("UPDATE" != cC[p])) |
---|
505 | | - | then throw("Only UPDATE type can be applied") |
---|
506 | | - | else { |
---|
507 | | - | let cB = split(H(this, as(at)), b) |
---|
508 | | - | if ((cB[F] == "true")) |
---|
509 | | - | then throw("Voting is canceled") |
---|
510 | | - | else if ((cB[z] != "true")) |
---|
511 | | - | then throw("Voting status invalid") |
---|
512 | | - | else if ((cB[A] != "1")) |
---|
513 | | - | then throw("Winner is 'NO' - nothing to apply") |
---|
514 | | - | else if ((cB[D] == "true")) |
---|
515 | | - | then throw("Scripts are already applied") |
---|
516 | | - | else { |
---|
517 | | - | let db = parseIntValue(cB[E]) |
---|
518 | | - | if (((cF - l) > db)) |
---|
519 | | - | then throw((("Scripts timestamp=" + toString(db)) + " is too far in the past, max 2 hrs allowed")) |
---|
520 | | - | else if ((db > (cF + m))) |
---|
521 | | - | then throw((("Scripts timestamp=" + toString(db)) + " is too far in the future, max 1.5 hrs allowed")) |
---|
522 | | - | else { |
---|
523 | | - | let dc = K(aA(), -1) |
---|
524 | | - | if ((dc != -1)) |
---|
525 | | - | then throw((("proposalId=" + toString(dc)) + " is already being applied. Finish it first!")) |
---|
526 | | - | else { |
---|
527 | | - | let dd = invoke(ag, "callEmergencyShutdown", ["Applying Governance UPDATE"], nil) |
---|
528 | | - | if ((dd == dd)) |
---|
529 | | - | then $Tuple2([IntegerEntry(aA(), at)], unit) |
---|
530 | | - | else throw("Strict value is not equal to itself.") |
---|
531 | | - | } |
---|
532 | | - | } |
---|
533 | | - | } |
---|
534 | | - | } |
---|
535 | | - | } |
---|
536 | | - | |
---|
537 | | - | |
---|
538 | | - | |
---|
539 | | - | @Callable(aR) |
---|
540 | | - | func finishApply () = { |
---|
541 | | - | let at = valueOrErrorMessage(getInteger(aA()), "No apply in progress, nothing to finish") |
---|
542 | | - | let cC = split(H(this, au(at)), b) |
---|
543 | | - | let bn = split(cC[w], c) |
---|
544 | | - | let cB = split(H(this, as(at)), b) |
---|
545 | | - | if ((cB[D] == "true")) |
---|
546 | | - | then throw("Scripts are already applied") |
---|
547 | | - | else { |
---|
548 | | - | func de (bp,bq) = if (!(isDefined(transactionHeightById(fromBase58String(bq))))) |
---|
549 | | - | then throw(("NOT applied txId: " + bq)) |
---|
550 | | - | else unit |
---|
551 | | - | |
---|
552 | | - | let df = { |
---|
553 | | - | let br = bn |
---|
554 | | - | let bs = size(br) |
---|
555 | | - | let bt = unit |
---|
556 | | - | func bu (bv,bw) = if ((bw >= bs)) |
---|
557 | | - | then bv |
---|
558 | | - | else de(bv, br[bw]) |
---|
559 | | - | |
---|
560 | | - | func bx (bv,bw) = if ((bw >= bs)) |
---|
561 | | - | then bv |
---|
562 | | - | else throw("List size exceeds 20") |
---|
563 | | - | |
---|
564 | | - | bx(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bu(bt, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
565 | | - | } |
---|
566 | | - | let dg = (K(ar(), 0) + 1) |
---|
567 | | - | $Tuple2([DeleteEntry(aA()), IntegerEntry(ar(), dg), StringEntry(as(at), cq(cB)), cr(dg, cC[s], cC[r], at)], df) |
---|
568 | | - | } |
---|
569 | | - | } |
---|
570 | | - | |
---|
571 | | - | |
---|
572 | | - | |
---|
573 | | - | @Callable(aR) |
---|
574 | | - | func changeImplStatus (at,dh) = if ((aR.caller != this)) |
---|
575 | | - | then throw("not authorized") |
---|
576 | | - | else if (if ((dh != "ACTIVE")) |
---|
577 | | - | then (dh != "OUTDATED") |
---|
578 | | - | else false) |
---|
579 | | - | then throw("Unknown implementation status") |
---|
580 | | - | else { |
---|
581 | | - | let cB = split(H(this, as(at)), b) |
---|
582 | | - | let di = makeString(["%b%d%d%d%b%d%b%s", cB[z], cB[A], cB[B], cB[C], cB[D], cB[E], cB[F], dh], b) |
---|
583 | | - | $Tuple2([StringEntry(as(at), di)], unit) |
---|
584 | | - | } |
---|
585 | | - | |
---|
586 | | - | |
---|
| 1 | + | # no script |
---|