tx · EALXEC9wXp8w3Yb74H7jeuEBCvFbGG8hAxYPqGrTkYjr

3N1MvvKPNWqQ9JWYV1vWE84GnMKP3mENpSg:  -0.01400000 Waves

2019.06.26 03:01 [558343] smart account 3N1MvvKPNWqQ9JWYV1vWE84GnMKP3mENpSg > SELF 0.00000000 Waves

{ "type": 13, "id": "EALXEC9wXp8w3Yb74H7jeuEBCvFbGG8hAxYPqGrTkYjr", "fee": 1400000, "feeAssetId": null, "timestamp": 1561507296063, "version": 1, "sender": "3N1MvvKPNWqQ9JWYV1vWE84GnMKP3mENpSg", "senderPublicKey": "GBcKAM5muVn8dBji3B7ciEqt4XzrT4CBrAKXoTVfbw7", "proofs": [ "uKQwDS5Vdw6SwYGF7FeUx9hxkRAEkvMiC2Yns1r4GxaKoKE5Bwzj3yYPMgAaaj9CfwbNbR8HWvCAxAspTMqGMBY" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAROT05FAgAAAARub25lAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9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VtBQAAAAR1c2VyBQAAAAR2b3RlCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAPZ2V0S2V5Vm90ZUNvdW50AAAAAgUAAAAEaXRlbQUAAAAEdm90ZQUAAAAMbmV3Vm90ZUNvdW50CQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAQZ2V0S2V5SXRlbVN0YXR1cwAAAAEFAAAABGl0ZW0DCQAAZwAAAAIFAAAADG5ld1ZvdGVDb3VudAUAAAAGUVVPUlVNBQAAAAR2b3RlBQAAAAZSRVZFQUwFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V50MNg/w==", "chainId": 84, "height": 558343, "spentComplexity": 0 } View: original | compacted Prev: 752eT2Co8GFow7ozvXL4xyUAWij8Y86tdqKofbUUvmQ1 Next: 65HSqoTVHZQzszVjhYDhdptkffVSi2e9h5cexDBLTzCc Diff:
OldNewDifferences
1010 let VOTING = "voting"
1111
1212 let REVEAL = "reveal"
13+
14+let FEATURED = "featured"
15+
16+let DELISTED = "delisted"
1317
1418 func getNumberByKey (key) = {
1519 let num = match getInteger(this, key) {
159163 }
160164
161165
166+
167+@Callable(i)
168+func voteReveal (item,vote,salt) = {
169+ let user = toBase58String(i.caller.bytes)
170+ let status = getValueItemStatus(item)
171+ let newVoteCount = (getValueVoteCount(item, vote) + 1)
172+ if ((toBase64String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
173+ then throw("reveal data is not valid")
174+ else if ((VOTERS > getValueCommitsCount(item)))
175+ then throw("Max number of votes hasn't been reached yet")
176+ else if ((getValueReveal(item, user) != NONE))
177+ then throw("user has already participated")
178+ else if (if ((status != VOTING))
179+ then (status != REVEAL)
180+ else false)
181+ then throw("wrong status")
182+ else if (if ((vote != FEATURED))
183+ then (vote != DELISTED)
184+ else false)
185+ then throw("wrong vote")
186+ else if (if ((vote != FEATURED))
187+ then true
188+ else (vote != DELISTED))
189+ then throw("Vote has finished")
190+ else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
191+ then vote
192+ else REVEAL)])
193+ }
194+
195+
162196 @Verifier(tx)
163197 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
164198
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
55
66 let VOTERS = 3
77
88 let QUORUM = 2
99
1010 let VOTING = "voting"
1111
1212 let REVEAL = "reveal"
13+
14+let FEATURED = "featured"
15+
16+let DELISTED = "delisted"
1317
1418 func getNumberByKey (key) = {
1519 let num = match getInteger(this, key) {
1620 case a: Int =>
1721 a
1822 case _ =>
1923 0
2024 }
2125 num
2226 }
2327
2428
2529 func getStrByKey (key) = {
2630 let str = match getString(this, key) {
2731 case a: String =>
2832 a
2933 case _ =>
3034 NONE
3135 }
3236 str
3337 }
3438
3539
3640 func getKeyItemPrice (item) = (item + "_price")
3741
3842
3943 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
4044
4145
4246 func getKeyUserItemCounter (user,item) = ((item + "_user") + "_cnt")
4347
4448
4549 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
4650
4751
4852 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4953
5054
5155 func getKeyItemData (item) = (item + "_data")
5256
5357
5458 func getKeyItemSupplier (item) = (item + "_owner")
5559
5660
5761 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5862
5963
6064 func getKeyBalanceSupplier (account) = (account + "_balance")
6165
6266
6367 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
6468
6569
6670 func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
6771
6872
6973 func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
7074
7175
7276 func getKeyCommitsCount (item) = (item + "_comcnt")
7377
7478
7579 func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
7680
7781
7882 func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
7983
8084
8185 func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
8286
8387
8488 func getKeyItemStatus (item) = (item + "_status")
8589
8690
8791 func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
8892
8993
9094 func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
9195
9296
9397 func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
9498
9599
96100 @Callable(i)
97101 func addItem (title,price,data) = {
98102 let supplierAddress = toBase58String(i.caller.bytes)
99103 let item = getKeyItem(supplierAddress, title)
100104 if ((0 >= price))
101105 then throw("Purchase amount cannot be less that item price")
102106 else if ((getValueItemSupplier(item) != NONE))
103107 then throw("This item already exist")
104108 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
105109 }
106110
107111
108112
109113 @Callable(i)
110114 func purchase (item) = {
111115 let pmt = extract(i.payment)
112116 if (isDefined(pmt.assetId))
113117 then throw("Waves token only at this moment")
114118 else {
115119 let userAddress = toBase58String(i.caller.bytes)
116120 let price = getValueItemPrice(item)
117121 let supplierAddress = getValueItemSupplier(item)
118122 if ((price > pmt.amount))
119123 then throw("Purchase amount can not be less than item price")
120124 else if ((pmt.amount > price))
121125 then throw("Purchase amount can not be higher than item price")
122126 else if ((supplierAddress == NONE))
123127 then throw("Supplier does not exist")
124128 else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
125129 }
126130 }
127131
128132
129133
130134 @Callable(i)
131135 func withdraw () = {
132136 let supplierAddress = toBase58String(i.caller.bytes)
133137 let balance = getValueBalanceSupplier(supplierAddress)
134138 if ((0 >= balance))
135139 then throw("Insufficient Balance")
136140 else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
137141 }
138142
139143
140144
141145 @Callable(i)
142146 func voteCommit (item,hash) = {
143147 let user = toBase58String(i.caller.bytes)
144148 let commits = getValueCommitsCount(item)
145149 let status = getValueItemStatus(item)
146150 if ((commits >= VOTERS))
147151 then throw("Reached max numbers of voters")
148152 else if ((getValueCommit(item, user) != NONE))
149153 then throw("User has already participated")
150154 else if ((getKeyItemSupplier(item) == NONE))
151155 then throw("Item does not exist")
152156 else if (if ((status != NONE))
153157 then (status != VOTING)
154158 else false)
155159 then throw("Voting is not possible")
156160 else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
157161 then REVEAL
158162 else VOTING)])
159163 }
160164
161165
166+
167+@Callable(i)
168+func voteReveal (item,vote,salt) = {
169+ let user = toBase58String(i.caller.bytes)
170+ let status = getValueItemStatus(item)
171+ let newVoteCount = (getValueVoteCount(item, vote) + 1)
172+ if ((toBase64String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
173+ then throw("reveal data is not valid")
174+ else if ((VOTERS > getValueCommitsCount(item)))
175+ then throw("Max number of votes hasn't been reached yet")
176+ else if ((getValueReveal(item, user) != NONE))
177+ then throw("user has already participated")
178+ else if (if ((status != VOTING))
179+ then (status != REVEAL)
180+ else false)
181+ then throw("wrong status")
182+ else if (if ((vote != FEATURED))
183+ then (vote != DELISTED)
184+ else false)
185+ then throw("wrong vote")
186+ else if (if ((vote != FEATURED))
187+ then true
188+ else (vote != DELISTED))
189+ then throw("Vote has finished")
190+ else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
191+ then vote
192+ else REVEAL)])
193+ }
194+
195+
162196 @Verifier(tx)
163197 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
164198

github/deemru/w8io/169f3d6 
48.37 ms