tx · 9iiwT1LASVMPfQGFTWbMTRfNsirwT1jUcnHy6CQqRRkw

3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx:  -0.01300000 Waves

2023.09.05 23:13 [2742544] smart account 3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx > SELF 0.00000000 Waves

{ "type": 13, "id": "9iiwT1LASVMPfQGFTWbMTRfNsirwT1jUcnHy6CQqRRkw", "fee": 1300000, "feeAssetId": null, "timestamp": 1693944793733, "version": 2, "chainId": 84, "sender": "3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx", "senderPublicKey": "UGqkWsCpv7xRVXkQRXyLd6pWPDtYGXmPip7FxSd1pAu", "proofs": [ "qWMcmHiZxUXz2S2Gnz6zKt4EdiRsmzpBNc6svZvVypacxd8paKT8rxPdX2Za2n1n3PEEifxSdQKZTbmnr4cAVkZ" ], "script": "base64:BgIlCAISBwoFAQEBAQESABIAEgQKAggBEgQKAggBEgMKAQESAwoBATUAD0RFRkFVTFRMT0NBVElPTgIPQWZyaWNhX0ZfQWZyaWNhARRrZXlTdGFrZWREdWNrQnlPd25lcgEJb3duZXJBZGRyCQCsAgICEnN0YWtlZER1Y2tCeU93bmVyXwUJb3duZXJBZGRyAQ9rZXlEdWNrTG9jYXRpb24BC2R1Y2tBc3NldElkCQCsAgICDWR1Y2tMb2NhdGlvbl8FC2R1Y2tBc3NldElkAA1sYXN0VG91cklkS2V5Ag4lc19fbGFzdFRvdXJJZAEVa2V5VG91clN0YXRpY0RhdGFCeUlkAQN0SWQJAKwCAgIWJXMlZF9fdG91clN0YXRpY0RhdGFfXwkApAMBBQN0SWQBFmtleVRvdXJEeW5hbWljRGF0YUJ5SWQBA3RJZAkArAICAhclcyVkX190b3VyRHluYW1pY0RhdGFfXwkApAMBBQN0SWQBE2tleVNjb3JlQm9hcmRCeVRvdXIBA3RJZAkArAICAhIlcyVkX19zY29yZUJvYXJkX18JAKQDAQUDdElkARJrZXlTdW1TY29yZXNCeVRvd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HluYW1pY1N0YXR1cwMJAAACBQZzdGF0dXMCCEFSQ0hJVkVECQACAQkArAICCQCsAgICC1RvdXJuYW1lbnQgCQCkAwEFA3RJZAIUIGlzIGFscmVhZHkgQVJDSElWRUQEEnVwZGF0ZWREeW5hbWljRGF0YQkBC2R5bmFtaWNEYXRhBQIIQVJDSElWRUQJAJEDAgUHZHluYW1pYwUPdER5bmFtaWNXaW5EdWNrCQENcGFyc2VJbnRWYWx1ZQEJAJEDAgUHZHluYW1pYwURdER5bmFtaWNXaW5SZXN1bHQJAQ1wYXJzZUludFZhbHVlAQkAkQMCBQdkeW5hbWljBRV0RHluYW1pY1RvdGFsUmVnQ291bnQJAQ1wYXJzZUludFZhbHVlAQkAkQMCBQdkeW5hbWljBRV0RHluYW1pY1RvdGFsQXR0ZW1wdHMJAJQKAgkAzAgCCQELU3RyaW5nRW50cnkCCQEWa2V5VG91ckR5bmFtaWNEYXRhQnlJZAEFA3RJZAUSdXBkYXRlZER5bmFtaWNEYXRhBQNuaWwAAAAEE5eH", "height": 2742544, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3aoN9AuXMwdLHaBekAL7buTEmtTJQuxrgBgzypWPaab7 Next: CcWe6nSyg5XsK2swkVP3k79v1Bcz5gZcbb9cm25Kq1xP Diff:
OldNewDifferences
1818
1919
2020 func keyScoreBoardByTour (tId) = ("%s%d__scoreBoard__" + toString(tId))
21+
22+
23+func keySumScoresByTour (tId) = ("%s%d__sumScores__" + toString(tId))
2124
2225
2326 func keyLastRegisteredTourByDuck (duckAssetId) = ("%s%s__lastRegisteredTourByDuck__" + duckAssetId)
323326
324327
325328 @Callable(i)
326-func saveDuckResult (duckAssetId,newBest) = if ((i.caller != stakingContract))
329+func saveDuckResult (duckAssetId,duckNewBest) = if ((i.caller != stakingContract))
327330 then throw("Access denied")
328331 else {
329332 let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments")
332335 let dynamic = tData[idxDynamic]
333336 let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_")
334337 let bestResultKey = keyBestResultByTourAndDuck(lastId, duckAssetId)
338+ let sumScoresKey = keySumScoresByTour(lastId)
339+ let oldSumScores = valueOrElse(getInteger(sumScoresKey), 0)
335340 if (if (if (if ((curLocation[locIdxType] == "T"))
336341 then (parseIntValue(curLocation[locIdxContinent]) == lastId)
337342 else false)
340345 then (parseIntValue(static[tStaticEnd]) >= lastBlock.timestamp)
341346 else false)
342347 then {
343- let oldBestResult = valueOrElse(getInteger(bestResultKey), 0)
348+ let duckOldBest = valueOrElse(getInteger(bestResultKey), 0)
344349 let scoreKey = keyScoreBoardByTour(lastId)
345350 let oldScoreBoard = valueOrElse(getString(scoreKey), "")
346- let updated = if ((newBest > oldBestResult))
351+ let $t092539652 = if ((duckNewBest > duckOldBest))
347352 then if (!(contains(oldScoreBoard, duckAssetId)))
348353 then throw(("scoreBoard does not contain " + duckAssetId))
349354 else {
350355 let parts = split_51C(oldScoreBoard, duckAssetId)
351- ((((parts[0] + duckAssetId) + ":") + padL(newBest, 3)) + drop(parts[1], 4))
356+ $Tuple2(((((parts[0] + duckAssetId) + ":") + padL(duckNewBest, 3)) + drop(parts[1], 4)), ((oldSumScores + duckNewBest) - duckOldBest))
352357 }
353- else oldScoreBoard
354- $Tuple2([IntegerEntry(bestResultKey, max([oldBestResult, newBest])), StringEntry(scoreKey, updated)], 0)
358+ else $Tuple2(oldScoreBoard, oldSumScores)
359+ let newScoreBoard = $t092539652._1
360+ let newSumScores = $t092539652._2
361+ $Tuple2([IntegerEntry(bestResultKey, max([duckOldBest, duckNewBest])), IntegerEntry(sumScoresKey, newSumScores), StringEntry(scoreKey, newScoreBoard)], 0)
355362 }
356363 else $Tuple2(nil, 0)
357364 }
365+
366+
367+
368+@Callable(i)
369+func processTournament (tId) = {
370+ let caller = toString(i.caller)
371+ if (!(containsElement(adminsList, caller)))
372+ then throw("Permission denied")
373+ else {
374+ let now = lastBlock.timestamp
375+ let tData = getTourData(this, tId)
376+ let static = tData[idxStatic]
377+ let dynamic = tData[idxDynamic]
378+ let status = dynamic[tDynamicStatus]
379+ if ((status == "ARCHIVED"))
380+ then throw((("Tournament " + toString(tId)) + " is already ARCHIVED"))
381+ else if (if ((status == "INPROGRESS"))
382+ then (parseIntValue(static[tStaticEnd]) > now)
383+ else false)
384+ then throw((("Tournament " + toString(tId)) + " is not over yet"))
385+ else {
386+ let updatedDynamicData = dynamicData("PROCESSING", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
387+ $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0)
388+ }
389+ }
390+ }
358391
359392
360393
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let DEFAULTLOCATION = "Africa_F_Africa"
55
66 func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr)
77
88
99 func keyDuckLocation (duckAssetId) = ("duckLocation_" + duckAssetId)
1010
1111
1212 let lastTourIdKey = "%s__lastTourId"
1313
1414 func keyTourStaticDataById (tId) = ("%s%d__tourStaticData__" + toString(tId))
1515
1616
1717 func keyTourDynamicDataById (tId) = ("%s%d__tourDynamicData__" + toString(tId))
1818
1919
2020 func keyScoreBoardByTour (tId) = ("%s%d__scoreBoard__" + toString(tId))
21+
22+
23+func keySumScoresByTour (tId) = ("%s%d__sumScores__" + toString(tId))
2124
2225
2326 func keyLastRegisteredTourByDuck (duckAssetId) = ("%s%s__lastRegisteredTourByDuck__" + duckAssetId)
2427
2528
2629 func keyIsRegisteredByTourAndDuck (tId,duckAssetId) = makeString(["%s%d%s__isRegisteredByTourAndDuck", toString(tId), duckAssetId], "__")
2730
2831
2932 func keyLastAttemptByTourAndDuck (tId,duckAssetId) = makeString(["%s%d%s__lastAttemptByTourAndDuck", toString(tId), duckAssetId], "__")
3033
3134
3235 func keyBestResultByTourAndDuck (tId,duckAssetId) = makeString(["%s%d%s__bestResultByTourAndDuck", toString(tId), duckAssetId], "__")
3336
3437
3538 let idxStatic = 0
3639
3740 let idxDynamic = 1
3841
3942 func getTourData (tourContract,tId) = {
4043 let static = split(valueOrErrorMessage(getString(tourContract, keyTourStaticDataById(tId)), (("Error reading tournament " + toString(tId)) + " data")), "__")
4144 let dynamic = split(valueOrErrorMessage(getString(tourContract, keyTourDynamicDataById(tId)), (("Error reading tournament " + toString(tId)) + " data")), "__")
4245 [static, dynamic]
4346 }
4447
4548
4649 let tStaticRegisterCost = 2
4750
4851 let tStaticAttemptCost = 3
4952
5053 let tStaticStart = 5
5154
5255 let tStaticEnd = 6
5356
5457 let tDynamicStatus = 1
5558
5659 let tDynamicWinDuck = 2
5760
5861 let tDynamicWinResult = 3
5962
6063 let tDynamicTotalRegCount = 4
6164
6265 let tDynamicTotalAttempts = 5
6366
6467 let locIdxContinent = 0
6568
6669 let locIdxType = 1
6770
6871 let chain = take(drop(this.bytes, 1), 1)
6972
7073 let defaultRestAddressStr = match chain {
7174 case _ =>
7275 if ((base58'2W' == $match0))
7376 then "3PQCuvFbvh4LkPUnrnU1z3jnbA1p9m3WNhv"
7477 else if ((base58'2T' == $match0))
7578 then "3MumkGGztCKAXpWDqxkddofqXSUbqQkvSJy"
7679 else throw("Unknown chain")
7780 }
7881
7982 let SEP = "__"
8083
8184 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
8285
8386
8487 let IdxCfgStakingDapp = 1
8588
8689 let IdxCfgWlgDapp = 4
8790
8891 func keyRestCfg () = "%s__restConfig"
8992
9093
9194 func keyRestAddress () = "%s__restAddr"
9295
9396
9497 func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP)
9598
9699
97100 func getContractAddressOrFail (restCfg,idx) = valueOrErrorMessage(addressFromString(restCfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx)))
98101
99102
100103 let restContract = addressFromStringValue(valueOrElse(getString(this, keyRestAddress()), defaultRestAddressStr))
101104
102105 let restCfg = readRestCfgOrFail(restContract)
103106
104107 let stakingContract = getContractAddressOrFail(restCfg, IdxCfgStakingDapp)
105108
106109 let wlgContract = getContractAddressOrFail(restCfg, IdxCfgWlgDapp)
107110
108111 let wlgAssetIdKey = "wlg_assetId"
109112
110113 let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "Not initialized yet")
111114
112115 func asString (v) = match v {
113116 case s: String =>
114117 s
115118 case _ =>
116119 throw("fail to cast into String")
117120 }
118121
119122
120123 func asInt (v) = match v {
121124 case n: Int =>
122125 n
123126 case _ =>
124127 throw("fail to cast into Int")
125128 }
126129
127130
128131 func fixedPoint (val,decimals) = {
129132 let tenPow = pow(10, 0, decimals, 0, 0, DOWN)
130133 let lowPart = toString((val % tenPow))
131134 let zeroes = drop(toString(tenPow), (1 + size(lowPart)))
132135 (((toString((val / tenPow)) + ".") + zeroes) + lowPart)
133136 }
134137
135138
136139 func padL (val,len) = {
137140 let valS = toString(val)
138141 let zeroes = drop(toString(pow(10, 0, (len - size(valS)), 0, 0, DOWN)), 1)
139142 (zeroes + valS)
140143 }
141144
142145
143146 let MAXTOURNAMENTLENGTH = 432000000
144147
145148 let HOUR = 3600000
146149
147150 let adminsList = [toString(this), match chain {
148151 case _ =>
149152 if ((base58'2W' == $match0))
150153 then "3PEe2RELUHCFCBsmSCNcBJ8N3URLVQende7"
151154 else if ((base58'2T' == $match0))
152155 then "3MtBgJTaLxPB3C7UJD1UE8qjkHthfKvFQYY"
153156 else throw("Unknown chain")
154157 }]
155158
156159 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)
157160
158161
159162 func dynamicData (status,winDuck,winResult,totalRegs,totalAttempts) = makeString(["%s%s%d%d%d", status, winDuck, toString(winResult), toString(totalRegs), toString(totalAttempts)], SEP)
160163
161164
162165 func prolog () = asInt(invoke(stakingContract, "saveLastTx", nil, nil))
163166
164167
165168 func duckByCaller (caller) = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(caller))), "You don't have a duck staked")
166169
167170
168171 @Callable(i)
169172 func createTournament (startTime,endTime,registerCost,attemptCost,numGrands) = {
170173 let caller = toString(i.caller)
171174 if (!(containsElement(adminsList, caller)))
172175 then throw("Permission denied")
173176 else {
174177 let lastId = getInteger(lastTourIdKey)
175178 let tId = if (isDefined(lastId))
176179 then {
177180 let lastTourId = value(lastId)
178181 let dynamic = valueOrErrorMessage(getString(keyTourDynamicDataById(lastTourId)), (("Error reading tournament " + toString(lastTourId)) + " data"))
179182 let status = split(dynamic, SEP)[tDynamicStatus]
180183 if ((status != "ARCHIVED"))
181184 then throw(("Current tournement is not completed, status=" + status))
182185 else (lastTourId + 1)
183186 }
184187 else 1
185188 let now = lastBlock.timestamp
186189 if ((now > startTime))
187190 then throw(((("startTime=" + toString(startTime)) + " < creationTime=") + toString(now)))
188191 else if ((startTime > endTime))
189192 then throw(((("endTime=" + toString(endTime)) + " < startTime=") + toString(startTime)))
190193 else if (((endTime - startTime) > MAXTOURNAMENTLENGTH))
191194 then throw(((("Tournament period exceeds max: " + toString((endTime - startTime))) + " > ") + toString(MAXTOURNAMENTLENGTH)))
192195 else if (if ((0 >= registerCost))
193196 then true
194197 else (0 >= attemptCost))
195198 then throw(((("Cost should be positive, but passed " + toString(registerCost)) + " and ") + toString(attemptCost)))
196199 else if ((0 > numGrands))
197200 then throw("Number of Grand Prizes should be non-negative")
198201 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)
199202 }
200203 }
201204
202205
203206
204207 @Callable(i)
205208 func register () = {
206209 let prologResult = prolog()
207210 if ((size(i.payments) != 1))
208211 then throw("exactly 1 payment must be attached")
209212 else {
210213 let pmt = i.payments[0]
211214 let wlgAmt = pmt.amount
212215 let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WLGOLD payments only!")
213216 if ((pmtAssetId != wlgAssetId))
214217 then throw("WLGOLD payments only!")
215218 else {
216219 let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments")
217220 let now = lastBlock.timestamp
218221 let tData = getTourData(this, lastId)
219222 let static = tData[idxStatic]
220223 let dynamic = tData[idxDynamic]
221224 let status = dynamic[tDynamicStatus]
222225 if (!(if (if (if ((status == "CREATED"))
223226 then (now > parseIntValue(static[tStaticStart]))
224227 else false)
225228 then ((parseIntValue(static[tStaticEnd]) - HOUR) > now)
226229 else false)
227230 then true
228231 else if ((status == "INPROGRESS"))
229232 then ((parseIntValue(static[tStaticEnd]) - HOUR) > now)
230233 else false))
231234 then throw("Cannot register now")
232235 else {
233236 let regCost = parseIntValue(static[tStaticRegisterCost])
234237 if ((wlgAmt != regCost))
235238 then throw((("Need payment of " + fixedPoint(regCost, 8)) + " WLGOLD"))
236239 else {
237240 let duckAssetId = duckByCaller(i.originCaller)
238241 let oldScoreBoard = valueOrElse(getString(keyScoreBoardByTour(lastId)), "")
239242 if (if (valueOrElse(getBoolean(keyIsRegisteredByTourAndDuck(lastId, duckAssetId)), false))
240243 then true
241244 else contains(oldScoreBoard, duckAssetId))
242245 then throw(((("Your duck " + duckAssetId) + " is already registered at tournament ") + toString(lastId)))
243246 else {
244247 let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), (parseIntValue(dynamic[tDynamicTotalRegCount]) + 1), parseIntValue(dynamic[tDynamicTotalAttempts]))
245248 $Tuple2([IntegerEntry(keyLastRegisteredTourByDuck(duckAssetId), lastId), BooleanEntry(keyIsRegisteredByTourAndDuck(lastId, duckAssetId), true), StringEntry(keyScoreBoardByTour(lastId), if ((oldScoreBoard == ""))
246249 then (duckAssetId + ":000")
247250 else (((oldScoreBoard + "_") + duckAssetId) + ":000")), StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], prologResult)
248251 }
249252 }
250253 }
251254 }
252255 }
253256 }
254257
255258
256259
257260 @Callable(i)
258261 func newAttempt () = {
259262 let prologResult = prolog()
260263 let duckAssetId = duckByCaller(i.originCaller)
261264 let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments")
262265 let now = lastBlock.timestamp
263266 let tData = getTourData(this, lastId)
264267 let static = tData[idxStatic]
265268 let dynamic = tData[idxDynamic]
266269 let status = dynamic[tDynamicStatus]
267270 if (!(if ((status == "INPROGRESS"))
268271 then ((parseIntValue(static[tStaticEnd]) - HOUR) > now)
269272 else false))
270273 then throw("Attempt is not possible")
271274 else if (!(valueOrElse(getBoolean(keyIsRegisteredByTourAndDuck(lastId, duckAssetId)), false)))
272275 then throw(((("Your duck " + duckAssetId) + " is not registered at tournament ") + toString(lastId)))
273276 else {
274277 let attemptsIteratorKey = keyLastAttemptByTourAndDuck(lastId, duckAssetId)
275278 let lastAttempt = getInteger(attemptsIteratorKey)
276279 let $t060886720 = if (!(isDefined(lastAttempt)))
277280 then $Tuple2(0, 0)
278281 else if ((size(i.payments) != 1))
279282 then throw("exactly 1 payment must be attached")
280283 else {
281284 let pmt = i.payments[0]
282285 let wlgAmt = pmt.amount
283286 let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WLGOLD payments only!")
284287 if ((pmtAssetId != wlgAssetId))
285288 then throw("WLGOLD payments only!")
286289 else {
287290 let attCost = parseIntValue(static[tStaticAttemptCost])
288291 if ((wlgAmt != attCost))
289292 then throw((("Need payment of " + fixedPoint(attCost, 8)) + " WLGOLD"))
290293 else $Tuple2((value(lastAttempt) + 1), 1)
291294 }
292295 }
293296 let payedAttempts = $t060886720._1
294297 let increment = $t060886720._2
295298 let updatedDynamicData = dynamicData("INPROGRESS", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), (parseIntValue(dynamic[tDynamicTotalAttempts]) + increment))
296299 let tourLoc = asString(invoke(stakingContract, "initDuckTourAttempt", [duckAssetId], nil))
297300 $Tuple2([IntegerEntry(attemptsIteratorKey, payedAttempts), StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], [prologResult, payedAttempts, tourLoc])
298301 }
299302 }
300303
301304
302305
303306 @Callable(i)
304307 func updateDynamicData (duckAssetId,newBest) = if ((i.caller != stakingContract))
305308 then throw("Access denied")
306309 else {
307310 let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments")
308311 let tData = getTourData(this, lastId)
309312 let static = tData[idxStatic]
310313 let dynamic = tData[idxDynamic]
311314 if (if (if ((parseIntValue(dynamic[tDynamicWinResult]) >= newBest))
312315 then true
313316 else (dynamic[tDynamicStatus] != "INPROGRESS"))
314317 then true
315318 else (lastBlock.timestamp > parseIntValue(static[tStaticEnd])))
316319 then $Tuple2(nil, 0)
317320 else {
318321 let updatedDynamicData = dynamicData("INPROGRESS", duckAssetId, newBest, parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
319322 $Tuple2([StringEntry(keyTourDynamicDataById(lastId), updatedDynamicData)], 0)
320323 }
321324 }
322325
323326
324327
325328 @Callable(i)
326-func saveDuckResult (duckAssetId,newBest) = if ((i.caller != stakingContract))
329+func saveDuckResult (duckAssetId,duckNewBest) = if ((i.caller != stakingContract))
327330 then throw("Access denied")
328331 else {
329332 let lastId = valueOrErrorMessage(getInteger(lastTourIdKey), "No active tournaments")
330333 let tData = getTourData(this, lastId)
331334 let static = tData[idxStatic]
332335 let dynamic = tData[idxDynamic]
333336 let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_")
334337 let bestResultKey = keyBestResultByTourAndDuck(lastId, duckAssetId)
338+ let sumScoresKey = keySumScoresByTour(lastId)
339+ let oldSumScores = valueOrElse(getInteger(sumScoresKey), 0)
335340 if (if (if (if ((curLocation[locIdxType] == "T"))
336341 then (parseIntValue(curLocation[locIdxContinent]) == lastId)
337342 else false)
338343 then (dynamic[tDynamicStatus] == "INPROGRESS")
339344 else false)
340345 then (parseIntValue(static[tStaticEnd]) >= lastBlock.timestamp)
341346 else false)
342347 then {
343- let oldBestResult = valueOrElse(getInteger(bestResultKey), 0)
348+ let duckOldBest = valueOrElse(getInteger(bestResultKey), 0)
344349 let scoreKey = keyScoreBoardByTour(lastId)
345350 let oldScoreBoard = valueOrElse(getString(scoreKey), "")
346- let updated = if ((newBest > oldBestResult))
351+ let $t092539652 = if ((duckNewBest > duckOldBest))
347352 then if (!(contains(oldScoreBoard, duckAssetId)))
348353 then throw(("scoreBoard does not contain " + duckAssetId))
349354 else {
350355 let parts = split_51C(oldScoreBoard, duckAssetId)
351- ((((parts[0] + duckAssetId) + ":") + padL(newBest, 3)) + drop(parts[1], 4))
356+ $Tuple2(((((parts[0] + duckAssetId) + ":") + padL(duckNewBest, 3)) + drop(parts[1], 4)), ((oldSumScores + duckNewBest) - duckOldBest))
352357 }
353- else oldScoreBoard
354- $Tuple2([IntegerEntry(bestResultKey, max([oldBestResult, newBest])), StringEntry(scoreKey, updated)], 0)
358+ else $Tuple2(oldScoreBoard, oldSumScores)
359+ let newScoreBoard = $t092539652._1
360+ let newSumScores = $t092539652._2
361+ $Tuple2([IntegerEntry(bestResultKey, max([duckOldBest, duckNewBest])), IntegerEntry(sumScoresKey, newSumScores), StringEntry(scoreKey, newScoreBoard)], 0)
355362 }
356363 else $Tuple2(nil, 0)
357364 }
365+
366+
367+
368+@Callable(i)
369+func processTournament (tId) = {
370+ let caller = toString(i.caller)
371+ if (!(containsElement(adminsList, caller)))
372+ then throw("Permission denied")
373+ else {
374+ let now = lastBlock.timestamp
375+ let tData = getTourData(this, tId)
376+ let static = tData[idxStatic]
377+ let dynamic = tData[idxDynamic]
378+ let status = dynamic[tDynamicStatus]
379+ if ((status == "ARCHIVED"))
380+ then throw((("Tournament " + toString(tId)) + " is already ARCHIVED"))
381+ else if (if ((status == "INPROGRESS"))
382+ then (parseIntValue(static[tStaticEnd]) > now)
383+ else false)
384+ then throw((("Tournament " + toString(tId)) + " is not over yet"))
385+ else {
386+ let updatedDynamicData = dynamicData("PROCESSING", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
387+ $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0)
388+ }
389+ }
390+ }
358391
359392
360393
361394 @Callable(i)
362395 func finishTournament (tId) = {
363396 let caller = toString(i.caller)
364397 if (!(containsElement(adminsList, caller)))
365398 then throw("Permission denied")
366399 else {
367400 let tData = getTourData(this, tId)
368401 let dynamic = tData[idxDynamic]
369402 let status = dynamic[tDynamicStatus]
370403 if ((status == "ARCHIVED"))
371404 then throw((("Tournament " + toString(tId)) + " is already ARCHIVED"))
372405 else {
373406 let updatedDynamicData = dynamicData("ARCHIVED", dynamic[tDynamicWinDuck], parseIntValue(dynamic[tDynamicWinResult]), parseIntValue(dynamic[tDynamicTotalRegCount]), parseIntValue(dynamic[tDynamicTotalAttempts]))
374407 $Tuple2([StringEntry(keyTourDynamicDataById(tId), updatedDynamicData)], 0)
375408 }
376409 }
377410 }
378411
379412

github/deemru/w8io/169f3d6 
57.10 ms