173 | | - | |
---|
174 | | - | func aE (aB) = { |
---|
175 | | - | let aC = aB |
---|
176 | | - | if ($isInstanceOf(aC, "Int")) |
---|
177 | | - | then { |
---|
178 | | - | let aF = aC |
---|
179 | | - | aF |
---|
180 | | - | } |
---|
181 | | - | else throw("fail to cast into Int") |
---|
182 | | - | } |
---|
183 | | - | |
---|
184 | | - | |
---|
185 | | - | func aG (aH,aI,aJ,aK,aL,aM,aN) = makeString(["%b%d%d%d%b%d%b", toString(aH), toString(aI), toString(aJ), toString(aK), toString(aL), toString(aM), toString(aN)], b) |
---|
186 | | - | |
---|
187 | | - | |
---|
188 | | - | func aO (aP,aQ,aR,aS,aT,aU,aV,aW,aX,aY,aZ) = makeString(["%s%s%s%s%s%d%d%d%s%d%s", aP, aQ, aR, aS, aT, toString(aU), toString(aV), toString(aW), aX, toString(aY), aZ], b) |
---|
189 | | - | |
---|
190 | | - | |
---|
191 | | - | func ba (bb) = if ((size(bb) > 20)) |
---|
192 | | - | then throw(("Too many transactions: " + toString(size(bb)))) |
---|
193 | | - | else { |
---|
194 | | - | func bc (bd,be) = if ((size(fromBase58String(be)) != 32)) |
---|
195 | | - | then throw(("Wrong txId: " + be)) |
---|
196 | | - | else if ((bd == "")) |
---|
197 | | - | then be |
---|
198 | | - | else ((bd + c) + be) |
---|
199 | | - | |
---|
200 | | - | let bf = bb |
---|
201 | | - | let bg = size(bf) |
---|
202 | | - | let bh = "" |
---|
203 | | - | func bi (bj,bk) = if ((bk >= bg)) |
---|
204 | | - | then bj |
---|
205 | | - | else bc(bj, bf[bk]) |
---|
206 | | - | |
---|
207 | | - | func bl (bj,bk) = if ((bk >= bg)) |
---|
208 | | - | then bj |
---|
209 | | - | else throw("List size exceeds 20") |
---|
210 | | - | |
---|
211 | | - | bl(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bh, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
212 | | - | } |
---|
213 | | - | |
---|
214 | | - | |
---|
215 | | - | func bm (bn,aP,aQ,aR,aS,aT,aV,aW,bo,bb,bp) = if ((bn.assetId != unit)) |
---|
216 | | - | then throw("Allowed WAVES payment only!") |
---|
217 | | - | else { |
---|
218 | | - | let bq = I(ai(), j) |
---|
219 | | - | if ((bq > bn.amount)) |
---|
220 | | - | then throw(("Payment attached should be at least " + toString(bq))) |
---|
221 | | - | else if ((value(indexOf(aS, e)) != 0)) |
---|
222 | | - | then throw("Invalid url") |
---|
223 | | - | else if ((size(aS) > g)) |
---|
224 | | - | then throw("Url too long!") |
---|
225 | | - | else if ((aT == "")) |
---|
226 | | - | then throw("Title is empty") |
---|
227 | | - | else if ((size(aT) > f)) |
---|
228 | | - | then throw("Too long title") |
---|
229 | | - | else { |
---|
230 | | - | let aU = lastBlock.timestamp |
---|
231 | | - | if ((aU > aV)) |
---|
232 | | - | then throw(((("votingStartTime=" + toString(aV)) + " < proposalTime=") + toString(aU))) |
---|
233 | | - | else if ((aV > aW)) |
---|
234 | | - | then throw(((("votingEndTime=" + toString(aW)) + " < votingStartTime=") + toString(aV))) |
---|
235 | | - | else if (((aW - aV) > h)) |
---|
236 | | - | then throw(((("Voting period exceeds max: " + toString((aW - aV))) + " > ") + toString(h))) |
---|
237 | | - | else { |
---|
238 | | - | let aX = if ((aQ == "IDEA")) |
---|
239 | | - | then "" |
---|
240 | | - | else ba(bb) |
---|
241 | | - | if ((1 >= size(bp))) |
---|
242 | | - | then throw("Too few choices to vote") |
---|
243 | | - | else { |
---|
244 | | - | let br = aA(invoke(ag, "gnsbtInfoSYSREADONLY", [aR, 0, 0], nil)) |
---|
245 | | - | let bs = aE(br[1]) |
---|
246 | | - | let bt = aE(br[0]) |
---|
247 | | - | let bu = I(aj(), k) |
---|
248 | | - | if ((bu > bt)) |
---|
249 | | - | then throw((("You need at least " + toString(bu)) + " gNsbt to create voting")) |
---|
250 | | - | else { |
---|
251 | | - | let bv = invoke(af, "acceptWaves", nil, [bn]) |
---|
252 | | - | if ((bv == bv)) |
---|
253 | | - | then { |
---|
254 | | - | let bw = I(ah(), d) |
---|
255 | | - | let aY = fraction(bw, bs, i) |
---|
256 | | - | let am = (I(ak(), 0) + 1) |
---|
257 | | - | let bx = (I(ay(aR), 0) + 1) |
---|
258 | | - | let by = (I(ax(), 0) + (if ((bx == 1)) |
---|
259 | | - | then 1 |
---|
260 | | - | else 0)) |
---|
261 | | - | let bz = makeString(bp, c) |
---|
262 | | - | $Tuple2([IntegerEntry(ak(), am), StringEntry(al(am), aG(false, 0, 0, 0, false, 0, false)), StringEntry(an(am), aO(aP, aQ, aR, aS, aT, aU, aV, aW, aX, aY, bz)), IntegerEntry(ay(aR), bx), IntegerEntry(ax(), by)], aP) |
---|
263 | | - | } |
---|
264 | | - | else throw("Strict value is not equal to itself.") |
---|
265 | | - | } |
---|
266 | | - | } |
---|
267 | | - | } |
---|
268 | | - | } |
---|
269 | | - | } |
---|
270 | | - | |
---|
271 | | - | |
---|
272 | | - | func bA (am,bp,bB,bC,bD,bE,bF) = { |
---|
273 | | - | func bG (bd,bH) = { |
---|
274 | | - | let ad = value(indexOf(bp, bH)) |
---|
275 | | - | let bI = if (bB) |
---|
276 | | - | then if ((ad == bE)) |
---|
277 | | - | then bF |
---|
278 | | - | else I(ao(am, ad), 0) |
---|
279 | | - | else if ((ad == value(bC))) |
---|
280 | | - | then bD |
---|
281 | | - | else if ((ad == bE)) |
---|
282 | | - | then bF |
---|
283 | | - | else I(ao(am, ad), 0) |
---|
284 | | - | if ((bd._2 > bI)) |
---|
285 | | - | then bd |
---|
286 | | - | else $Tuple2(ad, bI) |
---|
287 | | - | } |
---|
288 | | - | |
---|
289 | | - | let bf = bp |
---|
290 | | - | let bg = size(bf) |
---|
291 | | - | let bh = $Tuple2(0, 0) |
---|
292 | | - | func bi (bj,bk) = if ((bk >= bg)) |
---|
293 | | - | then bj |
---|
294 | | - | else bG(bj, bf[bk]) |
---|
295 | | - | |
---|
296 | | - | func bl (bj,bk) = if ((bk >= bg)) |
---|
297 | | - | then bj |
---|
298 | | - | else throw("List size exceeds 10") |
---|
299 | | - | |
---|
300 | | - | bl(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bh, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) |
---|
301 | | - | } |
---|
302 | | - | |
---|
303 | | - | |
---|
304 | | - | func bJ (bK,bL,bM,bN) = makeString(["%b%d%d%d%b%d%b", toString(bL), toString(bM._1), toString(bM._2), toString(bN), bK[C], bK[D], bK[E]], b) |
---|
305 | | - | |
---|
306 | | - | |
---|
307 | | - | func bO (bK) = makeString(["%b%d%d%d%b%d%b", bK[y], bK[z], bK[A], bK[B], "true", bK[D], bK[E]], b) |
---|
308 | | - | |
---|
309 | | - | |
---|
310 | | - | @Callable(aF) |
---|
311 | | - | func castVote (am,bP) = { |
---|
312 | | - | let bQ = toString(aF.caller) |
---|
313 | | - | let bR = split(F(this, al(am)), b) |
---|
314 | | - | if ((bR[E] == "true")) |
---|
315 | | - | then throw("Voting is canceled by team") |
---|
316 | | - | else { |
---|
317 | | - | let bS = split(F(this, an(am)), b) |
---|
318 | | - | let bT = parseIntValue(bS[t]) |
---|
319 | | - | let bU = parseIntValue(bS[u]) |
---|
320 | | - | let bV = lastBlock.timestamp |
---|
321 | | - | if ((bT > bV)) |
---|
322 | | - | then throw("Voting not started yet") |
---|
323 | | - | else if ((bV >= bU)) |
---|
324 | | - | then throw("Voting already finished") |
---|
325 | | - | else { |
---|
326 | | - | let bW = split(bS[x], c) |
---|
327 | | - | let bX = size(bW) |
---|
328 | | - | if ((1 >= bX)) |
---|
329 | | - | then throw("Too few choices to vote") |
---|
330 | | - | else if ((bP >= bX)) |
---|
331 | | - | then throw(("Unknown choice! Must be 0.." + toString((bX - 1)))) |
---|
332 | | - | else { |
---|
333 | | - | let bY = aA(invoke(ag, "gnsbtInfoSYSREADONLY", [bQ, 0, 0], nil)) |
---|
334 | | - | let bZ = aE(bY[0]) |
---|
335 | | - | if ((0 >= bZ)) |
---|
336 | | - | then throw("no gnsbt to vote") |
---|
337 | | - | else { |
---|
338 | | - | let bs = aE(bY[1]) |
---|
339 | | - | let bC = getInteger(as(am, bQ)) |
---|
340 | | - | let ca = if (!(isDefined(bC))) |
---|
341 | | - | then 0 |
---|
342 | | - | else I(aq(am, bQ), 0) |
---|
343 | | - | let cb = if (isDefined(bC)) |
---|
344 | | - | then I(ao(am, value(bC)), 0) |
---|
345 | | - | else 0 |
---|
346 | | - | let cc = I(ao(am, bP), 0) |
---|
347 | | - | let cd = parseIntValue(bR[B]) |
---|
348 | | - | let ce = if (!(isDefined(bC))) |
---|
349 | | - | then 0 |
---|
350 | | - | else ((cb - ca) + (if ((value(bC) == bP)) |
---|
351 | | - | then bZ |
---|
352 | | - | else 0)) |
---|
353 | | - | let bF = if (if (isDefined(bC)) |
---|
354 | | - | then (value(bC) == bP) |
---|
355 | | - | else false) |
---|
356 | | - | then ce |
---|
357 | | - | else (cc + bZ) |
---|
358 | | - | let cf = ((cd - ca) + bZ) |
---|
359 | | - | let cg = (cf > parseIntValue(bS[w])) |
---|
360 | | - | let ch = I(au(am), 0) |
---|
361 | | - | let ci = I(av(), 0) |
---|
362 | | - | let cj = getIntegerValue(ak()) |
---|
363 | | - | let ck = if ((ca == 0)) |
---|
364 | | - | then 1 |
---|
365 | | - | else 0 |
---|
366 | | - | let cl = (ci + fraction(ck, i, cj)) |
---|
367 | | - | let cm = I(aw(), 0) |
---|
368 | | - | let cn = (cm + ((bZ - ca) / cj)) |
---|
369 | | - | let bB = if (!(isDefined(bC))) |
---|
370 | | - | then true |
---|
371 | | - | else (value(bC) == bP) |
---|
372 | | - | let bD = if (bB) |
---|
373 | | - | then nil |
---|
374 | | - | else [IntegerEntry(ao(am, value(bC)), ce)] |
---|
375 | | - | let co = bA(am, bW, bB, bC, ce, bP, bF) |
---|
376 | | - | $Tuple2(([IntegerEntry(as(am, bQ), bP), IntegerEntry(aq(am, bQ), bZ), IntegerEntry(ao(am, bP), bF), IntegerEntry(au(am), (ch + ck)), IntegerEntry(av(), cl), IntegerEntry(aw(), cn), StringEntry(al(am), bJ(bR, cg, co, cf))] ++ bD), unit) |
---|
377 | | - | } |
---|
378 | | - | } |
---|
379 | | - | } |
---|
380 | | - | } |
---|
381 | | - | } |
---|
382 | | - | |
---|
383 | | - | |
---|
384 | | - | |
---|
385 | | - | @Callable(aF) |
---|
386 | | - | func initiateIdeaVoting (aS,aT,aV,aW,bp) = if ((size(aF.payments) != 1)) |
---|
387 | | - | then throw("Exactly one payment required") |
---|
388 | | - | else bm(value(aF.payments[0]), toBase58String(aF.transactionId), "IDEA", toString(aF.caller), aS, aT, aV, aW, "PENDING", nil, bp) |
---|
389 | | - | |
---|
390 | | - | |
---|
391 | | - | |
---|
392 | | - | @Callable(aF) |
---|
393 | | - | func initiateUpdateVoting (aS,aT,aV,aW,bb) = if ((size(aF.payments) != 1)) |
---|
394 | | - | then throw("Exactly one payment required") |
---|
395 | | - | else if ((1 > size(bb))) |
---|
396 | | - | then throw("Transactions list is empty") |
---|
397 | | - | else bm(value(aF.payments[0]), toBase58String(aF.transactionId), "UPDATE", toString(aF.caller), aS, aT, aV, aW, "PENDING", bb, ["NO", "YES"]) |
---|
398 | | - | |
---|
399 | | - | |
---|
400 | | - | |
---|
401 | | - | @Callable(aF) |
---|
402 | | - | func cancelVoting (am) = if ((aF.caller != this)) |
---|
403 | | - | then throw("not authorized") |
---|
404 | | - | else { |
---|
405 | | - | let cp = F(this, al(am)) |
---|
406 | | - | let cq = ((take(cp, value(lastIndexOf(cp, b))) + b) + "true") |
---|
407 | | - | $Tuple2([StringEntry(al(am), cq)], unit) |
---|
408 | | - | } |
---|
409 | | - | |
---|
410 | | - | |
---|
411 | | - | |
---|
412 | | - | @Callable(aF) |
---|
413 | | - | func applyUpdate (am) = { |
---|
414 | | - | let bS = split(F(this, an(am)), b) |
---|
415 | | - | let bU = parseIntValue(bS[u]) |
---|
416 | | - | let bV = lastBlock.timestamp |
---|
417 | | - | if ((bU > bV)) |
---|
418 | | - | then throw("Voting is not finished yet") |
---|
419 | | - | else if (("UPDATE" != bS[o])) |
---|
420 | | - | then throw("Only UPDATE type can be applied") |
---|
421 | | - | else { |
---|
422 | | - | let bR = split(F(this, al(am)), b) |
---|
423 | | - | if ((bR[E] == "true")) |
---|
424 | | - | then throw("Voting is canceled") |
---|
425 | | - | else if ((bR[y] != "true")) |
---|
426 | | - | then throw("Voting status invalid") |
---|
427 | | - | else if ((bR[z] != "1")) |
---|
428 | | - | then throw("Winner is 'NO' - nothing to apply") |
---|
429 | | - | else if ((bR[C] == "true")) |
---|
430 | | - | then throw("Scripts are already applied") |
---|
431 | | - | else { |
---|
432 | | - | let cr = parseIntValue(bR[D]) |
---|
433 | | - | if (((bV - l) > cr)) |
---|
434 | | - | then throw((("Scripts timestamp=" + toString(cr)) + " is too far in the past, max 2 hrs allowed")) |
---|
435 | | - | else if ((cr > (bV + m))) |
---|
436 | | - | then throw((("Scripts timestamp=" + toString(cr)) + " is too far in the future, max 1.5 hrs allowed")) |
---|
437 | | - | else { |
---|
438 | | - | let cs = I(at(), -1) |
---|
439 | | - | if ((cs != -1)) |
---|
440 | | - | then throw((("proposalId=" + toString(cs)) + " is already being applied. Finish it first!")) |
---|
441 | | - | else { |
---|
442 | | - | let ct = invoke(ae, "callEmergencyShutdown", ["Applying Governance UPDATE"], nil) |
---|
443 | | - | if ((ct == ct)) |
---|
444 | | - | then $Tuple2([IntegerEntry(at(), am)], unit) |
---|
445 | | - | else throw("Strict value is not equal to itself.") |
---|
446 | | - | } |
---|
447 | | - | } |
---|
448 | | - | } |
---|
449 | | - | } |
---|
450 | | - | } |
---|
451 | | - | |
---|
452 | | - | |
---|
453 | | - | |
---|
454 | | - | @Callable(aF) |
---|
455 | | - | func finishApply () = { |
---|
456 | | - | let am = valueOrErrorMessage(getInteger(at()), "No apply in progress, nothing to finish") |
---|
457 | | - | let bS = split(F(this, an(am)), b) |
---|
458 | | - | let bb = split(bS[v], c) |
---|
459 | | - | let bR = split(F(this, al(am)), b) |
---|
460 | | - | if ((bR[C] == "true")) |
---|
461 | | - | then throw("Scripts are already applied") |
---|
462 | | - | else { |
---|
463 | | - | func cu (bd,be) = if (!(isDefined(transactionHeightById(fromBase58String(be))))) |
---|
464 | | - | then throw(("NOT applied txId: " + be)) |
---|
465 | | - | else unit |
---|
466 | | - | |
---|
467 | | - | let cv = { |
---|
468 | | - | let bf = bb |
---|
469 | | - | let bg = size(bf) |
---|
470 | | - | let bh = unit |
---|
471 | | - | func bi (bj,bk) = if ((bk >= bg)) |
---|
472 | | - | then bj |
---|
473 | | - | else cu(bj, bf[bk]) |
---|
474 | | - | |
---|
475 | | - | func bl (bj,bk) = if ((bk >= bg)) |
---|
476 | | - | then bj |
---|
477 | | - | else throw("List size exceeds 20") |
---|
478 | | - | |
---|
479 | | - | bl(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bi(bh, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
480 | | - | } |
---|
481 | | - | $Tuple2([DeleteEntry(at()), StringEntry(al(am), bO(bR))], cv) |
---|
482 | | - | } |
---|
| 15 | + | @Callable(d) |
---|
| 16 | + | func walletInfoREADONLY (e) = { |
---|
| 17 | + | let f = addressFromString(e) |
---|
| 18 | + | let g = if (isDefined(f)) |
---|
| 19 | + | then wavesBalance(value(f)) |
---|
| 20 | + | else BalanceDetails(0, 0, 0, 0) |
---|
| 21 | + | let h = if (isDefined(f)) |
---|
| 22 | + | then assetBalance(value(f), b) |
---|
| 23 | + | else 0 |
---|
| 24 | + | $Tuple2(nil, makeString(["%d%d%d%d%d", toString(g.regular), toString(g.available), toString(g.generating), toString(g.effective), toString(h)], "_")) |
---|