tx · 3DbZwjaAuUyfQ27aXGvqvGvvT6kv1dFthJDUD1FAtJKQ

3MybEQqZkhfmYgTkR9V8uZPueo5hsHTL7AE:  -0.01400000 Waves

2019.07.03 11:55 [569019] smart account 3MybEQqZkhfmYgTkR9V8uZPueo5hsHTL7AE > SELF 0.00000000 Waves

{ "type": 13, "id": "3DbZwjaAuUyfQ27aXGvqvGvvT6kv1dFthJDUD1FAtJKQ", "fee": 1400000, "feeAssetId": null, "timestamp": 1562144140259, "version": 1, "sender": "3MybEQqZkhfmYgTkR9V8uZPueo5hsHTL7AE", "senderPublicKey": "E2hFWtSsYVbt6M9BGBAd8wrh98cgk6B3LoVKnMwrY4Lk", "proofs": [ "2zM5YyyVRD6eFkD4JFLEnifLTYnLF2Wrwo9gwRu97MEGfPr87uyK7EEMXyo46FPj4Vu2ZV2Z7PZjmH8g6RudRLwZ" ], "script": "base64:AAIDAAAAAAAAAAAAAAAEAAAAAAh2ZXJpZmllcgIAAAAjM015YkVRcVpraGZtWWdUa1I5Vjh1WlB1ZW81aHNIVEw3QUUAAAAACFZFUklGSUVEAgAAAAh2ZXJpZmllZAAAAAALQkxBQ0tMSVNURUQCAAAACWJsYWNrbGlzdAEAAAAfZ2V0RXh0VmFsdWVJdGVtc1doaXRlTGlzdFN0YXR1cwAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAABBfdmVyaWZpZXJfc3RhdHVzAAAAAQAAAAFpAQAAAAlzZXRzdGF0dXMAAAACAAAACHN1cHBsaWVyAAAABnN0YXR1cwQAAAAHYWNjb3VudAkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzAwkBAAAAAiE9AAAAAgUAAAAHYWNjb3VudAUAAAAIdmVyaWZpZXIJAAACAAAAAQIAAAAxb25seSBvcmFjbGUgdmVyeWZpZXIgYXJlIGFibGUgdG8gbWFuYWdlIHdoaXRlbGlzdAMDCQEAAAACIT0AAAACBQAAAAZzdGF0dXMFAAAACFZFUklGSUVECQEAAAACIT0AAAACBQAAAAZzdGF0dXMFAAAAC0JMQUNLTElTVEVEBwkAAAIAAAABAgAAAAt3cm9nIHN0YXR1cwkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAH2dldEV4dFZhbHVlSXRlbXNXaGl0ZUxpc3RTdGF0dXMAAAABBQAAAAhzdXBwbGllcgUAAAAGc3RhdHVzBQAAAANuaWwAAAAAGjiOzw==", "chainId": 84, "height": 569019, "spentComplexity": 0 } View: original | compacted Prev: Hwv5u9jKF2Er4dcwpgD11ueN6Uo7MmQVwoyRUHxyUBSK Next: 2zgogptgpFPLQc8fyxeCzvfJbrGgVBmLfQnH65woZT4e Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let NONE = "none"
4+let verifier = "3MybEQqZkhfmYgTkR9V8uZPueo5hsHTL7AE"
55
6-let VOTERS = 1
7-
8-let QUARUM = 2
9-
10-let VOTING = "voting"
11-
12-let REVEAL = "reveal"
13-
14-let FEATURED = "featured"
15-
16-let DELISTED = "delisted"
6+let VERIFIED = "verified"
177
188 let BLACKLISTED = "blacklist"
199
20-func getNumberByKey (key) = {
21- let num = match getInteger(this, key) {
22- case a: Int =>
23- a
24- case _ =>
25- 0
26- }
27- num
28- }
29-
30-
31-func getStrByKey (key) = {
32- let str = match getString(this, key) {
33- case a: String =>
34- a
35- case _ =>
36- NONE
37- }
38- str
39- }
40-
41-
42-func getKeyItemPrice (item) = (item + "_price")
43-
44-
45-func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
46-
47-
48-func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
49-
50-
51-func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
52-
53-
54-func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
55-
56-
57-func getKeyItemData (item) = (item + "_data")
58-
59-
60-func getKeyItemSupplier (item) = (item + "_owner")
61-
62-
63-func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
64-
65-
66-func getKeyBalanceSupplier (account) = (account + "_balance")
67-
68-
69-func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
70-
71-
72-func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
73-
74-
75-func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
76-
77-
78-func getKeyCommitsCount (item) = (item + "_comcnt")
79-
80-
81-func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
82-
83-
84-func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
85-
86-
87-func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
88-
89-
90-func getKeyItemStatus (item) = (item + "_status")
91-
92-
93-func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
94-
95-
96-func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
97-
98-
99-func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
100-
101-
102-func getExtAddressOracle () = extract(addressFromString("3MybEQqZkhfmYgTkR9V8uZPueo5hsHTL7AE"))
103-
104-
105-func getExtKeyItemsWhiteListStatus (account) = (account + "_verifier_status")
106-
107-
108-func getExtValueItemsWhiteListStatus (oracle,account) = {
109- let str = match getString(oracle, getExtKeyItemsWhiteListStatus(account)) {
110- case a: String =>
111- a
112- case _ =>
113- NONE
114- }
115- str
116- }
10+func getExtValueItemsWhiteListStatus (item) = (item + "_verifier_status")
11711
11812
11913 @Callable(i)
120-func addItem (title,price,data) = {
121- let supplierAddress = toBase58String(i.caller.bytes)
122- let item = getKeyItem(supplierAddress, title)
123- let supplierWhiteList = getExtValueItemsWhiteListStatus(getExtAddressOracle(), supplierAddress)
124- if ((0 >= price))
125- then throw("purchase amount cannot be less than item price")
126- else if ((getValueItemSupplier(item) != NONE))
127- then throw("an item is already exist")
128- else if ((supplierWhiteList == BLACKLISTED))
129- then throw("supplier`s account has been blacklisted")
130- else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data), DataEntry(getExtKeyItemsWhiteListStatus(supplierAddress), supplierWhiteList)])
131- }
132-
133-
134-
135-@Callable(i)
136-func purchase (item) = {
137- let pmt = extract(i.payment)
138- if (isDefined(pmt.assetId))
139- then throw("WAVES tokens only at the moment")
140- else {
141- let userAddress = toBase58String(i.caller.bytes)
142- let price = getValueItemPrice(item)
143- let supplierAddress = getValueItemSupplier(item)
144- if ((price > pmt.amount))
145- then throw("purchase amount cannot be less than item price")
146- else if ((pmt.amount > price))
147- then throw("purchase amount cannot be higher than item price")
148- else if ((supplierAddress == NONE))
149- then throw("supplier does not exist")
150- else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
151- }
152- }
153-
154-
155-
156-@Callable(i)
157-func withdraw () = {
158- let supplierAddress = toBase58String(i.caller.bytes)
159- let balance = getValueBalanceSupplier(supplierAddress)
160- if ((0 > balance))
161- then throw("insufficient balance")
162- else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
163- }
164-
165-
166-
167-@Callable(i)
168-func voteCommit (item,hash) = {
169- let user = toBase58String(i.caller.bytes)
170- let commits = getValueCommitsCount(item)
171- let status = getValueItemStatus(item)
172- if ((commits >= VOTERS))
173- then throw("reached max num of voters")
174- else if ((getValueCommit(item, user) != NONE))
175- then throw("user has already participated")
176- else if ((getKeyItemSupplier(item) == NONE))
177- then throw("item does not exist")
178- else if (if ((status != NONE))
179- then (status != VOTING)
180- else false)
181- then throw("voting is not possible")
182- else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
183- then REVEAL
184- else VOTING)])
185- }
186-
187-
188-
189-@Callable(i)
190-func voteReveal (item,vote,salt) = {
191- let user = toBase58String(i.caller.bytes)
192- let status = getValueItemStatus(item)
193- let newVoteCount = (getValueVoteCount(item, vote) + 1)
194- if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
195- then throw("reveal data is not valid")
196- else if ((VOTERS > getValueCommitsCount(item)))
197- then throw("max num of voters hasn`t reached yet")
198- else if ((getValueReveal(item, user) != NONE))
199- then throw("user has already participated")
200- else if (if ((status != VOTING))
201- then (status != REVEAL)
202- else false)
203- then throw("wrong status")
204- else if (if ((vote != FEATURED))
205- then (vote != DELISTED)
206- else false)
207- then throw("wrong vote")
208- else if (if ((status == FEATURED))
209- then true
210- else (status == DELISTED))
211- then throw("vote has finished")
212- else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUARUM))
213- then vote
214- else REVEAL)])
14+func setstatus (supplier,status) = {
15+ let account = toBase58String(i.caller.bytes)
16+ if ((account != verifier))
17+ then throw("only oracle veryfier are able to manage whitelist")
18+ else if (if ((status != VERIFIED))
19+ then (status != BLACKLISTED)
20+ else false)
21+ then throw("wrog status")
22+ else WriteSet([DataEntry(getExtValueItemsWhiteListStatus(supplier), status)])
21523 }
21624
21725

github/deemru/w8io/169f3d6 
58.46 ms