tx · BVRiNuxqVnhZrnED9hQRixz6KqEu3G1mz3oU5PukqoxC

3MyZc63LNUPHStRm6Y38NTQGzPjDREyqiRf:  -0.01400000 Waves

2019.08.10 01:14 [624041] smart account 3MyZc63LNUPHStRm6Y38NTQGzPjDREyqiRf > SELF 0.00000000 Waves

{ "type": 13, "id": "BVRiNuxqVnhZrnED9hQRixz6KqEu3G1mz3oU5PukqoxC", "fee": 1400000, "feeAssetId": null, "timestamp": 1565388976737, "version": 1, "sender": "3MyZc63LNUPHStRm6Y38NTQGzPjDREyqiRf", "senderPublicKey": "FGm3vtnGW6r9XgBJwAL6exsKRRNxhnEB5XiYUGpuPpUF", "proofs": [ "2gUbbyGdJcJTAGzhd8jEsMqPHT73PgTqHPAwV6hNSypPWxZbwPQ9ZCgJWiB2doJ5Q5i8wXD71qtSeNLZWfZNdy1t" ], "script": "base64:AAIDAAAAAAAAAAAAAAAEAQAAAB5nZXRFeHRWYWx1ZUl0ZW1XaGl0ZUxpc3RTdGF0dXMAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAQX3ZlcmlmaWVyX3N0YXR1cwAAAAAIdmVyaWZpZXICAAAAIzNOQTk4eGRrWnJZUEhjcGZxc0I4WGdla0RvUWkyRXVmenMyAAAAAAhWRVJJRklFRAIAAAAIdmVyaWZpZWQAAAAAC0JMQUNLTElTVEVEAgAAAAlibGFja2xpc3QAAAABAAAAAWkBAAAACXNldHN0YXR1cwAAAAIAAAAIc3VwcGxpZXIAAAAGc3RhdHVzBAAAAAdhY2NvdW50CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMDCQEAAAACIT0AAAACBQAAAAdhY2NvdW50BQAAAAh2ZXJpZmllcgkAAAIAAAABAgAAADFvbmx5IG9yYWNsZSB2ZXJ5ZmllciBhcmUgYWJsZSB0byBtYW5hZ2Ugd2hpdGVsaXN0AwMJAQAAAAIhPQAAAAIFAAAABnN0YXR1cwUAAAAIVkVSSUZJRUQJAQAAAAIhPQAAAAIFAAAABnN0YXR1cwUAAAALQkxBQ0tMSVNURUQHCQAAAgAAAAECAAAADHdyb25nIHN0YXR1cwkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAHmdldEV4dFZhbHVlSXRlbVdoaXRlTGlzdFN0YXR1cwAAAAEFAAAACHN1cHBsaWVyBQAAAAZzdGF0dXMFAAAAA25pbAAAAADEZZs+", "chainId": 84, "height": 624041, "spentComplexity": 0 } View: original | compacted Prev: H6CWVnaFTEfwCXRp7SbNtyxXSjkfqa2mhpkWSjun9gPL Next: EfkCThhPMLXJAj9mqTdhtXpFs5Uk5z2nzf4BPuDrSs1i Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let ownerPublicKey = base58'FGm3vtnGW6r9XgBJwAL6exsKRRNxhnEB5XiYUGpuPpUF'
4+func getExtValueItemWhiteListStatus (item) = (item + "_verifier_status")
55
6-let NONE = "none"
76
8-let VOTERS = 3
7+let verifier = "3NA98xdkZrYPHcpfqsB8XgekDoQi2Eufzs2"
98
10-let QUORUM = 2
9+let VERIFIED = "verified"
1110
12-let VOTING = "voting"
11+let BLACKLISTED = "blacklist"
1312
14-let REVEAL = "reveal"
15-
16-let FEATURED = "featured"
17-
18-let DELISTED = "delisted"
19-
20-func getNumberByKey (key) = {
21- let num = match getInteger(this, key) {
22- case a: Int =>
23- a
24- case _ =>
25- 0
26- }
27- num
13+@Callable(i)
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("wrong status")
22+ else WriteSet([DataEntry(getExtValueItemWhiteListStatus(supplier), status)])
2823 }
2924
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 getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
43-
44-
45-func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
46-
47-
48-func getKeyCommitsCount (item) = (item + "_comcnt")
49-
50-
51-func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
52-
53-
54-func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
55-
56-
57-func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
58-
59-
60-func getKeyItemStatus (item) = (item + "_status")
61-
62-
63-func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
64-
65-
66-func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
67-
68-
69-func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
70-
71-
72-func getKeyItemPrice (item) = (item + "_price")
73-
74-
75-func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
76-
77-
78-func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
79-
80-
81-func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
82-
83-
84-func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
85-
86-
87-func getKeyItemData (item) = (item + "_data")
88-
89-
90-func getKeyItemSupplier (item) = (item + "_owner")
91-
92-
93-func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
94-
95-
96-func getKeyBalanceSupplier (account) = (account + "_balance")
97-
98-
99-func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
100-
101-
102-@Callable(i)
103-func voteReveal (item,vote,salt) = {
104- let user = toBase58String(i.caller.bytes)
105- let status = getValueItemStatus(item)
106- let newVoteCount = (getValueVoteCount(item, vote) + 1)
107- if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
108- then throw("reveal data is not valid")
109- else if ((VOTERS > getValueCommitsCount(item)))
110- then throw("max num of voters hasn't been reached yet")
111- else if ((getValueReveal(item, user) != NONE))
112- then throw("user has already participated")
113- else if (if ((status != VOTING))
114- then (status != REVEAL)
115- else false)
116- then throw("wrong status")
117- else if (if ((vote != FEATURED))
118- then (vote != DELISTED)
119- else false)
120- then throw("wrong vote")
121- else if (if ((status == FEATURED))
122- then true
123- else (status == DELISTED))
124- then throw("vote has finished")
125- else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
126- then vote
127- else REVEAL)])
128- }
129-
130-
131-
132-@Callable(i)
133-func voteCommit (item,hash) = {
134- let user = toBase58String(i.caller.bytes)
135- let commits = getValueCommitsCount(item)
136- let status = getValueItemStatus(item)
137- if ((commits >= VOTERS))
138- then throw("reached max num of voters")
139- else if ((getValueCommit(item, user) != NONE))
140- then throw("user has already participated")
141- else if ((getKeyItemSupplier(item) == NONE))
142- then throw("item does not exist")
143- else if (if ((status != NONE))
144- then (status != VOTING)
145- else false)
146- then throw("voting is not possible")
147- else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
148- then REVEAL
149- else VOTING)])
150- }
151-
152-
153-
154-@Callable(i)
155-func purchase (item) = {
156- let pmt = extract(i.payment)
157- if (isDefined(pmt.assetId))
158- then throw("can use WAVES only at the moment")
159- else {
160- let userAddress = toBase58String(i.caller.bytes)
161- let price = getValueItemPrice(item)
162- let supplierAddress = getValueItemSupplier(item)
163- if ((price > pmt.amount))
164- then throw("purchase amount cannot be less than item price")
165- else if ((pmt.amount > price))
166- then throw("purchase amount cannot be higher than item price")
167- else if ((supplierAddress == NONE))
168- then throw("supplier does not exist")
169- else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
170- }
171- }
172-
173-
174-
175-@Callable(i)
176-func withdraw () = {
177- let supplierAddress = toBase58String(i.caller.bytes)
178- let balance = getValueBalanceSupplier(supplierAddress)
179- if ((0 >= balance))
180- then throw("insufficient balance")
181- else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
182- }
183-
184-
185-
186-@Callable(i)
187-func addItem (title,price,data) = {
188- let supplierAddress = toBase58String(i.caller.bytes)
189- let item = getKeyItem(supplierAddress, title)
190- if ((0 >= price))
191- then throw("purchase amount cannot be less than item price")
192- else if ((getValueItemSupplier(item) != NONE))
193- then throw("an item is already exist")
194- else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
195- }
196-
197-
198-@Verifier(tx)
199-func verify () = match tx {
200- case d: SetScriptTransaction =>
201- sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey)
202- case d: DataTransaction =>
203- true
204- case d: TransferTransaction =>
205- true
206- case _ =>
207- false
208-}
20925

github/deemru/w8io/026f985 
24.24 ms