tx · GgxepTxMZteQCP5HtU6VQe9fehEdoMP5sgRr4BjqkuCw 3MyrsoUShtK8LVWE6mGVinCdwiJeedCtkvr: -0.01400000 Waves 2023.12.11 16:42 [2882030] smart account 3MyrsoUShtK8LVWE6mGVinCdwiJeedCtkvr > SELF 0.00000000 Waves
{ "type": 13, "id": "GgxepTxMZteQCP5HtU6VQe9fehEdoMP5sgRr4BjqkuCw", "fee": 1400000, "feeAssetId": null, "timestamp": 1702302187528, "version": 2, "chainId": 84, "sender": "3MyrsoUShtK8LVWE6mGVinCdwiJeedCtkvr", "senderPublicKey": "53WfUfPHKFYj846Npe6Bu5indsxPueAsu9YWe8fnprXh", "proofs": [ "5NJHDtjjtyn8BYGTw4Re3XmJzE6F7sHsz2JEPwEj9VQTmvzzCNMzgTAT9UArxyNvMK5PBZrzZnuva7KkbCqADHtD" ], "script": "base64:BgIaCAISBgoECAgBCBIDCgEEEgMKAQgSBAoCCAJCAANTRVACAl9fAAdXQVZFU0lEAQQTq9kzAAZXQVZFU0QAgMLXLwAJR0FNRV9OQU1FAg9DYXJkIG9mIHRoZSBEYXkADFJBTkRPTV9SQU5HRQkAZAIJAGQCACgABgAFAAhOVU1fQkVUUwABAAhXSU5fQ0FSRAIBMAEMZ2V0U3RyT3JGYWlsAgdhZGRyZXNzA2tleQkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCdCAIFB2FkZHJlc3MFA2tleQkAuQkCCQDMCAICCm1hbmRhdG9yeSAJAMwIAgkApQgBBQdhZGRyZXNzCQDMCAICAS4JAMwIAgUDa2V5CQDMCAICDyBpcyBub3QgZGVmaW5lZAUDbmlsAgABDGdldEludE9yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAmggCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGR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JAQhnZXRJbnRPcgIJARhrZXlSZXNlcnZhdGlvbkJ5QXNzZXRTdHIBBQVhc3NldAAAAAAHCgACJGwFBkFTU0VUUwoAAiRzCQCQAwEFAiRsCgAFJGFjYzAGCgEFJGYwXzECAiRhAiRpAwkAZwIFAiRpBQIkcwUCJGEJAQdjaGVja2VyAgUCJGEJAJEDAgUCJGwFAiRpCgEFJGYwXzICAiRhAiRpAwkAZwIFAiRpBQIkcwUCJGEJAAIBAhRMaXN0IHNpemUgZXhjZWVkcyAxMAkBBSRmMF8yAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgUFJGFjYzAAAAABAAIAAwAEAAUABgAHAAgACQAKBwdzS+Gl", "height": 2882030, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DGsR1vDJrNaRA1WeRT65YhtvBeNefZrwUSMGXTQ1f4cU Next: none Diff:
Old | New | Differences | |
---|---|---|---|
9 | 9 | ||
10 | 10 | let GAME_NAME = "Card of the Day" | |
11 | 11 | ||
12 | - | let RANDOM_RANGE = 40 | |
12 | + | let RANDOM_RANGE = ((40 + 6) + 5) | |
13 | 13 | ||
14 | 14 | let NUM_BETS = 1 | |
15 | 15 | ||
16 | - | let WIN_CARD = | |
16 | + | let WIN_CARD = "0" | |
17 | 17 | ||
18 | 18 | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
19 | 19 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let WAVESID = base58'WAVES' | |
7 | 7 | ||
8 | 8 | let WAVESD = 100000000 | |
9 | 9 | ||
10 | 10 | let GAME_NAME = "Card of the Day" | |
11 | 11 | ||
12 | - | let RANDOM_RANGE = 40 | |
12 | + | let RANDOM_RANGE = ((40 + 6) + 5) | |
13 | 13 | ||
14 | 14 | let NUM_BETS = 1 | |
15 | 15 | ||
16 | - | let WIN_CARD = | |
16 | + | let WIN_CARD = "0" | |
17 | 17 | ||
18 | 18 | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func getBoolOrFail (address,key) = valueOrErrorMessage(getBoolean(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | let allowedAssetsKey = "%s%s__cfg__allowedAssets" | |
28 | 28 | ||
29 | 29 | let assetsDecimalsKey = "%s%s__cfg__assetsDecimals" | |
30 | 30 | ||
31 | 31 | let betDividersKey = "%s%s__cfg__assetsBetDividers" | |
32 | 32 | ||
33 | 33 | let RSAPUBLIC64KEY = "%s%s__cfg__rsaPublic64" | |
34 | 34 | ||
35 | 35 | let SERVERADDRESSKEY = "%s%s__cfg__benzAddress" | |
36 | 36 | ||
37 | 37 | let RANDTIMEFRAMEKEY = "%s%s__cfg__withdrawTimeFrame" | |
38 | 38 | ||
39 | 39 | let GAMESCOUNTERKEY = "%s%s__runtime__gameNum" | |
40 | 40 | ||
41 | 41 | let blockedKey = "%s%s__runtime__contractIsBlocked" | |
42 | 42 | ||
43 | 43 | func getIntArray (key) = { | |
44 | 44 | let a = getStrOrFail(this, key) | |
45 | 45 | func filler (acc,el) = (acc :+ parseIntValue(el)) | |
46 | 46 | ||
47 | 47 | let $l = split(a, SEP) | |
48 | 48 | let $s = size($l) | |
49 | 49 | let $acc0 = nil | |
50 | 50 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
51 | 51 | then $a | |
52 | 52 | else filler($a, $l[$i]) | |
53 | 53 | ||
54 | 54 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
55 | 55 | then $a | |
56 | 56 | else throw("List size exceeds 10") | |
57 | 57 | ||
58 | 58 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | let ASSETS = split(getStrOrFail(this, allowedAssetsKey), SEP) | |
63 | 63 | ||
64 | 64 | let DECIMALS = getIntArray(assetsDecimalsKey) | |
65 | 65 | ||
66 | 66 | let BETDIVIDERS = getIntArray(betDividersKey) | |
67 | 67 | ||
68 | 68 | func keyReservationByAssetStr (assetStr) = ("$RESERVED_AMOUNT_" + assetStr) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func keyReservationByAssetIdx (assetIdx) = keyReservationByAssetStr(ASSETS[assetIdx]) | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | let MINFEEWAVES = ((5 * WAVESD) / 1000) | |
75 | 75 | ||
76 | 76 | let idxAssets = 0 | |
77 | 77 | ||
78 | 78 | let idxDecimals = 1 | |
79 | 79 | ||
80 | 80 | let idxDividers = 2 | |
81 | 81 | ||
82 | 82 | let BET1 = 1 | |
83 | 83 | ||
84 | 84 | let BET2 = 2 | |
85 | 85 | ||
86 | 86 | let BET4 = 4 | |
87 | 87 | ||
88 | 88 | let BET8 = 8 | |
89 | 89 | ||
90 | 90 | let BET14 = 14 | |
91 | 91 | ||
92 | 92 | let RATEMULT = 10000 | |
93 | 93 | ||
94 | 94 | let RATE = 250000 | |
95 | 95 | ||
96 | 96 | let BETS = [BET2] | |
97 | 97 | ||
98 | 98 | let IdxGameState = 0 | |
99 | 99 | ||
100 | 100 | let IdxPlayerChoice = 1 | |
101 | 101 | ||
102 | 102 | let IdxPlayerPubKey58 = 2 | |
103 | 103 | ||
104 | 104 | let IdxStartedHeight = 3 | |
105 | 105 | ||
106 | 106 | let IdxWinAmount = 4 | |
107 | 107 | ||
108 | 108 | let IdxAssetId = 5 | |
109 | 109 | ||
110 | 110 | let STATESUBMITTED = "SUBMITTED" | |
111 | 111 | ||
112 | 112 | let STATEWON = "WON" | |
113 | 113 | ||
114 | 114 | let STATELOST = "LOST" | |
115 | 115 | ||
116 | 116 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (key + " key is not specified in this.state")) | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | let RSAPUBLIC = fromBase64String(getStringOrFail(RSAPUBLIC64KEY)) | |
120 | 120 | ||
121 | 121 | let SERVER = addressFromStringValue(getStringOrFail(SERVERADDRESSKEY)) | |
122 | 122 | ||
123 | 123 | let RANDORACLETIMEFRAME = valueOrElse(getInteger(this, RANDTIMEFRAMEKEY), 7200) | |
124 | 124 | ||
125 | 125 | func getIntOr (key,default) = if (isDefined(getInteger(key))) | |
126 | 126 | then getIntegerValue(key) | |
127 | 127 | else default | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | func setInt (key,value) = IntegerEntry(key, value) | |
131 | 131 | ||
132 | 132 | ||
133 | 133 | func incrementInt (key) = setInt(key, (getIntOr(key, -1) + 1)) | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func changeInt (key,by) = setInt(key, (getIntOr(key, 0) + by)) | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func assetIdToStr (assetIdOrUnit) = match assetIdOrUnit { | |
140 | 140 | case b: ByteVector => | |
141 | 141 | toBase58String(b) | |
142 | 142 | case _ => | |
143 | 143 | "WAVES" | |
144 | 144 | } | |
145 | 145 | ||
146 | 146 | ||
147 | 147 | func assetIdFromStr (assetIdStr) = if ((assetIdStr == "WAVES")) | |
148 | 148 | then unit | |
149 | 149 | else fromBase58String(assetIdStr) | |
150 | 150 | ||
151 | 151 | ||
152 | 152 | func getAssetBalance (assetIdOrUnit) = match assetIdOrUnit { | |
153 | 153 | case assetId: ByteVector => | |
154 | 154 | assetBalance(this, assetId) | |
155 | 155 | case _ => | |
156 | 156 | wavesBalance(this).available | |
157 | 157 | } | |
158 | 158 | ||
159 | 159 | ||
160 | 160 | func increaseReserveAmount (winAmount,assetIdx) = { | |
161 | 161 | let assetIdStr = ASSETS[assetIdx] | |
162 | 162 | let newReservedAmount = (getIntOr(keyReservationByAssetIdx(assetIdx), 0) + winAmount) | |
163 | 163 | if ((newReservedAmount > getAssetBalance(assetIdFromStr(assetIdStr)))) | |
164 | 164 | then throw((("Insufficient funds on " + GAME_NAME) + " account. Transaction was rejected for your safety.")) | |
165 | 165 | else newReservedAmount | |
166 | 166 | } | |
167 | 167 | ||
168 | 168 | ||
169 | 169 | func decreaseReservedAmount (gameId,assetIdx,winAmount) = if ((0 > (getIntOr(keyReservationByAssetIdx(assetIdx), 0) - winAmount))) | |
170 | 170 | then throw((("Invalid " + GAME_NAME) + " account state - reserved amount is less than 0")) | |
171 | 171 | else changeInt(keyReservationByAssetIdx(assetIdx), -(winAmount)) | |
172 | 172 | ||
173 | 173 | ||
174 | 174 | func validateAndGetAssetIdx (assetIdStr) = { | |
175 | 175 | let idx = indexOf(ASSETS, assetIdStr) | |
176 | 176 | if (!(isDefined(idx))) | |
177 | 177 | then throw("Invalid payment asset") | |
178 | 178 | else value(idx) | |
179 | 179 | } | |
180 | 180 | ||
181 | 181 | ||
182 | 182 | func validateBetAndGetWinAmount (bet,internalAssetIdx,playerChoice) = { | |
183 | 183 | let dicesCount = size(playerChoice) | |
184 | 184 | func checkAmount (a,x) = if (a) | |
185 | 185 | then true | |
186 | 186 | else (bet == ((x * DECIMALS[internalAssetIdx]) / BETDIVIDERS[internalAssetIdx])) | |
187 | 187 | ||
188 | 188 | if (!({ | |
189 | 189 | let $l = BETS | |
190 | 190 | let $s = size($l) | |
191 | 191 | let $acc0 = false | |
192 | 192 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
193 | 193 | then $a | |
194 | 194 | else checkAmount($a, $l[$i]) | |
195 | 195 | ||
196 | 196 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
197 | 197 | then $a | |
198 | 198 | else throw("List size exceeds 5") | |
199 | 199 | ||
200 | 200 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
201 | 201 | })) | |
202 | 202 | then throw("Bet amount is not valid") | |
203 | 203 | else if ((parseInt(playerChoice) == unit)) | |
204 | 204 | then throw("Invalid player's choice") | |
205 | 205 | else fraction(bet, RATE, RATEMULT) | |
206 | 206 | } | |
207 | 207 | ||
208 | 208 | ||
209 | 209 | func generateRandChoice (gameId,rsaSign,playerChoice) = { | |
210 | 210 | let rsaSigValid = rsaVerify_16Kb(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
211 | 211 | if (!(rsaSigValid)) | |
212 | 212 | then throw("Invalid RSA signature") | |
213 | 213 | else { | |
214 | 214 | let rand = (toInt(sha256((rsaSign + toBytes(playerChoice)))) % RANDOM_RANGE) | |
215 | 215 | toString(rand) | |
216 | 216 | } | |
217 | 217 | } | |
218 | 218 | ||
219 | 219 | ||
220 | 220 | func isPlayerWin (playerChoice,randChoise) = (playerChoice == randChoise) | |
221 | 221 | ||
222 | 222 | ||
223 | 223 | func formatGameDataS (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty) = makeString([gameStatus, playerChoice, playerPubKey58, startedHeight, winAmount, assetIdx, if ((randOrEmpty == "")) | |
224 | 224 | then "" | |
225 | 225 | else randOrEmpty], "_") | |
226 | 226 | ||
227 | 227 | ||
228 | 228 | func formatGameData (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty) = formatGameDataS(gameStatus, playerChoice, playerPubKey58, toString(startedHeight), toString(winAmount), toString(assetIdx), randOrEmpty) | |
229 | 229 | ||
230 | 230 | ||
231 | 231 | func finishGameData (origGameData,gameStatus,rand,winByTimeout) = { | |
232 | 232 | let finishGameData = formatGameDataS(gameStatus, rand, origGameData[IdxPlayerPubKey58], origGameData[IdxStartedHeight], origGameData[IdxWinAmount], origGameData[IdxAssetId], WIN_CARD) | |
233 | 233 | if (winByTimeout) | |
234 | 234 | then (finishGameData + "_TIMEOUT") | |
235 | 235 | else finishGameData | |
236 | 236 | } | |
237 | 237 | ||
238 | 238 | ||
239 | 239 | func extractGameData (gameId) = split(match getString(this, gameId) { | |
240 | 240 | case str: String => | |
241 | 241 | str | |
242 | 242 | case _ => | |
243 | 243 | throw((("Game: " + gameId) + " not found.")) | |
244 | 244 | }, "_") | |
245 | 245 | ||
246 | 246 | ||
247 | 247 | @Callable(i) | |
248 | 248 | func constructorV1 (rsaPublic64,benzAddress,randOracleTimeFrame,tokensDescriptor) = if ((i.caller != SERVER)) | |
249 | 249 | then throw("not authorized") | |
250 | 250 | else { | |
251 | 251 | func splitter (acc,elem) = { | |
252 | 252 | let tokList = split(elem, ":") | |
253 | 253 | if ((size(tokList) != 4)) | |
254 | 254 | then throw("Invalid asset record") | |
255 | 255 | else $Tuple3((acc._1 :+ tokList[idxAssets]), (acc._2 :+ tokList[idxDecimals]), (acc._3 :+ tokList[idxDividers])) | |
256 | 256 | } | |
257 | 257 | ||
258 | 258 | let r = { | |
259 | 259 | let $l = split_4C(tokensDescriptor, "_") | |
260 | 260 | let $s = size($l) | |
261 | 261 | let $acc0 = $Tuple3(nil, nil, nil) | |
262 | 262 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
263 | 263 | then $a | |
264 | 264 | else splitter($a, $l[$i]) | |
265 | 265 | ||
266 | 266 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
267 | 267 | then $a | |
268 | 268 | else throw("List size exceeds 10") | |
269 | 269 | ||
270 | 270 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
271 | 271 | } | |
272 | 272 | [StringEntry(RSAPUBLIC64KEY, rsaPublic64), StringEntry(SERVERADDRESSKEY, benzAddress), IntegerEntry(RANDTIMEFRAMEKEY, randOracleTimeFrame), StringEntry(allowedAssetsKey, makeString_2C(r._1, SEP)), StringEntry(assetsDecimalsKey, makeString(r._2, SEP)), StringEntry(betDividersKey, makeString(r._3, SEP))] | |
273 | 273 | } | |
274 | 274 | ||
275 | 275 | ||
276 | 276 | ||
277 | 277 | @Callable(i) | |
278 | 278 | func maintenance (blocked) = if ((i.caller != SERVER)) | |
279 | 279 | then throw("not authorized") | |
280 | 280 | else [BooleanEntry(blockedKey, blocked)] | |
281 | 281 | ||
282 | 282 | ||
283 | 283 | ||
284 | 284 | @Callable(i) | |
285 | 285 | func bet (playerChoice) = if (valueOrElse(getBoolean(blockedKey), false)) | |
286 | 286 | then throw("Game is stopped for maintenence") | |
287 | 287 | else { | |
288 | 288 | let gameId = toBase58String(i.transactionId) | |
289 | 289 | if ((1 >= size(i.payments))) | |
290 | 290 | then throw("2 payments must be attached") | |
291 | 291 | else if (isDefined(getString(this, gameId))) | |
292 | 292 | then throw((("Bet for: " + gameId) + " was already made.")) | |
293 | 293 | else { | |
294 | 294 | let betPmt = value(i.payments[0]) | |
295 | 295 | let feePmt = value(i.payments[1]) | |
296 | 296 | if (isDefined(feePmt.assetId)) | |
297 | 297 | then throw("feePmt (2nd payment) assetId must be in Waves") | |
298 | 298 | else if ((MINFEEWAVES > feePmt.amount)) | |
299 | 299 | then throw("feePmt (2nd payment) must be >= 0.005 Waves") | |
300 | 300 | else { | |
301 | 301 | let assetIdStr = assetIdToStr(betPmt.assetId) | |
302 | 302 | let internalAssetIdx = validateAndGetAssetIdx(assetIdStr) | |
303 | 303 | let commission = feePmt.amount | |
304 | 304 | let winAmount = validateBetAndGetWinAmount(betPmt.amount, internalAssetIdx, playerChoice) | |
305 | 305 | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
306 | 306 | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, internalAssetIdx, "") | |
307 | 307 | [IntegerEntry(keyReservationByAssetIdx(internalAssetIdx), increaseReserveAmount(winAmount, internalAssetIdx)), incrementInt(GAMESCOUNTERKEY), StringEntry(gameId, gameData), ScriptTransfer(SERVER, commission, feePmt.assetId)] | |
308 | 308 | } | |
309 | 309 | } | |
310 | 310 | } | |
311 | 311 | ||
312 | 312 | ||
313 | 313 | ||
314 | 314 | @Callable(i) | |
315 | 315 | func withdraw (gameId,rsaSign) = { | |
316 | 316 | let gameData = extractGameData(gameId) | |
317 | 317 | let gameState = gameData[IdxGameState] | |
318 | 318 | let playerChoice = gameData[IdxPlayerChoice] | |
319 | 319 | let startedHeight = parseIntValue(gameData[IdxStartedHeight]) | |
320 | 320 | let winAmount = parseIntValue(gameData[IdxWinAmount]) | |
321 | 321 | let assetIdx = parseIntValue(gameData[IdxAssetId]) | |
322 | 322 | let playerPubKey58 = gameData[IdxPlayerPubKey58] | |
323 | 323 | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
324 | 324 | if ((gameState != STATESUBMITTED)) | |
325 | 325 | then throw("Invalid game state for passed gameId") | |
326 | 326 | else if ((i.caller != SERVER)) | |
327 | 327 | then throw("Regular withdraw can be done by server only") | |
328 | 328 | else { | |
329 | 329 | let winByTimeout = ((height - startedHeight) > RANDORACLETIMEFRAME) | |
330 | 330 | let randChoise = if (winByTimeout) | |
331 | 331 | then WIN_CARD | |
332 | 332 | else generateRandChoice(gameId, rsaSign, playerChoice) | |
333 | 333 | let playerWin = isPlayerWin(randChoise, WIN_CARD) | |
334 | 334 | let newGameStatus = if (playerWin) | |
335 | 335 | then STATEWON | |
336 | 336 | else STATELOST | |
337 | 337 | let newGameData = finishGameData(gameData, newGameStatus, randChoise, winByTimeout) | |
338 | 338 | ([StringEntry(gameId, newGameData), decreaseReservedAmount(gameId, assetIdx, winAmount)] ++ (if (playerWin) | |
339 | 339 | then [ScriptTransfer(playerAddress, winAmount, assetIdFromStr(ASSETS[assetIdx]))] | |
340 | 340 | else nil)) | |
341 | 341 | } | |
342 | 342 | } | |
343 | 343 | ||
344 | 344 | ||
345 | 345 | @Verifier(tx) | |
346 | 346 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
347 | 347 | then match tx { | |
348 | 348 | case ttx: TransferTransaction => | |
349 | 349 | let assetIdx = validateAndGetAssetIdx(assetIdToStr(ttx.assetId)) | |
350 | 350 | ((getAssetBalance(ttx.assetId) - ttx.amount) >= getIntOr(keyReservationByAssetIdx(assetIdx), 0)) | |
351 | 351 | case stx: SetScriptTransaction => | |
352 | 352 | func checker (acc,asset) = if (acc) | |
353 | 353 | then (getIntOr(keyReservationByAssetStr(asset), 0) == 0) | |
354 | 354 | else false | |
355 | 355 | ||
356 | 356 | let $l = ASSETS | |
357 | 357 | let $s = size($l) | |
358 | 358 | let $acc0 = true | |
359 | 359 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
360 | 360 | then $a | |
361 | 361 | else checker($a, $l[$i]) | |
362 | 362 | ||
363 | 363 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
364 | 364 | then $a | |
365 | 365 | else throw("List size exceeds 10") | |
366 | 366 | ||
367 | 367 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
368 | 368 | case _ => | |
369 | 369 | false | |
370 | 370 | } | |
371 | 371 | else false | |
372 | 372 |
github/deemru/w8io/026f985 57.70 ms ◑