tx · EunLSRdx9WjgtLMr6umAfhxiJyEsyHcXDbfnNDZ44dqM 3MpfKPtuGkDUZkw6iHWTqNgdUzpPA44bma5: -0.01400000 Waves 2019.07.16 21:04 [588709] smart account 3MpfKPtuGkDUZkw6iHWTqNgdUzpPA44bma5 > SELF 0.00000000 Waves
{ "type": 13, "id": "EunLSRdx9WjgtLMr6umAfhxiJyEsyHcXDbfnNDZ44dqM", "fee": 1400000, "feeAssetId": null, "timestamp": 1563300256296, "version": 1, "sender": "3MpfKPtuGkDUZkw6iHWTqNgdUzpPA44bma5", "senderPublicKey": "75T1yn3QVjmV2bCHEnoPm5GX5i2H3kr8j32LZNiZSoJe", "proofs": [ "5TZpjVx9vYzmNHxn2kbj2ouoXD1dfUGdFjZymLGi9ZEFTLNtGuTzRPRniwFKaVnKnKb8Zd9dKUrdWmkiXPEWwo1j" ], "script": "base64:AAIDAAAAAAAAAAAAAAALAAAAAApzZXJ2aWNlRmVlAAAAAAAAAYagAAAAAAVlbXB0eQIAAAAETlVMTAAAAAASYWxsTWVzc2FnZUJvYXJkS2V5AgAAAAthbGxfbWVzc2FnZQAAAAAQYWN0aXZlTWVzc2FnZUtleQIAAAAOYWN0aXZlX21lc3NhZ2UAAAAADmVhcm5lZFdhdmVzS2V5AgAAAAtlYXJuZWRXYXZlcwAAAAANc2VydmljZUZlZUtleQIAAAAKc2VydmljZUZlZQAAAAAJZEFwcE93bmVyAgAAACMzTXZpS2U4dnlibmtZdUo4M2U4UVZTV1ExVkh5ZmdwaUYzVwEAAAAJdW5pcXVlS2V5AAAAAgAAAAVvd25lcgAAAAR0ZXh0BAAAAAR1S2V5CQACWAAAAAEJAAH3AAAAAQkAAZsAAAABCQABLAAAAAIFAAAABW93bmVyBQAAAAR0ZXh0BQAAAAR1S2V5AQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAA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AQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAEGFjdGl2ZU1lc3NhZ2VLZXkJAABlAAAAAgUAAAAKYWN0TWVzc2FnZQAAAAAAAAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACAgAAAAhtZXNzYWdlXwUAAAAEdUtleQIAAAAUI1ZJT0xBVElPTiBPRiBSVUxFUyMFAAAAA25pbAAAAAFpAQAAAAh3aXRoZHJhdwAAAAEAAAAGYW1vdW50BAAAAA1zZW5kZXJBZGRyZXNzCQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMDCQEAAAACIT0AAAACBQAAAA1zZW5kZXJBZGRyZXNzBQAAAAlkQXBwT3duZXIJAAACAAAAAQIAAAAaWW91IGFyZW4ndCBvd25lciB0aGlzIGRBcHAJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAABHVuaXQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5iGVSUg==", "chainId": 84, "height": 588709, "spentComplexity": 0 } View: original | compacted Prev: 9YXXWiRoPQ8dx3NRD4c8t3PWWrncErJtz7aiDyjyS5bD Next: BKKzgqecgpX8VsTLwSviScgceFcAP6xR36qzzdMpMXJ7 Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let serviceFee = 100000 | |
5 | 5 | ||
6 | - | let | |
6 | + | let empty = "NULL" | |
7 | 7 | ||
8 | - | ||
8 | + | let allMessageBoardKey = "all_message" | |
9 | 9 | ||
10 | + | let activeMessageKey = "active_message" | |
10 | 11 | ||
11 | - | ||
12 | + | let earnedWavesKey = "earnedWaves" | |
12 | 13 | ||
14 | + | let serviceFeeKey = "serviceFee" | |
13 | 15 | ||
14 | - | func getExtValueItemWhiteListStatus (oracle,account) = { | |
15 | - | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { | |
16 | - | case a: String => | |
17 | - | a | |
18 | - | case _ => | |
19 | - | NONE | |
20 | - | } | |
21 | - | str | |
16 | + | let dAppOwner = "3MviKe8vybnkYuJ83e8QVSWQ1VHyfgpiF3W" | |
17 | + | ||
18 | + | func uniqueKey (owner,text) = { | |
19 | + | let uKey = toBase58String(sha256(toBytes((owner + text)))) | |
20 | + | uKey | |
22 | 21 | } | |
23 | 22 | ||
24 | 23 | ||
38 | 37 | case a: String => | |
39 | 38 | a | |
40 | 39 | case _ => | |
41 | - | | |
40 | + | empty | |
42 | 41 | } | |
43 | 42 | str | |
44 | 43 | } | |
45 | 44 | ||
46 | 45 | ||
47 | - | func getKeyItemPrice (item) = (item + "_price") | |
48 | - | ||
49 | - | ||
50 | - | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
51 | - | ||
52 | - | ||
53 | - | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
54 | - | ||
55 | - | ||
56 | - | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
57 | - | ||
58 | - | ||
59 | - | func getKeyItem (supplier,title) = ("Item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
60 | - | ||
61 | - | ||
62 | - | func getKeyItemData (item) = (item + "_data") | |
63 | - | ||
64 | - | ||
65 | - | func getKeyItemSupplier (item) = (item + "_owner") | |
66 | - | ||
67 | - | ||
68 | - | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
69 | - | ||
70 | - | ||
71 | - | func getKeyBalanceSupplier (account) = (account + "_balance") | |
72 | - | ||
73 | - | ||
74 | - | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
46 | + | func getSeviceFee () = { | |
47 | + | let fee = match getInteger(this, serviceFeeKey) { | |
48 | + | case a: Int => | |
49 | + | a | |
50 | + | case _ => | |
51 | + | serviceFee | |
52 | + | } | |
53 | + | fee | |
54 | + | } | |
75 | 55 | ||
76 | 56 | ||
77 | 57 | @Callable(i) | |
78 | - | func addItem (title,price,data) = { | |
79 | - | let supplierAddress = toBase58String(i.caller.bytes) | |
80 | - | let item = getKeyItem(supplierAddress, title) | |
81 | - | let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
82 | - | if ((0 >= price)) | |
83 | - | then throw("purchase amount cannot be less than item price") | |
84 | - | else if ((getValueItemSupplier(item) != NONE)) | |
85 | - | then throw("an item is already exist") | |
86 | - | else if ((supplierWhiteList == BLACKLISTED)) | |
87 | - | then throw("supplier's account has been blackliested") | |
88 | - | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data), DataEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierAddress)]) | |
58 | + | func setMessage (text) = { | |
59 | + | let pmt = extract(i.payment) | |
60 | + | let localFee = getSeviceFee() | |
61 | + | if (isDefined(pmt.assetId)) | |
62 | + | then throw("WAVES token only at the moment") | |
63 | + | else if ((pmt.amount != localFee)) | |
64 | + | then throw("Wrong service fee amount") | |
65 | + | else { | |
66 | + | let ownerAddress = toBase58String(i.caller.bytes) | |
67 | + | let uKey = uniqueKey(ownerAddress, (toString(height) + toBase58String(i.transactionId))) | |
68 | + | let allMessage = getNumberByKey(allMessageBoardKey) | |
69 | + | let actMessage = getNumberByKey(activeMessageKey) | |
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 + localFee))]) | |
72 | + | } | |
89 | 73 | } | |
90 | 74 | ||
75 | + | ||
76 | + | ||
77 | + | @Callable(i) | |
78 | + | func removeMessage (uKey) = { | |
79 | + | let owner = getStrByKey(("owner_" + uKey)) | |
80 | + | let actMessage = getNumberByKey(activeMessageKey) | |
81 | + | let senderAddress = toBase58String(i.caller.bytes) | |
82 | + | if ((owner == empty)) | |
83 | + | then throw("Message didn't found") | |
84 | + | else if ((owner != senderAddress)) | |
85 | + | then throw(("You don't owner of message " + uKey)) | |
86 | + | else WriteSet([DataEntry(activeMessageKey, (actMessage - 1)), DataEntry(("message_" + uKey), "#REMOVED#")]) | |
87 | + | } | |
88 | + | ||
89 | + | ||
90 | + | ||
91 | + | @Callable(i) | |
92 | + | func setServiceFee (newFee) = { | |
93 | + | let senderAddress = toBase58String(i.caller.bytes) | |
94 | + | if ((senderAddress != dAppOwner)) | |
95 | + | then throw("You aren't owner this dApp") | |
96 | + | else WriteSet([DataEntry(serviceFeeKey, newFee)]) | |
97 | + | } | |
98 | + | ||
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 | + | ||
111 | + | ||
112 | + | @Callable(i) | |
113 | + | func withdraw (amount) = { | |
114 | + | let senderAddress = toBase58String(i.caller.bytes) | |
115 | + | if ((senderAddress != dAppOwner)) | |
116 | + | then throw("You aren't owner this dApp") | |
117 | + | else TransferSet([ScriptTransfer(i.caller, amount, unit)]) | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | @Verifier(tx) | |
122 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
91 | 123 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let serviceFee = 100000 | |
5 | 5 | ||
6 | - | let | |
6 | + | let empty = "NULL" | |
7 | 7 | ||
8 | - | ||
8 | + | let allMessageBoardKey = "all_message" | |
9 | 9 | ||
10 | + | let activeMessageKey = "active_message" | |
10 | 11 | ||
11 | - | ||
12 | + | let earnedWavesKey = "earnedWaves" | |
12 | 13 | ||
14 | + | let serviceFeeKey = "serviceFee" | |
13 | 15 | ||
14 | - | func getExtValueItemWhiteListStatus (oracle,account) = { | |
15 | - | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { | |
16 | - | case a: String => | |
17 | - | a | |
18 | - | case _ => | |
19 | - | NONE | |
20 | - | } | |
21 | - | str | |
16 | + | let dAppOwner = "3MviKe8vybnkYuJ83e8QVSWQ1VHyfgpiF3W" | |
17 | + | ||
18 | + | func uniqueKey (owner,text) = { | |
19 | + | let uKey = toBase58String(sha256(toBytes((owner + text)))) | |
20 | + | uKey | |
22 | 21 | } | |
23 | 22 | ||
24 | 23 | ||
25 | 24 | func getNumberByKey (key) = { | |
26 | 25 | let num = match getInteger(this, key) { | |
27 | 26 | case a: Int => | |
28 | 27 | a | |
29 | 28 | case _ => | |
30 | 29 | 0 | |
31 | 30 | } | |
32 | 31 | num | |
33 | 32 | } | |
34 | 33 | ||
35 | 34 | ||
36 | 35 | func getStrByKey (key) = { | |
37 | 36 | let str = match getString(this, key) { | |
38 | 37 | case a: String => | |
39 | 38 | a | |
40 | 39 | case _ => | |
41 | - | | |
40 | + | empty | |
42 | 41 | } | |
43 | 42 | str | |
44 | 43 | } | |
45 | 44 | ||
46 | 45 | ||
47 | - | func getKeyItemPrice (item) = (item + "_price") | |
48 | - | ||
49 | - | ||
50 | - | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
51 | - | ||
52 | - | ||
53 | - | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
54 | - | ||
55 | - | ||
56 | - | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
57 | - | ||
58 | - | ||
59 | - | func getKeyItem (supplier,title) = ("Item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
60 | - | ||
61 | - | ||
62 | - | func getKeyItemData (item) = (item + "_data") | |
63 | - | ||
64 | - | ||
65 | - | func getKeyItemSupplier (item) = (item + "_owner") | |
66 | - | ||
67 | - | ||
68 | - | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
69 | - | ||
70 | - | ||
71 | - | func getKeyBalanceSupplier (account) = (account + "_balance") | |
72 | - | ||
73 | - | ||
74 | - | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
46 | + | func getSeviceFee () = { | |
47 | + | let fee = match getInteger(this, serviceFeeKey) { | |
48 | + | case a: Int => | |
49 | + | a | |
50 | + | case _ => | |
51 | + | serviceFee | |
52 | + | } | |
53 | + | fee | |
54 | + | } | |
75 | 55 | ||
76 | 56 | ||
77 | 57 | @Callable(i) | |
78 | - | func addItem (title,price,data) = { | |
79 | - | let supplierAddress = toBase58String(i.caller.bytes) | |
80 | - | let item = getKeyItem(supplierAddress, title) | |
81 | - | let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
82 | - | if ((0 >= price)) | |
83 | - | then throw("purchase amount cannot be less than item price") | |
84 | - | else if ((getValueItemSupplier(item) != NONE)) | |
85 | - | then throw("an item is already exist") | |
86 | - | else if ((supplierWhiteList == BLACKLISTED)) | |
87 | - | then throw("supplier's account has been blackliested") | |
88 | - | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data), DataEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierAddress)]) | |
58 | + | func setMessage (text) = { | |
59 | + | let pmt = extract(i.payment) | |
60 | + | let localFee = getSeviceFee() | |
61 | + | if (isDefined(pmt.assetId)) | |
62 | + | then throw("WAVES token only at the moment") | |
63 | + | else if ((pmt.amount != localFee)) | |
64 | + | then throw("Wrong service fee amount") | |
65 | + | else { | |
66 | + | let ownerAddress = toBase58String(i.caller.bytes) | |
67 | + | let uKey = uniqueKey(ownerAddress, (toString(height) + toBase58String(i.transactionId))) | |
68 | + | let allMessage = getNumberByKey(allMessageBoardKey) | |
69 | + | let actMessage = getNumberByKey(activeMessageKey) | |
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 + localFee))]) | |
72 | + | } | |
89 | 73 | } | |
90 | 74 | ||
75 | + | ||
76 | + | ||
77 | + | @Callable(i) | |
78 | + | func removeMessage (uKey) = { | |
79 | + | let owner = getStrByKey(("owner_" + uKey)) | |
80 | + | let actMessage = getNumberByKey(activeMessageKey) | |
81 | + | let senderAddress = toBase58String(i.caller.bytes) | |
82 | + | if ((owner == empty)) | |
83 | + | then throw("Message didn't found") | |
84 | + | else if ((owner != senderAddress)) | |
85 | + | then throw(("You don't owner of message " + uKey)) | |
86 | + | else WriteSet([DataEntry(activeMessageKey, (actMessage - 1)), DataEntry(("message_" + uKey), "#REMOVED#")]) | |
87 | + | } | |
88 | + | ||
89 | + | ||
90 | + | ||
91 | + | @Callable(i) | |
92 | + | func setServiceFee (newFee) = { | |
93 | + | let senderAddress = toBase58String(i.caller.bytes) | |
94 | + | if ((senderAddress != dAppOwner)) | |
95 | + | then throw("You aren't owner this dApp") | |
96 | + | else WriteSet([DataEntry(serviceFeeKey, newFee)]) | |
97 | + | } | |
98 | + | ||
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 | + | ||
111 | + | ||
112 | + | @Callable(i) | |
113 | + | func withdraw (amount) = { | |
114 | + | let senderAddress = toBase58String(i.caller.bytes) | |
115 | + | if ((senderAddress != dAppOwner)) | |
116 | + | then throw("You aren't owner this dApp") | |
117 | + | else TransferSet([ScriptTransfer(i.caller, amount, unit)]) | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | @Verifier(tx) | |
122 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
91 | 123 |
github/deemru/w8io/169f3d6 30.37 ms ◑![]()