tx · E5c52KUeYkmwnaTnnfDuB5JosQg3sXCRB8hz2BJoXL7T

3N1dByHUoXjvxXXmRo1NsS9Z52TkVTMbMfE:  -0.01000000 Waves

2021.07.09 12:02 [1605871] smart account 3N1dByHUoXjvxXXmRo1NsS9Z52TkVTMbMfE > SELF 0.00000000 Waves

{ "type": 13, "id": "E5c52KUeYkmwnaTnnfDuB5JosQg3sXCRB8hz2BJoXL7T", "fee": 1000000, "feeAssetId": null, "timestamp": 1625821343532, "version": 2, "chainId": 84, "sender": "3N1dByHUoXjvxXXmRo1NsS9Z52TkVTMbMfE", "senderPublicKey": "xb4uHqMmBpMNrqAdGQyGQKu8BXJxp57LqWAjybjT9um", "proofs": [ "4fKGp82oY5jcHV61LDBDj7f5drRVkART8LRA6hYU9VxbwBycN3xuMwvbSzfscPjo1QtsSNSnDrRkfFDrys8K691V" ], "script": "base64:AAIFAAAAAAAABLoIAhIFCgMIAQgSAwoBCBIECgIICBIFCgMICAgSBAoCCAgaDAoCYTESBlZPVEVSUxoMCgJhMhIGUVVPUlVNGgwKAmEzEgZWT1RJTkcaDAoCYTQSBlJFVkVBTBoOCgJhNRIIRkVBVFVSRUQaDgoCYTYSCERFTElTVEVEGgoKAmE3EgROT05FGhQKAmE4Eg5nZXROdW1iZXJCeUtleRoJCgJhORIDa2V5GgkKAmIxEgNudW0aDQoCYjISByRtYXRjaDAaBwoCYjMSAWEaEQoCYjQSC2dldFN0ckJ5S2V5GgkKAmI1EgNzdHIaEgoCYjYSDGdldEtleUNvbW1pdBoKCgJiNxIEaXRlbRoKCgJiOBIEdXNlchoUCgJiORIOZ2V0VmFsdWVDb21taXQaGAoCYzESEmdldEtleUNvbW1pdHNDb3VudBoaCgJjMhIUZ2V0VmFsdWVDb21taXRzQ291bnQaEgoCYzMSDGdldEtleVJldmVhbBoUCgJjNBIOZ2V0VmFsdWVSZXZlYWwaFgoCYzUSEGdldEtleUl0ZW1TdGF0dXMaGAoCYzYSEmdldFZhbHVlSXRlbVN0YXR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YWdlIHdoaXRlbGlzdAMDCQEAAAACIT0AAAACBQAAAAJnNAUAAAACZjIJAQAAAAIhPQAAAAIFAAAAAmc0BQAAAAJmMwcJAAACAAAAAQIAAAAMd3Jvbmcgc3RhdHVzCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAAAJlOQAAAAEFAAAAAmQ2BQAAAAJnNAUAAAADbmlsAAAAAPukN7U=", "height": 1605871, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Gdo4GUnS39yTCWJetL2r5JiYfcTvq6uCa5spgekujbD9 Next: none Diff:
OldNewDifferences
9797 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
9898
9999
100+func getExtAddressOracle () = value(addressFromString("3N1dByHUoXjvxXXmRo1NsS9Z52TkVTMbMfE"))
101+
102+
103+func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status")
104+
105+
106+func getExtValueItemWhiteListStatus (oracle,account) = {
107+ let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) {
108+ case a: String =>
109+ a
110+ case _ =>
111+ NONE
112+ }
113+ str
114+ }
115+
116+
117+func getExtValueItemWhiteListed (item) = (item + "_verifier_status")
118+
119+
120+let verifier = "3N93qv25rFSewqXGvmKGZpKvEovK4c1Gg6d"
121+
122+let VERIFIED = "verified"
123+
124+let BLACKLISTED = "blacklist"
125+
100126 @Callable(i)
101127 func addItem (title,price,data) = {
102128 let supplierAddress = toBase58String(i.caller.bytes)
103129 let item = getKeyItem(supplierAddress, title)
130+ let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress)
104131 if ((0 >= price))
105132 then throw("Purchase amount cannot be less than item price")
106133 else if ((getValueItemSupplier(item) != NONE))
107134 then throw("an item already exists")
108- else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
135+ else if ((supplierWhiteList == BLACKLISTED))
136+ then throw("Supplier's account has been blacklisted")
137+ else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data), StringEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierWhiteList)]
109138 }
110139
111140
180209 }
181210
182211
212+
213+@Callable(i)
214+func setstatus (supplier,status) = {
215+ let accoount = toBase58String(i.caller.bytes)
216+ if ((accoount != verifier))
217+ then throw("only oracle verifier are able to manage whitelist")
218+ else if (if ((status != VERIFIED))
219+ then (status != BLACKLISTED)
220+ else false)
221+ then throw("wrong status")
222+ else [StringEntry(getExtValueItemWhiteListed(supplier), status)]
223+ }
224+
225+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let VOTERS = 3
55
66 let QUORUM = 2
77
88 let VOTING = "voting"
99
1010 let REVEAL = "reveal"
1111
1212 let FEATURED = "featured"
1313
1414 let DELISTED = "delisted"
1515
1616 let NONE = "none"
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 getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
4141
4242
4343 func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
4444
4545
4646 func getKeyCommitsCount (item) = (item + "_comcnt")
4747
4848
4949 func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
5050
5151
5252 func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
5353
5454
5555 func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
5656
5757
5858 func getKeyItemStatus (item) = (item + "_status")
5959
6060
6161 func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
6262
6363
6464 func getKeyVoteCount (item,vote) = ((item + "_res") + vote)
6565
6666
6767 func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
6868
6969
7070 func getKeyItemPrice (item) = (item + "_price")
7171
7272
7373 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
7474
7575
7676 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
7777
7878
7979 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
8080
8181
8282 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
8383
8484
8585 func getKeyItemData (item) = (item + "_data")
8686
8787
8888 func getKeyItemSupplier (item) = (item + "_owner")
8989
9090
9191 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
9292
9393
9494 func getKeyBalanceSupplier (account) = (account + "_balance")
9595
9696
9797 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
9898
9999
100+func getExtAddressOracle () = value(addressFromString("3N1dByHUoXjvxXXmRo1NsS9Z52TkVTMbMfE"))
101+
102+
103+func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status")
104+
105+
106+func getExtValueItemWhiteListStatus (oracle,account) = {
107+ let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) {
108+ case a: String =>
109+ a
110+ case _ =>
111+ NONE
112+ }
113+ str
114+ }
115+
116+
117+func getExtValueItemWhiteListed (item) = (item + "_verifier_status")
118+
119+
120+let verifier = "3N93qv25rFSewqXGvmKGZpKvEovK4c1Gg6d"
121+
122+let VERIFIED = "verified"
123+
124+let BLACKLISTED = "blacklist"
125+
100126 @Callable(i)
101127 func addItem (title,price,data) = {
102128 let supplierAddress = toBase58String(i.caller.bytes)
103129 let item = getKeyItem(supplierAddress, title)
130+ let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress)
104131 if ((0 >= price))
105132 then throw("Purchase amount cannot be less than item price")
106133 else if ((getValueItemSupplier(item) != NONE))
107134 then throw("an item already exists")
108- else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
135+ else if ((supplierWhiteList == BLACKLISTED))
136+ then throw("Supplier's account has been blacklisted")
137+ else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data), StringEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierWhiteList)]
109138 }
110139
111140
112141
113142 @Callable(i)
114143 func purchase (item) = {
115144 let pmt = i.payments[0]
116145 if (isDefined(pmt.assetId))
117146 then throw("WAVES tokens only at moment")
118147 else {
119148 let userAddress = toBase58String(i.caller.bytes)
120149 let price = getValueItemPrice(item)
121150 let supplierAddress = getValueItemSupplier(item)
122151 if ((price > pmt.amount))
123152 then throw("Purchase amount cannot be less than item price")
124153 else if ((supplierAddress == NONE))
125154 then throw("Supplier does not exist")
126155 else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]
127156 }
128157 }
129158
130159
131160
132161 @Callable(i)
133162 func voteCommit (item,hash) = {
134163 let user = toBase58String(i.caller.bytes)
135164 let commits = getValueCommitsCount(item)
136165 let status = getValueItemStatus(item)
137166 if ((commits >= VOTERS))
138167 then throw("reached max num of voters")
139168 else if ((getValueCommit(item, user) != NONE))
140169 then throw("user has already participated")
141170 else if ((getKeyItemSupplier(item) == NONE))
142171 then throw("item does not exist")
143172 else if (if ((status != NONE))
144173 then (status != VOTING)
145174 else false)
146175 then throw("voting is not possible")
147176 else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS))
148177 then REVEAL
149178 else VOTING)]
150179 }
151180
152181
153182
154183 @Callable(i)
155184 func voteReveal (item,vote,salt) = {
156185 let user = toBase58String(i.caller.bytes)
157186 let status = getValueItemStatus(item)
158187 let newVoteCount = (getValueVoteCount(item, vote) + 1)
159188 if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
160189 then throw("reveal data is not valid")
161190 else if ((VOTERS > getValueCommitsCount(item)))
162191 then throw("max num of voters hasnt reached yet")
163192 else if ((getValueReveal(item, user) != NONE))
164193 then throw("user has already participated")
165194 else if (if ((status != VOTING))
166195 then (status != REVEAL)
167196 else false)
168197 then throw("wrong status")
169198 else if (if ((vote != FEATURED))
170199 then (vote != DELISTED)
171200 else false)
172201 then throw("wrong vote")
173202 else if (if ((status == FEATURED))
174203 then true
175204 else (status == DELISTED))
176205 then throw("vote has finished")
177206 else [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVoteCount(item, vote), newVoteCount), StringEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
178207 then vote
179208 else REVEAL)]
180209 }
181210
182211
212+
213+@Callable(i)
214+func setstatus (supplier,status) = {
215+ let accoount = toBase58String(i.caller.bytes)
216+ if ((accoount != verifier))
217+ then throw("only oracle verifier are able to manage whitelist")
218+ else if (if ((status != VERIFIED))
219+ then (status != BLACKLISTED)
220+ else false)
221+ then throw("wrong status")
222+ else [StringEntry(getExtValueItemWhiteListed(supplier), status)]
223+ }
224+
225+

github/deemru/w8io/026f985 
32.51 ms