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