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:BgIfCAISBwoFAQEBAQESABIAEgQKAggBEgMKAQESAwoBATYAD0RFRkFVTFRMT0NBVElPTgIPQWZyaWNhX0ZfQWZyaWNhAA9sb2NJZHhDb250aW5lbnQAAAAKbG9jSWR4VHlwZQABARRrZXlTdGFrZWREdWNrQnlPd25lcgEJb3duZXJBZGRyCQCsAgICEnN0YWtlZER1Y2tCeU93bmVyXwUJb3duZXJBZGRyAQ9rZXlEdWNrTG9jYXRpb24BC2R1Y2tBc3NldElkCQCsAgICDWR1Y2tMb2NhdGlvbl8FC2R1Y2tBc3NldElkAA1sYXN0VG91cklkS2V5Ag4lc19fbGFzdFRvdXJJZAEVa2V5VG91clN0YXRpY0RhdGFCeUlkAQN0SWQJAKwCAgIWJXMlZF9fdG91clN0YXRpY0RhdGFfXwkApAMBBQN0SWQBFmtleVRvdXJEeW5hbWljRGF0YUJ5SWQBA3RJZAkArAICAhclcyVkX190b3VyRHluYW1pY0RhdGFfXwkApAMBBQN0SWQBE2tleVNjb3JlQm9hcmRCeVRvdXIBA3RJZAkArAICAhIlcyVkX19zY29yZUJvYXJkX18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ZAUSdXBkYXRlZER5bmFtaWNEYXRhBQNuaWwAAAFpARBmaW5pc2hUb3VybmFtZW50AQN0SWQEBmNhbGxlcgkApQgBCAUBaQZjYWxsZXIDCQEBIQEJAQ9jb250YWluc0VsZW1lbnQCBQphZG1pbnNMaXN0BQZjYWxsZXIJAAIBAhFQZXJtaXNzaW9uIGRlbmllZAQFdERhdGEJAQtnZXRUb3VyRGF0YQIFBHRoaXMFA3RJZAQHZHluYW1pYwkAkQMCBQV0RGF0YQUKaWR4RHluYW1pYwQGc3RhdHVzCQCRAwIFB2R5bmFtaWMFDnREeW5hbWljU3RhdHVzAwkAAAIFBnN0YXR1cwIIQVJDSElWRUQJAAIBCQCsAgIJAKwCAgILVG91cm5hbWVudCAJAKQDAQUDdElkAhQgaXMgYWxyZWFkeSBBUkNISVZFRAQSdXBkYXRlZER5bmFtaWNEYXRhCQELZHluYW1pY0RhdGEFAghBUkNISVZFRAkAkQMCBQdkeW5hbWljBQ90RHluYW1pY0xlYWRlcnMJAQ1wYXJzZUludFZhbHVlAQkAkQMCBQdkeW5hbWljBRF0RHluYW1pY1dpblJlc3VsdAkBDXBhcnNlSW50VmFsdWUBCQCRAwIFB2R5bmFtaWMFFXREeW5hbWljVG90YWxSZWdDb3VudAkBDXBhcnNlSW50VmFsdWUBCQCRAwIFB2R5bmFtaWMFFXREeW5hbWljVG90YWxBdHRlbXB0cwkAlAoCCQDMCAIJAQtTdHJpbmdFbnRyeQIJARZrZXlUb3VyRHluYW1pY0RhdGFCeUlkAQUDdElkBRJ1cGRhdGVkRHluYW1pY0RhdGEFA25pbAAAAAVVQds=", "height": 2743319, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CcWe6nSyg5XsK2swkVP3k79v1Bcz5gZcbb9cm25Kq1xP Next: 8ZEdvgUApGJyayBBLykckYVwvowotejjpMVn5GnxwmwK Diff:
OldNewDifferences
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let DEFAULTLOCATION = "Africa_F_Africa"
5+
6+let locIdxContinent = 0
7+
8+let locIdxType = 1
59
610 func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr)
711
2327 func keySumScoresByTour (tId) = ("%s%d__sumScores__" + toString(tId))
2428
2529
26-func keyWinnersByTour (tId) = ("%s%d__winners__" + toString(tId))
27-
28-
2930 func keyLastRegisteredTourByDuck (duckAssetId) = ("%s%s__lastRegisteredTourByDuck__" + duckAssetId)
3031
3132
4243
4344 let idxDynamic = 1
4445
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-
5246 let tStaticRegisterCost = 2
5347
5448 let tStaticAttemptCost = 3
5953
6054 let tDynamicStatus = 1
6155
62-let tDynamicWinDuck = 2
56+let tDynamicLeaders = 2
6357
6458 let tDynamicWinResult = 3
6559
6761
6862 let tDynamicTotalAttempts = 5
6963
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+ }
7169
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+
7387
7488 let chain = take(drop(this.bytes, 1), 1)
7589
162176 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)
163177
164178
165-func dynamicData (status,winDuck,winResult,totalRegs,totalAttempts) = makeString(["%s%s%d%d%d", status, winDuck, toString(winResult), toString(totalRegs), toString(totalAttempts)], SEP)
179+func dynamicData (status,leaders,winResult,totalRegs,totalAttempts) = makeString_2C(["%s%s%d%d%d", status, leaders, toString(winResult), toString(totalRegs), toString(totalAttempts)], SEP)
166180
167181
168182 func prolog () = asInt(invoke(stakingContract, "saveLastTx", nil, nil))
247261 else contains(oldScoreBoard, duckAssetId))
248262 then throw(((("Your duck " + duckAssetId) + " is already registered at tournament ") + toString(lastId)))
249263 else {
250- let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), (parseIntValue(dynamic[tDynamicTotalRegCount]) + 1), parseIntValue(dynamic[tDynamicTotalAttempts]))
264+ let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), (parseIntValue(dynamic[tDynamicTotalRegCount]) + 1), parseIntValue(dynamic[tDynamicTotalAttempts]))
251265 $Tuple2([IntegerEntry(keyLastRegisteredTourByDuck(duckAssetId), lastId), BooleanEntry(keyIsRegisteredByTourAndDuck(lastId, duckAssetId), true), StringEntry(keyScoreBoardByTour(lastId), if ((oldScoreBoard == ""))
252266 then (duckAssetId + ":000")
253267 else (((oldScoreBoard + "_") + duckAssetId) + ":000")), StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], prologResult)
279293 else {
280294 let attemptsIteratorKey = keyLastAttemptByTourAndDuck(lastId, duckAssetId)
281295 let lastAttempt = getInteger(attemptsIteratorKey)
282- let $t060886720 = if (!(isDefined(lastAttempt)))
296+ let $t061046736 = if (!(isDefined(lastAttempt)))
283297 then $Tuple2(0, 0)
284298 else if ((size(i.payments) != 1))
285299 then throw("exactly 1 payment must be attached")
296310 else $Tuple2((value(lastAttempt) + 1), 1)
297311 }
298312 }
299- let payedAttempts = $t060886720._1
300- let increment = $t060886720._2
301- let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), (parseIntValue(dynamic[tDynamicTotalAttempts]) + increment))
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))
302316 let tourLoc = asString(invoke(stakingContract, "initDuckTourAttempt", [duckAssetId], nil))
303317 $Tuple2([IntegerEntry(attemptsIteratorKey, payedAttempts), StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], [prologResult, payedAttempts, tourLoc])
304318 }
305319 }
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- }
339320
340321
341322
347328 let tData = getTourData(this, lastId)
348329 let static = tData[idxStatic]
349330 let dynamic = tData[idxDynamic]
350- let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_")
331+ let curLocation = valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION)
351332 let bestResultKey = keyBestResultByTourAndDuck(lastId, duckAssetId)
352333 let sumScoresKey = keySumScoresByTour(lastId)
353334 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))
361336 then {
362337 let duckOldBest = valueOrElse(getInteger(bestResultKey), 0)
363338 let scoreKey = keyScoreBoardByTour(lastId)
364339 let oldScoreBoard = valueOrElse(getString(scoreKey), "")
365- let $t0969710096 = if ((duckNewBest > duckOldBest))
340+ let $t0959210753 = if ((duckNewBest > duckOldBest))
366341 then if (!(contains(oldScoreBoard, duckAssetId)))
367342 then throw(("scoreBoard does not contain " + duckAssetId))
368343 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]))
369359 let parts = split_51C(oldScoreBoard, duckAssetId)
370- $Tuple2(((((parts[0] + duckAssetId) + ":") + padL(duckNewBest, 3)) + drop(parts[1], 4)), ((oldSumScores + duckNewBest) - duckOldBest))
360+ $Tuple3(((((parts[0] + duckAssetId) + ":") + padL(duckNewBest, 3)) + drop(parts[1], 4)), ((oldSumScores + duckNewBest) - duckOldBest), [StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)])
371361 }
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)
376367 }
377368 else $Tuple2(nil, 0)
378369 }
397388 else false)
398389 then throw((("Tournament " + toString(tId)) + " is not over yet"))
399390 else {
400- let updatedDynamicData = dynamicData("PROCESSING", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
391+ let updatedDynamicData = dynamicData("PROCESSING", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
401392 $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0)
402393 }
403394 }
417408 if ((status == "ARCHIVED"))
418409 then throw((("Tournament " + toString(tId)) + " is already ARCHIVED"))
419410 else {
420- let updatedDynamicData = dynamicData("ARCHIVED", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
411+ let updatedDynamicData = dynamicData("ARCHIVED", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
421412 $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0)
422413 }
423414 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let DEFAULTLOCATION = "Africa_F_Africa"
5+
6+let locIdxContinent = 0
7+
8+let locIdxType = 1
59
610 func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr)
711
812
913 func keyDuckLocation (duckAssetId) = ("duckLocation_" + duckAssetId)
1014
1115
1216 let lastTourIdKey = "%s__lastTourId"
1317
1418 func keyTourStaticDataById (tId) = ("%s%d__tourStaticData__" + toString(tId))
1519
1620
1721 func keyTourDynamicDataById (tId) = ("%s%d__tourDynamicData__" + toString(tId))
1822
1923
2024 func keyScoreBoardByTour (tId) = ("%s%d__scoreBoard__" + toString(tId))
2125
2226
2327 func keySumScoresByTour (tId) = ("%s%d__sumScores__" + toString(tId))
2428
2529
26-func keyWinnersByTour (tId) = ("%s%d__winners__" + toString(tId))
27-
28-
2930 func keyLastRegisteredTourByDuck (duckAssetId) = ("%s%s__lastRegisteredTourByDuck__" + duckAssetId)
3031
3132
3233 func keyIsRegisteredByTourAndDuck (tId,duckAssetId) = makeString(["%s%d%s__isRegisteredByTourAndDuck", toString(tId), duckAssetId], "__")
3334
3435
3536 func keyLastAttemptByTourAndDuck (tId,duckAssetId) = makeString(["%s%d%s__lastAttemptByTourAndDuck", toString(tId), duckAssetId], "__")
3637
3738
3839 func keyBestResultByTourAndDuck (tId,duckAssetId) = makeString(["%s%d%s__bestResultByTourAndDuck", toString(tId), duckAssetId], "__")
3940
4041
4142 let idxStatic = 0
4243
4344 let idxDynamic = 1
4445
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-
5246 let tStaticRegisterCost = 2
5347
5448 let tStaticAttemptCost = 3
5549
5650 let tStaticStart = 5
5751
5852 let tStaticEnd = 6
5953
6054 let tDynamicStatus = 1
6155
62-let tDynamicWinDuck = 2
56+let tDynamicLeaders = 2
6357
6458 let tDynamicWinResult = 3
6559
6660 let tDynamicTotalRegCount = 4
6761
6862 let tDynamicTotalAttempts = 5
6963
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+ }
7169
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+
7387
7488 let chain = take(drop(this.bytes, 1), 1)
7589
7690 let defaultRestAddressStr = match chain {
7791 case _ =>
7892 if ((base58'2W' == $match0))
7993 then "3PQCuvFbvh4LkPUnrnU1z3jnbA1p9m3WNhv"
8094 else if ((base58'2T' == $match0))
8195 then "3MumkGGztCKAXpWDqxkddofqXSUbqQkvSJy"
8296 else throw("Unknown chain")
8397 }
8498
8599 let SEP = "__"
86100
87101 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
88102
89103
90104 let IdxCfgStakingDapp = 1
91105
92106 let IdxCfgWlgDapp = 4
93107
94108 func keyRestCfg () = "%s__restConfig"
95109
96110
97111 func keyRestAddress () = "%s__restAddr"
98112
99113
100114 func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP)
101115
102116
103117 func getContractAddressOrFail (restCfg,idx) = valueOrErrorMessage(addressFromString(restCfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx)))
104118
105119
106120 let restContract = addressFromStringValue(valueOrElse(getString(this, keyRestAddress()), defaultRestAddressStr))
107121
108122 let restCfg = readRestCfgOrFail(restContract)
109123
110124 let stakingContract = getContractAddressOrFail(restCfg, IdxCfgStakingDapp)
111125
112126 let wlgContract = getContractAddressOrFail(restCfg, IdxCfgWlgDapp)
113127
114128 let wlgAssetIdKey = "wlg_assetId"
115129
116130 let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "Not initialized yet")
117131
118132 func asString (v) = match v {
119133 case s: String =>
120134 s
121135 case _ =>
122136 throw("fail to cast into String")
123137 }
124138
125139
126140 func asInt (v) = match v {
127141 case n: Int =>
128142 n
129143 case _ =>
130144 throw("fail to cast into Int")
131145 }
132146
133147
134148 func fixedPoint (val,decimals) = {
135149 let tenPow = pow(10, 0, decimals, 0, 0, DOWN)
136150 let lowPart = toString((val % tenPow))
137151 let zeroes = drop(toString(tenPow), (1 + size(lowPart)))
138152 (((toString((val / tenPow)) + ".") + zeroes) + lowPart)
139153 }
140154
141155
142156 func padL (val,len) = {
143157 let valS = toString(val)
144158 let zeroes = drop(toString(pow(10, 0, (len - size(valS)), 0, 0, DOWN)), 1)
145159 (zeroes + valS)
146160 }
147161
148162
149163 let MAXTOURNAMENTLENGTH = 432000000
150164
151165 let HOUR = 3600000
152166
153167 let adminsList = [toString(this), match chain {
154168 case _ =>
155169 if ((base58'2W' == $match0))
156170 then "3PEe2RELUHCFCBsmSCNcBJ8N3URLVQende7"
157171 else if ((base58'2T' == $match0))
158172 then "3MtBgJTaLxPB3C7UJD1UE8qjkHthfKvFQYY"
159173 else throw("Unknown chain")
160174 }]
161175
162176 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)
163177
164178
165-func dynamicData (status,winDuck,winResult,totalRegs,totalAttempts) = makeString(["%s%s%d%d%d", status, winDuck, toString(winResult), toString(totalRegs), toString(totalAttempts)], SEP)
179+func dynamicData (status,leaders,winResult,totalRegs,totalAttempts) = makeString_2C(["%s%s%d%d%d", status, leaders, toString(winResult), toString(totalRegs), toString(totalAttempts)], SEP)
166180
167181
168182 func prolog () = asInt(invoke(stakingContract, "saveLastTx", nil, nil))
169183
170184
171185 func duckByCaller (caller) = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(caller))), "You don't have a duck staked")
172186
173187
174188 @Callable(i)
175189 func createTournament (startTime,endTime,registerCost,attemptCost,numGrands) = {
176190 let caller = toString(i.caller)
177191 if (!(containsElement(adminsList, caller)))
178192 then throw("Permission denied")
179193 else {
180194 let lastId = getInteger(lastTourIdKey)
181195 let tId = if (isDefined(lastId))
182196 then {
183197 let lastTourId = value(lastId)
184198 let dynamic = valueOrErrorMessage(getString(keyTourDynamicDataById(lastTourId)), (("Error reading tournament " + toString(lastTourId)) + " data"))
185199 let status = split(dynamic, SEP)[tDynamicStatus]
186200 if ((status != "ARCHIVED"))
187201 then throw(("Current tournement is not completed, status=" + status))
188202 else (lastTourId + 1)
189203 }
190204 else 1
191205 let now = lastBlock.timestamp
192206 if ((now > startTime))
193207 then throw(((("startTime=" + toString(startTime)) + " < creationTime=") + toString(now)))
194208 else if ((startTime > endTime))
195209 then throw(((("endTime=" + toString(endTime)) + " < startTime=") + toString(startTime)))
196210 else if (((endTime - startTime) > MAXTOURNAMENTLENGTH))
197211 then throw(((("Tournament period exceeds max: " + toString((endTime - startTime))) + " > ") + toString(MAXTOURNAMENTLENGTH)))
198212 else if (if ((0 >= registerCost))
199213 then true
200214 else (0 >= attemptCost))
201215 then throw(((("Cost should be positive, but passed " + toString(registerCost)) + " and ") + toString(attemptCost)))
202216 else if ((0 > numGrands))
203217 then throw("Number of Grand Prizes should be non-negative")
204218 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)
205219 }
206220 }
207221
208222
209223
210224 @Callable(i)
211225 func register () = {
212226 let prologResult = prolog()
213227 if ((size(i.payments) != 1))
214228 then throw("exactly 1 payment must be attached")
215229 else {
216230 let pmt = i.payments[0]
217231 let wlgAmt = pmt.amount
218232 let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WLGOLD payments only!")
219233 if ((pmtAssetId != wlgAssetId))
220234 then throw("WLGOLD payments only!")
221235 else {
222236 let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments")
223237 let now = lastBlock.timestamp
224238 let tData = getTourData(this, lastId)
225239 let static = tData[idxStatic]
226240 let dynamic = tData[idxDynamic]
227241 let status = dynamic[tDynamicStatus]
228242 if (!(if (if (if ((status == "CREATED"))
229243 then (now > parseIntValue(static[tStaticStart]))
230244 else false)
231245 then ((parseIntValue(static[tStaticEnd]) - HOUR) > now)
232246 else false)
233247 then true
234248 else if ((status == "INPROGRESS"))
235249 then ((parseIntValue(static[tStaticEnd]) - HOUR) > now)
236250 else false))
237251 then throw("Cannot register now")
238252 else {
239253 let regCost = parseIntValue(static[tStaticRegisterCost])
240254 if ((wlgAmt != regCost))
241255 then throw((("Need payment of " + fixedPoint(regCost, 8)) + " WLGOLD"))
242256 else {
243257 let duckAssetId = duckByCaller(i.originCaller)
244258 let oldScoreBoard = valueOrElse(getString(keyScoreBoardByTour(lastId)), "")
245259 if (if (valueOrElse(getBoolean(keyIsRegisteredByTourAndDuck(lastId, duckAssetId)), false))
246260 then true
247261 else contains(oldScoreBoard, duckAssetId))
248262 then throw(((("Your duck " + duckAssetId) + " is already registered at tournament ") + toString(lastId)))
249263 else {
250- let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), (parseIntValue(dynamic[tDynamicTotalRegCount]) + 1), parseIntValue(dynamic[tDynamicTotalAttempts]))
264+ let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), (parseIntValue(dynamic[tDynamicTotalRegCount]) + 1), parseIntValue(dynamic[tDynamicTotalAttempts]))
251265 $Tuple2([IntegerEntry(keyLastRegisteredTourByDuck(duckAssetId), lastId), BooleanEntry(keyIsRegisteredByTourAndDuck(lastId, duckAssetId), true), StringEntry(keyScoreBoardByTour(lastId), if ((oldScoreBoard == ""))
252266 then (duckAssetId + ":000")
253267 else (((oldScoreBoard + "_") + duckAssetId) + ":000")), StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], prologResult)
254268 }
255269 }
256270 }
257271 }
258272 }
259273 }
260274
261275
262276
263277 @Callable(i)
264278 func newAttempt () = {
265279 let prologResult = prolog()
266280 let duckAssetId = duckByCaller(i.originCaller)
267281 let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments")
268282 let now = lastBlock.timestamp
269283 let tData = getTourData(this, lastId)
270284 let static = tData[idxStatic]
271285 let dynamic = tData[idxDynamic]
272286 let status = dynamic[tDynamicStatus]
273287 if (!(if ((status == "INPROGRESS"))
274288 then ((parseIntValue(static[tStaticEnd]) - HOUR) > now)
275289 else false))
276290 then throw("Attempt is not possible")
277291 else if (!(valueOrElse(getBoolean(keyIsRegisteredByTourAndDuck(lastId, duckAssetId)), false)))
278292 then throw(((("Your duck " + duckAssetId) + " is not registered at tournament ") + toString(lastId)))
279293 else {
280294 let attemptsIteratorKey = keyLastAttemptByTourAndDuck(lastId, duckAssetId)
281295 let lastAttempt = getInteger(attemptsIteratorKey)
282- let $t060886720 = if (!(isDefined(lastAttempt)))
296+ let $t061046736 = if (!(isDefined(lastAttempt)))
283297 then $Tuple2(0, 0)
284298 else if ((size(i.payments) != 1))
285299 then throw("exactly 1 payment must be attached")
286300 else {
287301 let pmt = i.payments[0]
288302 let wlgAmt = pmt.amount
289303 let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WLGOLD payments only!")
290304 if ((pmtAssetId != wlgAssetId))
291305 then throw("WLGOLD payments only!")
292306 else {
293307 let attCost = parseIntValue(static[tStaticAttemptCost])
294308 if ((wlgAmt != attCost))
295309 then throw((("Need payment of " + fixedPoint(attCost, 8)) + " WLGOLD"))
296310 else $Tuple2((value(lastAttempt) + 1), 1)
297311 }
298312 }
299- let payedAttempts = $t060886720._1
300- let increment = $t060886720._2
301- let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), (parseIntValue(dynamic[tDynamicTotalAttempts]) + increment))
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))
302316 let tourLoc = asString(invoke(stakingContract, "initDuckTourAttempt", [duckAssetId], nil))
303317 $Tuple2([IntegerEntry(attemptsIteratorKey, payedAttempts), StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], [prologResult, payedAttempts, tourLoc])
304318 }
305319 }
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- }
339320
340321
341322
342323 @Callable(i)
343324 func saveDuckResult (duckAssetId,duckNewBest) = if ((i.caller != stakingContract))
344325 then throw("Access denied")
345326 else {
346327 let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments")
347328 let tData = getTourData(this, lastId)
348329 let static = tData[idxStatic]
349330 let dynamic = tData[idxDynamic]
350- let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_")
331+ let curLocation = valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION)
351332 let bestResultKey = keyBestResultByTourAndDuck(lastId, duckAssetId)
352333 let sumScoresKey = keySumScoresByTour(lastId)
353334 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))
361336 then {
362337 let duckOldBest = valueOrElse(getInteger(bestResultKey), 0)
363338 let scoreKey = keyScoreBoardByTour(lastId)
364339 let oldScoreBoard = valueOrElse(getString(scoreKey), "")
365- let $t0969710096 = if ((duckNewBest > duckOldBest))
340+ let $t0959210753 = if ((duckNewBest > duckOldBest))
366341 then if (!(contains(oldScoreBoard, duckAssetId)))
367342 then throw(("scoreBoard does not contain " + duckAssetId))
368343 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]))
369359 let parts = split_51C(oldScoreBoard, duckAssetId)
370- $Tuple2(((((parts[0] + duckAssetId) + ":") + padL(duckNewBest, 3)) + drop(parts[1], 4)), ((oldSumScores + duckNewBest) - duckOldBest))
360+ $Tuple3(((((parts[0] + duckAssetId) + ":") + padL(duckNewBest, 3)) + drop(parts[1], 4)), ((oldSumScores + duckNewBest) - duckOldBest), [StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)])
371361 }
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)
376367 }
377368 else $Tuple2(nil, 0)
378369 }
379370
380371
381372
382373 @Callable(i)
383374 func processTournament (tId) = {
384375 let caller = toString(i.caller)
385376 if (!(containsElement(adminsList, caller)))
386377 then throw("Permission denied")
387378 else {
388379 let now = lastBlock.timestamp
389380 let tData = getTourData(this, tId)
390381 let static = tData[idxStatic]
391382 let dynamic = tData[idxDynamic]
392383 let status = dynamic[tDynamicStatus]
393384 if ((status == "ARCHIVED"))
394385 then throw((("Tournament " + toString(tId)) + " is already ARCHIVED"))
395386 else if (if ((status == "INPROGRESS"))
396387 then (parseIntValue(static[tStaticEnd]) > now)
397388 else false)
398389 then throw((("Tournament " + toString(tId)) + " is not over yet"))
399390 else {
400- let updatedDynamicData = dynamicData("PROCESSING", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
391+ let updatedDynamicData = dynamicData("PROCESSING", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
401392 $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0)
402393 }
403394 }
404395 }
405396
406397
407398
408399 @Callable(i)
409400 func finishTournament (tId) = {
410401 let caller = toString(i.caller)
411402 if (!(containsElement(adminsList, caller)))
412403 then throw("Permission denied")
413404 else {
414405 let tData = getTourData(this, tId)
415406 let dynamic = tData[idxDynamic]
416407 let status = dynamic[tDynamicStatus]
417408 if ((status == "ARCHIVED"))
418409 then throw((("Tournament " + toString(tId)) + " is already ARCHIVED"))
419410 else {
420- let updatedDynamicData = dynamicData("ARCHIVED", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
411+ let updatedDynamicData = dynamicData("ARCHIVED", dynamic[tDynamicLeaders], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
421412 $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0)
422413 }
423414 }
424415 }
425416
426417

github/deemru/w8io/169f3d6 
71.39 ms