tx · 444cQjJ4rjJTwfZyY7RACgdndZhJY8UExxjrHAvvfANz 3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2: -0.01400000 Waves 2019.08.12 15:20 [627834] smart account 3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2 > SELF 0.00000000 Waves
{ "type": 13, "id": "444cQjJ4rjJTwfZyY7RACgdndZhJY8UExxjrHAvvfANz", "fee": 1400000, "feeAssetId": null, "timestamp": 1565612433113, "version": 1, "sender": "3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2", "senderPublicKey": "F3vhYapU4NBzfM2X4KNkoFcxj3UbYnJjqituG6KE7ZPG", "proofs": [ "3WHYm2ur881kw7eoN1Ldmpnqvjyq6X7tPHPtdKeauKEmyGaHPh1BpNLyusw7a1AfaFEL6f6HqnPcAqK9yPxph1oB" ], "script": "base64:AAIDAAAAAAAAAAAAAAAJAAAAAAdSVU5OSU5HAgAAAAdSVU5OSU5HAAAAAAZDTE9TRUQCAAAABkNMT1NFRAAAAAAJREFQUE9XTkVSAgAAACMzTjROUGl2b1RodHNrcjdKeG5OcktMN3M4QnptUkd4OXJUMgAAAAAFV0FWRVMCAAAABVdBVkVTAAAAAAROT05FAgAAAAROT05FAQAAAAtnZXROdW1CeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAEGdldENvbnRlc3RTdGF0dXMAAAAABA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QGCQEAAAACIT0AAAACCAUAAAADcG10AAAABmFtb3VudAAAAAAAAAehIAkAAAIAAAABAgAAABpZb3UgbXVzdCBwYXkgNSBXTFQgdG8gYmV0LgMJAQAAAAIhPQAAAAIJAQAAAAZnZXRCZXQAAAABBQAAAA1jdXJyZW5jeVZhbHVlBQAAAAROT05FCQAAAgAAAAECAAAAIlNvbWVvbmUgYWxyZWFkeSBiZXQgb24gdGhpcyB2YWx1ZS4JAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAABGJldF8JAAGkAAAAAQUAAAARY29udGVzdEN1cnJOdW1iZXICAAAAAV8FAAAADWN1cnJlbmN5VmFsdWUFAAAAB2FjY291bnQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAByRtYXRjaDAFAAAAAnR4AwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24GCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBgbgYxE5", "chainId": 84, "height": 627834, "spentComplexity": 0 } View: original | compacted Prev: GHpH2Pr3BzzUUeagvePuuyKa7bv4UzohXxasNMYKjQzC Next: 3GeV3g3qiPq4QuRpVgjWVX36BrRX2PjEajTKZQfyRvBu Diff:
Old | New | Differences | |
---|---|---|---|
36 | 36 | func getContestStatus () = { | |
37 | 37 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
38 | 38 | getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
39 | + | } | |
40 | + | ||
41 | + | ||
42 | + | func getBet (currencyValue) = { | |
43 | + | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
44 | + | getStrByKey(((("contest_" + toString(contestCurrNumber)) + "_") + currencyValue)) | |
39 | 45 | } | |
40 | 46 | ||
41 | 47 | ||
92 | 98 | then true | |
93 | 99 | else (pmt.amount != 500000)) | |
94 | 100 | then throw("You must pay 5 WLT to bet.") | |
95 | - | else WriteSet([DataEntry(((("bet_" + toString(contestCurrNumber)) + "_") + account), currencyValue)]) | |
101 | + | else if ((getBet(currencyValue) != NONE)) | |
102 | + | then throw("Someone already bet on this value.") | |
103 | + | else WriteSet([DataEntry(((("bet_" + toString(contestCurrNumber)) + "_") + currencyValue), account)]) | |
96 | 104 | } | |
97 | 105 | ||
98 | 106 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let RUNNING = "RUNNING" | |
5 | 5 | ||
6 | 6 | let CLOSED = "CLOSED" | |
7 | 7 | ||
8 | 8 | let DAPPOWNER = "3N4NPivoThtskr7JxnNrKL7s8BzmRGx9rT2" | |
9 | 9 | ||
10 | 10 | let WAVES = "WAVES" | |
11 | 11 | ||
12 | 12 | let NONE = "NONE" | |
13 | 13 | ||
14 | 14 | func getNumByKey (key) = { | |
15 | 15 | let num = match getInteger(this, key) { | |
16 | 16 | case a: Int => | |
17 | 17 | a | |
18 | 18 | case _ => | |
19 | 19 | 0 | |
20 | 20 | } | |
21 | 21 | num | |
22 | 22 | } | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func getStrByKey (key) = { | |
26 | 26 | let str = match getString(this, key) { | |
27 | 27 | case a: String => | |
28 | 28 | a | |
29 | 29 | case _ => | |
30 | 30 | NONE | |
31 | 31 | } | |
32 | 32 | str | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getContestStatus () = { | |
37 | 37 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
38 | 38 | getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
39 | + | } | |
40 | + | ||
41 | + | ||
42 | + | func getBet (currencyValue) = { | |
43 | + | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
44 | + | getStrByKey(((("contest_" + toString(contestCurrNumber)) + "_") + currencyValue)) | |
39 | 45 | } | |
40 | 46 | ||
41 | 47 | ||
42 | 48 | @Callable(i) | |
43 | 49 | func setContestStatus (contestNumber,contestStatus) = { | |
44 | 50 | let account = toBase58String(i.caller.bytes) | |
45 | 51 | if ((account != DAPPOWNER)) | |
46 | 52 | then throw("Only dAPP Owner can set Contest Status.") | |
47 | 53 | else if (if ((contestStatus != RUNNING)) | |
48 | 54 | then (contestStatus != CLOSED) | |
49 | 55 | else false) | |
50 | 56 | then throw(("Invalid status: " + contestStatus)) | |
51 | 57 | else WriteSet([DataEntry((("contest_" + toString(contestNumber)) + "_status"), contestStatus)]) | |
52 | 58 | } | |
53 | 59 | ||
54 | 60 | ||
55 | 61 | ||
56 | 62 | @Callable(i) | |
57 | 63 | func setContestConfiguration (currencyTicker,contestStartHeight) = { | |
58 | 64 | let account = toBase58String(i.caller.bytes) | |
59 | 65 | let contestPrevNumber = getNumByKey("contest_currentnumber") | |
60 | 66 | let contestPrevStatus = getStrByKey((("contest_" + toString(contestPrevNumber)) + "_status")) | |
61 | 67 | let contestCurrNumber = (contestPrevNumber + 1) | |
62 | 68 | if ((account != DAPPOWNER)) | |
63 | 69 | then throw("Only dAPP Owner can Configure Contest.") | |
64 | 70 | else if ((height >= contestStartHeight)) | |
65 | 71 | then throw(("Start Height must be greater than current Blockchain height: " + toString(height))) | |
66 | 72 | else if ((contestPrevStatus == RUNNING)) | |
67 | 73 | then throw(("You cannot configure a new Contest while old Contest status is: " + contestPrevStatus)) | |
68 | 74 | else if ((currencyTicker != WAVES)) | |
69 | 75 | then throw((("dAPP does not support currency: " + currencyTicker) + " yet.")) | |
70 | 76 | else { | |
71 | 77 | let contestFinishHeight = (contestStartHeight + (7 * 1440)) | |
72 | 78 | WriteSet([DataEntry("contest_currentnumber", contestCurrNumber), DataEntry((("contest_" + toString(contestCurrNumber)) + "_currency"), currencyTicker), DataEntry((("contest_" + toString(contestCurrNumber)) + "_startheight"), contestStartHeight), DataEntry((("contest_" + toString(contestCurrNumber)) + "_finishheight"), contestFinishHeight), DataEntry((("contest_" + toString(contestCurrNumber)) + "_status"), RUNNING)]) | |
73 | 79 | } | |
74 | 80 | } | |
75 | 81 | ||
76 | 82 | ||
77 | 83 | ||
78 | 84 | @Callable(i) | |
79 | 85 | func bet (currencyValue) = { | |
80 | 86 | let WLT = base58'2B3mWxfnhAaCpJuqbkbiD6HVCTEcgwdmzxFCjZe65NYg' | |
81 | 87 | let account = toBase58String(i.caller.bytes) | |
82 | 88 | let pmt = extract(i.payment) | |
83 | 89 | let contestCurrNumber = getNumByKey("contest_currentnumber") | |
84 | 90 | let contestStartHeight = getNumByKey((("contest_" + toString(contestCurrNumber)) + "_startheight")) | |
85 | 91 | let contestFinishHeight = getNumByKey((("contest_" + toString(contestCurrNumber)) + "_finishheight")) | |
86 | 92 | let contestStatus = getStrByKey((("contest_" + toString(contestCurrNumber)) + "_status")) | |
87 | 93 | if ((height > (contestFinishHeight - (2 * 1440)))) | |
88 | 94 | then throw("You cannot bet anymore at this height.") | |
89 | 95 | else if ((contestStatus != RUNNING)) | |
90 | 96 | then throw("Invalid status: you cannot bet now.") | |
91 | 97 | else if (if ((pmt.assetId != WLT)) | |
92 | 98 | then true | |
93 | 99 | else (pmt.amount != 500000)) | |
94 | 100 | then throw("You must pay 5 WLT to bet.") | |
95 | - | else WriteSet([DataEntry(((("bet_" + toString(contestCurrNumber)) + "_") + account), currencyValue)]) | |
101 | + | else if ((getBet(currencyValue) != NONE)) | |
102 | + | then throw("Someone already bet on this value.") | |
103 | + | else WriteSet([DataEntry(((("bet_" + toString(contestCurrNumber)) + "_") + currencyValue), account)]) | |
96 | 104 | } | |
97 | 105 | ||
98 | 106 | ||
99 | 107 | @Verifier(tx) | |
100 | 108 | func verify () = match tx { | |
101 | 109 | case _: SetScriptTransaction|DataTransaction => | |
102 | 110 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
103 | 111 | case _: InvokeScriptTransaction => | |
104 | 112 | true | |
105 | 113 | case _ => | |
106 | 114 | true | |
107 | 115 | } | |
108 | 116 |
github/deemru/w8io/169f3d6 33.19 ms ◑