tx · Gb1METas8sCSMMZjfEWKYCAEMhmCLotbQmPmcWTT9jZB 3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE: -0.01400000 Waves 2019.09.08 08:53 [666713] smart account 3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE > SELF 0.00000000 Waves
{ "type": 13, "id": "Gb1METas8sCSMMZjfEWKYCAEMhmCLotbQmPmcWTT9jZB", "fee": 1400000, "feeAssetId": null, "timestamp": 1567922077895, "version": 1, "sender": "3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE", "senderPublicKey": "ESNVczQiY4oxY2hoRSZcruKNBwsPdXVu1nSCbpprDGJB", "proofs": [ "pgRuktLa6qY2qQiTc3qEudM3mnizYXrJjV7Y2kHaMsvTqEHy1uwTwQFyaF1Tccg27yUsYq1VzS1KuzgeuP3HABY" ], "script": "base64:AAIDAAAAAAAAAAAAAAAPAAAAAA9TZXJ2ZXJQdWJsaWNLZXkJAAJZAAAAAQIAAAAsN2ltOWNhaUNtRTRTTDZqVG00S1RpY0hINGJHUGY1djU5cm5mVUEzY0NSRGoAAAAACUJldFNlcnZlcgkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAACMzTjZ5Rko1WjhOVVVRdmZHR01McDVlZm1ldlJSdFRnUXV1bgAAAAAHV0FWRUxFVAkAAGgAAAACCQAAaAAAAAIAAAAAAAAAAGQAAAAAAAAAA+gAAAAAAAAAA+gAAAAACkNPTU1JU1NJT04JAABpAAAAAgkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAAAAAPoAAAAAA5UaWNrZXRzUGVyV2F2ZQAAAAAAAAAAZAAAAAALQ1VSUkVOVEdBTUUCAAAADSRDVVJSRU5UX0dBTUUAAAAACkxBU1RUSUNLRVQCAAAADCRMQVNUX1RJQ0tFVAEAAAAPR2VuZXJhdGVSYW5kSW50AAAAAgAAAAZnYW1lSWQAAAAHcnNhU2lnbgQAAAAKbGFzdFRp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AAZnYW1lSWQFAAAAB3JzYVNpZ24EAAAAEHdpbm5lckFkZHJlc3NTdHIJAQAAAAxkZWZpbmVXaW5uZXIAAAACBQAAAAZnYW1lSWQFAAAACXdpblRpY2tldAQAAAAGd2luQW10CQEAAAAMZGVmaW5lV2luQW10AAAAAQUAAAAQd2lubmVyQWRkcmVzc1N0cgQAAAAFd2luVFgJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAABB3aW5uZXJBZGRyZXNzU3RyBQAAAAZ3aW5BbXQFAAAABHVuaXQFAAAAA25pbAQAAAAKZ2FtZVJlc3VsdAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAZnYW1lSWQCAAAAB19yZXN1bHQJAAGkAAAAAQUAAAAJd2luVGlja2V0CQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAABmdhbWVJZAIAAAAHX3dpbm5lcgUAAAAQd2lubmVyQWRkcmVzc1N0cgkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAZnYW1lSWQCAAAAB193aW5BbXQFAAAABndpbkFtdAUAAAADbmlsCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQUAAAAKZ2FtZVJlc3VsdAkBAAAAC1RyYW5zZmVyU2V0AAAAAQUAAAAFd2luVFgJAAACAAAAAQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAQQ3VycmVudCBHYW1lIGlzIAUAAAALY3VycmVudEdhbWUCAAAACiwgYnV0IG5vdCAFAAAABmdhbWVJZAAAAADJg0yO", "chainId": 84, "height": 666713, "spentComplexity": 0 } View: original | compacted Prev: BdcbaA9oBiVYJpP7HCLpMmnisL3mptRw2ZkBsYowHGSV Next: GPMEoeDGzmpAZ4cCpxx3DAVdRYRx4mEmVSRTUbfw3A3a Diff:
Old | New | Differences | |
---|---|---|---|
52 | 52 | func parseTicketsStr (ticketsStr) = ["1", "100", "101", "300", "0", "0", "0", "0"] | |
53 | 53 | ||
54 | 54 | ||
55 | + | func getTestTickets (player) = if ((player == "3MsD5LWNJmQkkWpj3RtaeRVrKGLgoCE7kpB")) | |
56 | + | then ["1", "100", "0", "0", "0", "0", "0", "0"] | |
57 | + | else if ((player == "3N8bMv9V4spvb9bAeRtGve5RLkVN8swFDWc")) | |
58 | + | then ["101", "300", "0", "0", "0", "0", "0", "0"] | |
59 | + | else throw("Победитель не учавствовал епт") | |
60 | + | ||
61 | + | ||
55 | 62 | func isWinner (gameId,player,winTicket) = { | |
56 | - | let tickets = | |
63 | + | let tickets = getTestTickets(player) | |
57 | 64 | if (if ((winTicket >= parseIntValue(tickets[0]))) | |
58 | 65 | then (parseIntValue(tickets[1]) >= winTicket) | |
59 | 66 | else false) | |
99 | 106 | then { | |
100 | 107 | let rsaSign = fromBase58String(rsaSignCrypted) | |
101 | 108 | let winTicket = GenerateRandInt(gameId, rsaSign) | |
102 | - | let winnerAddressStr = | |
109 | + | let winnerAddressStr = defineWinner(gameId, winTicket) | |
103 | 110 | let winAmt = defineWinAmt(winnerAddressStr) | |
104 | 111 | let winTX = [ScriptTransfer(addressFromStringValue(winnerAddressStr), winAmt, unit)] | |
105 | 112 | let gameResult = [DataEntry((gameId + "_result"), toString(winTicket)), DataEntry((gameId + "_winner"), winnerAddressStr), DataEntry((gameId + "_winAmt"), winAmt)] |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ServerPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj") | |
5 | 5 | ||
6 | 6 | let BetServer = addressFromStringValue("3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun") | |
7 | 7 | ||
8 | 8 | let WAVELET = ((100 * 1000) * 1000) | |
9 | 9 | ||
10 | 10 | let COMMISSION = ((5 * WAVELET) / 1000) | |
11 | 11 | ||
12 | 12 | let TicketsPerWave = 100 | |
13 | 13 | ||
14 | 14 | let CURRENTGAME = "$CURRENT_GAME" | |
15 | 15 | ||
16 | 16 | let LASTTICKET = "$LAST_TICKET" | |
17 | 17 | ||
18 | 18 | func GenerateRandInt (gameId,rsaSign) = { | |
19 | 19 | let lastTicket = getIntegerValue(BetServer, LASTTICKET) | |
20 | 20 | let rsaSigValid = sigVerify(toBytes(gameId), rsaSign, ServerPublicKey) | |
21 | 21 | if (rsaSigValid) | |
22 | 22 | then { | |
23 | 23 | let rand = (toInt(sha256(rsaSign)) % lastTicket) | |
24 | 24 | if ((0 > rand)) | |
25 | 25 | then ((-1 * rand) + 1) | |
26 | 26 | else (rand + 1) | |
27 | 27 | } | |
28 | 28 | else throw("Invalid RSA signature") | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func getPlayersTickets (gameId,player) = { | |
33 | 33 | let ticketsStr = (((gameId + "_") + player) + "_tickets") | |
34 | 34 | getStringValue(BetServer, ticketsStr) | |
35 | 35 | } | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func ParseNextAttribute (remaining) = { | |
39 | 39 | let s = size(remaining) | |
40 | 40 | if ((s > 0)) | |
41 | 41 | then { | |
42 | 42 | let nn = parseIntValue(take(remaining, 2)) | |
43 | 43 | let v = take(drop(remaining, 2), nn) | |
44 | 44 | let tmpRemaining = drop(remaining, (nn + 2)) | |
45 | 45 | let remainingState = tmpRemaining | |
46 | 46 | [v, remainingState] | |
47 | 47 | } | |
48 | 48 | else throw("Empty string was passed into parseNextAttribute func") | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func parseTicketsStr (ticketsStr) = ["1", "100", "101", "300", "0", "0", "0", "0"] | |
53 | 53 | ||
54 | 54 | ||
55 | + | func getTestTickets (player) = if ((player == "3MsD5LWNJmQkkWpj3RtaeRVrKGLgoCE7kpB")) | |
56 | + | then ["1", "100", "0", "0", "0", "0", "0", "0"] | |
57 | + | else if ((player == "3N8bMv9V4spvb9bAeRtGve5RLkVN8swFDWc")) | |
58 | + | then ["101", "300", "0", "0", "0", "0", "0", "0"] | |
59 | + | else throw("Победитель не учавствовал епт") | |
60 | + | ||
61 | + | ||
55 | 62 | func isWinner (gameId,player,winTicket) = { | |
56 | - | let tickets = | |
63 | + | let tickets = getTestTickets(player) | |
57 | 64 | if (if ((winTicket >= parseIntValue(tickets[0]))) | |
58 | 65 | then (parseIntValue(tickets[1]) >= winTicket) | |
59 | 66 | else false) | |
60 | 67 | then true | |
61 | 68 | else if (if ((winTicket >= parseIntValue(tickets[2]))) | |
62 | 69 | then (parseIntValue(tickets[3]) >= winTicket) | |
63 | 70 | else false) | |
64 | 71 | then true | |
65 | 72 | else if (if ((winTicket >= parseIntValue(tickets[4]))) | |
66 | 73 | then (parseIntValue(tickets[5]) >= winTicket) | |
67 | 74 | else false) | |
68 | 75 | then true | |
69 | 76 | else if (if ((winTicket >= parseIntValue(tickets[6]))) | |
70 | 77 | then (parseIntValue(tickets[7]) >= winTicket) | |
71 | 78 | else false) | |
72 | 79 | then true | |
73 | 80 | else false | |
74 | 81 | } | |
75 | 82 | ||
76 | 83 | ||
77 | 84 | func defineWinner (gameId,winTicket) = { | |
78 | 85 | let players = getStringValue(BetServer, (gameId + "_players")) | |
79 | 86 | let playersList = split(players, "_") | |
80 | 87 | if (isWinner(gameId, playersList[0], winTicket)) | |
81 | 88 | then playersList[0] | |
82 | 89 | else if (isWinner(gameId, playersList[1], winTicket)) | |
83 | 90 | then playersList[1] | |
84 | 91 | else if (isWinner(gameId, playersList[2], winTicket)) | |
85 | 92 | then playersList[2] | |
86 | 93 | else if (isWinner(gameId, playersList[3], winTicket)) | |
87 | 94 | then playersList[3] | |
88 | 95 | else throw("Error with defining winner") | |
89 | 96 | } | |
90 | 97 | ||
91 | 98 | ||
92 | 99 | func defineWinAmt (winnerAddressStr) = (1 * WAVELET) | |
93 | 100 | ||
94 | 101 | ||
95 | 102 | @Callable(i) | |
96 | 103 | func generateResult (gameId,rsaSignCrypted) = { | |
97 | 104 | let currentGame = getStringValue(BetServer, CURRENTGAME) | |
98 | 105 | if ((currentGame == gameId)) | |
99 | 106 | then { | |
100 | 107 | let rsaSign = fromBase58String(rsaSignCrypted) | |
101 | 108 | let winTicket = GenerateRandInt(gameId, rsaSign) | |
102 | - | let winnerAddressStr = | |
109 | + | let winnerAddressStr = defineWinner(gameId, winTicket) | |
103 | 110 | let winAmt = defineWinAmt(winnerAddressStr) | |
104 | 111 | let winTX = [ScriptTransfer(addressFromStringValue(winnerAddressStr), winAmt, unit)] | |
105 | 112 | let gameResult = [DataEntry((gameId + "_result"), toString(winTicket)), DataEntry((gameId + "_winner"), winnerAddressStr), DataEntry((gameId + "_winAmt"), winAmt)] | |
106 | 113 | ScriptResult(WriteSet(gameResult), TransferSet(winTX)) | |
107 | 114 | } | |
108 | 115 | else throw(((("Current Game is " + currentGame) + ", but not ") + gameId)) | |
109 | 116 | } | |
110 | 117 | ||
111 | 118 |
github/deemru/w8io/169f3d6 24.69 ms ◑