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