tx · CFJTzodtTfc9BN6gqaKMCjoN9S9G4Er3fHxoYvtWZ8EZ 3N8NLvRGsbGhgoXy7EdigPbAz6N2i7ygBcZ: -0.01700000 Waves 2023.12.12 19:18 [2883744] smart account 3N8NLvRGsbGhgoXy7EdigPbAz6N2i7ygBcZ > SELF 0.00000000 Waves
{ "type": 13, "id": "CFJTzodtTfc9BN6gqaKMCjoN9S9G4Er3fHxoYvtWZ8EZ", "fee": 1700000, "feeAssetId": null, "timestamp": 1702397936732, "version": 2, "chainId": 84, "sender": "3N8NLvRGsbGhgoXy7EdigPbAz6N2i7ygBcZ", "senderPublicKey": "CQoe8BRHR78TuPQLcK3Ykv39w9CeNLhjKdj6TNbJ5FrM", "proofs": [ "3HxcftkfdWDtAehWv4UUvW4EePw5VkMaL87SVfXkTzTHWo4pyQ6cmyVbNxwde5RxzGc9vR36aAwvhCJtnfADfVX4" ], "script": "base64:BgIaCAISBgoECAgBCBIDCgEEEgMKAQgSBAoCCAJGAANTRVACAl9fAAdXQVZFU0lEAQQTq9kzAAZXQVZFU0QAgMLXLwAJR0FNRV9OQU1FAglYbWFzIFRyZWUADFJBTkRPTV9SQU5HRQAFAAhOVU1fQkVUUwABAQxnZXRTdHJPckZhaWwCB2FkZHJlc3MDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUHYWRkcmVzcwUDa2V5CQC5CQIJAMwIAgIKbWFuZGF0b3J5IAkAzAgCCQClCAEFB2FkZHJlc3MJAMwIAgIBLgkAzAgCBQNrZXkJAMwIAgIPIGlzIG5vdCBkZWZpbmVkBQNuaWwCAAEMZ2V0SW50T3JGYWlsAgdhZGRyZXNzA2tleQkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCaCAIFB2FkZHJlc3MFA2tleQkAuQkCCQDMCAICCm1hbmRhdG9yeSAJAMwIAgkApQgBBQdhZGRyZXNzCQDMCAICAS4JAMwIAgUDa2V5CQDMCAICDyBpcyBub3QgZGVmaW5lZAUDbmlsAgAB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JG1hdGNoMAoBB2NoZWNrZXICA2FjYwVhc3NldAMFA2FjYwkAAAIJAQhnZXRJbnRPcgIJARhrZXlSZXNlcnZhdGlvbkJ5QXNzZXRTdHIBBQVhc3NldAAAAAAHCgACJGwFBkFTU0VUUwoAAiRzCQCQAwEFAiRsCgAFJGFjYzAGCgEFJGYwXzECAiRhAiRpAwkAZwIFAiRpBQIkcwUCJGEJAQdjaGVja2VyAgUCJGEJAJEDAgUCJGwFAiRpCgEFJGYwXzICAiRhAiRpAwkAZwIFAiRpBQIkcwUCJGEJAAIBAhRMaXN0IHNpemUgZXhjZWVkcyAxMAkBBSRmMF8yAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgUFJGFjYzAAAAABAAIAAwAEAAUABgAHAAgACQAKAwkAAQIFByRtYXRjaDACF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBANpdHgFByRtYXRjaDADCQAAAggFA2l0eARkQXBwBQR0aGlzCQAAAggFA2l0eAhmdW5jdGlvbgINY29uc3RydWN0b3JWMQcHBwHq5S4=", "height": 2883744, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9pLrAG7Mx534ypsMBVJRpL2Deo2cMyNdBajZsjcooiPM Next: 2fKnLFXeMRi15d4aYSuwwSv34kWdRbmGpWC3qgVUyJf5 Diff:
Old | New | Differences | |
---|---|---|---|
12 | 12 | let RANDOM_RANGE = 5 | |
13 | 13 | ||
14 | 14 | let NUM_BETS = 1 | |
15 | - | ||
16 | - | let HOR_LINES = [[491, 506, 44], [455, 542, 120], [404, 596, 166], [441, 556, 177], [387, 620, 232], [410, 592, 244], [329, 665, 321], [370, 666, 337], [355, 645, 349], [313, 692, 384], [289, 682, 405], [324, 657, 461], [450, 575, 525], [505, 505, 532]] | |
17 | 15 | ||
18 | 16 | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
19 | 17 | ||
41 | 39 | let blockedKey = "%s%s__runtime__contractIsBlocked" | |
42 | 40 | ||
43 | 41 | let reservedAmountsKey = "%s%s__runtime__reservedAmounts" | |
44 | - | ||
45 | - | func keyCoords (gameId) = ("%s%s%s__runtime__coordsByGameId__" + gameId) | |
46 | - | ||
47 | 42 | ||
48 | 43 | func getIntArray (key) = { | |
49 | 44 | let a = getStrOrFail(this, key) | |
213 | 208 | } | |
214 | 209 | ||
215 | 210 | ||
211 | + | let HOR_LINES = [[491, 506, 44], [455, 542, 120], [404, 596, 166], [441, 556, 177], [387, 620, 232], [423, 620, 232], [410, 592, 244], [329, 665, 321], [370, 666, 337], [355, 645, 349], [313, 692, 384], [289, 682, 405], [324, 657, 461], [450, 575, 525], [505, 505, 532]] | |
212 | + | ||
213 | + | let HALF = 5000 | |
214 | + | ||
215 | + | let M4 = 10000 | |
216 | + | ||
217 | + | func getCoords (gameId,rsaSign) = { | |
218 | + | func calcAreas (acc,ignored) = { | |
219 | + | let i = acc._3 | |
220 | + | let top = HOR_LINES[i] | |
221 | + | let bottom = HOR_LINES[(i + 1)] | |
222 | + | let area4 = (((((top[1] - top[0]) + bottom[1]) - bottom[0]) * (bottom[2] - top[2])) * 5000) | |
223 | + | $Tuple3((acc._1 :+ area4), (acc._2 + area4), (acc._3 + 1)) | |
224 | + | } | |
225 | + | ||
226 | + | let $t079398006 = { | |
227 | + | let $l = HOR_LINES | |
228 | + | let $s = size($l) | |
229 | + | let $acc0 = $Tuple3(nil, 0, 0) | |
230 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
231 | + | then $a | |
232 | + | else calcAreas($a, $l[$i]) | |
233 | + | ||
234 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
235 | + | then $a | |
236 | + | else throw("List size exceeds 14") | |
237 | + | ||
238 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14) | |
239 | + | } | |
240 | + | let areas = $t079398006._1 | |
241 | + | let totalArea = $t079398006._2 | |
242 | + | let rand = (toInt(sha256(rsaSign)) % totalArea) | |
243 | + | func check (acc,area) = { | |
244 | + | let i = acc._1 | |
245 | + | let newArea = (acc._2 + area) | |
246 | + | $Tuple3((i + 1), newArea, if ((newArea > rand)) | |
247 | + | then i | |
248 | + | else acc._3) | |
249 | + | } | |
250 | + | ||
251 | + | let j = ( let $l = areas | |
252 | + | let $s = size($l) | |
253 | + | let $acc0 = $Tuple3(0, 0, -1) | |
254 | + | func $f1_1 ($a,$i) = if (($i >= $s)) | |
255 | + | then $a | |
256 | + | else check($a, $l[$i]) | |
257 | + | ||
258 | + | func $f1_2 ($a,$i) = if (($i >= $s)) | |
259 | + | then $a | |
260 | + | else throw("List size exceeds 14") | |
261 | + | ||
262 | + | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14))._3 | |
263 | + | let top = HOR_LINES[j] | |
264 | + | let bottom = HOR_LINES[(j + 1)] | |
265 | + | let mx04 = ((top[0] + bottom[0]) * HALF) | |
266 | + | let mx14 = ((top[1] + bottom[1]) * HALF) | |
267 | + | let h4 = ((bottom[2] - top[2]) * M4) | |
268 | + | let my4 = ((top[2] + bottom[2]) * HALF) | |
269 | + | let randX4 = (mx04 + (toInt(sha256((rsaSign + toBytes(j)))) % (mx14 - mx04))) | |
270 | + | let randY4 = (top[2] + (toInt(sha256((rsaSign + toBytes(randX4)))) % h4)) | |
271 | + | let a4 = ((top[2] * M4) - randY4) | |
272 | + | let b4 = ((bottom[2] * M4) - randY4) | |
273 | + | let x04 = fraction(((top[0] * b4) - (bottom[0] * a4)), M4, h4) | |
274 | + | let x14 = fraction(((top[1] * b4) - (bottom[1] * a4)), M4, h4) | |
275 | + | if ((x04 > randX4)) | |
276 | + | then [((2 * mx04) - randX4), ((2 * my4) - randY4)] | |
277 | + | else if ((randX4 > x14)) | |
278 | + | then [((2 * mx14) - randX4), ((2 * my4) - randY4)] | |
279 | + | else [randX4, randY4] | |
280 | + | } | |
281 | + | ||
282 | + | ||
216 | 283 | func generateRandChoice (gameId,rsaSign) = { | |
217 | 284 | let rsaSigValid = rsaVerify_16Kb(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
218 | 285 | if (!(rsaSigValid)) | |
247 | 314 | } | |
248 | 315 | ||
249 | 316 | ||
250 | - | func formatGameDataS (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty) = makeString([gameStatus, playerChoice, playerPubKey58, startedHeight, winAmount, assetIdx, if ((randOrEmpty == "")) | |
317 | + | func formatGameDataS (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord) = makeString([gameStatus, playerChoice, playerPubKey58, startedHeight, winAmount, assetIdx, if ((randOrEmpty == "")) | |
251 | 318 | then "" | |
252 | - | else randOrEmpty], "_") | |
319 | + | else randOrEmpty, xCoord, yCoord], "_") | |
253 | 320 | ||
254 | 321 | ||
255 | - | func formatGameData (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty) = formatGameDataS(gameStatus, playerChoice, playerPubKey58, toString(startedHeight), toString(winAmount), toString(assetIdx), randOrEmpty) | |
322 | + | func formatGameData (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord) = formatGameDataS(gameStatus, playerChoice, playerPubKey58, toString(startedHeight), toString(winAmount), toString(assetIdx), randOrEmpty, toString(xCoord), toString(yCoord)) | |
256 | 323 | ||
257 | 324 | ||
258 | - | func finishGameData (origGameData,gameStatus,rand,winByTimeout) = { | |
259 | - | let finishGameData = formatGameDataS(gameStatus, origGameData[IdxPlayerChoice], origGameData[IdxPlayerPubKey58], origGameData[IdxStartedHeight], origGameData[IdxWinAmount], origGameData[IdxAssetId], rand) | |
325 | + | func finishGameData (origGameData,gameStatus,rand,winByTimeout,xCoord,yCoord) = { | |
326 | + | let finishGameData = formatGameDataS(gameStatus, origGameData[IdxPlayerChoice], origGameData[IdxPlayerPubKey58], origGameData[IdxStartedHeight], origGameData[IdxWinAmount], origGameData[IdxAssetId], rand, toString(xCoord), toString(yCoord)) | |
260 | 327 | if (winByTimeout) | |
261 | 328 | then (finishGameData + "_TIMEOUT") | |
262 | 329 | else finishGameData | |
272 | 339 | ||
273 | 340 | ||
274 | 341 | @Callable(i) | |
275 | - | func constructorV1 (rsaPublic64,benzAddress,randOracleTimeFrame,tokensDescriptor) = if ((i.caller != | |
342 | + | func constructorV1 (rsaPublic64,benzAddress,randOracleTimeFrame,tokensDescriptor) = if ((i.caller != this)) | |
276 | 343 | then throw("not authorized") | |
277 | 344 | else { | |
278 | 345 | func splitter (acc,elem) = { | |
330 | 397 | let commission = feePmt.amount | |
331 | 398 | let winAmount = validateBetAndGetWinAmount(betPmt.amount, internalAssetIdx, playerChoice) | |
332 | 399 | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
333 | - | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, internalAssetIdx, "") | |
400 | + | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, internalAssetIdx, "", -1, -1) | |
334 | 401 | [IntegerEntry(keyReservationByAssetIdx(internalAssetIdx), increaseReserveAmount(winAmount, internalAssetIdx)), incrementInt(GAMESCOUNTERKEY), StringEntry(gameId, gameData), ScriptTransfer(SERVER, commission, feePmt.assetId)] | |
335 | 402 | } | |
336 | 403 | } | |
361 | 428 | let newGameStatus = if (playerWin) | |
362 | 429 | then STATEWON | |
363 | 430 | else STATELOST | |
364 | - | let newGameData = finishGameData(gameData, newGameStatus, randChoice, winByTimeout) | |
431 | + | let coords = if (playerWin) | |
432 | + | then [-(M4), -(M4)] | |
433 | + | else getCoords(gameId, rsaSign) | |
434 | + | let newGameData = finishGameData(gameData, newGameStatus, randChoice, winByTimeout, (coords[0] / M4), (coords[1] / M4)) | |
365 | 435 | ([StringEntry(gameId, newGameData), decreaseReservedAmount(gameId, assetIdx, winAmount)] ++ (if (playerWin) | |
366 | 436 | then [ScriptTransfer(playerAddress, winAmount, assetIdFromStr(ASSETS[assetIdx]))] | |
367 | - | else | |
437 | + | else nil)) | |
368 | 438 | } | |
369 | 439 | } | |
370 | 440 | ||
392 | 462 | else throw("List size exceeds 10") | |
393 | 463 | ||
394 | 464 | $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) | |
465 | + | case itx: InvokeScriptTransaction => | |
466 | + | if ((itx.dApp == this)) | |
467 | + | then (itx.function == "constructorV1") | |
468 | + | else false | |
395 | 469 | case _ => | |
396 | 470 | false | |
397 | 471 | } |
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 = "Xmas Tree" | |
11 | 11 | ||
12 | 12 | let RANDOM_RANGE = 5 | |
13 | 13 | ||
14 | 14 | let NUM_BETS = 1 | |
15 | - | ||
16 | - | let HOR_LINES = [[491, 506, 44], [455, 542, 120], [404, 596, 166], [441, 556, 177], [387, 620, 232], [410, 592, 244], [329, 665, 321], [370, 666, 337], [355, 645, 349], [313, 692, 384], [289, 682, 405], [324, 657, 461], [450, 575, 525], [505, 505, 532]] | |
17 | 15 | ||
18 | 16 | func getStrOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
19 | 17 | ||
20 | 18 | ||
21 | 19 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
22 | 20 | ||
23 | 21 | ||
24 | 22 | func getBoolOrFail (address,key) = valueOrErrorMessage(getBoolean(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
25 | 23 | ||
26 | 24 | ||
27 | 25 | let allowedAssetsKey = "%s%s__cfg__allowedAssets" | |
28 | 26 | ||
29 | 27 | let assetsDecimalsKey = "%s%s__cfg__assetsDecimals" | |
30 | 28 | ||
31 | 29 | let betDividersKey = "%s%s__cfg__assetsBetDividers" | |
32 | 30 | ||
33 | 31 | let RSAPUBLIC64KEY = "%s%s__cfg__rsaPublic64" | |
34 | 32 | ||
35 | 33 | let SERVERADDRESSKEY = "%s%s__cfg__benzAddress" | |
36 | 34 | ||
37 | 35 | let RANDTIMEFRAMEKEY = "%s%s__cfg__withdrawTimeFrame" | |
38 | 36 | ||
39 | 37 | let GAMESCOUNTERKEY = "%s%s__runtime__gameNum" | |
40 | 38 | ||
41 | 39 | let blockedKey = "%s%s__runtime__contractIsBlocked" | |
42 | 40 | ||
43 | 41 | let reservedAmountsKey = "%s%s__runtime__reservedAmounts" | |
44 | - | ||
45 | - | func keyCoords (gameId) = ("%s%s%s__runtime__coordsByGameId__" + gameId) | |
46 | - | ||
47 | 42 | ||
48 | 43 | func getIntArray (key) = { | |
49 | 44 | let a = getStrOrFail(this, key) | |
50 | 45 | func filler (acc,el) = (acc :+ parseIntValue(el)) | |
51 | 46 | ||
52 | 47 | let $l = split(a, SEP) | |
53 | 48 | let $s = size($l) | |
54 | 49 | let $acc0 = nil | |
55 | 50 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
56 | 51 | then $a | |
57 | 52 | else filler($a, $l[$i]) | |
58 | 53 | ||
59 | 54 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
60 | 55 | then $a | |
61 | 56 | else throw("List size exceeds 10") | |
62 | 57 | ||
63 | 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) | |
64 | 59 | } | |
65 | 60 | ||
66 | 61 | ||
67 | 62 | let ASSETS = split(getStrOrFail(this, allowedAssetsKey), SEP) | |
68 | 63 | ||
69 | 64 | let DECIMALS = getIntArray(assetsDecimalsKey) | |
70 | 65 | ||
71 | 66 | let BETDIVIDERS = getIntArray(betDividersKey) | |
72 | 67 | ||
73 | 68 | func keyReservationByAssetStr (assetStr) = ("$RESERVED_AMOUNT_" + assetStr) | |
74 | 69 | ||
75 | 70 | ||
76 | 71 | func keyReservationByAssetIdx (assetIdx) = keyReservationByAssetStr(ASSETS[assetIdx]) | |
77 | 72 | ||
78 | 73 | ||
79 | 74 | let MINFEEWAVES = ((5 * WAVESD) / 1000) | |
80 | 75 | ||
81 | 76 | let idxAssets = 0 | |
82 | 77 | ||
83 | 78 | let idxDecimals = 1 | |
84 | 79 | ||
85 | 80 | let idxDividers = 2 | |
86 | 81 | ||
87 | 82 | let BET1 = 1 | |
88 | 83 | ||
89 | 84 | let BET2 = 2 | |
90 | 85 | ||
91 | 86 | let BET4 = 4 | |
92 | 87 | ||
93 | 88 | let BET8 = 8 | |
94 | 89 | ||
95 | 90 | let BET14 = 14 | |
96 | 91 | ||
97 | 92 | let RATEMULT = 10000 | |
98 | 93 | ||
99 | 94 | let RATE = 250000 | |
100 | 95 | ||
101 | 96 | let BETS = [BET2] | |
102 | 97 | ||
103 | 98 | let IdxGameState = 0 | |
104 | 99 | ||
105 | 100 | let IdxPlayerChoice = 1 | |
106 | 101 | ||
107 | 102 | let IdxPlayerPubKey58 = 2 | |
108 | 103 | ||
109 | 104 | let IdxStartedHeight = 3 | |
110 | 105 | ||
111 | 106 | let IdxWinAmount = 4 | |
112 | 107 | ||
113 | 108 | let IdxAssetId = 5 | |
114 | 109 | ||
115 | 110 | let STATESUBMITTED = "SUBMITTED" | |
116 | 111 | ||
117 | 112 | let STATEWON = "WON" | |
118 | 113 | ||
119 | 114 | let STATELOST = "LOST" | |
120 | 115 | ||
121 | 116 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (key + " key is not specified in this.state")) | |
122 | 117 | ||
123 | 118 | ||
124 | 119 | let RSAPUBLIC = fromBase64String(getStringOrFail(RSAPUBLIC64KEY)) | |
125 | 120 | ||
126 | 121 | let SERVER = addressFromStringValue(getStringOrFail(SERVERADDRESSKEY)) | |
127 | 122 | ||
128 | 123 | let RANDORACLETIMEFRAME = valueOrElse(getInteger(this, RANDTIMEFRAMEKEY), 7200) | |
129 | 124 | ||
130 | 125 | func getIntOr (key,default) = if (isDefined(getInteger(key))) | |
131 | 126 | then getIntegerValue(key) | |
132 | 127 | else default | |
133 | 128 | ||
134 | 129 | ||
135 | 130 | func setInt (key,value) = IntegerEntry(key, value) | |
136 | 131 | ||
137 | 132 | ||
138 | 133 | func incrementInt (key) = setInt(key, (getIntOr(key, -1) + 1)) | |
139 | 134 | ||
140 | 135 | ||
141 | 136 | func changeInt (key,by) = setInt(key, (getIntOr(key, 0) + by)) | |
142 | 137 | ||
143 | 138 | ||
144 | 139 | func assetIdToStr (assetIdOrUnit) = match assetIdOrUnit { | |
145 | 140 | case b: ByteVector => | |
146 | 141 | toBase58String(b) | |
147 | 142 | case _ => | |
148 | 143 | "WAVES" | |
149 | 144 | } | |
150 | 145 | ||
151 | 146 | ||
152 | 147 | func assetIdFromStr (assetIdStr) = if ((assetIdStr == "WAVES")) | |
153 | 148 | then unit | |
154 | 149 | else fromBase58String(assetIdStr) | |
155 | 150 | ||
156 | 151 | ||
157 | 152 | func getAssetBalance (assetIdOrUnit) = match assetIdOrUnit { | |
158 | 153 | case assetId: ByteVector => | |
159 | 154 | assetBalance(this, assetId) | |
160 | 155 | case _ => | |
161 | 156 | wavesBalance(this).available | |
162 | 157 | } | |
163 | 158 | ||
164 | 159 | ||
165 | 160 | func increaseReserveAmount (winAmount,assetIdx) = { | |
166 | 161 | let assetIdStr = ASSETS[assetIdx] | |
167 | 162 | let newReservedAmount = (getIntOr(keyReservationByAssetIdx(assetIdx), 0) + winAmount) | |
168 | 163 | if ((newReservedAmount > getAssetBalance(assetIdFromStr(assetIdStr)))) | |
169 | 164 | then throw((("Insufficient funds on " + GAME_NAME) + " account. Transaction was rejected for your safety.")) | |
170 | 165 | else newReservedAmount | |
171 | 166 | } | |
172 | 167 | ||
173 | 168 | ||
174 | 169 | func decreaseReservedAmount (gameId,assetIdx,winAmount) = if ((0 > (getIntOr(keyReservationByAssetIdx(assetIdx), 0) - winAmount))) | |
175 | 170 | then throw((("Invalid " + GAME_NAME) + " account state - reserved amount is less than 0")) | |
176 | 171 | else changeInt(keyReservationByAssetIdx(assetIdx), -(winAmount)) | |
177 | 172 | ||
178 | 173 | ||
179 | 174 | func validateAndGetAssetIdx (assetIdStr) = { | |
180 | 175 | let idx = indexOf(ASSETS, assetIdStr) | |
181 | 176 | if (!(isDefined(idx))) | |
182 | 177 | then throw("Invalid payment asset") | |
183 | 178 | else value(idx) | |
184 | 179 | } | |
185 | 180 | ||
186 | 181 | ||
187 | 182 | func validateBetAndGetWinAmount (bet,internalAssetIdx,playerChoice) = { | |
188 | 183 | let dicesCount = size(playerChoice) | |
189 | 184 | func checkAmount (a,x) = if (a) | |
190 | 185 | then true | |
191 | 186 | else (bet == ((x * DECIMALS[internalAssetIdx]) / BETDIVIDERS[internalAssetIdx])) | |
192 | 187 | ||
193 | 188 | if (!({ | |
194 | 189 | let $l = BETS | |
195 | 190 | let $s = size($l) | |
196 | 191 | let $acc0 = false | |
197 | 192 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
198 | 193 | then $a | |
199 | 194 | else checkAmount($a, $l[$i]) | |
200 | 195 | ||
201 | 196 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
202 | 197 | then $a | |
203 | 198 | else throw("List size exceeds 5") | |
204 | 199 | ||
205 | 200 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
206 | 201 | })) | |
207 | 202 | then throw("Bet amount is not valid") | |
208 | 203 | else if ((parseInt(playerChoice) == unit)) | |
209 | 204 | then throw("Invalid player's choice") | |
210 | 205 | else if ((dicesCount != NUM_BETS)) | |
211 | 206 | then throw("Invalid length of player's choice") | |
212 | 207 | else fraction(bet, RATE, RATEMULT) | |
213 | 208 | } | |
214 | 209 | ||
215 | 210 | ||
211 | + | let HOR_LINES = [[491, 506, 44], [455, 542, 120], [404, 596, 166], [441, 556, 177], [387, 620, 232], [423, 620, 232], [410, 592, 244], [329, 665, 321], [370, 666, 337], [355, 645, 349], [313, 692, 384], [289, 682, 405], [324, 657, 461], [450, 575, 525], [505, 505, 532]] | |
212 | + | ||
213 | + | let HALF = 5000 | |
214 | + | ||
215 | + | let M4 = 10000 | |
216 | + | ||
217 | + | func getCoords (gameId,rsaSign) = { | |
218 | + | func calcAreas (acc,ignored) = { | |
219 | + | let i = acc._3 | |
220 | + | let top = HOR_LINES[i] | |
221 | + | let bottom = HOR_LINES[(i + 1)] | |
222 | + | let area4 = (((((top[1] - top[0]) + bottom[1]) - bottom[0]) * (bottom[2] - top[2])) * 5000) | |
223 | + | $Tuple3((acc._1 :+ area4), (acc._2 + area4), (acc._3 + 1)) | |
224 | + | } | |
225 | + | ||
226 | + | let $t079398006 = { | |
227 | + | let $l = HOR_LINES | |
228 | + | let $s = size($l) | |
229 | + | let $acc0 = $Tuple3(nil, 0, 0) | |
230 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
231 | + | then $a | |
232 | + | else calcAreas($a, $l[$i]) | |
233 | + | ||
234 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
235 | + | then $a | |
236 | + | else throw("List size exceeds 14") | |
237 | + | ||
238 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14) | |
239 | + | } | |
240 | + | let areas = $t079398006._1 | |
241 | + | let totalArea = $t079398006._2 | |
242 | + | let rand = (toInt(sha256(rsaSign)) % totalArea) | |
243 | + | func check (acc,area) = { | |
244 | + | let i = acc._1 | |
245 | + | let newArea = (acc._2 + area) | |
246 | + | $Tuple3((i + 1), newArea, if ((newArea > rand)) | |
247 | + | then i | |
248 | + | else acc._3) | |
249 | + | } | |
250 | + | ||
251 | + | let j = ( let $l = areas | |
252 | + | let $s = size($l) | |
253 | + | let $acc0 = $Tuple3(0, 0, -1) | |
254 | + | func $f1_1 ($a,$i) = if (($i >= $s)) | |
255 | + | then $a | |
256 | + | else check($a, $l[$i]) | |
257 | + | ||
258 | + | func $f1_2 ($a,$i) = if (($i >= $s)) | |
259 | + | then $a | |
260 | + | else throw("List size exceeds 14") | |
261 | + | ||
262 | + | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14))._3 | |
263 | + | let top = HOR_LINES[j] | |
264 | + | let bottom = HOR_LINES[(j + 1)] | |
265 | + | let mx04 = ((top[0] + bottom[0]) * HALF) | |
266 | + | let mx14 = ((top[1] + bottom[1]) * HALF) | |
267 | + | let h4 = ((bottom[2] - top[2]) * M4) | |
268 | + | let my4 = ((top[2] + bottom[2]) * HALF) | |
269 | + | let randX4 = (mx04 + (toInt(sha256((rsaSign + toBytes(j)))) % (mx14 - mx04))) | |
270 | + | let randY4 = (top[2] + (toInt(sha256((rsaSign + toBytes(randX4)))) % h4)) | |
271 | + | let a4 = ((top[2] * M4) - randY4) | |
272 | + | let b4 = ((bottom[2] * M4) - randY4) | |
273 | + | let x04 = fraction(((top[0] * b4) - (bottom[0] * a4)), M4, h4) | |
274 | + | let x14 = fraction(((top[1] * b4) - (bottom[1] * a4)), M4, h4) | |
275 | + | if ((x04 > randX4)) | |
276 | + | then [((2 * mx04) - randX4), ((2 * my4) - randY4)] | |
277 | + | else if ((randX4 > x14)) | |
278 | + | then [((2 * mx14) - randX4), ((2 * my4) - randY4)] | |
279 | + | else [randX4, randY4] | |
280 | + | } | |
281 | + | ||
282 | + | ||
216 | 283 | func generateRandChoice (gameId,rsaSign) = { | |
217 | 284 | let rsaSigValid = rsaVerify_16Kb(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
218 | 285 | if (!(rsaSigValid)) | |
219 | 286 | then throw("Invalid RSA signature") | |
220 | 287 | else { | |
221 | 288 | let rand = (toInt(sha256(rsaSign)) % RANDOM_RANGE) | |
222 | 289 | toString((rand + 1)) | |
223 | 290 | } | |
224 | 291 | } | |
225 | 292 | ||
226 | 293 | ||
227 | 294 | func isPlayerWin (playerChoice,randChoise) = { | |
228 | 295 | let s = size(playerChoice) | |
229 | 296 | func check (a,x) = if (a) | |
230 | 297 | then true | |
231 | 298 | else if ((s >= x)) | |
232 | 299 | then (take(drop(playerChoice, (x - 1)), 1) == randChoise) | |
233 | 300 | else false | |
234 | 301 | ||
235 | 302 | let $l = [1, 2, 3, 4, 5] | |
236 | 303 | let $s = size($l) | |
237 | 304 | let $acc0 = false | |
238 | 305 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
239 | 306 | then $a | |
240 | 307 | else check($a, $l[$i]) | |
241 | 308 | ||
242 | 309 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
243 | 310 | then $a | |
244 | 311 | else throw("List size exceeds 5") | |
245 | 312 | ||
246 | 313 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
247 | 314 | } | |
248 | 315 | ||
249 | 316 | ||
250 | - | func formatGameDataS (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty) = makeString([gameStatus, playerChoice, playerPubKey58, startedHeight, winAmount, assetIdx, if ((randOrEmpty == "")) | |
317 | + | func formatGameDataS (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord) = makeString([gameStatus, playerChoice, playerPubKey58, startedHeight, winAmount, assetIdx, if ((randOrEmpty == "")) | |
251 | 318 | then "" | |
252 | - | else randOrEmpty], "_") | |
319 | + | else randOrEmpty, xCoord, yCoord], "_") | |
253 | 320 | ||
254 | 321 | ||
255 | - | func formatGameData (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty) = formatGameDataS(gameStatus, playerChoice, playerPubKey58, toString(startedHeight), toString(winAmount), toString(assetIdx), randOrEmpty) | |
322 | + | func formatGameData (gameStatus,playerChoice,playerPubKey58,startedHeight,winAmount,assetIdx,randOrEmpty,xCoord,yCoord) = formatGameDataS(gameStatus, playerChoice, playerPubKey58, toString(startedHeight), toString(winAmount), toString(assetIdx), randOrEmpty, toString(xCoord), toString(yCoord)) | |
256 | 323 | ||
257 | 324 | ||
258 | - | func finishGameData (origGameData,gameStatus,rand,winByTimeout) = { | |
259 | - | let finishGameData = formatGameDataS(gameStatus, origGameData[IdxPlayerChoice], origGameData[IdxPlayerPubKey58], origGameData[IdxStartedHeight], origGameData[IdxWinAmount], origGameData[IdxAssetId], rand) | |
325 | + | func finishGameData (origGameData,gameStatus,rand,winByTimeout,xCoord,yCoord) = { | |
326 | + | let finishGameData = formatGameDataS(gameStatus, origGameData[IdxPlayerChoice], origGameData[IdxPlayerPubKey58], origGameData[IdxStartedHeight], origGameData[IdxWinAmount], origGameData[IdxAssetId], rand, toString(xCoord), toString(yCoord)) | |
260 | 327 | if (winByTimeout) | |
261 | 328 | then (finishGameData + "_TIMEOUT") | |
262 | 329 | else finishGameData | |
263 | 330 | } | |
264 | 331 | ||
265 | 332 | ||
266 | 333 | func extractGameData (gameId) = split(match getString(this, gameId) { | |
267 | 334 | case str: String => | |
268 | 335 | str | |
269 | 336 | case _ => | |
270 | 337 | throw((("Game: " + gameId) + " not found.")) | |
271 | 338 | }, "_") | |
272 | 339 | ||
273 | 340 | ||
274 | 341 | @Callable(i) | |
275 | - | func constructorV1 (rsaPublic64,benzAddress,randOracleTimeFrame,tokensDescriptor) = if ((i.caller != | |
342 | + | func constructorV1 (rsaPublic64,benzAddress,randOracleTimeFrame,tokensDescriptor) = if ((i.caller != this)) | |
276 | 343 | then throw("not authorized") | |
277 | 344 | else { | |
278 | 345 | func splitter (acc,elem) = { | |
279 | 346 | let tokList = split(elem, ":") | |
280 | 347 | if ((size(tokList) != 3)) | |
281 | 348 | then throw("Invalid asset record") | |
282 | 349 | else $Tuple3((acc._1 :+ tokList[idxAssets]), (acc._2 :+ tokList[idxDecimals]), (acc._3 :+ tokList[idxDividers])) | |
283 | 350 | } | |
284 | 351 | ||
285 | 352 | let r = { | |
286 | 353 | let $l = split_4C(tokensDescriptor, "_") | |
287 | 354 | let $s = size($l) | |
288 | 355 | let $acc0 = $Tuple3(nil, nil, nil) | |
289 | 356 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
290 | 357 | then $a | |
291 | 358 | else splitter($a, $l[$i]) | |
292 | 359 | ||
293 | 360 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
294 | 361 | then $a | |
295 | 362 | else throw("List size exceeds 10") | |
296 | 363 | ||
297 | 364 | $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) | |
298 | 365 | } | |
299 | 366 | [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))] | |
300 | 367 | } | |
301 | 368 | ||
302 | 369 | ||
303 | 370 | ||
304 | 371 | @Callable(i) | |
305 | 372 | func maintenance (blocked) = if ((i.caller != SERVER)) | |
306 | 373 | then throw("not authorized") | |
307 | 374 | else [BooleanEntry(blockedKey, blocked)] | |
308 | 375 | ||
309 | 376 | ||
310 | 377 | ||
311 | 378 | @Callable(i) | |
312 | 379 | func bet (playerChoice) = if (valueOrElse(getBoolean(blockedKey), false)) | |
313 | 380 | then throw("Game is stopped for maintenence") | |
314 | 381 | else { | |
315 | 382 | let gameId = toBase58String(i.transactionId) | |
316 | 383 | if ((1 >= size(i.payments))) | |
317 | 384 | then throw("2 payments must be attached") | |
318 | 385 | else if (isDefined(getString(this, gameId))) | |
319 | 386 | then throw((("Bet for: " + gameId) + " was already made.")) | |
320 | 387 | else { | |
321 | 388 | let betPmt = value(i.payments[0]) | |
322 | 389 | let feePmt = value(i.payments[1]) | |
323 | 390 | if (isDefined(feePmt.assetId)) | |
324 | 391 | then throw("feePmt (2nd payment) assetId must be in Waves") | |
325 | 392 | else if ((MINFEEWAVES > feePmt.amount)) | |
326 | 393 | then throw("feePmt (2nd payment) must be >= 0.005 Waves") | |
327 | 394 | else { | |
328 | 395 | let assetIdStr = assetIdToStr(betPmt.assetId) | |
329 | 396 | let internalAssetIdx = validateAndGetAssetIdx(assetIdStr) | |
330 | 397 | let commission = feePmt.amount | |
331 | 398 | let winAmount = validateBetAndGetWinAmount(betPmt.amount, internalAssetIdx, playerChoice) | |
332 | 399 | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
333 | - | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, internalAssetIdx, "") | |
400 | + | let gameData = formatGameData(STATESUBMITTED, playerChoice, playerPubKey58, height, winAmount, internalAssetIdx, "", -1, -1) | |
334 | 401 | [IntegerEntry(keyReservationByAssetIdx(internalAssetIdx), increaseReserveAmount(winAmount, internalAssetIdx)), incrementInt(GAMESCOUNTERKEY), StringEntry(gameId, gameData), ScriptTransfer(SERVER, commission, feePmt.assetId)] | |
335 | 402 | } | |
336 | 403 | } | |
337 | 404 | } | |
338 | 405 | ||
339 | 406 | ||
340 | 407 | ||
341 | 408 | @Callable(i) | |
342 | 409 | func withdraw (gameId,rsaSign) = { | |
343 | 410 | let gameData = extractGameData(gameId) | |
344 | 411 | let gameState = gameData[IdxGameState] | |
345 | 412 | let playerChoice = gameData[IdxPlayerChoice] | |
346 | 413 | let startedHeight = parseIntValue(gameData[IdxStartedHeight]) | |
347 | 414 | let winAmount = parseIntValue(gameData[IdxWinAmount]) | |
348 | 415 | let assetIdx = parseIntValue(gameData[IdxAssetId]) | |
349 | 416 | let playerPubKey58 = gameData[IdxPlayerPubKey58] | |
350 | 417 | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
351 | 418 | if ((gameState != STATESUBMITTED)) | |
352 | 419 | then throw("Invalid game state for passed gameId") | |
353 | 420 | else if ((i.caller != SERVER)) | |
354 | 421 | then throw("Regular withdraw can be done by server only") | |
355 | 422 | else { | |
356 | 423 | let winByTimeout = ((height - startedHeight) > RANDORACLETIMEFRAME) | |
357 | 424 | let randChoice = if (winByTimeout) | |
358 | 425 | then take(playerChoice, 1) | |
359 | 426 | else generateRandChoice(gameId, rsaSign) | |
360 | 427 | let playerWin = isPlayerWin(playerChoice, randChoice) | |
361 | 428 | let newGameStatus = if (playerWin) | |
362 | 429 | then STATEWON | |
363 | 430 | else STATELOST | |
364 | - | let newGameData = finishGameData(gameData, newGameStatus, randChoice, winByTimeout) | |
431 | + | let coords = if (playerWin) | |
432 | + | then [-(M4), -(M4)] | |
433 | + | else getCoords(gameId, rsaSign) | |
434 | + | let newGameData = finishGameData(gameData, newGameStatus, randChoice, winByTimeout, (coords[0] / M4), (coords[1] / M4)) | |
365 | 435 | ([StringEntry(gameId, newGameData), decreaseReservedAmount(gameId, assetIdx, winAmount)] ++ (if (playerWin) | |
366 | 436 | then [ScriptTransfer(playerAddress, winAmount, assetIdFromStr(ASSETS[assetIdx]))] | |
367 | - | else | |
437 | + | else nil)) | |
368 | 438 | } | |
369 | 439 | } | |
370 | 440 | ||
371 | 441 | ||
372 | 442 | @Verifier(tx) | |
373 | 443 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
374 | 444 | then match tx { | |
375 | 445 | case ttx: TransferTransaction => | |
376 | 446 | let assetIdx = validateAndGetAssetIdx(assetIdToStr(ttx.assetId)) | |
377 | 447 | ((getAssetBalance(ttx.assetId) - ttx.amount) >= getIntOr(keyReservationByAssetIdx(assetIdx), 0)) | |
378 | 448 | case stx: SetScriptTransaction => | |
379 | 449 | func checker (acc,asset) = if (acc) | |
380 | 450 | then (getIntOr(keyReservationByAssetStr(asset), 0) == 0) | |
381 | 451 | else false | |
382 | 452 | ||
383 | 453 | let $l = ASSETS | |
384 | 454 | let $s = size($l) | |
385 | 455 | let $acc0 = true | |
386 | 456 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
387 | 457 | then $a | |
388 | 458 | else checker($a, $l[$i]) | |
389 | 459 | ||
390 | 460 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
391 | 461 | then $a | |
392 | 462 | else throw("List size exceeds 10") | |
393 | 463 | ||
394 | 464 | $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) | |
465 | + | case itx: InvokeScriptTransaction => | |
466 | + | if ((itx.dApp == this)) | |
467 | + | then (itx.function == "constructorV1") | |
468 | + | else false | |
395 | 469 | case _ => | |
396 | 470 | false | |
397 | 471 | } | |
398 | 472 | else false | |
399 | 473 |
github/deemru/w8io/169f3d6 62.28 ms ◑