tx · GPMEoeDGzmpAZ4cCpxx3DAVdRYRx4mEmVSRTUbfw3A3a

3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE:  -0.01400000 Waves

2019.09.08 11:11 [666843] smart account 3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE > SELF 0.00000000 Waves

{ "type": 13, "id": "GPMEoeDGzmpAZ4cCpxx3DAVdRYRx4mEmVSRTUbfw3A3a", "fee": 1400000, "feeAssetId": null, "timestamp": 1567930268717, "version": 1, "sender": "3N9XnyPpWxYohKH7z5dEuq8rpnobpyzPrzE", "senderPublicKey": "ESNVczQiY4oxY2hoRSZcruKNBwsPdXVu1nSCbpprDGJB", "proofs": [ "5aLHTjPRghJKnkQhUa92NXQcoqSi3VpfPL3UJTj3w9VSFS5jWs6j5n7nwrJbcbZkCBLLfnjyuXRp5RSGiMS9YNvP" ], "script": "base64:AAIDAAAAAAAAAAAAAAAKAAAAAA9TZXJ2ZXJQdWJsaWNLZXkJAAJZAAAAAQIAAAAsN2ltOWNhaUNtRTRTTDZqVG00S1RpY0hINGJHUGY1djU5cm5mVUEzY0NSRGoAAAAACUJldFNlcnZlcgkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAACMzTjZ5Rko1WjhOVVVRdmZHR01McDVlZm1ldlJSdFRnUXV1bgAAAAAHV0FWRUxFVAkAAGgAAAACCQAAaAAAAAIAAAAAAAAAAGQAAAAAAAAAA+gAAAAAAAAAA+gAAAAACkNPTU1JU1NJT04JAABpAAAAAgkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAAAAAPoAAAAAA5UaWNrZXRzUGVyV2F2ZQAAAAAAAAAAZAAAAAALQ1VSUkVOVEdBTUUCAAAADSRDVVJSRU5UX0dBTUUAAAAACkxBU1RUSUNLRVQCAAAADCRMQVNUX1RJQ0tFVAEAAAAPR2VuZXJhdGVSYW5kSW50AAAAAgAAAAZnYW1lSWQAAAAHcnNhU2lnbgQA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ABAkAAAIAAAABAgAAAAVFcnJvcgkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABBDdXJyZW50IEdhbWUgaXMgBQAAAAtjdXJyZW50R2FtZQIAAAAKLCBidXQgbm90IAUAAAAGZ2FtZUlkAAAAAHno5F8=", "chainId": 84, "height": 666843, "spentComplexity": 0 } View: original | compacted Prev: Gb1METas8sCSMMZjfEWKYCAEMhmCLotbQmPmcWTT9jZB Next: 4j8FQcv5Vib3a7s3y8M1L3pjMA85ULsFqCtSCfCbspnS Diff:
OldNewDifferences
2929 }
3030
3131
32-func getPlayersTickets (gameId,player) = {
33- let ticketsStr = (((gameId + "_") + player) + "_tickets")
34- getStringValue(BetServer, ticketsStr)
35- }
36-
37-
38-func ParseNextAttribute (remaining) = {
39- let s = size(remaining)
40- if ((s > 0))
41- then {
42- let nn = parseIntValue(take(remaining, 2))
43- let v = take(drop(remaining, 2), nn)
44- let tmpRemaining = drop(remaining, (nn + 2))
45- let remainingState = tmpRemaining
46-[v, remainingState]
47- }
48- else throw("Empty string was passed into parseNextAttribute func")
49- }
50-
51-
52-func parseTicketsStr (ticketsStr) = ["1", "100", "101", "300", "0", "0", "0", "0"]
53-
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-
62-func isWinner (gameId,player,winTicket) = {
63- let tickets = getTestTickets(player)
32+func isWinner (ticketsStr,winTicket) = {
33+ let tickets = split(ticketsStr, "_")
6434 if (if ((winTicket >= parseIntValue(tickets[0])))
6535 then (parseIntValue(tickets[1]) >= winTicket)
6636 else false)
8151 }
8252
8353
84-func defineWinner (gameId,winTicket) = {
85- let players = getStringValue(BetServer, (gameId + "_players"))
86- let playersList = split(players, "_")
87- if (isWinner(gameId, playersList[0], winTicket))
88- then playersList[0]
89- else if (isWinner(gameId, playersList[1], winTicket))
90- then playersList[1]
91- else if (isWinner(gameId, playersList[2], winTicket))
92- then playersList[2]
93- else if (isWinner(gameId, playersList[3], winTicket))
94- then playersList[3]
95- else throw("Error with defining winner")
54+func win (gameId,winTicket,winnerAddressStr) = {
55+ let winAmt = getIntegerValue(BetServer, (((gameId + "_") + winnerAddressStr) + "_bank"))
56+ let winTX = [ScriptTransfer(addressFromStringValue(winnerAddressStr), winAmt, unit)]
57+ let gameResult = [DataEntry((gameId + "_result"), toString(winTicket)), DataEntry((gameId + "_winner"), winnerAddressStr), DataEntry((gameId + "_winAmt"), winAmt)]
58+ ScriptResult(WriteSet(gameResult), TransferSet(winTX))
9659 }
97-
98-
99-func defineWinAmt (winnerAddressStr) = (1 * WAVELET)
10060
10161
10262 @Callable(i)
10666 then {
10767 let rsaSign = fromBase58String(rsaSignCrypted)
10868 let winTicket = GenerateRandInt(gameId, rsaSign)
109- let winnerAddressStr = defineWinner(gameId, winTicket)
110- let winAmt = defineWinAmt(winnerAddressStr)
111- let winTX = [ScriptTransfer(addressFromStringValue(winnerAddressStr), winAmt, unit)]
112- let gameResult = [DataEntry((gameId + "_result"), toString(winTicket)), DataEntry((gameId + "_winner"), winnerAddressStr), DataEntry((gameId + "_winAmt"), winAmt)]
113- ScriptResult(WriteSet(gameResult), TransferSet(winTX))
69+ let players = getStringValue(BetServer, (gameId + "_players"))
70+ let playersList = split(players, "_")
71+ if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[0]) + "_tickets")), winTicket))
72+ then win(gameId, winTicket, playersList[0])
73+ else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[1]) + "_tickets")), winTicket))
74+ then win(gameId, winTicket, playersList[1])
75+ else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[2]) + "_tickets")), winTicket))
76+ then win(gameId, winTicket, playersList[2])
77+ else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[3]) + "_tickets")), winTicket))
78+ then win(gameId, winTicket, playersList[3])
79+ else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[4]) + "_tickets")), winTicket))
80+ then win(gameId, winTicket, playersList[4])
81+ else throw("Error")
11482 }
11583 else throw(((("Current Game is " + currentGame) + ", but not ") + gameId))
11684 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let ServerPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj")
55
66 let BetServer = addressFromStringValue("3N6yFJ5Z8NUUQvfGGMLp5efmevRRtTgQuun")
77
88 let WAVELET = ((100 * 1000) * 1000)
99
1010 let COMMISSION = ((5 * WAVELET) / 1000)
1111
1212 let TicketsPerWave = 100
1313
1414 let CURRENTGAME = "$CURRENT_GAME"
1515
1616 let LASTTICKET = "$LAST_TICKET"
1717
1818 func GenerateRandInt (gameId,rsaSign) = {
1919 let lastTicket = getIntegerValue(BetServer, LASTTICKET)
2020 let rsaSigValid = sigVerify(toBytes(gameId), rsaSign, ServerPublicKey)
2121 if (rsaSigValid)
2222 then {
2323 let rand = (toInt(sha256(rsaSign)) % lastTicket)
2424 if ((0 > rand))
2525 then ((-1 * rand) + 1)
2626 else (rand + 1)
2727 }
2828 else throw("Invalid RSA signature")
2929 }
3030
3131
32-func getPlayersTickets (gameId,player) = {
33- let ticketsStr = (((gameId + "_") + player) + "_tickets")
34- getStringValue(BetServer, ticketsStr)
35- }
36-
37-
38-func ParseNextAttribute (remaining) = {
39- let s = size(remaining)
40- if ((s > 0))
41- then {
42- let nn = parseIntValue(take(remaining, 2))
43- let v = take(drop(remaining, 2), nn)
44- let tmpRemaining = drop(remaining, (nn + 2))
45- let remainingState = tmpRemaining
46-[v, remainingState]
47- }
48- else throw("Empty string was passed into parseNextAttribute func")
49- }
50-
51-
52-func parseTicketsStr (ticketsStr) = ["1", "100", "101", "300", "0", "0", "0", "0"]
53-
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-
62-func isWinner (gameId,player,winTicket) = {
63- let tickets = getTestTickets(player)
32+func isWinner (ticketsStr,winTicket) = {
33+ let tickets = split(ticketsStr, "_")
6434 if (if ((winTicket >= parseIntValue(tickets[0])))
6535 then (parseIntValue(tickets[1]) >= winTicket)
6636 else false)
6737 then true
6838 else if (if ((winTicket >= parseIntValue(tickets[2])))
6939 then (parseIntValue(tickets[3]) >= winTicket)
7040 else false)
7141 then true
7242 else if (if ((winTicket >= parseIntValue(tickets[4])))
7343 then (parseIntValue(tickets[5]) >= winTicket)
7444 else false)
7545 then true
7646 else if (if ((winTicket >= parseIntValue(tickets[6])))
7747 then (parseIntValue(tickets[7]) >= winTicket)
7848 else false)
7949 then true
8050 else false
8151 }
8252
8353
84-func defineWinner (gameId,winTicket) = {
85- let players = getStringValue(BetServer, (gameId + "_players"))
86- let playersList = split(players, "_")
87- if (isWinner(gameId, playersList[0], winTicket))
88- then playersList[0]
89- else if (isWinner(gameId, playersList[1], winTicket))
90- then playersList[1]
91- else if (isWinner(gameId, playersList[2], winTicket))
92- then playersList[2]
93- else if (isWinner(gameId, playersList[3], winTicket))
94- then playersList[3]
95- else throw("Error with defining winner")
54+func win (gameId,winTicket,winnerAddressStr) = {
55+ let winAmt = getIntegerValue(BetServer, (((gameId + "_") + winnerAddressStr) + "_bank"))
56+ let winTX = [ScriptTransfer(addressFromStringValue(winnerAddressStr), winAmt, unit)]
57+ let gameResult = [DataEntry((gameId + "_result"), toString(winTicket)), DataEntry((gameId + "_winner"), winnerAddressStr), DataEntry((gameId + "_winAmt"), winAmt)]
58+ ScriptResult(WriteSet(gameResult), TransferSet(winTX))
9659 }
97-
98-
99-func defineWinAmt (winnerAddressStr) = (1 * WAVELET)
10060
10161
10262 @Callable(i)
10363 func generateResult (gameId,rsaSignCrypted) = {
10464 let currentGame = getStringValue(BetServer, CURRENTGAME)
10565 if ((currentGame == gameId))
10666 then {
10767 let rsaSign = fromBase58String(rsaSignCrypted)
10868 let winTicket = GenerateRandInt(gameId, rsaSign)
109- let winnerAddressStr = defineWinner(gameId, winTicket)
110- let winAmt = defineWinAmt(winnerAddressStr)
111- let winTX = [ScriptTransfer(addressFromStringValue(winnerAddressStr), winAmt, unit)]
112- let gameResult = [DataEntry((gameId + "_result"), toString(winTicket)), DataEntry((gameId + "_winner"), winnerAddressStr), DataEntry((gameId + "_winAmt"), winAmt)]
113- ScriptResult(WriteSet(gameResult), TransferSet(winTX))
69+ let players = getStringValue(BetServer, (gameId + "_players"))
70+ let playersList = split(players, "_")
71+ if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[0]) + "_tickets")), winTicket))
72+ then win(gameId, winTicket, playersList[0])
73+ else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[1]) + "_tickets")), winTicket))
74+ then win(gameId, winTicket, playersList[1])
75+ else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[2]) + "_tickets")), winTicket))
76+ then win(gameId, winTicket, playersList[2])
77+ else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[3]) + "_tickets")), winTicket))
78+ then win(gameId, winTicket, playersList[3])
79+ else if (isWinner(getStringValue(BetServer, (((gameId + "_") + playersList[4]) + "_tickets")), winTicket))
80+ then win(gameId, winTicket, playersList[4])
81+ else throw("Error")
11482 }
11583 else throw(((("Current Game is " + currentGame) + ", but not ") + gameId))
11684 }
11785
11886

github/deemru/w8io/169f3d6 
26.37 ms