tx · 7XpYiUDLYrdNCBVLJUF7udpMq3jKJdEvvmjxfhmrCnRv

3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3:  -0.01400000 Waves

2020.11.23 12:58 [1277881] smart account 3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3 > SELF 0.00000000 Waves

{ "type": 13, "id": "7XpYiUDLYrdNCBVLJUF7udpMq3jKJdEvvmjxfhmrCnRv", "fee": 1400000, "feeAssetId": null, "timestamp": 1606125523607, "version": 2, "chainId": 84, "sender": "3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3", "senderPublicKey": "24o2mnMP6y64dijDFoZKhDpV73e1gCFKxQcZ6X9q3z1B", "proofs": [ "4jtNjpuTQJtCLY7JKBmQecrdG4DzWh6xHVjNfcAmugJSTJ2gbm6KbZPzvDRRrwFu2Genyw8FyA3z8Aj7DfwgfBXz" ], "script": "base64:AAIEAAAAAAAAAB0IAhIDCgEIEgUKAwgBCBIAEgQKAggIEgUKAwgICAAAACAAAAAAEWFjY291bnQxUHVibGljS2V5AQAAACD3jXgw7OE1lYUdW8zpPeJRbBzq2i/QfxUY9F31TI9ITgAAAAARYWNjb3VudDJQdWJsaWNLZXkBAAAAIBtXv2hMCq7TJHKvVsoiywB7SjyYC3f6AKFF3CrlAyIVAAAAAA5vdGhlclB1YmxpY0tleQEAAAAg525Riaa48RgJvYxM/FeTNEzhBum4Tb2zEKrgTa8dHVoAAAAABE5PTkUCAAAABG5vbmUAAAAABlZPVEVSUwAAAAAAAAAAAwAAAAAGUVVPUlVNAAAAAAAAAAACAAAAAAZWT1RJTkcCAAAABnZvdGluZwAAAAAGUkVWRUFMAgAAAAZyZXZlYWwAAAAACEZFQVRVUkVEAgAAAAhmZWF0dXJlZAAAAAAIREVMSVNURUQCAAAACGRlbGlzdGVkAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5A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AAAABnN0YXR1cwUAAAAIRkVBVFVSRUQGCQAAAAAAAAIFAAAABnN0YXR1cwUAAAAIREVMSVNURUQJAAACAAAAAQIAAAARdm90ZSBoYXMgZmluaXNoZWQJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAADGdldEtleVJldmVhbAAAAAIFAAAABGl0ZW0FAAAABHVzZXIFAAAABHZvdGUJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAAA9nZXRLZXlWb3RlQ291bnQAAAACBQAAAARpdGVtBQAAAAR2b3RlBQAAAAxuZXdWb3RlQ291bnQJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAAEGdldEtleUl0ZW1TdGF0dXMAAAABBQAAAARpdGVtAwkAAGcAAAACBQAAAAxuZXdWb3RlQ291bnQFAAAABlFVT1JVTQUAAAAEdm90ZQUAAAAGUkVWRUFMBQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABjnRBhE=", "height": 1277881, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8jmkyYve2ey2uqgxv62N2sSstm4jUoBKbW8Pthdjgeqd Next: none Diff:
OldNewDifferences
171171 }
172172
173173
174+
175+@Callable(i)
176+func voteReveal (item,vote,salt) = {
177+ let user = toBase58String(i.caller.bytes)
178+ let status = getValueItemStatus(item)
179+ let newVoteCount = (getValueVoteCount(item, vote) + 1)
180+ if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
181+ then throw("reveal data is not valid")
182+ else if ((VOTERS > getValueCommitsCount(item)))
183+ then throw("max num of voters hasn't reached yet")
184+ else if ((getValueReveal(item, user) != NONE))
185+ then throw("user has already participated")
186+ else if (if ((status != VOTING))
187+ then (status != REVEAL)
188+ else false)
189+ then throw("wrong status")
190+ else if (if ((vote != FEATURED))
191+ then (vote != DELISTED)
192+ else false)
193+ then throw("wrong vote")
194+ else if (if ((status == FEATURED))
195+ then true
196+ else (status == DELISTED))
197+ then throw("vote has finished")
198+ else [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVoteCount(item, vote), newVoteCount), StringEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
199+ then vote
200+ else REVEAL)]
201+ }
202+
203+
174204 @Verifier(tx)
175205 func verify () = true
176206
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let account1PublicKey = base58'HfLpRhXtnuCabRyNT6z7soaXcbUpwLUhjyBCVQ4szwzd'
55
66 let account2PublicKey = base58'2qjcWuL7QitmuhkSTM7CnNxurCYXuqJ9ubswLBGmXfDv'
77
88 let otherPublicKey = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw'
99
1010 let NONE = "none"
1111
1212 let VOTERS = 3
1313
1414 let QUORUM = 2
1515
1616 let VOTING = "voting"
1717
1818 let REVEAL = "reveal"
1919
2020 let FEATURED = "featured"
2121
2222 let DELISTED = "delisted"
2323
2424 func getNumberByKey (key) = {
2525 let num = match getInteger(this, key) {
2626 case a: Int =>
2727 a
2828 case _ =>
2929 0
3030 }
3131 num
3232 }
3333
3434
3535 func getStrByKey (key) = {
3636 let str = match getString(this, key) {
3737 case a: String =>
3838 a
3939 case _ =>
4040 NONE
4141 }
4242 str
4343 }
4444
4545
4646 func getKeyItemPrice (item) = (item + "_price")
4747
4848
4949 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
5050
5151
5252 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
5353
5454
5555 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
5656
5757
5858 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
5959
6060
6161 func getKeyItemData (item) = (item + "_data")
6262
6363
6464 func getKeyItemSupplier (item) = (item + "_owner")
6565
6666
6767 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
6868
6969
7070 func getKeyBalanceSupplier (account) = (account + "_balance")
7171
7272
7373 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
7474
7575
7676 func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
7777
7878
7979 func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
8080
8181
8282 func getKeyCommitsCount (item) = (item + "_comcnt")
8383
8484
8585 func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
8686
8787
8888 func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
8989
9090
9191 func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
9292
9393
9494 func getKeyItemStatus (item) = (item + "_status")
9595
9696
9797 func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
9898
9999
100100 func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
101101
102102
103103 func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
104104
105105
106106 @Callable(i)
107107 func purchase (item) = {
108108 let pmt = value(i.payments)
109109 if (isDefined(pmt[0].assetId))
110110 then throw("WAVES tokens only")
111111 else {
112112 let userAddress = toBase58String(i.caller.bytes)
113113 let price = getValueItemPrice(item)
114114 let supplierAddress = getValueItemSupplier(item)
115115 if ((price > pmt[0].amount))
116116 then throw("purchase less than item price")
117117 else if ((pmt[0].amount > price))
118118 then throw("purchase amount higher than item price")
119119 else if ((size(pmt) > 1))
120120 then throw("single item only")
121121 else if ((supplierAddress == NONE))
122122 then throw("supplier doesn't exist")
123123 else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt[0].amount))]
124124 }
125125 }
126126
127127
128128
129129 @Callable(i)
130130 func addItem (title,price,data) = {
131131 let supplierAddress = toBase58String(i.caller.bytes)
132132 let item = getKeyItem(supplierAddress, title)
133133 if ((0 >= price))
134134 then throw("purchase amount cannot be less than item price")
135135 else if ((getValueItemSupplier(item) != NONE))
136136 then throw("an item already exist")
137137 else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
138138 }
139139
140140
141141
142142 @Callable(i)
143143 func withdraw () = {
144144 let supplierAddress = toBase58String(i.caller.bytes)
145145 let balance = getValueBalanceSupplier(supplierAddress)
146146 if ((0 >= balance))
147147 then throw("insufficient balance")
148148 else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]
149149 }
150150
151151
152152
153153 @Callable(i)
154154 func voteCommit (item,hash) = {
155155 let user = toBase58String(i.caller.bytes)
156156 let commits = getValueCommitsCount(item)
157157 let status = getValueItemStatus(item)
158158 if ((commits >= VOTERS))
159159 then throw("reached max num of voters")
160160 else if ((getValueCommit(item, user) != NONE))
161161 then throw("user has already participated")
162162 else if ((getKeyItemSupplier(item) == NONE))
163163 then throw("item does not exist")
164164 else if (if ((status != NONE))
165165 then (status != VOTING)
166166 else false)
167167 then throw("voting is not possible")
168168 else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS))
169169 then REVEAL
170170 else VOTING)]
171171 }
172172
173173
174+
175+@Callable(i)
176+func voteReveal (item,vote,salt) = {
177+ let user = toBase58String(i.caller.bytes)
178+ let status = getValueItemStatus(item)
179+ let newVoteCount = (getValueVoteCount(item, vote) + 1)
180+ if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
181+ then throw("reveal data is not valid")
182+ else if ((VOTERS > getValueCommitsCount(item)))
183+ then throw("max num of voters hasn't reached yet")
184+ else if ((getValueReveal(item, user) != NONE))
185+ then throw("user has already participated")
186+ else if (if ((status != VOTING))
187+ then (status != REVEAL)
188+ else false)
189+ then throw("wrong status")
190+ else if (if ((vote != FEATURED))
191+ then (vote != DELISTED)
192+ else false)
193+ then throw("wrong vote")
194+ else if (if ((status == FEATURED))
195+ then true
196+ else (status == DELISTED))
197+ then throw("vote has finished")
198+ else [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVoteCount(item, vote), newVoteCount), StringEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
199+ then vote
200+ else REVEAL)]
201+ }
202+
203+
174204 @Verifier(tx)
175205 func verify () = true
176206

github/deemru/w8io/169f3d6 
43.70 ms