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