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