tx · AxUFqyitAkhAfhyhDbtPAYdpnSDDV34HgTjLa2aNU5Aj

3MzZVNwvKoTH3V7x9x82gVw5dBeytVkY5sA:  -0.01400000 Waves

2019.07.09 07:46 [577633] smart account 3MzZVNwvKoTH3V7x9x82gVw5dBeytVkY5sA > SELF 0.00000000 Waves

{ "type": 13, "id": "AxUFqyitAkhAfhyhDbtPAYdpnSDDV34HgTjLa2aNU5Aj", "fee": 1400000, "feeAssetId": null, "timestamp": 1562647697940, "version": 1, "sender": "3MzZVNwvKoTH3V7x9x82gVw5dBeytVkY5sA", "senderPublicKey": "2zNrrVcRpgUJg9kb4fqpm2HSkQ85LMSwYBY4RAriw6fN", "proofs": [ "8ukeQH3MHTY8BZHkDRxLMQks8JhnDci7XZmGPcHLhmJ7KPJGPk4Zah6os9u3Y6Xw2tA4Q6oPq7amAqkntXHUSZF" ], "script": "base64:AAIDAAAAAAAAAAAAAAAEAQAAAB5nZXRFeHRWYWx1ZUl0ZW1XaGl0ZUxpc3RTdGF0dXMAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAQX3ZlcmlmaWVyX3N0YXR1cwAAAAAIdmVyaWZpZXICAAAAIzNNenR3N0JRUFdoQ1hEeEhFU3JCb1gyREtrMTJ5TkFHSzVFAAAAAAhWRVJJRklFRAIAAAAIdmVyaWZpZWQAAAAAC0JMQUNLTElTVEVEAgAAAAtibGFja2xpc3RlZAAAAAEAAAABaQEAAAAJc2V0c3RhdHVzAAAAAgAAAAhzdXBwbGllcgAAAAZzdGF0dXMEAAAAB2FjY291bnQJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwMJAQAAAAIhPQAAAAIFAAAAB2FjY291bnQFAAAACHZlcmlmaWVyCQAAAgAAAAECAAAAMW9ubHkgb3JhY2xlIHZlcmlmaWVyIGFyZSBhYmxlIHRvIG1hbmFnZSB3aGl0ZWxpc3QDAwkBAAAAAiE9AAAAAgUAAAAGc3RhdHVzBQAAAAhWRVJJRklFRAkBAAAAAiE9AAAAAgUAAAAGc3RhdHVzBQAAAAtCTEFDS0xJU1RFRAcJAAACAAAAAQIAAAAMd3Jvbmcgc3RhdHVzCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAeZ2V0RXh0VmFsdWVJdGVtV2hpdGVMaXN0U3RhdHVzAAAAAQUAAAAIc3VwcGxpZXIFAAAABnN0YXR1cwUAAAADbmlsAAAAAJkGhqc=", "chainId": 84, "height": 577633, "spentComplexity": 0 } View: original | compacted Prev: 9uRcJBo4qMUXxaYpAbuhLutUdxn9gZRMNdW4jfmZutcs Next: 3K7EETbtsdFbMDLBoAzmx8LPCZ43ajRSPicVJuDk9Lf9 Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let NONE = "none"
5-
6-func getNumberByKey (key) = {
7- let num = match getInteger(this, key) {
8- case a: Int =>
9- a
10- case _ =>
11- 0
12- }
13- num
14- }
4+func getExtValueItemWhiteListStatus (item) = (item + "_verifier_status")
155
166
17-func getStrByKey (key) = {
18- let str = match getString(this, key) {
19- case a: String =>
20- a
21- case _ =>
22- NONE
23- }
24- str
25- }
7+let verifier = "3Mztw7BQPWhCXDxHESrBoX2DKk12yNAGK5E"
268
27-
28-func getKeyItemPrice (item) = (item + "_price")
29-
30-
31-func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
32-
33-
34-func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
35-
36-
37-func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
38-
39-
40-func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
41-
42-
43-func getKeyItemData (item) = (item + "_data")
44-
45-
46-func getKeyItemSupplier (item) = (item + "_owner")
47-
48-
49-func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
50-
51-
52-func getKeyBalanceSupplier (account) = (account + "_balance")
53-
54-
55-func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
56-
57-
58-let VOTERS = 3
59-
60-let QUORUM = 2
61-
62-let VOTING = "voting"
63-
64-let REVEAL = "reveal"
65-
66-let FEATURED = "featured"
67-
68-let DELISTED = "delisted"
69-
70-func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
71-
72-
73-func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
74-
75-
76-func getKeyCommitsCount (item) = (item + "_comcnt")
77-
78-
79-func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
80-
81-
82-func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
83-
84-
85-func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
86-
87-
88-func getKeyItemStatus (item) = (item + "_status")
89-
90-
91-func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
92-
93-
94-func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
95-
96-
97-func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
98-
99-
100-func getExtAddressOracle () = extract(addressFromString("3MzZVNwvKoTH3V7x9x82gVw5dBeytVkY5sA"))
101-
9+let VERIFIED = "verified"
10210
10311 let BLACKLISTED = "blacklisted"
10412
105-func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status")
106-
107-
108-func getExtValueItemWhiteListStatus (oracle,account) = {
109- let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) {
110- case a: String =>
111- a
112- case _ =>
113- NONE
114- }
115- str
116- }
117-
118-
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 = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress)
124- if ((0 >= price))
125- then throw("purchase amount can't be less than item price")
126- else if ((getValueItemSupplier(item) != NONE))
127- then throw("an item 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)])
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("can use WAVES 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 doesn't 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("insufficent funds")
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 run of voters")
198- else if ((getValueReveal(item, user) != NONE))
199- then throw("user 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 >= QUORUM))
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 verifier are able to manage whitelist")
18+ else if (if ((status != VERIFIED))
19+ then (status != BLACKLISTED)
20+ else false)
21+ then throw("wrong status")
22+ else WriteSet([DataEntry(getExtValueItemWhiteListStatus(supplier), status)])
21523 }
21624
21725

github/deemru/w8io/873ac7e 
25.34 ms