tx · 24x7gEHVJS9TYsfDzeny3xko4KrExNnwzFwq2gBV63Js

3MqiiiD5GiCgJENfvC6HA8MyUeZfX1fB4yD:  -0.01400000 Waves

2019.06.25 23:33 [558128] smart account 3MqiiiD5GiCgJENfvC6HA8MyUeZfX1fB4yD > SELF 0.00000000 Waves

{ "type": 13, "id": "24x7gEHVJS9TYsfDzeny3xko4KrExNnwzFwq2gBV63Js", "fee": 1400000, "feeAssetId": null, "timestamp": 1561494846305, "version": 1, "sender": "3MqiiiD5GiCgJENfvC6HA8MyUeZfX1fB4yD", "senderPublicKey": "2XEK2wpQ5tXMZdzxJPyGzitzHyVyQxp3WT9Ekxe8br7N", "proofs": [ "49f3ckehFGrj4qivZE8sdLDrf1BcxH7dW5gatyXpMiNVHc8NS1fuFfQ355sZ3hqVEjWMJWL8cdxZyT3abCC5Zctr" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAROT05FAgAAAARub25lAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9ORQUAAAADc3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RyeQAAAAIJAQAAAA9nZXRLZXlWb3RlQ291bnQAAAACBQAAAARpdGVtBQAAAAR2b3RlBQAAAAxuZXdWb3RlQ291bnQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABBnZXRLZXlJdGVtU3RhdHVzAAAAAQUAAAAEaXRlbQMJAABnAAAAAgUAAAAMbmV3Vm90ZUNvdW50BQAAAAZRVU9SVU0FAAAABHZvdGUFAAAABlJFVkVBTAUAAAADbmlsAAAAAI6HQOo=", "chainId": 84, "height": 558128, "spentComplexity": 0 } View: original | compacted Prev: Fs6icRBs9uCmurrkHrb1UREQkT7vYWmbgp4mT72h3Vfb Next: none Diff:
OldNewDifferences
180180 else false)
181181 then throw("wrong status")
182182 else if (if ((vote != FEATURED))
183- then true
184- else (vote != DELISTED))
183+ then (vote != DELISTED)
184+ else false)
185185 then throw("wrong vote")
186186 else if (if ((status == FEATURED))
187187 then true
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"
1313
1414 let FEATURED = "featured"
1515
1616 let DELISTED = "delisted"
1717
1818 func getNumberByKey (key) = {
1919 let num = match getInteger(this, key) {
2020 case a: Int =>
2121 a
2222 case _ =>
2323 0
2424 }
2525 num
2626 }
2727
2828
2929 func getStrByKey (key) = {
3030 let str = match getString(this, key) {
3131 case a: String =>
3232 a
3333 case _ =>
3434 NONE
3535 }
3636 str
3737 }
3838
3939
4040 func getKeyItemPrice (item) = (item + "_price")
4141
4242
4343 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
4444
4545
4646 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
4747
4848
4949 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
5050
5151
5252 func getKeyItem (supplier,item) = ("item_" + toBase58String(sha256(toBytes((supplier + item)))))
5353
5454
5555 func getKeyItemData (item) = (item + "_data")
5656
5757
5858 func getKeyItemSupplier (item) = (item + "_owner")
5959
6060
6161 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
6262
6363
6464 func getKeyBalanceSupplier (account) = (account + "_balance")
6565
6666
6767 func getValueBalanceSupplier (item) = getNumberByKey(getKeyBalanceSupplier(item))
6868
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 purchase (item) = {
102102 let pmt = extract(i.payment)
103103 if (isDefined(pmt.assetId))
104104 then throw("can use WAVES only at the moment")
105105 else {
106106 let userAddress = toBase58String(i.caller.bytes)
107107 let price = getValueItemPrice(item)
108108 let supplierAddress = getValueItemSupplier(item)
109109 if ((price > pmt.amount))
110110 then throw("purchase amount cannot be less than item price")
111111 else if ((pmt.amount > price))
112112 then throw("purchase amount cannot be higher than item price")
113113 else if ((supplierAddress == NONE))
114114 then throw("supplier does not exist")
115115 else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
116116 }
117117 }
118118
119119
120120
121121 @Callable(i)
122122 func addItem (title,price,data) = {
123123 let supplierAddress = toBase58String(i.caller.bytes)
124124 let item = getKeyItem(supplierAddress, title)
125125 if ((0 >= price))
126126 then throw("purchase amount cannot be less than item price")
127127 else if ((getValueItemSupplier(item) != NONE))
128128 then throw("Item already exists")
129129 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
130130 }
131131
132132
133133
134134 @Callable(i)
135135 func withdraw () = {
136136 let supplierAddress = toBase58String(i.caller.bytes)
137137 let balance = getValueBalanceSupplier(supplierAddress)
138138 if ((0 >= balance))
139139 then throw("insufficient balance")
140140 else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
141141 }
142142
143143
144144
145145 @Callable(i)
146146 func voteCommit (item,hash) = {
147147 let user = toBase58String(i.caller.bytes)
148148 let commits = getValueCommitsCount(item)
149149 let status = getValueItemStatus(item)
150150 if ((commits >= VOTERS))
151151 then throw("reached max num of voters")
152152 else if ((getValueCommit(item, user) != NONE))
153153 then throw("user has already participated")
154154 else if ((getKeyItemSupplier(item) == NONE))
155155 then throw("item does not exist")
156156 else if (if ((status != NONE))
157157 then (status != VOTING)
158158 else false)
159159 then throw("voting is not possible")
160160 else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
161161 then REVEAL
162162 else VOTING)])
163163 }
164164
165165
166166
167167 @Callable(i)
168168 func voteReveal (item,vote,salt) = {
169169 let user = toBase58String(i.caller.bytes)
170170 let status = getValueItemStatus(item)
171171 let newVoteCount = (getValueVoteCount(item, vote) + 1)
172172 if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
173173 then throw("Reveal data is not valid")
174174 else if ((VOTERS > getValueCommitsCount(item)))
175175 then throw("max number of voters hasn't reached yet")
176176 else if ((getValueReveal(item, user) != NONE))
177177 then throw("user has already participated")
178178 else if (if ((status != VOTING))
179179 then (status != REVEAL)
180180 else false)
181181 then throw("wrong status")
182182 else if (if ((vote != FEATURED))
183- then true
184- else (vote != DELISTED))
183+ then (vote != DELISTED)
184+ else false)
185185 then throw("wrong vote")
186186 else if (if ((status == FEATURED))
187187 then true
188188 else (status == DELISTED))
189189 then throw("vote has finished")
190190 else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
191191 then vote
192192 else REVEAL)])
193193 }
194194
195195

github/deemru/w8io/026f985 
48.25 ms