tx · 8H1ayE7nm48vp3Rn6eMhteBorsxKc8rGKTMvS31on4qt

3ND6EFqVoR6r9jWRL87nSf2Zs5AMiNnGWD3:  -0.01000000 Waves

2021.07.08 14:29 [1604565] smart account 3ND6EFqVoR6r9jWRL87nSf2Zs5AMiNnGWD3 > SELF 0.00000000 Waves

{ "type": 13, "id": "8H1ayE7nm48vp3Rn6eMhteBorsxKc8rGKTMvS31on4qt", "fee": 1000000, "feeAssetId": null, "timestamp": 1625743769676, "version": 2, "chainId": 84, "sender": "3ND6EFqVoR6r9jWRL87nSf2Zs5AMiNnGWD3", "senderPublicKey": "KUUrvP3E8GJqJe8m89JhbWoFxA5Y6ZArXcUs6XDthT6", "proofs": [ "5dcmRSN8CAQhL8NrxYuCVDMpg4rqEYZsGng7ZF3efFdMPDtDZpFxUe3KyeAnR2FgGoZ4RFCrdgYu4umqyMxiQmdb" ], "script": "base64:AAIDAAAAAAAAAz0IARIFCgMIAQgSBAoCCAgSBQoDCAgIGgoKAmExEgROT05FGgwKAmEyEgZWT1RFUlMaDAoCYTMSBlFVT1JVTRoOCgJhNBIIRkVBVFVSRUQaDgoCYTUSCERFTElTVEVEGgwKAmE2EgZWT1RJTkcaDAoCYTcSBlJFVkVBTBoUCgJhOBIOZ2V0U3RyaW5nQnlLZXkaCQoCYTkSA2tleRoNCgJiMRIHJG1hdGNoMBoHCgJiMhIBYRoVCgJiMxIPZ2V0SW50ZWdlckJ5S2V5GhAKAmI0EgpnZXRLZXlJdGVtGg4KAmI1EghzdXBwbGllchoLCgJiNhIFdGl0bGUaEwoCYjcSDXN1cHBsaWVyVGl0bGUaGAoCYjgSEmdldEtleUl0ZW1TdXBwbGllchoKCgJiORIEaXRlbRoVCgJjMRIPZ2V0S2V5SXRlbVByaWNlGhQKAmMyEg5nZXRLZXlJdGVtRGF0YRoSCgJjMxIMZ2V0S2V5Q29tbWl0GgoKAmM0EgR1c2VyGhgKAmM1EhJnZXRLZXlDb21taXRzQ291bnQaEgoCYzYSDGdld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JiOQUAAAACYzQFAAAAAmExCQAAAgAAAAECAAAAEVlvdSBWb3RlZCBBbHJlYWR5AwMJAQAAAAIhPQAAAAIFAAAAAmU1BQAAAAJhNgkBAAAAAiE9AAAAAgUAAAACZTUFAAAAAmE3BwkAAAIAAAABAgAAACZWb3RpbmcgaXMgbm90IGFjdGl2ZSBmb3IgdGhpcyBpdGVtIG5vdwMDCQEAAAACIT0AAAACBQAAAAJjOQUAAAACYTQJAQAAAAIhPQAAAAIFAAAAAmM5BQAAAAJhNQcJAAACAAAAAQIAAAAjUHJvdmlkZWQgdm90aW5nIG9wdGlvbiBpcyBpbmNvcnJlY3QEAAAAAmU2AwkAAGcAAAACBQAAAAJlOAUAAAACYTMFAAAAAmM5BQAAAAJhNwkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAAmM2AAAAAgUAAAACYjkFAAAAAmM0BQAAAAJjOQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAAmM4AAAAAgUAAAACYjkFAAAAAmM5BQAAAAJlOAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAAmM3AAAAAQUAAAACYjkFAAAAAmU2BQAAAANuaWwAAAAAwMOmkg==", "height": 1604565, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8bQBiW1Ls5PgrUgZGde395t6gyaUzUYsCT9WTAwS2hpE Next: 2BaQqHwYrXmhqq2UrR91KMH1mA3vSuxc3ZAg7hvbgEFq Diff:
OldNewDifferences
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "NONE"
5+
6+let VOTERS = 3
7+
8+let QUORUM = 2
9+
10+let FEATURED = "featured"
11+
12+let DELISTED = "delisted"
13+
14+let VOTING = "voting"
15+
16+let REVEAL = "reveal"
17+
18+func getStringByKey (key) = match getString(this, key) {
19+ case a: String =>
20+ a
21+ case _ =>
22+ NONE
23+}
24+
25+
26+func getIntegerByKey (key) = match getInteger(this, key) {
27+ case a: Int =>
28+ a
29+ case _ =>
30+ 0
31+}
32+
533
634 func getKeyItem (supplier,title) = {
735 let supplierTitle = (supplier + title)
1846 func getKeyItemData (item) = (item + "_data")
1947
2048
21-func getValueItemSupplier (item) = {
22- let key = match getString(this, (item + "_owner")) {
23- case t: String =>
24- t
25- case _ =>
26- NONE
27- }
28- key
29- }
49+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
50+
51+
52+func getKeyCommitsCount (item) = (item + "_cmtcnt")
53+
54+
55+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
56+
57+
58+func getKeyItemStatus (item) = (item + "_status")
59+
60+
61+func getKeyVotesCount (item,vote) = ((item + "_res:") + vote)
62+
63+
64+func getValueItemSupplier (account) = getStringByKey(getKeyItemSupplier(account))
65+
66+
67+func getValueCommit (item,user) = getStringByKey(getKeyCommit(item, user))
68+
69+
70+func getValueCommitsCount (item) = getIntegerByKey(getKeyCommitsCount(item))
71+
72+
73+func getValueReveal (item,user) = getStringByKey(getKeyReveal(item, user))
74+
75+
76+func getValueItemStatus (item) = getStringByKey(getKeyItemStatus(item))
77+
78+
79+func getValueVotesCount (item,vote) = getIntegerByKey(getKeyVotesCount(item, vote))
3080
3181
3282 @Callable(i)
4191 }
4292
4393
94+
95+@Callable(i)
96+func voteCommit (item,hash) = {
97+ let user = toBase58String(i.caller.bytes)
98+ let commitsCount = getValueCommitsCount(item)
99+ let status = getValueItemStatus(item)
100+ if ((commitsCount >= VOTERS))
101+ then throw("Reached max number of voters")
102+ else if ((getValueCommit(item, user) != NONE))
103+ then throw("Your Voted already")
104+ else if ((getValueItemSupplier(getKeyItemSupplier(item)) == NONE))
105+ then throw("Item Does not exist")
106+ else if (if ((status != NONE))
107+ then (status != VOTING)
108+ else false)
109+ then throw("Voting is not active for this Item now")
110+ else {
111+ let newStatus = if ((commitsCount == VOTERS))
112+ then REVEAL
113+ else VOTING
114+ WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commitsCount + 1)), DataEntry(getKeyItemStatus(item), newStatus)])
115+ }
116+ }
117+
118+
119+
120+@Callable(i)
121+func voteReveal (item,vote,salt) = {
122+ let user = toBase58String(i.caller.bytes)
123+ let status = getValueItemStatus(item)
124+ let newVotesCount = (getValueVotesCount(item, vote) + 1)
125+ let saltedVote = ((item + vote) + salt)
126+ if ((toBase58String(sha256(toBytes(saltedVote))) != getValueCommit(item, user)))
127+ then throw("Reveal data is not valid")
128+ else if ((VOTERS > getValueCommitsCount(item)))
129+ then throw("Max Number of Voters not reached")
130+ else if ((getValueReveal(item, user) != NONE))
131+ then throw("You Voted Already")
132+ else if (if ((status != VOTING))
133+ then (status != REVEAL)
134+ else false)
135+ then throw("Voting is not active for this item now")
136+ else if (if ((vote != FEATURED))
137+ then (vote != DELISTED)
138+ else false)
139+ then throw("Provided voting option is incorrect")
140+ else {
141+ let newStatus = if ((newVotesCount >= QUORUM))
142+ then vote
143+ else REVEAL
144+ WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVotesCount(item, vote), newVotesCount), DataEntry(getKeyItemStatus(item), newStatus)])
145+ }
146+ }
147+
148+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "NONE"
5+
6+let VOTERS = 3
7+
8+let QUORUM = 2
9+
10+let FEATURED = "featured"
11+
12+let DELISTED = "delisted"
13+
14+let VOTING = "voting"
15+
16+let REVEAL = "reveal"
17+
18+func getStringByKey (key) = match getString(this, key) {
19+ case a: String =>
20+ a
21+ case _ =>
22+ NONE
23+}
24+
25+
26+func getIntegerByKey (key) = match getInteger(this, key) {
27+ case a: Int =>
28+ a
29+ case _ =>
30+ 0
31+}
32+
533
634 func getKeyItem (supplier,title) = {
735 let supplierTitle = (supplier + title)
836 ("item_" + toBase58String(sha256(toBytes(supplierTitle))))
937 }
1038
1139
1240 func getKeyItemSupplier (item) = (item + "_owner")
1341
1442
1543 func getKeyItemPrice (item) = (item + "_price")
1644
1745
1846 func getKeyItemData (item) = (item + "_data")
1947
2048
21-func getValueItemSupplier (item) = {
22- let key = match getString(this, (item + "_owner")) {
23- case t: String =>
24- t
25- case _ =>
26- NONE
27- }
28- key
29- }
49+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
50+
51+
52+func getKeyCommitsCount (item) = (item + "_cmtcnt")
53+
54+
55+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
56+
57+
58+func getKeyItemStatus (item) = (item + "_status")
59+
60+
61+func getKeyVotesCount (item,vote) = ((item + "_res:") + vote)
62+
63+
64+func getValueItemSupplier (account) = getStringByKey(getKeyItemSupplier(account))
65+
66+
67+func getValueCommit (item,user) = getStringByKey(getKeyCommit(item, user))
68+
69+
70+func getValueCommitsCount (item) = getIntegerByKey(getKeyCommitsCount(item))
71+
72+
73+func getValueReveal (item,user) = getStringByKey(getKeyReveal(item, user))
74+
75+
76+func getValueItemStatus (item) = getStringByKey(getKeyItemStatus(item))
77+
78+
79+func getValueVotesCount (item,vote) = getIntegerByKey(getKeyVotesCount(item, vote))
3080
3181
3282 @Callable(i)
3383 func addItem (title,price,data) = {
3484 let supplierAddress = toBase58String(i.caller.bytes)
3585 let item = getKeyItem(supplierAddress, title)
3686 if ((0 >= price))
3787 then throw("purchase amount cannot be less than item price")
3888 else if ((getValueItemSupplier(item) != NONE))
3989 then throw("An item already exists")
4090 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
4191 }
4292
4393
94+
95+@Callable(i)
96+func voteCommit (item,hash) = {
97+ let user = toBase58String(i.caller.bytes)
98+ let commitsCount = getValueCommitsCount(item)
99+ let status = getValueItemStatus(item)
100+ if ((commitsCount >= VOTERS))
101+ then throw("Reached max number of voters")
102+ else if ((getValueCommit(item, user) != NONE))
103+ then throw("Your Voted already")
104+ else if ((getValueItemSupplier(getKeyItemSupplier(item)) == NONE))
105+ then throw("Item Does not exist")
106+ else if (if ((status != NONE))
107+ then (status != VOTING)
108+ else false)
109+ then throw("Voting is not active for this Item now")
110+ else {
111+ let newStatus = if ((commitsCount == VOTERS))
112+ then REVEAL
113+ else VOTING
114+ WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commitsCount + 1)), DataEntry(getKeyItemStatus(item), newStatus)])
115+ }
116+ }
117+
118+
119+
120+@Callable(i)
121+func voteReveal (item,vote,salt) = {
122+ let user = toBase58String(i.caller.bytes)
123+ let status = getValueItemStatus(item)
124+ let newVotesCount = (getValueVotesCount(item, vote) + 1)
125+ let saltedVote = ((item + vote) + salt)
126+ if ((toBase58String(sha256(toBytes(saltedVote))) != getValueCommit(item, user)))
127+ then throw("Reveal data is not valid")
128+ else if ((VOTERS > getValueCommitsCount(item)))
129+ then throw("Max Number of Voters not reached")
130+ else if ((getValueReveal(item, user) != NONE))
131+ then throw("You Voted Already")
132+ else if (if ((status != VOTING))
133+ then (status != REVEAL)
134+ else false)
135+ then throw("Voting is not active for this item now")
136+ else if (if ((vote != FEATURED))
137+ then (vote != DELISTED)
138+ else false)
139+ then throw("Provided voting option is incorrect")
140+ else {
141+ let newStatus = if ((newVotesCount >= QUORUM))
142+ then vote
143+ else REVEAL
144+ WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVotesCount(item, vote), newVotesCount), DataEntry(getKeyItemStatus(item), newStatus)])
145+ }
146+ }
147+
148+

github/deemru/w8io/026f985 
37.12 ms