tx · DGsR1vDJrNaRA1WeRT65YhtvBeNefZrwUSMGXTQ1f4cU 3MyrsoUShtK8LVWE6mGVinCdwiJeedCtkvr: -0.01400000 Waves 2023.11.28 13:36 [2863132] smart account 3MyrsoUShtK8LVWE6mGVinCdwiJeedCtkvr > SELF 0.00000000 Waves
{ "type": 13, "id": "DGsR1vDJrNaRA1WeRT65YhtvBeNefZrwUSMGXTQ1f4cU", "fee": 1400000, "feeAssetId": null, "timestamp": 1701167803265, "version": 1, "sender": "3MyrsoUShtK8LVWE6mGVinCdwiJeedCtkvr", "senderPublicKey": "53WfUfPHKFYj846Npe6Bu5indsxPueAsu9YWe8fnprXh", "proofs": [ "5c6URsJwZugGdwfdm4TagU3EwZp3JxF9Au1H1rySZ6A7BLtDkPqbdzmUyftrprU4VFF95pubZwZsRBn1ttz81Khc" ], "script": "base64:BgIaCAISBgoECAgBCBIDCgEEEgMKAQgSBAoCCAJCAANTRVACAl9fAAdXQVZFU0lEAQQTq9kzAAZXQVZFU0QAgMLXLwAJR0FNRV9OQU1FAg9DYXJkIG9mIHRoZSBEYXkADFJBTkRPTV9SQU5HRQAoAAhOVU1fQkVUUwABAAhXSU5fQ0FSRAkApAMBCQBlAgUMUkFORE9NX1JBTkdFAAEBDGdldFN0ck9yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGRlZmluZWQFA25pbAIAAQxnZXRJbnRPckZhaWwCB2FkZHJlc3MDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJoIAgUHYWRkcmVzcwUDa2V5CQC5CQIJAMwIAgIKbWFuZGF0b3J5IAkAzAgCCQClCAEFB2FkZHJlc3MJAMwIAgIBLgkAzAgCBQNrZXkJAMwIAgIPIGlzIG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ICCQEYa2V5UmVzZXJ2YXRpb25CeUFzc2V0U3RyAQUFYXNzZXQAAAAABwoAAiRsBQZBU1NFVFMKAAIkcwkAkAMBBQIkbAoABSRhY2MwBgoBBSRmMF8xAgIkYQIkaQMJAGcCBQIkaQUCJHMFAiRhCQEHY2hlY2tlcgIFAiRhCQCRAwIFAiRsBQIkaQoBBSRmMF8yAgIkYQIkaQMJAGcCBQIkaQUCJHMFAiRhCQACAQIUTGlzdCBzaXplIGV4Y2VlZHMgMTAJAQUkZjBfMgIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIFBSRhY2MwAAAAAQACAAMABAAFAAYABwAIAAkACgcHKYev3Q==", "chainId": 84, "height": 2863132, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6HkiJZhvmR393T8YxBmF85gjSsyRMGhGGpe1W1C2nAgF Next: GgxepTxMZteQCP5HtU6VQe9fehEdoMP5sgRr4BjqkuCw Diff:
Old | New | Differences | |
---|---|---|---|
12 | 12 | let RANDOM_RANGE = 40 | |
13 | 13 | ||
14 | 14 | let NUM_BETS = 1 | |
15 | + | ||
16 | + | let WIN_CARD = toString((RANDOM_RANGE - 1)) | |
15 | 17 | ||
16 | 18 | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
17 | 19 | ||
215 | 217 | } | |
216 | 218 | ||
217 | 219 | ||
218 | - | func isPlayerWin (playerChoice,randChoise) = if ((size(playerChoice) == NUM_BETS)) | |
219 | - | then (randChoise == toString((RANDOM_RANGE - 1))) | |
220 | - | else false | |
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 == "")) | |
229 | 229 | ||
230 | 230 | ||
231 | 231 | func finishGameData (origGameData,gameStatus,rand,winByTimeout) = { | |
232 | - | let finishGameData = formatGameDataS(gameStatus, | |
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 | |
328 | 328 | else { | |
329 | 329 | let winByTimeout = ((height - startedHeight) > RANDORACLETIMEFRAME) | |
330 | 330 | let randChoise = if (winByTimeout) | |
331 | - | then | |
331 | + | then WIN_CARD | |
332 | 332 | else generateRandChoice(gameId, rsaSign, playerChoice) | |
333 | - | let playerWin = isPlayerWin( | |
333 | + | let playerWin = isPlayerWin(randChoise, WIN_CARD) | |
334 | 334 | let newGameStatus = if (playerWin) | |
335 | 335 | then STATEWON | |
336 | 336 | else STATELOST |
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 | 12 | let RANDOM_RANGE = 40 | |
13 | 13 | ||
14 | 14 | let NUM_BETS = 1 | |
15 | + | ||
16 | + | let WIN_CARD = toString((RANDOM_RANGE - 1)) | |
15 | 17 | ||
16 | 18 | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
17 | 19 | ||
18 | 20 | ||
19 | 21 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
20 | 22 | ||
21 | 23 | ||
22 | 24 | func getBoolOrFail (address,key) = valueOrErrorMessage(getBoolean(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
23 | 25 | ||
24 | 26 | ||
25 | 27 | let allowedAssetsKey = "%s%s__cfg__allowedAssets" | |
26 | 28 | ||
27 | 29 | let assetsDecimalsKey = "%s%s__cfg__assetsDecimals" | |
28 | 30 | ||
29 | 31 | let betDividersKey = "%s%s__cfg__assetsBetDividers" | |
30 | 32 | ||
31 | 33 | let RSAPUBLIC64KEY = "%s%s__cfg__rsaPublic64" | |
32 | 34 | ||
33 | 35 | let SERVERADDRESSKEY = "%s%s__cfg__benzAddress" | |
34 | 36 | ||
35 | 37 | let RANDTIMEFRAMEKEY = "%s%s__cfg__withdrawTimeFrame" | |
36 | 38 | ||
37 | 39 | let GAMESCOUNTERKEY = "%s%s__runtime__gameNum" | |
38 | 40 | ||
39 | 41 | let blockedKey = "%s%s__runtime__contractIsBlocked" | |
40 | 42 | ||
41 | 43 | func getIntArray (key) = { | |
42 | 44 | let a = getStrOrFail(this, key) | |
43 | 45 | func filler (acc,el) = (acc :+ parseIntValue(el)) | |
44 | 46 | ||
45 | 47 | let $l = split(a, SEP) | |
46 | 48 | let $s = size($l) | |
47 | 49 | let $acc0 = nil | |
48 | 50 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
49 | 51 | then $a | |
50 | 52 | else filler($a, $l[$i]) | |
51 | 53 | ||
52 | 54 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
53 | 55 | then $a | |
54 | 56 | else throw("List size exceeds 10") | |
55 | 57 | ||
56 | 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) | |
57 | 59 | } | |
58 | 60 | ||
59 | 61 | ||
60 | 62 | let ASSETS = split(getStrOrFail(this, allowedAssetsKey), SEP) | |
61 | 63 | ||
62 | 64 | let DECIMALS = getIntArray(assetsDecimalsKey) | |
63 | 65 | ||
64 | 66 | let BETDIVIDERS = getIntArray(betDividersKey) | |
65 | 67 | ||
66 | 68 | func keyReservationByAssetStr (assetStr) = ("$RESERVED_AMOUNT_" + assetStr) | |
67 | 69 | ||
68 | 70 | ||
69 | 71 | func keyReservationByAssetIdx (assetIdx) = keyReservationByAssetStr(ASSETS[assetIdx]) | |
70 | 72 | ||
71 | 73 | ||
72 | 74 | let MINFEEWAVES = ((5 * WAVESD) / 1000) | |
73 | 75 | ||
74 | 76 | let idxAssets = 0 | |
75 | 77 | ||
76 | 78 | let idxDecimals = 1 | |
77 | 79 | ||
78 | 80 | let idxDividers = 2 | |
79 | 81 | ||
80 | 82 | let BET1 = 1 | |
81 | 83 | ||
82 | 84 | let BET2 = 2 | |
83 | 85 | ||
84 | 86 | let BET4 = 4 | |
85 | 87 | ||
86 | 88 | let BET8 = 8 | |
87 | 89 | ||
88 | 90 | let BET14 = 14 | |
89 | 91 | ||
90 | 92 | let RATEMULT = 10000 | |
91 | 93 | ||
92 | 94 | let RATE = 250000 | |
93 | 95 | ||
94 | 96 | let BETS = [BET2] | |
95 | 97 | ||
96 | 98 | let IdxGameState = 0 | |
97 | 99 | ||
98 | 100 | let IdxPlayerChoice = 1 | |
99 | 101 | ||
100 | 102 | let IdxPlayerPubKey58 = 2 | |
101 | 103 | ||
102 | 104 | let IdxStartedHeight = 3 | |
103 | 105 | ||
104 | 106 | let IdxWinAmount = 4 | |
105 | 107 | ||
106 | 108 | let IdxAssetId = 5 | |
107 | 109 | ||
108 | 110 | let STATESUBMITTED = "SUBMITTED" | |
109 | 111 | ||
110 | 112 | let STATEWON = "WON" | |
111 | 113 | ||
112 | 114 | let STATELOST = "LOST" | |
113 | 115 | ||
114 | 116 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (key + " key is not specified in this.state")) | |
115 | 117 | ||
116 | 118 | ||
117 | 119 | let RSAPUBLIC = fromBase64String(getStringOrFail(RSAPUBLIC64KEY)) | |
118 | 120 | ||
119 | 121 | let SERVER = addressFromStringValue(getStringOrFail(SERVERADDRESSKEY)) | |
120 | 122 | ||
121 | 123 | let RANDORACLETIMEFRAME = valueOrElse(getInteger(this, RANDTIMEFRAMEKEY), 7200) | |
122 | 124 | ||
123 | 125 | func getIntOr (key,default) = if (isDefined(getInteger(key))) | |
124 | 126 | then getIntegerValue(key) | |
125 | 127 | else default | |
126 | 128 | ||
127 | 129 | ||
128 | 130 | func setInt (key,value) = IntegerEntry(key, value) | |
129 | 131 | ||
130 | 132 | ||
131 | 133 | func incrementInt (key) = setInt(key, (getIntOr(key, -1) + 1)) | |
132 | 134 | ||
133 | 135 | ||
134 | 136 | func changeInt (key,by) = setInt(key, (getIntOr(key, 0) + by)) | |
135 | 137 | ||
136 | 138 | ||
137 | 139 | func assetIdToStr (assetIdOrUnit) = match assetIdOrUnit { | |
138 | 140 | case b: ByteVector => | |
139 | 141 | toBase58String(b) | |
140 | 142 | case _ => | |
141 | 143 | "WAVES" | |
142 | 144 | } | |
143 | 145 | ||
144 | 146 | ||
145 | 147 | func assetIdFromStr (assetIdStr) = if ((assetIdStr == "WAVES")) | |
146 | 148 | then unit | |
147 | 149 | else fromBase58String(assetIdStr) | |
148 | 150 | ||
149 | 151 | ||
150 | 152 | func getAssetBalance (assetIdOrUnit) = match assetIdOrUnit { | |
151 | 153 | case assetId: ByteVector => | |
152 | 154 | assetBalance(this, assetId) | |
153 | 155 | case _ => | |
154 | 156 | wavesBalance(this).available | |
155 | 157 | } | |
156 | 158 | ||
157 | 159 | ||
158 | 160 | func increaseReserveAmount (winAmount,assetIdx) = { | |
159 | 161 | let assetIdStr = ASSETS[assetIdx] | |
160 | 162 | let newReservedAmount = (getIntOr(keyReservationByAssetIdx(assetIdx), 0) + winAmount) | |
161 | 163 | if ((newReservedAmount > getAssetBalance(assetIdFromStr(assetIdStr)))) | |
162 | 164 | then throw((("Insufficient funds on " + GAME_NAME) + " account. Transaction was rejected for your safety.")) | |
163 | 165 | else newReservedAmount | |
164 | 166 | } | |
165 | 167 | ||
166 | 168 | ||
167 | 169 | func decreaseReservedAmount (gameId,assetIdx,winAmount) = if ((0 > (getIntOr(keyReservationByAssetIdx(assetIdx), 0) - winAmount))) | |
168 | 170 | then throw((("Invalid " + GAME_NAME) + " account state - reserved amount is less than 0")) | |
169 | 171 | else changeInt(keyReservationByAssetIdx(assetIdx), -(winAmount)) | |
170 | 172 | ||
171 | 173 | ||
172 | 174 | func validateAndGetAssetIdx (assetIdStr) = { | |
173 | 175 | let idx = indexOf(ASSETS, assetIdStr) | |
174 | 176 | if (!(isDefined(idx))) | |
175 | 177 | then throw("Invalid payment asset") | |
176 | 178 | else value(idx) | |
177 | 179 | } | |
178 | 180 | ||
179 | 181 | ||
180 | 182 | func validateBetAndGetWinAmount (bet,internalAssetIdx,playerChoice) = { | |
181 | 183 | let dicesCount = size(playerChoice) | |
182 | 184 | func checkAmount (a,x) = if (a) | |
183 | 185 | then true | |
184 | 186 | else (bet == ((x * DECIMALS[internalAssetIdx]) / BETDIVIDERS[internalAssetIdx])) | |
185 | 187 | ||
186 | 188 | if (!({ | |
187 | 189 | let $l = BETS | |
188 | 190 | let $s = size($l) | |
189 | 191 | let $acc0 = false | |
190 | 192 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
191 | 193 | then $a | |
192 | 194 | else checkAmount($a, $l[$i]) | |
193 | 195 | ||
194 | 196 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
195 | 197 | then $a | |
196 | 198 | else throw("List size exceeds 5") | |
197 | 199 | ||
198 | 200 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
199 | 201 | })) | |
200 | 202 | then throw("Bet amount is not valid") | |
201 | 203 | else if ((parseInt(playerChoice) == unit)) | |
202 | 204 | then throw("Invalid player's choice") | |
203 | 205 | else fraction(bet, RATE, RATEMULT) | |
204 | 206 | } | |
205 | 207 | ||
206 | 208 | ||
207 | 209 | func generateRandChoice (gameId,rsaSign,playerChoice) = { | |
208 | 210 | let rsaSigValid = rsaVerify_16Kb(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
209 | 211 | if (!(rsaSigValid)) | |
210 | 212 | then throw("Invalid RSA signature") | |
211 | 213 | else { | |
212 | 214 | let rand = (toInt(sha256((rsaSign + toBytes(playerChoice)))) % RANDOM_RANGE) | |
213 | 215 | toString(rand) | |
214 | 216 | } | |
215 | 217 | } | |
216 | 218 | ||
217 | 219 | ||
218 | - | func isPlayerWin (playerChoice,randChoise) = if ((size(playerChoice) == NUM_BETS)) | |
219 | - | then (randChoise == toString((RANDOM_RANGE - 1))) | |
220 | - | else false | |
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 | - | let finishGameData = formatGameDataS(gameStatus, | |
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 | - | then | |
331 | + | then WIN_CARD | |
332 | 332 | else generateRandChoice(gameId, rsaSign, playerChoice) | |
333 | - | let playerWin = isPlayerWin( | |
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 62.30 ms ◑