tx · 9cd9kgwP15GTNXrGwYWsftcYSCoRWkWkiPRpVYtqhCjo 3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx: -0.01300000 Waves 2023.09.06 12:16 [2743319] smart account 3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx > SELF 0.00000000 Waves
{ "type": 13, "id": "9cd9kgwP15GTNXrGwYWsftcYSCoRWkWkiPRpVYtqhCjo", "fee": 1300000, "feeAssetId": null, "timestamp": 1693991844687, "version": 2, "chainId": 84, "sender": "3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx", "senderPublicKey": "UGqkWsCpv7xRVXkQRXyLd6pWPDtYGXmPip7FxSd1pAu", "proofs": [ "4ACyrm1LmaENt5f5KAiejcHF5rHkvwzmBtnXJQBdsDXLmV8VE2PVXRrmXUcRfd1n6RfUJqL6psuUvqTMjsLxb6n7" ], "script": "base64:BgIfCAISBwoFAQEBAQESABIAEgQKAggBEgMKAQESAwoBATYAD0RFRkFVTFRMT0NBVElPTgIPQWZyaWNhX0ZfQWZyaWNhAA9sb2NJZHhDb250aW5lbnQAAAAKbG9jSWR4VHlwZQABARRrZXlTdGFrZWREdWNrQnlPd25lcgEJb3duZXJBZGRyCQCsAgICEnN0YWtlZER1Y2tCeU93bmVyXwUJb3duZXJBZGRyAQ9rZXlEdWNrTG9jYXRpb24BC2R1Y2tBc3NldElkCQCsAgICDWR1Y2tMb2NhdGlvbl8FC2R1Y2tBc3NldElkAA1sYXN0VG91cklkS2V5Ag4lc19fbGFzdFRvdXJJZAEVa2V5VG91clN0YXRpY0RhdGFCeUlkAQN0SWQJAKwCAgIWJXMlZF9fdG91clN0YXRpY0RhdGFfXwkApAMBBQN0SWQBFmtleVRvdXJEeW5hbWljRGF0YUJ5SWQBA3RJZAkArAICAhclcyVkX190b3VyRHluYW1pY0RhdGFfXwkApAMBBQN0SWQBE2tleVNjb3JlQm9hcmRCeVRvdXIBA3RJZAkArAICAhIlcyVkX19zY29yZUJvYXJkX18J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AUSdXBkYXRlZER5bmFtaWNEYXRhBQNuaWwAAAFpARBmaW5pc2hUb3VybmFtZW50AQN0SWQEBmNhbGxlcgkApQgBCAUBaQZjYWxsZXIDCQEBIQEJAQ9jb250YWluc0VsZW1lbnQCBQphZG1pbnNMaXN0BQZjYWxsZXIJAAIBAhFQZXJtaXNzaW9uIGRlbmllZAQFdERhdGEJAQtnZXRUb3VyRGF0YQIFBHRoaXMFA3RJZAQHZHluYW1pYwkAkQMCBQV0RGF0YQUKaWR4RHluYW1pYwQGc3RhdHVzCQCRAwIFB2R5bmFtaWMFDnREeW5hbWljU3RhdHVzAwkAAAIFBnN0YXR1cwIIQVJDSElWRUQJAAIBCQCsAgIJAKwCAgILVG91cm5hbWVudCAJAKQDAQUDdElkAhQgaXMgYWxyZWFkeSBBUkNISVZFRAQSdXBkYXRlZER5bmFtaWNEYXRhCQELZHluYW1pY0RhdGEFAghBUkNISVZFRAkAkQMCBQdkeW5hbWljBQ90RHluYW1pY0xlYWRlcnMJAQ1wYXJzZUludFZhbHVlAQkAkQMCBQdkeW5hbWljBRF0RHluYW1pY1dpblJlc3VsdAkBDXBhcnNlSW50VmFsdWUBCQCRAwIFB2R5bmFtaWMFFXREeW5hbWljVG90YWxSZWdDb3VudAkBDXBhcnNlSW50VmFsdWUBCQCRAwIFB2R5bmFtaWMFFXREeW5hbWljVG90YWxBdHRlbXB0cwkAlAoCCQDMCAIJAQtTdHJpbmdFbnRyeQIJARZrZXlUb3VyRHluYW1pY0RhdGFCeUlkAQUDdElkBRJ1cGRhdGVkRHluYW1pY0RhdGEFA25pbAAAAAVVQds=", "height": 2743319, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CcWe6nSyg5XsK2swkVP3k79v1Bcz5gZcbb9cm25Kq1xP Next: 8ZEdvgUApGJyayBBLykckYVwvowotejjpMVn5GnxwmwK Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let DEFAULTLOCATION = "Africa_F_Africa" | |
5 | + | ||
6 | + | let locIdxContinent = 0 | |
7 | + | ||
8 | + | let locIdxType = 1 | |
5 | 9 | ||
6 | 10 | func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr) | |
7 | 11 | ||
23 | 27 | func keySumScoresByTour (tId) = ("%s%d__sumScores__" + toString(tId)) | |
24 | 28 | ||
25 | 29 | ||
26 | - | func keyWinnersByTour (tId) = ("%s%d__winners__" + toString(tId)) | |
27 | - | ||
28 | - | ||
29 | 30 | func keyLastRegisteredTourByDuck (duckAssetId) = ("%s%s__lastRegisteredTourByDuck__" + duckAssetId) | |
30 | 31 | ||
31 | 32 | ||
42 | 43 | ||
43 | 44 | let idxDynamic = 1 | |
44 | 45 | ||
45 | - | func getTourData (tourContract,tId) = { | |
46 | - | let static = split(valueOrErrorMessage(getString(tourContract, keyTourStaticDataById(tId)), (("Error reading tournament " + toString(tId)) + " data")), "__") | |
47 | - | let dynamic = split(valueOrErrorMessage(getString(tourContract, keyTourDynamicDataById(tId)), (("Error reading tournament " + toString(tId)) + " data")), "__") | |
48 | - | [static, dynamic] | |
49 | - | } | |
50 | - | ||
51 | - | ||
52 | 46 | let tStaticRegisterCost = 2 | |
53 | 47 | ||
54 | 48 | let tStaticAttemptCost = 3 | |
59 | 53 | ||
60 | 54 | let tDynamicStatus = 1 | |
61 | 55 | ||
62 | - | let | |
56 | + | let tDynamicLeaders = 2 | |
63 | 57 | ||
64 | 58 | let tDynamicWinResult = 3 | |
65 | 59 | ||
67 | 61 | ||
68 | 62 | let tDynamicTotalAttempts = 5 | |
69 | 63 | ||
70 | - | let locIdxContinent = 0 | |
64 | + | func getTourData (tourContract,tId) = { | |
65 | + | let static = split(valueOrErrorMessage(getString(tourContract, keyTourStaticDataById(tId)), (("Error reading tournament " + toString(tId)) + " data")), "__") | |
66 | + | let dynamic = split_4C(valueOrErrorMessage(getString(tourContract, keyTourDynamicDataById(tId)), (("Error reading tournament " + toString(tId)) + " data")), "__") | |
67 | + | [static, dynamic] | |
68 | + | } | |
71 | 69 | ||
72 | - | let locIdxType = 1 | |
70 | + | ||
71 | + | func isInTournament (tourContract,location) = { | |
72 | + | let lastId = valueOrElse(getInteger(tourContract, lastTourIdKey), 0) | |
73 | + | let loc = split(location, "_") | |
74 | + | let now = lastBlock.timestamp | |
75 | + | let tData = getTourData(tourContract, lastId) | |
76 | + | let static = tData[idxStatic] | |
77 | + | let dynamic = tData[idxDynamic] | |
78 | + | if (if (if ((loc[locIdxType] == "T")) | |
79 | + | then (parseIntValue(loc[locIdxContinent]) == lastId) | |
80 | + | else false) | |
81 | + | then (dynamic[tDynamicStatus] == "INPROGRESS") | |
82 | + | else false) | |
83 | + | then (parseIntValue(static[tStaticEnd]) > now) | |
84 | + | else false | |
85 | + | } | |
86 | + | ||
73 | 87 | ||
74 | 88 | let chain = take(drop(this.bytes, 1), 1) | |
75 | 89 | ||
162 | 176 | func staticData (txId,registerCost,attemptCost,creationTime,startTime,endTime,numGrands) = makeString(["%s%d%d%d%d%d%d", txId, toString(registerCost), toString(attemptCost), toString(creationTime), toString(startTime), toString(endTime), toString(numGrands)], SEP) | |
163 | 177 | ||
164 | 178 | ||
165 | - | func dynamicData (status, | |
179 | + | func dynamicData (status,leaders,winResult,totalRegs,totalAttempts) = makeString_2C(["%s%s%d%d%d", status, leaders, toString(winResult), toString(totalRegs), toString(totalAttempts)], SEP) | |
166 | 180 | ||
167 | 181 | ||
168 | 182 | func prolog () = asInt(invoke(stakingContract, "saveLastTx", nil, nil)) | |
247 | 261 | else contains(oldScoreBoard, duckAssetId)) | |
248 | 262 | then throw(((("Your duck " + duckAssetId) + " is already registered at tournament ") + toString(lastId))) | |
249 | 263 | else { | |
250 | - | let updatedDynamicData = dynamicData("INPROGRESS", dynamic[ | |
264 | + | let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), (parseIntValue(dynamic[tDynamicTotalRegCount]) + 1), parseIntValue(dynamic[tDynamicTotalAttempts])) | |
251 | 265 | $Tuple2([IntegerEntry(keyLastRegisteredTourByDuck(duckAssetId), lastId), BooleanEntry(keyIsRegisteredByTourAndDuck(lastId, duckAssetId), true), StringEntry(keyScoreBoardByTour(lastId), if ((oldScoreBoard == "")) | |
252 | 266 | then (duckAssetId + ":000") | |
253 | 267 | else (((oldScoreBoard + "_") + duckAssetId) + ":000")), StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], prologResult) | |
279 | 293 | else { | |
280 | 294 | let attemptsIteratorKey = keyLastAttemptByTourAndDuck(lastId, duckAssetId) | |
281 | 295 | let lastAttempt = getInteger(attemptsIteratorKey) | |
282 | - | let $ | |
296 | + | let $t061046736 = if (!(isDefined(lastAttempt))) | |
283 | 297 | then $Tuple2(0, 0) | |
284 | 298 | else if ((size(i.payments) != 1)) | |
285 | 299 | then throw("exactly 1 payment must be attached") | |
296 | 310 | else $Tuple2((value(lastAttempt) + 1), 1) | |
297 | 311 | } | |
298 | 312 | } | |
299 | - | let payedAttempts = $ | |
300 | - | let increment = $ | |
301 | - | let updatedDynamicData = dynamicData("INPROGRESS", dynamic[ | |
313 | + | let payedAttempts = $t061046736._1 | |
314 | + | let increment = $t061046736._2 | |
315 | + | let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), (parseIntValue(dynamic[tDynamicTotalAttempts]) + increment)) | |
302 | 316 | let tourLoc = asString(invoke(stakingContract, "initDuckTourAttempt", [duckAssetId], nil)) | |
303 | 317 | $Tuple2([IntegerEntry(attemptsIteratorKey, payedAttempts), StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], [prologResult, payedAttempts, tourLoc]) | |
304 | 318 | } | |
305 | 319 | } | |
306 | - | ||
307 | - | ||
308 | - | ||
309 | - | @Callable(i) | |
310 | - | func updateDynamicData (duckAssetId,newBest) = if ((i.caller != stakingContract)) | |
311 | - | then throw("Access denied") | |
312 | - | else { | |
313 | - | let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments") | |
314 | - | let tData = getTourData(this, lastId) | |
315 | - | let static = tData[idxStatic] | |
316 | - | let dynamic = tData[idxDynamic] | |
317 | - | let oldBest = parseIntValue(dynamic[tDynamicWinResult]) | |
318 | - | if (if (if ((oldBest > newBest)) | |
319 | - | then true | |
320 | - | else (dynamic[tDynamicStatus] != "INPROGRESS")) | |
321 | - | then true | |
322 | - | else (lastBlock.timestamp > parseIntValue(static[tStaticEnd]))) | |
323 | - | then $Tuple2(nil, 0) | |
324 | - | else { | |
325 | - | let winnersKey = keyWinnersByTour(lastId) | |
326 | - | let winners = getString(winnersKey) | |
327 | - | let oldWinnersList = if (!(isDefined(winners))) | |
328 | - | then nil | |
329 | - | else split_4C(value(winners), "_") | |
330 | - | let newWinnersList = if ((newBest > oldBest)) | |
331 | - | then [duckAssetId] | |
332 | - | else if (containsElement(oldWinnersList, duckAssetId)) | |
333 | - | then oldWinnersList | |
334 | - | else (oldWinnersList :+ duckAssetId) | |
335 | - | let updatedDynamicData = dynamicData("INPROGRESS", duckAssetId, newBest, parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts])) | |
336 | - | $Tuple2([StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData), StringEntry(winnersKey, makeString_2C(newWinnersList, "_"))], 0) | |
337 | - | } | |
338 | - | } | |
339 | 320 | ||
340 | 321 | ||
341 | 322 | ||
347 | 328 | let tData = getTourData(this, lastId) | |
348 | 329 | let static = tData[idxStatic] | |
349 | 330 | let dynamic = tData[idxDynamic] | |
350 | - | let curLocation = | |
331 | + | let curLocation = valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION) | |
351 | 332 | let bestResultKey = keyBestResultByTourAndDuck(lastId, duckAssetId) | |
352 | 333 | let sumScoresKey = keySumScoresByTour(lastId) | |
353 | 334 | let oldSumScores = valueOrElse(getInteger(sumScoresKey), 0) | |
354 | - | if (if (if (if ((curLocation[locIdxType] == "T")) | |
355 | - | then (parseIntValue(curLocation[locIdxContinent]) == lastId) | |
356 | - | else false) | |
357 | - | then (dynamic[tDynamicStatus] == "INPROGRESS") | |
358 | - | else false) | |
359 | - | then (parseIntValue(static[tStaticEnd]) >= lastBlock.timestamp) | |
360 | - | else false) | |
335 | + | if (isInTournament(this, curLocation)) | |
361 | 336 | then { | |
362 | 337 | let duckOldBest = valueOrElse(getInteger(bestResultKey), 0) | |
363 | 338 | let scoreKey = keyScoreBoardByTour(lastId) | |
364 | 339 | let oldScoreBoard = valueOrElse(getString(scoreKey), "") | |
365 | - | let $ | |
340 | + | let $t0959210753 = if ((duckNewBest > duckOldBest)) | |
366 | 341 | then if (!(contains(oldScoreBoard, duckAssetId))) | |
367 | 342 | then throw(("scoreBoard does not contain " + duckAssetId)) | |
368 | 343 | else { | |
344 | + | let oldBest = parseIntValue(dynamic[tDynamicWinResult]) | |
345 | + | let leaders = dynamic[tDynamicLeaders] | |
346 | + | let oldLeadersList = if (if ((leaders == "")) | |
347 | + | then true | |
348 | + | else (leaders == " ")) | |
349 | + | then nil | |
350 | + | else split_4C(leaders, ",") | |
351 | + | let newLeadersList = if ((duckNewBest > oldBest)) | |
352 | + | then [duckAssetId] | |
353 | + | else if (if ((oldBest > duckNewBest)) | |
354 | + | then true | |
355 | + | else containsElement(oldLeadersList, duckAssetId)) | |
356 | + | then oldLeadersList | |
357 | + | else (oldLeadersList :+ duckAssetId) | |
358 | + | let updatedDynamicData = dynamicData("INPROGRESS", makeString_2C(newLeadersList, ","), max([duckNewBest, oldBest]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts])) | |
369 | 359 | let parts = split_51C(oldScoreBoard, duckAssetId) | |
370 | - | $ | |
360 | + | $Tuple3(((((parts[0] + duckAssetId) + ":") + padL(duckNewBest, 3)) + drop(parts[1], 4)), ((oldSumScores + duckNewBest) - duckOldBest), [StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)]) | |
371 | 361 | } | |
372 | - | else $Tuple2(oldScoreBoard, oldSumScores) | |
373 | - | let newScoreBoard = $t0969710096._1 | |
374 | - | let newSumScores = $t0969710096._2 | |
375 | - | $Tuple2([IntegerEntry(bestResultKey, max([duckOldBest, duckNewBest])), IntegerEntry(sumScoresKey, newSumScores), StringEntry(scoreKey, newScoreBoard)], 0) | |
362 | + | else $Tuple3(oldScoreBoard, oldSumScores, nil) | |
363 | + | let newScoreBoard = $t0959210753._1 | |
364 | + | let newSumScores = $t0959210753._2 | |
365 | + | let globalActions = $t0959210753._3 | |
366 | + | $Tuple2(([IntegerEntry(bestResultKey, max([duckOldBest, duckNewBest])), IntegerEntry(sumScoresKey, newSumScores), StringEntry(scoreKey, newScoreBoard)] ++ globalActions), 0) | |
376 | 367 | } | |
377 | 368 | else $Tuple2(nil, 0) | |
378 | 369 | } | |
397 | 388 | else false) | |
398 | 389 | then throw((("Tournament " + toString(tId)) + " is not over yet")) | |
399 | 390 | else { | |
400 | - | let updatedDynamicData = dynamicData("PROCESSING", dynamic[ | |
391 | + | let updatedDynamicData = dynamicData("PROCESSING", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts])) | |
401 | 392 | $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0) | |
402 | 393 | } | |
403 | 394 | } | |
417 | 408 | if ((status == "ARCHIVED")) | |
418 | 409 | then throw((("Tournament " + toString(tId)) + " is already ARCHIVED")) | |
419 | 410 | else { | |
420 | - | let updatedDynamicData = dynamicData("ARCHIVED", dynamic[ | |
411 | + | let updatedDynamicData = dynamicData("ARCHIVED", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts])) | |
421 | 412 | $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0) | |
422 | 413 | } | |
423 | 414 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let DEFAULTLOCATION = "Africa_F_Africa" | |
5 | + | ||
6 | + | let locIdxContinent = 0 | |
7 | + | ||
8 | + | let locIdxType = 1 | |
5 | 9 | ||
6 | 10 | func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr) | |
7 | 11 | ||
8 | 12 | ||
9 | 13 | func keyDuckLocation (duckAssetId) = ("duckLocation_" + duckAssetId) | |
10 | 14 | ||
11 | 15 | ||
12 | 16 | let lastTourIdKey = "%s__lastTourId" | |
13 | 17 | ||
14 | 18 | func keyTourStaticDataById (tId) = ("%s%d__tourStaticData__" + toString(tId)) | |
15 | 19 | ||
16 | 20 | ||
17 | 21 | func keyTourDynamicDataById (tId) = ("%s%d__tourDynamicData__" + toString(tId)) | |
18 | 22 | ||
19 | 23 | ||
20 | 24 | func keyScoreBoardByTour (tId) = ("%s%d__scoreBoard__" + toString(tId)) | |
21 | 25 | ||
22 | 26 | ||
23 | 27 | func keySumScoresByTour (tId) = ("%s%d__sumScores__" + toString(tId)) | |
24 | 28 | ||
25 | 29 | ||
26 | - | func keyWinnersByTour (tId) = ("%s%d__winners__" + toString(tId)) | |
27 | - | ||
28 | - | ||
29 | 30 | func keyLastRegisteredTourByDuck (duckAssetId) = ("%s%s__lastRegisteredTourByDuck__" + duckAssetId) | |
30 | 31 | ||
31 | 32 | ||
32 | 33 | func keyIsRegisteredByTourAndDuck (tId,duckAssetId) = makeString(["%s%d%s__isRegisteredByTourAndDuck", toString(tId), duckAssetId], "__") | |
33 | 34 | ||
34 | 35 | ||
35 | 36 | func keyLastAttemptByTourAndDuck (tId,duckAssetId) = makeString(["%s%d%s__lastAttemptByTourAndDuck", toString(tId), duckAssetId], "__") | |
36 | 37 | ||
37 | 38 | ||
38 | 39 | func keyBestResultByTourAndDuck (tId,duckAssetId) = makeString(["%s%d%s__bestResultByTourAndDuck", toString(tId), duckAssetId], "__") | |
39 | 40 | ||
40 | 41 | ||
41 | 42 | let idxStatic = 0 | |
42 | 43 | ||
43 | 44 | let idxDynamic = 1 | |
44 | 45 | ||
45 | - | func getTourData (tourContract,tId) = { | |
46 | - | let static = split(valueOrErrorMessage(getString(tourContract, keyTourStaticDataById(tId)), (("Error reading tournament " + toString(tId)) + " data")), "__") | |
47 | - | let dynamic = split(valueOrErrorMessage(getString(tourContract, keyTourDynamicDataById(tId)), (("Error reading tournament " + toString(tId)) + " data")), "__") | |
48 | - | [static, dynamic] | |
49 | - | } | |
50 | - | ||
51 | - | ||
52 | 46 | let tStaticRegisterCost = 2 | |
53 | 47 | ||
54 | 48 | let tStaticAttemptCost = 3 | |
55 | 49 | ||
56 | 50 | let tStaticStart = 5 | |
57 | 51 | ||
58 | 52 | let tStaticEnd = 6 | |
59 | 53 | ||
60 | 54 | let tDynamicStatus = 1 | |
61 | 55 | ||
62 | - | let | |
56 | + | let tDynamicLeaders = 2 | |
63 | 57 | ||
64 | 58 | let tDynamicWinResult = 3 | |
65 | 59 | ||
66 | 60 | let tDynamicTotalRegCount = 4 | |
67 | 61 | ||
68 | 62 | let tDynamicTotalAttempts = 5 | |
69 | 63 | ||
70 | - | let locIdxContinent = 0 | |
64 | + | func getTourData (tourContract,tId) = { | |
65 | + | let static = split(valueOrErrorMessage(getString(tourContract, keyTourStaticDataById(tId)), (("Error reading tournament " + toString(tId)) + " data")), "__") | |
66 | + | let dynamic = split_4C(valueOrErrorMessage(getString(tourContract, keyTourDynamicDataById(tId)), (("Error reading tournament " + toString(tId)) + " data")), "__") | |
67 | + | [static, dynamic] | |
68 | + | } | |
71 | 69 | ||
72 | - | let locIdxType = 1 | |
70 | + | ||
71 | + | func isInTournament (tourContract,location) = { | |
72 | + | let lastId = valueOrElse(getInteger(tourContract, lastTourIdKey), 0) | |
73 | + | let loc = split(location, "_") | |
74 | + | let now = lastBlock.timestamp | |
75 | + | let tData = getTourData(tourContract, lastId) | |
76 | + | let static = tData[idxStatic] | |
77 | + | let dynamic = tData[idxDynamic] | |
78 | + | if (if (if ((loc[locIdxType] == "T")) | |
79 | + | then (parseIntValue(loc[locIdxContinent]) == lastId) | |
80 | + | else false) | |
81 | + | then (dynamic[tDynamicStatus] == "INPROGRESS") | |
82 | + | else false) | |
83 | + | then (parseIntValue(static[tStaticEnd]) > now) | |
84 | + | else false | |
85 | + | } | |
86 | + | ||
73 | 87 | ||
74 | 88 | let chain = take(drop(this.bytes, 1), 1) | |
75 | 89 | ||
76 | 90 | let defaultRestAddressStr = match chain { | |
77 | 91 | case _ => | |
78 | 92 | if ((base58'2W' == $match0)) | |
79 | 93 | then "3PQCuvFbvh4LkPUnrnU1z3jnbA1p9m3WNhv" | |
80 | 94 | else if ((base58'2T' == $match0)) | |
81 | 95 | then "3MumkGGztCKAXpWDqxkddofqXSUbqQkvSJy" | |
82 | 96 | else throw("Unknown chain") | |
83 | 97 | } | |
84 | 98 | ||
85 | 99 | let SEP = "__" | |
86 | 100 | ||
87 | 101 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
88 | 102 | ||
89 | 103 | ||
90 | 104 | let IdxCfgStakingDapp = 1 | |
91 | 105 | ||
92 | 106 | let IdxCfgWlgDapp = 4 | |
93 | 107 | ||
94 | 108 | func keyRestCfg () = "%s__restConfig" | |
95 | 109 | ||
96 | 110 | ||
97 | 111 | func keyRestAddress () = "%s__restAddr" | |
98 | 112 | ||
99 | 113 | ||
100 | 114 | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
101 | 115 | ||
102 | 116 | ||
103 | 117 | func getContractAddressOrFail (restCfg,idx) = valueOrErrorMessage(addressFromString(restCfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
104 | 118 | ||
105 | 119 | ||
106 | 120 | let restContract = addressFromStringValue(valueOrElse(getString(this, keyRestAddress()), defaultRestAddressStr)) | |
107 | 121 | ||
108 | 122 | let restCfg = readRestCfgOrFail(restContract) | |
109 | 123 | ||
110 | 124 | let stakingContract = getContractAddressOrFail(restCfg, IdxCfgStakingDapp) | |
111 | 125 | ||
112 | 126 | let wlgContract = getContractAddressOrFail(restCfg, IdxCfgWlgDapp) | |
113 | 127 | ||
114 | 128 | let wlgAssetIdKey = "wlg_assetId" | |
115 | 129 | ||
116 | 130 | let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "Not initialized yet") | |
117 | 131 | ||
118 | 132 | func asString (v) = match v { | |
119 | 133 | case s: String => | |
120 | 134 | s | |
121 | 135 | case _ => | |
122 | 136 | throw("fail to cast into String") | |
123 | 137 | } | |
124 | 138 | ||
125 | 139 | ||
126 | 140 | func asInt (v) = match v { | |
127 | 141 | case n: Int => | |
128 | 142 | n | |
129 | 143 | case _ => | |
130 | 144 | throw("fail to cast into Int") | |
131 | 145 | } | |
132 | 146 | ||
133 | 147 | ||
134 | 148 | func fixedPoint (val,decimals) = { | |
135 | 149 | let tenPow = pow(10, 0, decimals, 0, 0, DOWN) | |
136 | 150 | let lowPart = toString((val % tenPow)) | |
137 | 151 | let zeroes = drop(toString(tenPow), (1 + size(lowPart))) | |
138 | 152 | (((toString((val / tenPow)) + ".") + zeroes) + lowPart) | |
139 | 153 | } | |
140 | 154 | ||
141 | 155 | ||
142 | 156 | func padL (val,len) = { | |
143 | 157 | let valS = toString(val) | |
144 | 158 | let zeroes = drop(toString(pow(10, 0, (len - size(valS)), 0, 0, DOWN)), 1) | |
145 | 159 | (zeroes + valS) | |
146 | 160 | } | |
147 | 161 | ||
148 | 162 | ||
149 | 163 | let MAXTOURNAMENTLENGTH = 432000000 | |
150 | 164 | ||
151 | 165 | let HOUR = 3600000 | |
152 | 166 | ||
153 | 167 | let adminsList = [toString(this), match chain { | |
154 | 168 | case _ => | |
155 | 169 | if ((base58'2W' == $match0)) | |
156 | 170 | then "3PEe2RELUHCFCBsmSCNcBJ8N3URLVQende7" | |
157 | 171 | else if ((base58'2T' == $match0)) | |
158 | 172 | then "3MtBgJTaLxPB3C7UJD1UE8qjkHthfKvFQYY" | |
159 | 173 | else throw("Unknown chain") | |
160 | 174 | }] | |
161 | 175 | ||
162 | 176 | func staticData (txId,registerCost,attemptCost,creationTime,startTime,endTime,numGrands) = makeString(["%s%d%d%d%d%d%d", txId, toString(registerCost), toString(attemptCost), toString(creationTime), toString(startTime), toString(endTime), toString(numGrands)], SEP) | |
163 | 177 | ||
164 | 178 | ||
165 | - | func dynamicData (status, | |
179 | + | func dynamicData (status,leaders,winResult,totalRegs,totalAttempts) = makeString_2C(["%s%s%d%d%d", status, leaders, toString(winResult), toString(totalRegs), toString(totalAttempts)], SEP) | |
166 | 180 | ||
167 | 181 | ||
168 | 182 | func prolog () = asInt(invoke(stakingContract, "saveLastTx", nil, nil)) | |
169 | 183 | ||
170 | 184 | ||
171 | 185 | func duckByCaller (caller) = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(caller))), "You don't have a duck staked") | |
172 | 186 | ||
173 | 187 | ||
174 | 188 | @Callable(i) | |
175 | 189 | func createTournament (startTime,endTime,registerCost,attemptCost,numGrands) = { | |
176 | 190 | let caller = toString(i.caller) | |
177 | 191 | if (!(containsElement(adminsList, caller))) | |
178 | 192 | then throw("Permission denied") | |
179 | 193 | else { | |
180 | 194 | let lastId = getInteger(lastTourIdKey) | |
181 | 195 | let tId = if (isDefined(lastId)) | |
182 | 196 | then { | |
183 | 197 | let lastTourId = value(lastId) | |
184 | 198 | let dynamic = valueOrErrorMessage(getString(keyTourDynamicDataById(lastTourId)), (("Error reading tournament " + toString(lastTourId)) + " data")) | |
185 | 199 | let status = split(dynamic, SEP)[tDynamicStatus] | |
186 | 200 | if ((status != "ARCHIVED")) | |
187 | 201 | then throw(("Current tournement is not completed, status=" + status)) | |
188 | 202 | else (lastTourId + 1) | |
189 | 203 | } | |
190 | 204 | else 1 | |
191 | 205 | let now = lastBlock.timestamp | |
192 | 206 | if ((now > startTime)) | |
193 | 207 | then throw(((("startTime=" + toString(startTime)) + " < creationTime=") + toString(now))) | |
194 | 208 | else if ((startTime > endTime)) | |
195 | 209 | then throw(((("endTime=" + toString(endTime)) + " < startTime=") + toString(startTime))) | |
196 | 210 | else if (((endTime - startTime) > MAXTOURNAMENTLENGTH)) | |
197 | 211 | then throw(((("Tournament period exceeds max: " + toString((endTime - startTime))) + " > ") + toString(MAXTOURNAMENTLENGTH))) | |
198 | 212 | else if (if ((0 >= registerCost)) | |
199 | 213 | then true | |
200 | 214 | else (0 >= attemptCost)) | |
201 | 215 | then throw(((("Cost should be positive, but passed " + toString(registerCost)) + " and ") + toString(attemptCost))) | |
202 | 216 | else if ((0 > numGrands)) | |
203 | 217 | then throw("Number of Grand Prizes should be non-negative") | |
204 | 218 | else $Tuple2([IntegerEntry(lastTourIdKey, tId), StringEntry(keyTourStaticDataById(tId), staticData(toBase58String(i.transactionId), registerCost, attemptCost, now, startTime, endTime, numGrands)), StringEntry(keyTourDynamicDataById(tId), dynamicData("CREATED", " ", 0, 0, 0))], tId) | |
205 | 219 | } | |
206 | 220 | } | |
207 | 221 | ||
208 | 222 | ||
209 | 223 | ||
210 | 224 | @Callable(i) | |
211 | 225 | func register () = { | |
212 | 226 | let prologResult = prolog() | |
213 | 227 | if ((size(i.payments) != 1)) | |
214 | 228 | then throw("exactly 1 payment must be attached") | |
215 | 229 | else { | |
216 | 230 | let pmt = i.payments[0] | |
217 | 231 | let wlgAmt = pmt.amount | |
218 | 232 | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WLGOLD payments only!") | |
219 | 233 | if ((pmtAssetId != wlgAssetId)) | |
220 | 234 | then throw("WLGOLD payments only!") | |
221 | 235 | else { | |
222 | 236 | let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments") | |
223 | 237 | let now = lastBlock.timestamp | |
224 | 238 | let tData = getTourData(this, lastId) | |
225 | 239 | let static = tData[idxStatic] | |
226 | 240 | let dynamic = tData[idxDynamic] | |
227 | 241 | let status = dynamic[tDynamicStatus] | |
228 | 242 | if (!(if (if (if ((status == "CREATED")) | |
229 | 243 | then (now > parseIntValue(static[tStaticStart])) | |
230 | 244 | else false) | |
231 | 245 | then ((parseIntValue(static[tStaticEnd]) - HOUR) > now) | |
232 | 246 | else false) | |
233 | 247 | then true | |
234 | 248 | else if ((status == "INPROGRESS")) | |
235 | 249 | then ((parseIntValue(static[tStaticEnd]) - HOUR) > now) | |
236 | 250 | else false)) | |
237 | 251 | then throw("Cannot register now") | |
238 | 252 | else { | |
239 | 253 | let regCost = parseIntValue(static[tStaticRegisterCost]) | |
240 | 254 | if ((wlgAmt != regCost)) | |
241 | 255 | then throw((("Need payment of " + fixedPoint(regCost, 8)) + " WLGOLD")) | |
242 | 256 | else { | |
243 | 257 | let duckAssetId = duckByCaller(i.originCaller) | |
244 | 258 | let oldScoreBoard = valueOrElse(getString(keyScoreBoardByTour(lastId)), "") | |
245 | 259 | if (if (valueOrElse(getBoolean(keyIsRegisteredByTourAndDuck(lastId, duckAssetId)), false)) | |
246 | 260 | then true | |
247 | 261 | else contains(oldScoreBoard, duckAssetId)) | |
248 | 262 | then throw(((("Your duck " + duckAssetId) + " is already registered at tournament ") + toString(lastId))) | |
249 | 263 | else { | |
250 | - | let updatedDynamicData = dynamicData("INPROGRESS", dynamic[ | |
264 | + | let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), (parseIntValue(dynamic[tDynamicTotalRegCount]) + 1), parseIntValue(dynamic[tDynamicTotalAttempts])) | |
251 | 265 | $Tuple2([IntegerEntry(keyLastRegisteredTourByDuck(duckAssetId), lastId), BooleanEntry(keyIsRegisteredByTourAndDuck(lastId, duckAssetId), true), StringEntry(keyScoreBoardByTour(lastId), if ((oldScoreBoard == "")) | |
252 | 266 | then (duckAssetId + ":000") | |
253 | 267 | else (((oldScoreBoard + "_") + duckAssetId) + ":000")), StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], prologResult) | |
254 | 268 | } | |
255 | 269 | } | |
256 | 270 | } | |
257 | 271 | } | |
258 | 272 | } | |
259 | 273 | } | |
260 | 274 | ||
261 | 275 | ||
262 | 276 | ||
263 | 277 | @Callable(i) | |
264 | 278 | func newAttempt () = { | |
265 | 279 | let prologResult = prolog() | |
266 | 280 | let duckAssetId = duckByCaller(i.originCaller) | |
267 | 281 | let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments") | |
268 | 282 | let now = lastBlock.timestamp | |
269 | 283 | let tData = getTourData(this, lastId) | |
270 | 284 | let static = tData[idxStatic] | |
271 | 285 | let dynamic = tData[idxDynamic] | |
272 | 286 | let status = dynamic[tDynamicStatus] | |
273 | 287 | if (!(if ((status == "INPROGRESS")) | |
274 | 288 | then ((parseIntValue(static[tStaticEnd]) - HOUR) > now) | |
275 | 289 | else false)) | |
276 | 290 | then throw("Attempt is not possible") | |
277 | 291 | else if (!(valueOrElse(getBoolean(keyIsRegisteredByTourAndDuck(lastId, duckAssetId)), false))) | |
278 | 292 | then throw(((("Your duck " + duckAssetId) + " is not registered at tournament ") + toString(lastId))) | |
279 | 293 | else { | |
280 | 294 | let attemptsIteratorKey = keyLastAttemptByTourAndDuck(lastId, duckAssetId) | |
281 | 295 | let lastAttempt = getInteger(attemptsIteratorKey) | |
282 | - | let $ | |
296 | + | let $t061046736 = if (!(isDefined(lastAttempt))) | |
283 | 297 | then $Tuple2(0, 0) | |
284 | 298 | else if ((size(i.payments) != 1)) | |
285 | 299 | then throw("exactly 1 payment must be attached") | |
286 | 300 | else { | |
287 | 301 | let pmt = i.payments[0] | |
288 | 302 | let wlgAmt = pmt.amount | |
289 | 303 | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WLGOLD payments only!") | |
290 | 304 | if ((pmtAssetId != wlgAssetId)) | |
291 | 305 | then throw("WLGOLD payments only!") | |
292 | 306 | else { | |
293 | 307 | let attCost = parseIntValue(static[tStaticAttemptCost]) | |
294 | 308 | if ((wlgAmt != attCost)) | |
295 | 309 | then throw((("Need payment of " + fixedPoint(attCost, 8)) + " WLGOLD")) | |
296 | 310 | else $Tuple2((value(lastAttempt) + 1), 1) | |
297 | 311 | } | |
298 | 312 | } | |
299 | - | let payedAttempts = $ | |
300 | - | let increment = $ | |
301 | - | let updatedDynamicData = dynamicData("INPROGRESS", dynamic[ | |
313 | + | let payedAttempts = $t061046736._1 | |
314 | + | let increment = $t061046736._2 | |
315 | + | let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), (parseIntValue(dynamic[tDynamicTotalAttempts]) + increment)) | |
302 | 316 | let tourLoc = asString(invoke(stakingContract, "initDuckTourAttempt", [duckAssetId], nil)) | |
303 | 317 | $Tuple2([IntegerEntry(attemptsIteratorKey, payedAttempts), StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], [prologResult, payedAttempts, tourLoc]) | |
304 | 318 | } | |
305 | 319 | } | |
306 | - | ||
307 | - | ||
308 | - | ||
309 | - | @Callable(i) | |
310 | - | func updateDynamicData (duckAssetId,newBest) = if ((i.caller != stakingContract)) | |
311 | - | then throw("Access denied") | |
312 | - | else { | |
313 | - | let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments") | |
314 | - | let tData = getTourData(this, lastId) | |
315 | - | let static = tData[idxStatic] | |
316 | - | let dynamic = tData[idxDynamic] | |
317 | - | let oldBest = parseIntValue(dynamic[tDynamicWinResult]) | |
318 | - | if (if (if ((oldBest > newBest)) | |
319 | - | then true | |
320 | - | else (dynamic[tDynamicStatus] != "INPROGRESS")) | |
321 | - | then true | |
322 | - | else (lastBlock.timestamp > parseIntValue(static[tStaticEnd]))) | |
323 | - | then $Tuple2(nil, 0) | |
324 | - | else { | |
325 | - | let winnersKey = keyWinnersByTour(lastId) | |
326 | - | let winners = getString(winnersKey) | |
327 | - | let oldWinnersList = if (!(isDefined(winners))) | |
328 | - | then nil | |
329 | - | else split_4C(value(winners), "_") | |
330 | - | let newWinnersList = if ((newBest > oldBest)) | |
331 | - | then [duckAssetId] | |
332 | - | else if (containsElement(oldWinnersList, duckAssetId)) | |
333 | - | then oldWinnersList | |
334 | - | else (oldWinnersList :+ duckAssetId) | |
335 | - | let updatedDynamicData = dynamicData("INPROGRESS", duckAssetId, newBest, parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts])) | |
336 | - | $Tuple2([StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData), StringEntry(winnersKey, makeString_2C(newWinnersList, "_"))], 0) | |
337 | - | } | |
338 | - | } | |
339 | 320 | ||
340 | 321 | ||
341 | 322 | ||
342 | 323 | @Callable(i) | |
343 | 324 | func saveDuckResult (duckAssetId,duckNewBest) = if ((i.caller != stakingContract)) | |
344 | 325 | then throw("Access denied") | |
345 | 326 | else { | |
346 | 327 | let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments") | |
347 | 328 | let tData = getTourData(this, lastId) | |
348 | 329 | let static = tData[idxStatic] | |
349 | 330 | let dynamic = tData[idxDynamic] | |
350 | - | let curLocation = | |
331 | + | let curLocation = valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION) | |
351 | 332 | let bestResultKey = keyBestResultByTourAndDuck(lastId, duckAssetId) | |
352 | 333 | let sumScoresKey = keySumScoresByTour(lastId) | |
353 | 334 | let oldSumScores = valueOrElse(getInteger(sumScoresKey), 0) | |
354 | - | if (if (if (if ((curLocation[locIdxType] == "T")) | |
355 | - | then (parseIntValue(curLocation[locIdxContinent]) == lastId) | |
356 | - | else false) | |
357 | - | then (dynamic[tDynamicStatus] == "INPROGRESS") | |
358 | - | else false) | |
359 | - | then (parseIntValue(static[tStaticEnd]) >= lastBlock.timestamp) | |
360 | - | else false) | |
335 | + | if (isInTournament(this, curLocation)) | |
361 | 336 | then { | |
362 | 337 | let duckOldBest = valueOrElse(getInteger(bestResultKey), 0) | |
363 | 338 | let scoreKey = keyScoreBoardByTour(lastId) | |
364 | 339 | let oldScoreBoard = valueOrElse(getString(scoreKey), "") | |
365 | - | let $ | |
340 | + | let $t0959210753 = if ((duckNewBest > duckOldBest)) | |
366 | 341 | then if (!(contains(oldScoreBoard, duckAssetId))) | |
367 | 342 | then throw(("scoreBoard does not contain " + duckAssetId)) | |
368 | 343 | else { | |
344 | + | let oldBest = parseIntValue(dynamic[tDynamicWinResult]) | |
345 | + | let leaders = dynamic[tDynamicLeaders] | |
346 | + | let oldLeadersList = if (if ((leaders == "")) | |
347 | + | then true | |
348 | + | else (leaders == " ")) | |
349 | + | then nil | |
350 | + | else split_4C(leaders, ",") | |
351 | + | let newLeadersList = if ((duckNewBest > oldBest)) | |
352 | + | then [duckAssetId] | |
353 | + | else if (if ((oldBest > duckNewBest)) | |
354 | + | then true | |
355 | + | else containsElement(oldLeadersList, duckAssetId)) | |
356 | + | then oldLeadersList | |
357 | + | else (oldLeadersList :+ duckAssetId) | |
358 | + | let updatedDynamicData = dynamicData("INPROGRESS", makeString_2C(newLeadersList, ","), max([duckNewBest, oldBest]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts])) | |
369 | 359 | let parts = split_51C(oldScoreBoard, duckAssetId) | |
370 | - | $ | |
360 | + | $Tuple3(((((parts[0] + duckAssetId) + ":") + padL(duckNewBest, 3)) + drop(parts[1], 4)), ((oldSumScores + duckNewBest) - duckOldBest), [StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)]) | |
371 | 361 | } | |
372 | - | else $Tuple2(oldScoreBoard, oldSumScores) | |
373 | - | let newScoreBoard = $t0969710096._1 | |
374 | - | let newSumScores = $t0969710096._2 | |
375 | - | $Tuple2([IntegerEntry(bestResultKey, max([duckOldBest, duckNewBest])), IntegerEntry(sumScoresKey, newSumScores), StringEntry(scoreKey, newScoreBoard)], 0) | |
362 | + | else $Tuple3(oldScoreBoard, oldSumScores, nil) | |
363 | + | let newScoreBoard = $t0959210753._1 | |
364 | + | let newSumScores = $t0959210753._2 | |
365 | + | let globalActions = $t0959210753._3 | |
366 | + | $Tuple2(([IntegerEntry(bestResultKey, max([duckOldBest, duckNewBest])), IntegerEntry(sumScoresKey, newSumScores), StringEntry(scoreKey, newScoreBoard)] ++ globalActions), 0) | |
376 | 367 | } | |
377 | 368 | else $Tuple2(nil, 0) | |
378 | 369 | } | |
379 | 370 | ||
380 | 371 | ||
381 | 372 | ||
382 | 373 | @Callable(i) | |
383 | 374 | func processTournament (tId) = { | |
384 | 375 | let caller = toString(i.caller) | |
385 | 376 | if (!(containsElement(adminsList, caller))) | |
386 | 377 | then throw("Permission denied") | |
387 | 378 | else { | |
388 | 379 | let now = lastBlock.timestamp | |
389 | 380 | let tData = getTourData(this, tId) | |
390 | 381 | let static = tData[idxStatic] | |
391 | 382 | let dynamic = tData[idxDynamic] | |
392 | 383 | let status = dynamic[tDynamicStatus] | |
393 | 384 | if ((status == "ARCHIVED")) | |
394 | 385 | then throw((("Tournament " + toString(tId)) + " is already ARCHIVED")) | |
395 | 386 | else if (if ((status == "INPROGRESS")) | |
396 | 387 | then (parseIntValue(static[tStaticEnd]) > now) | |
397 | 388 | else false) | |
398 | 389 | then throw((("Tournament " + toString(tId)) + " is not over yet")) | |
399 | 390 | else { | |
400 | - | let updatedDynamicData = dynamicData("PROCESSING", dynamic[ | |
391 | + | let updatedDynamicData = dynamicData("PROCESSING", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts])) | |
401 | 392 | $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0) | |
402 | 393 | } | |
403 | 394 | } | |
404 | 395 | } | |
405 | 396 | ||
406 | 397 | ||
407 | 398 | ||
408 | 399 | @Callable(i) | |
409 | 400 | func finishTournament (tId) = { | |
410 | 401 | let caller = toString(i.caller) | |
411 | 402 | if (!(containsElement(adminsList, caller))) | |
412 | 403 | then throw("Permission denied") | |
413 | 404 | else { | |
414 | 405 | let tData = getTourData(this, tId) | |
415 | 406 | let dynamic = tData[idxDynamic] | |
416 | 407 | let status = dynamic[tDynamicStatus] | |
417 | 408 | if ((status == "ARCHIVED")) | |
418 | 409 | then throw((("Tournament " + toString(tId)) + " is already ARCHIVED")) | |
419 | 410 | else { | |
420 | - | let updatedDynamicData = dynamicData("ARCHIVED", dynamic[ | |
411 | + | let updatedDynamicData = dynamicData("ARCHIVED", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts])) | |
421 | 412 | $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0) | |
422 | 413 | } | |
423 | 414 | } | |
424 | 415 | } | |
425 | 416 | ||
426 | 417 |
github/deemru/w8io/169f3d6 71.39 ms ◑