tx · 9pLz7eev4hTAbL6UederunZSrj6zHEg8pMaFjVMmHDXz 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs: -0.01400000 Waves 2019.09.07 03:55 [664963] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves
{ "type": 13, "id": "9pLz7eev4hTAbL6UederunZSrj6zHEg8pMaFjVMmHDXz", "fee": 1400000, "feeAssetId": null, "timestamp": 1567817706403, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "4fJFttL4imVj811i7fgqk9knB9qiTTaP3H11w54m4j64qhYNvx5CmgFQn8vfZfCfk5872qjGBoUdZC1CPdJsxuwV" ], "script": "base64:AAIDAAAAAAAAAAAAAAALAAAAAAdXQVZFTEVUCQAAaAAAAAIJAABoAAAAAgAAAAAAAAAAZAAAAAAAAAAD6AAAAAAAAAAD6AAAAAAKQ09NTUlTU0lPTgkAAGkAAAACCQAAaAAAAAIAAAAAAAAAAAUFAAAAB1dBVkVMRVQAAAAAAAAAA+gAAAAADlRpY2tldHNQZXJXYXZlAAAAAAAAAABkAAAAAAtDVVJSRU5UR0FNRQIAAAANJENVUlJFTlRfR0FNRQAAAAAPR0FNRVNDT1VOVEVSS0VZAgAAAAkkR0FNRV9OVU0AAAAACkxBU1RUSUNLRVQCAAAADCRMQVNUX1RJQ0tFVAEAAAAOZ2V0UGxheWVyc0xpc3QAAAACAAAABmdhbWVJZAAAAA1jdXJyZW50UGxheWVyBAAAABBwbGF5ZXJzUHJlc2VudGVkCQEAAAAJaXNEZWZpbmVkAAAAAQkABB0AAAACBQAAAAR0aGlzCQABLAAAAAIFAAAABmdhbWVJZAIAAAAIX3BsYXllcnMDCQEAAAABIQAAAAEFAAAAEHBsYXllcnNQcmVzZW50ZWQFAAAADWN1cnJlbnRQbGF5ZXIDCQ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JAAACAAAAAQIAAAAiVHJhbnNhY3Rpb24ncyBmZWUgbXVzdCBiZSBpbiBXYXZlcwQAAAAQcGxheWVyQWRkcmVzc1N0cgkABCUAAAABBQAAAA1wbGF5ZXJBZGRyZXNzBAAAAAdiZXREYXRhCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAtDVVJSRU5UR0FNRQUAAAAGZ2FtZUlkCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAA9HQU1FU0NPVU5URVJLRVkFAAAAB2dhbWVOdW0JAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIFAAAABmdhbWVJZAIAAAABXwUAAAAQcGxheWVyQWRkcmVzc1N0cgIAAAAIX3RpY2tldHMJAQAAAApnZXRUaWNrZXRzAAAAAwUAAAAGZ2FtZUlkBQAAABBwbGF5ZXJBZGRyZXNzU3RyCAUAAAADcG10AAAABmFtb3VudAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAZnYW1lSWQCAAAACF9wbGF5ZXJzCQEAAAAOZ2V0UGxheWVyc0xpc3QAAAACBQAAAAZnYW1lSWQFAAAAEHBsYXllckFkZHJlc3NTdHIFAAAAA25pbAkBAAAACFdyaXRlU2V0AAAAAQUAAAAHYmV0RGF0YQAAAACHZ1/t", "chainId": 84, "height": 664963, "spentComplexity": 0 } View: original | compacted Prev: 9pAnbzNCLGuURtfJX6wFQU47v6Pp24hYbU1EtHRbohjw Next: JBR3Ab46RRb7MWoEStof8mBaJAqHDJVY17wDZYUkWCwK Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let ServerBetPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj") | |
5 | - | ||
6 | 4 | let WAVELET = ((100 * 1000) * 1000) | |
7 | 5 | ||
8 | 6 | let COMMISSION = ((5 * WAVELET) / 1000) | |
16 | 14 | let LASTTICKET = "$LAST_TICKET" | |
17 | 15 | ||
18 | 16 | func getPlayersList (gameId,currentPlayer) = { | |
19 | - | let playersPresented = isDefined( | |
17 | + | let playersPresented = isDefined(getString(this, (gameId + "_players"))) | |
20 | 18 | if (!(playersPresented)) | |
21 | 19 | then currentPlayer | |
22 | - | else if (isDefined( | |
20 | + | else if (isDefined(getString(this, (((gameId + "_") + currentPlayer) + "_tickets")))) | |
23 | 21 | then getStringValue(this, (gameId + "_players")) | |
24 | 22 | else ((getStringValue(this, (gameId + "_players")) + "_") + currentPlayer) | |
25 | 23 | } | |
26 | 24 | ||
27 | 25 | ||
28 | - | func getTickets (paymentAmt) = { | |
26 | + | func FormatGameDataParam (p) = { | |
27 | + | let s = size(p) | |
28 | + | if ((s == 0)) | |
29 | + | then throw("Parameter size must be greater then 0") | |
30 | + | else if ((s > 99)) | |
31 | + | then throw("Parameter size must be less then 100") | |
32 | + | else if ((10 > s)) | |
33 | + | then (("0" + toString(s)) + p) | |
34 | + | else (toString(s) + p) | |
35 | + | } | |
36 | + | ||
37 | + | ||
38 | + | func getTickets (gameId,playerAddressStr,paymentAmt) = { | |
29 | 39 | let lastTicket = getIntegerValue(this, LASTTICKET) | |
30 | 40 | let wavesPayment = (paymentAmt / WAVELET) | |
31 | - | let tickets = "011_03100__03101_03300__010_010__010_010__010_010" | |
32 | - | tickets | |
41 | + | let firstNewTicket = (lastTicket + 1) | |
42 | + | let lastNewTicket = (firstNewTicket + (wavesPayment * TicketsPerWave)) | |
43 | + | let newTickets = ((FormatGameDataParam(toString(firstNewTicket)) + "_") + FormatGameDataParam(toString(lastNewTicket))) | |
44 | + | let ticketsStr = isDefined(getString(this, (((gameId + "_") + playerAddressStr) + "_tickets"))) | |
45 | + | if (ticketsStr) | |
46 | + | then { | |
47 | + | let currentTickets = getStringValue(this, (((gameId + "_") + playerAddressStr) + "_tickets")) | |
48 | + | ((currentTickets + " ") + newTickets) | |
49 | + | } | |
50 | + | else newTickets | |
33 | 51 | } | |
34 | 52 | ||
35 | 53 | ||
71 | 89 | then throw("Transaction's fee must be in Waves") | |
72 | 90 | else { | |
73 | 91 | let playerAddressStr = toString(playerAddress) | |
74 | - | let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), getTickets(pmt.amount)), DataEntry((gameId + "_players"), getPlayersList(gameId, playerAddressStr))] | |
92 | + | let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), getTickets(gameId, playerAddressStr, pmt.amount)), DataEntry((gameId + "_players"), getPlayersList(gameId, playerAddressStr))] | |
75 | 93 | WriteSet(betData) | |
76 | 94 | } | |
77 | 95 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let ServerBetPublicKey = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj") | |
5 | - | ||
6 | 4 | let WAVELET = ((100 * 1000) * 1000) | |
7 | 5 | ||
8 | 6 | let COMMISSION = ((5 * WAVELET) / 1000) | |
9 | 7 | ||
10 | 8 | let TicketsPerWave = 100 | |
11 | 9 | ||
12 | 10 | let CURRENTGAME = "$CURRENT_GAME" | |
13 | 11 | ||
14 | 12 | let GAMESCOUNTERKEY = "$GAME_NUM" | |
15 | 13 | ||
16 | 14 | let LASTTICKET = "$LAST_TICKET" | |
17 | 15 | ||
18 | 16 | func getPlayersList (gameId,currentPlayer) = { | |
19 | - | let playersPresented = isDefined( | |
17 | + | let playersPresented = isDefined(getString(this, (gameId + "_players"))) | |
20 | 18 | if (!(playersPresented)) | |
21 | 19 | then currentPlayer | |
22 | - | else if (isDefined( | |
20 | + | else if (isDefined(getString(this, (((gameId + "_") + currentPlayer) + "_tickets")))) | |
23 | 21 | then getStringValue(this, (gameId + "_players")) | |
24 | 22 | else ((getStringValue(this, (gameId + "_players")) + "_") + currentPlayer) | |
25 | 23 | } | |
26 | 24 | ||
27 | 25 | ||
28 | - | func getTickets (paymentAmt) = { | |
26 | + | func FormatGameDataParam (p) = { | |
27 | + | let s = size(p) | |
28 | + | if ((s == 0)) | |
29 | + | then throw("Parameter size must be greater then 0") | |
30 | + | else if ((s > 99)) | |
31 | + | then throw("Parameter size must be less then 100") | |
32 | + | else if ((10 > s)) | |
33 | + | then (("0" + toString(s)) + p) | |
34 | + | else (toString(s) + p) | |
35 | + | } | |
36 | + | ||
37 | + | ||
38 | + | func getTickets (gameId,playerAddressStr,paymentAmt) = { | |
29 | 39 | let lastTicket = getIntegerValue(this, LASTTICKET) | |
30 | 40 | let wavesPayment = (paymentAmt / WAVELET) | |
31 | - | let tickets = "011_03100__03101_03300__010_010__010_010__010_010" | |
32 | - | tickets | |
41 | + | let firstNewTicket = (lastTicket + 1) | |
42 | + | let lastNewTicket = (firstNewTicket + (wavesPayment * TicketsPerWave)) | |
43 | + | let newTickets = ((FormatGameDataParam(toString(firstNewTicket)) + "_") + FormatGameDataParam(toString(lastNewTicket))) | |
44 | + | let ticketsStr = isDefined(getString(this, (((gameId + "_") + playerAddressStr) + "_tickets"))) | |
45 | + | if (ticketsStr) | |
46 | + | then { | |
47 | + | let currentTickets = getStringValue(this, (((gameId + "_") + playerAddressStr) + "_tickets")) | |
48 | + | ((currentTickets + " ") + newTickets) | |
49 | + | } | |
50 | + | else newTickets | |
33 | 51 | } | |
34 | 52 | ||
35 | 53 | ||
36 | 54 | func IncrementGameNum (gameId,txId) = if ((gameId == txId)) | |
37 | 55 | then { | |
38 | 56 | let gameNum = match getInteger(this, GAMESCOUNTERKEY) { | |
39 | 57 | case num: Int => | |
40 | 58 | num | |
41 | 59 | case _ => | |
42 | 60 | 0 | |
43 | 61 | } | |
44 | 62 | toString((gameNum + 1)) | |
45 | 63 | } | |
46 | 64 | else toString(getIntegerValue(this, GAMESCOUNTERKEY)) | |
47 | 65 | ||
48 | 66 | ||
49 | 67 | func getCurrentGame (txId) = { | |
50 | 68 | let gameId = getStringValue(this, CURRENTGAME) | |
51 | 69 | let gameStillOpen = isDefined(getString(this, (gameId + "_result"))) | |
52 | 70 | if (gameStillOpen) | |
53 | 71 | then gameId | |
54 | 72 | else txId | |
55 | 73 | } | |
56 | 74 | ||
57 | 75 | ||
58 | 76 | @Callable(i) | |
59 | 77 | func bet () = { | |
60 | 78 | let txId = toBase58String(i.transactionId) | |
61 | 79 | let gameId = getCurrentGame(txId) | |
62 | 80 | let gameNum = IncrementGameNum(gameId, txId) | |
63 | 81 | let pmt = extract(i.payment) | |
64 | 82 | let betNotInWaves = isDefined(pmt.assetId) | |
65 | 83 | let feeNotInWaves = isDefined(pmt.assetId) | |
66 | 84 | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
67 | 85 | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
68 | 86 | if (betNotInWaves) | |
69 | 87 | then throw("Bet amount must be in Waves") | |
70 | 88 | else if (feeNotInWaves) | |
71 | 89 | then throw("Transaction's fee must be in Waves") | |
72 | 90 | else { | |
73 | 91 | let playerAddressStr = toString(playerAddress) | |
74 | - | let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), getTickets(pmt.amount)), DataEntry((gameId + "_players"), getPlayersList(gameId, playerAddressStr))] | |
92 | + | let betData = [DataEntry(CURRENTGAME, gameId), DataEntry(GAMESCOUNTERKEY, gameNum), DataEntry((((gameId + "_") + playerAddressStr) + "_tickets"), getTickets(gameId, playerAddressStr, pmt.amount)), DataEntry((gameId + "_players"), getPlayersList(gameId, playerAddressStr))] | |
75 | 93 | WriteSet(betData) | |
76 | 94 | } | |
77 | 95 | } | |
78 | 96 | ||
79 | 97 |
github/deemru/w8io/026f985 37.61 ms ◑