tx · 9wSgnJX48JcP9wAseqknKRjYGEjwm7kw5rZ4y7RhzAW 3MqxFhe869ri22Y1418TcrXUX2X9YMzG2Yb: -0.01400000 Waves 2019.06.28 21:07 [562320] smart account 3MqxFhe869ri22Y1418TcrXUX2X9YMzG2Yb > SELF 0.00000000 Waves
{ "type": 13, "id": "9wSgnJX48JcP9wAseqknKRjYGEjwm7kw5rZ4y7RhzAW", "fee": 1400000, "feeAssetId": null, "timestamp": 1561745259300, "version": 1, "sender": "3MqxFhe869ri22Y1418TcrXUX2X9YMzG2Yb", "senderPublicKey": "FRkBvFhV1T95mPTxp7sk2Ms2BuHViwyG7yPzxpxye1Kw", "proofs": [ "2Uo8T7zonBwLDmPp1m4eoN7aNmuaGPNGxweVeFBkAvSD3TNK2X78aycLg4CvMa6LeFGbgm9nAvKx2KLmzEcj716t" ], "script": "base64:AAIDAAAAAAAAAAAAAAALAAAAAApzZXJ2aWNlRmVlAAAAAAAAmJaAAAAAAAVlbXB0eQIAAAAETlVMTAAAAAASYWxsTWVzc2FnZUJvYXJkS2V5AgAAAAthbGxfbWVzc2FnZQAAAAAQYWN0aXZlTWVzc2FnZUtleQIAAAAOYWN0aXZlX21lc3NhZ2UAAAAADmVhcm5lZFdhdmVzS2V5AgAAAAtlYXJuZWRXYXZlcwAAAAANc2VydmljZUZlZUtleQIAAAAKc2VydmljZUZlZQAAAAAJZEFwcE93bmVyAgAAACMzTXZpS2U4dnlibmtZdUo4M2U4UVZTV1ExVkh5ZmdwaUYzVwEAAAAJdW5pcXVlS2V5AAAAAgAAAAVvd25lcgAAAAR0ZXh0BAAAAAR1S2V5CQACWAAAAAEJAAH3AAAAAQkAAZsAAAABCQABLAAAAAIFAAAABW93bmVyBQAAAAR0ZXh0BQAAAAR1S2V5AQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y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AAAACBQAAABBhY3RpdmVNZXNzYWdlS2V5CQAAZQAAAAIFAAAACmFjdE1lc3NhZ2UAAAAAAAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgIAAAAIbWVzc2FnZV8FAAAABHVLZXkCAAAAFCNWSU9MQVRJT04gT0YgUlVMRVMjBQAAAANuaWwAAAAA8fRtTg==", "chainId": 84, "height": 562320, "spentComplexity": 0 } View: original | compacted Prev: Bo8FsrnwbVoY8YX22459tGpgvw8Dwj3tXAw4KU2qieKh Next: DHX94DphffTH9sh442cCJYHDQS1qcTTq7mzw9pVAqAot Diff:
Old | New | Differences | |
---|---|---|---|
57 | 57 | @Callable(i) | |
58 | 58 | func setMessage (text) = { | |
59 | 59 | let pmt = extract(i.payment) | |
60 | - | let | |
60 | + | let localFee = getSeviceFee() | |
61 | 61 | if (isDefined(pmt.assetId)) | |
62 | 62 | then throw("WAVES token only at the moment") | |
63 | - | else if ((pmt.amount != | |
63 | + | else if ((pmt.amount != localFee)) | |
64 | 64 | then throw("Wrong service fee amount") | |
65 | 65 | else { | |
66 | 66 | let ownerAddress = toBase58String(i.caller.bytes) | |
68 | 68 | let allMessage = getNumberByKey(allMessageBoardKey) | |
69 | 69 | let actMessage = getNumberByKey(activeMessageKey) | |
70 | 70 | let earnedWaves = getNumberByKey(earnedWavesKey) | |
71 | - | WriteSet([DataEntry(("owner_" + uKey), ownerAddress), DataEntry(("message_" + uKey), text), DataEntry(allMessageBoardKey, (allMessage + 1)), DataEntry(activeMessageKey, (actMessage + 1)), DataEntry(earnedWavesKey, (earnedWaves + | |
71 | + | WriteSet([DataEntry(("owner_" + uKey), ownerAddress), DataEntry(("message_" + uKey), text), DataEntry(allMessageBoardKey, (allMessage + 1)), DataEntry(activeMessageKey, (actMessage + 1)), DataEntry(earnedWavesKey, (earnedWaves + localFee))]) | |
72 | 72 | } | |
73 | 73 | } | |
74 | 74 | ||
76 | 76 | ||
77 | 77 | @Callable(i) | |
78 | 78 | func removeMessage (uKey) = { | |
79 | - | let pmt = extract(i.payment) | |
80 | 79 | let owner = getStrByKey(("owner_" + uKey)) | |
81 | 80 | let actMessage = getNumberByKey(activeMessageKey) | |
82 | 81 | let senderAddress = toBase58String(i.caller.bytes) | |
98 | 97 | } | |
99 | 98 | ||
100 | 99 | ||
100 | + | ||
101 | + | @Callable(i) | |
102 | + | func violationDetected (uKey) = { | |
103 | + | let actMessage = getNumberByKey(activeMessageKey) | |
104 | + | let senderAddress = toBase58String(i.caller.bytes) | |
105 | + | if ((senderAddress != dAppOwner)) | |
106 | + | then throw("You aren't owner this dApp") | |
107 | + | else WriteSet([DataEntry(activeMessageKey, (actMessage - 1)), DataEntry(("message_" + uKey), "#VIOLATION OF RULES#")]) | |
108 | + | } | |
109 | + | ||
110 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let serviceFee = 10000000 | |
5 | 5 | ||
6 | 6 | let empty = "NULL" | |
7 | 7 | ||
8 | 8 | let allMessageBoardKey = "all_message" | |
9 | 9 | ||
10 | 10 | let activeMessageKey = "active_message" | |
11 | 11 | ||
12 | 12 | let earnedWavesKey = "earnedWaves" | |
13 | 13 | ||
14 | 14 | let serviceFeeKey = "serviceFee" | |
15 | 15 | ||
16 | 16 | let dAppOwner = "3MviKe8vybnkYuJ83e8QVSWQ1VHyfgpiF3W" | |
17 | 17 | ||
18 | 18 | func uniqueKey (owner,text) = { | |
19 | 19 | let uKey = toBase58String(sha256(toBytes((owner + text)))) | |
20 | 20 | uKey | |
21 | 21 | } | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func getNumberByKey (key) = { | |
25 | 25 | let num = match getInteger(this, key) { | |
26 | 26 | case a: Int => | |
27 | 27 | a | |
28 | 28 | case _ => | |
29 | 29 | 0 | |
30 | 30 | } | |
31 | 31 | num | |
32 | 32 | } | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func getStrByKey (key) = { | |
36 | 36 | let str = match getString(this, key) { | |
37 | 37 | case a: String => | |
38 | 38 | a | |
39 | 39 | case _ => | |
40 | 40 | empty | |
41 | 41 | } | |
42 | 42 | str | |
43 | 43 | } | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getSeviceFee () = { | |
47 | 47 | let fee = match getInteger(this, serviceFeeKey) { | |
48 | 48 | case a: Int => | |
49 | 49 | a | |
50 | 50 | case _ => | |
51 | 51 | serviceFee | |
52 | 52 | } | |
53 | 53 | fee | |
54 | 54 | } | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | @Callable(i) | |
58 | 58 | func setMessage (text) = { | |
59 | 59 | let pmt = extract(i.payment) | |
60 | - | let | |
60 | + | let localFee = getSeviceFee() | |
61 | 61 | if (isDefined(pmt.assetId)) | |
62 | 62 | then throw("WAVES token only at the moment") | |
63 | - | else if ((pmt.amount != | |
63 | + | else if ((pmt.amount != localFee)) | |
64 | 64 | then throw("Wrong service fee amount") | |
65 | 65 | else { | |
66 | 66 | let ownerAddress = toBase58String(i.caller.bytes) | |
67 | 67 | let uKey = uniqueKey(ownerAddress, text) | |
68 | 68 | let allMessage = getNumberByKey(allMessageBoardKey) | |
69 | 69 | let actMessage = getNumberByKey(activeMessageKey) | |
70 | 70 | let earnedWaves = getNumberByKey(earnedWavesKey) | |
71 | - | WriteSet([DataEntry(("owner_" + uKey), ownerAddress), DataEntry(("message_" + uKey), text), DataEntry(allMessageBoardKey, (allMessage + 1)), DataEntry(activeMessageKey, (actMessage + 1)), DataEntry(earnedWavesKey, (earnedWaves + | |
71 | + | WriteSet([DataEntry(("owner_" + uKey), ownerAddress), DataEntry(("message_" + uKey), text), DataEntry(allMessageBoardKey, (allMessage + 1)), DataEntry(activeMessageKey, (actMessage + 1)), DataEntry(earnedWavesKey, (earnedWaves + localFee))]) | |
72 | 72 | } | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | 77 | @Callable(i) | |
78 | 78 | func removeMessage (uKey) = { | |
79 | - | let pmt = extract(i.payment) | |
80 | 79 | let owner = getStrByKey(("owner_" + uKey)) | |
81 | 80 | let actMessage = getNumberByKey(activeMessageKey) | |
82 | 81 | let senderAddress = toBase58String(i.caller.bytes) | |
83 | 82 | if ((owner == empty)) | |
84 | 83 | then throw("Message didn't found") | |
85 | 84 | else if ((owner != senderAddress)) | |
86 | 85 | then throw(("You don't owner of message " + uKey)) | |
87 | 86 | else WriteSet([DataEntry(activeMessageKey, (actMessage - 1)), DataEntry(("message_" + uKey), "#REMOVED#")]) | |
88 | 87 | } | |
89 | 88 | ||
90 | 89 | ||
91 | 90 | ||
92 | 91 | @Callable(i) | |
93 | 92 | func setServiceFee (newFee) = { | |
94 | 93 | let senderAddress = toBase58String(i.caller.bytes) | |
95 | 94 | if ((senderAddress != dAppOwner)) | |
96 | 95 | then throw("You aren't owner this dApp") | |
97 | 96 | else WriteSet([DataEntry(serviceFeeKey, newFee)]) | |
98 | 97 | } | |
99 | 98 | ||
100 | 99 | ||
100 | + | ||
101 | + | @Callable(i) | |
102 | + | func violationDetected (uKey) = { | |
103 | + | let actMessage = getNumberByKey(activeMessageKey) | |
104 | + | let senderAddress = toBase58String(i.caller.bytes) | |
105 | + | if ((senderAddress != dAppOwner)) | |
106 | + | then throw("You aren't owner this dApp") | |
107 | + | else WriteSet([DataEntry(activeMessageKey, (actMessage - 1)), DataEntry(("message_" + uKey), "#VIOLATION OF RULES#")]) | |
108 | + | } | |
109 | + | ||
110 | + |
github/deemru/w8io/169f3d6 26.07 ms ◑