tx · 57G39WGVQUXRLFwSWHYycuiG1APrePxwX6t5cB1en8UJ

3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq:  -0.01400000 Waves

2019.06.22 22:28 [553673] smart account 3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq > SELF 0.00000000 Waves

{ "type": 13, "id": "57G39WGVQUXRLFwSWHYycuiG1APrePxwX6t5cB1en8UJ", "fee": 1400000, "feeAssetId": null, "timestamp": 1561231770850, "version": 1, "sender": "3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq", "senderPublicKey": "4fygXNNAjU52sT9N6uq4o9Ck8G75e94ukktN3pd4VxVo", "proofs": [ "581WaxgYmNpLbxxFWP4pDQu6TP7SQV2mQ1PP84NSXD89yZ7mgcdQUjMFFHD3JsT8kej8ReUyfXDsBVUbfQgqrVpk" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAROT05FAgAAAARub25lAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAFWdldEtleVVzZXJJdGVtQ291bnRlcgAAAAIAAAAEdXNlcgAAAARpdGVtCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAARpdGVtAgAAAA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Id": 84, "height": 553673, "spentComplexity": 0 } View: original | compacted Prev: 42ujvvpHFCiMcy7LXZpHraEq7P2agG58WrsiMxkN77FJ Next: 5cp6kSLnPCDNRt4Xo9LTgKpdGmQqGZs318NkncRMq7vS Diff:
OldNewDifferences
161161 }
162162
163163
164+
165+@Callable(i)
166+func voteReveal (item,vote,salt) = {
167+ let user = toBase58String(i.caller.bytes)
168+ let status = getValueItemStatus(item)
169+ let newVoteCount = (getValueVoteCount(item, vote) + 1)
170+ if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
171+ then throw("reveal is not valid")
172+ else if ((Voters > getValueCommitsCount(item)))
173+ then throw("not enough votes")
174+ else if ((getValueReveal(item, user) != NONE))
175+ then throw("usr already participated")
176+ else if (if ((status != Voting))
177+ then (status != Reveal)
178+ else false)
179+ then throw("wrong status")
180+ else if (if ((vote != Featured))
181+ then true
182+ else (status != Delisted))
183+ then throw("wrong vote")
184+ else if (if ((status == Featured))
185+ then true
186+ else (status == Delisted))
187+ then throw("voting finished already")
188+ else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= Quorum))
189+ then vote
190+ else Reveal)])
191+ }
192+
193+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
55
66 func getKeyItemPrice (item) = (item + "_price")
77
88
99 func getNumberByKey (key) = {
1010 let num = match getInteger(this, key) {
1111 case a: Int =>
1212 a
1313 case _ =>
1414 0
1515 }
1616 num
1717 }
1818
1919
2020 func getStrByKey (key) = {
2121 let str = match getString(this, key) {
2222 case a: String =>
2323 a
2424 case _ =>
2525 NONE
2626 }
2727 str
2828 }
2929
3030
3131 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
3232
3333
3434 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
3535
3636
3737 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
3838
3939
4040 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4141
4242
4343 func getKeyItemData (item) = (item + "_data")
4444
4545
4646 func getKeyItemSupplier (item) = (item + "_owner")
4747
4848
4949 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5050
5151
5252 func getKeyBalanceSupplier (account) = (account + "_balance")
5353
5454
5555 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
5656
5757
5858 let Voters = 3
5959
6060 let Quorum = 2
6161
6262 let Voting = "voting"
6363
6464 let Reveal = "reveal"
6565
6666 let Featured = "featured"
6767
6868 let Delisted = "delisted"
6969
7070 func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
7171
7272
7373 func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
7474
7575
7676 func getKeyCommitsCount (item) = (item + "+comcnt")
7777
7878
7979 func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
8080
8181
8282 func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
8383
8484
8585 func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
8686
8787
8888 func getKeyItemStatus (item) = (item + "_status")
8989
9090
9191 func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
9292
9393
9494 func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
9595
9696
9797 func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
9898
9999
100100 @Callable(i)
101101 func additem (title,price,data) = {
102102 let suppad = toBase58String(i.caller.bytes)
103103 let item = getKeyItem(suppad, title)
104104 if ((0 >= price))
105105 then throw("purchase amount cannot be less than 0 or 0")
106106 else if ((getValueItemSupplier(item) != NONE))
107107 then throw("an item already exists")
108108 else WriteSet([DataEntry(getKeyItemSupplier(item), suppad), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
109109 }
110110
111111
112112
113113 @Callable(i)
114114 func purchase (item) = {
115115 let pmt = extract(i.payment)
116116 if (isDefined(pmt.assetId))
117117 then throw("Can use Waves only at the moment")
118118 else {
119119 let customerAddress = toBase58String(i.caller.bytes)
120120 let price = getValueItemPrice(item)
121121 let supadd = getValueItemSupplier(item)
122122 if ((price > pmt.amount))
123123 then throw("purchase amount cannot be less than item price ")
124124 else if ((pmt.amount > price))
125125 then throw("purchase amount cannot be higher than item price")
126126 else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, item), (getValueUserItemCounter(customerAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supadd), (getValueBalanceSupplier(supadd) + pmt.amount))])
127127 }
128128 }
129129
130130
131131
132132 @Callable(i)
133133 func withdraw () = {
134134 let suppadd = toBase58String(i.caller.bytes)
135135 let bal = getNumberByKey("3MqjzNpmZAF3K7W6RRcezbSdWorMAXXwdqo_balance")
136136 if ((0 >= bal))
137137 then throw("Insufficient Balance xD")
138138 else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(suppadd), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(suppadd), bal, unit)]))
139139 }
140140
141141
142142
143143 @Callable(i)
144144 func voteCommit (item,hash) = {
145145 let user = toBase58String(i.caller.bytes)
146146 let commits = getValueCommitsCount(item)
147147 let status = getValueItemStatus(item)
148148 if ((commits >= Voters))
149149 then throw("Max votes")
150150 else if ((getValueCommit(item, user) != NONE))
151151 then throw("already done")
152152 else if ((getKeyItemSupplier(item) == NONE))
153153 then throw("item doesnot exist")
154154 else if (if ((status != NONE))
155155 then (status != Voting)
156156 else false)
157157 then throw("not possilble")
158158 else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == Voters))
159159 then Reveal
160160 else Voting)])
161161 }
162162
163163
164+
165+@Callable(i)
166+func voteReveal (item,vote,salt) = {
167+ let user = toBase58String(i.caller.bytes)
168+ let status = getValueItemStatus(item)
169+ let newVoteCount = (getValueVoteCount(item, vote) + 1)
170+ if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
171+ then throw("reveal is not valid")
172+ else if ((Voters > getValueCommitsCount(item)))
173+ then throw("not enough votes")
174+ else if ((getValueReveal(item, user) != NONE))
175+ then throw("usr already participated")
176+ else if (if ((status != Voting))
177+ then (status != Reveal)
178+ else false)
179+ then throw("wrong status")
180+ else if (if ((vote != Featured))
181+ then true
182+ else (status != Delisted))
183+ then throw("wrong vote")
184+ else if (if ((status == Featured))
185+ then true
186+ else (status == Delisted))
187+ then throw("voting finished already")
188+ else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= Quorum))
189+ then vote
190+ else Reveal)])
191+ }
192+
193+

github/deemru/w8io/026f985 
26.85 ms