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:AAIFAAAAAAAABLoIAhIFCgMIAQgSAwoBCBIECgIICBIFCgMICAgSBAoCCAgaDAoCYTESBlZPVEVSUxoMCgJhMhIGUVVPUlVNGgwKAmEzEgZWT1RJTkcaDAoCYTQSBlJFVkVBTBoOCgJhNRIIRkVBVFVSRUQaDgoCYTYSCERFTElTVEVEGgoKAmE3EgROT05FGhQKAmE4Eg5nZXROdW1iZXJCeUtleRoJCgJhORIDa2V5GgkKAmIxEgNudW0aDQoCYjISByRtYXRjaDAaBwoCYjMSAWEaEQoCYjQSC2dldFN0ckJ5S2V5GgkKAmI1EgNzdHIaEgoCYjYSDGdldEtleUNvbW1pdBoKCgJiNxIEaXRlbRoKCgJiOBIEdXNlchoUCgJiORIOZ2V0VmFsdWVDb21taXQaGAoCYzESEmdldEtleUNvbW1pdHNDb3VudBoaCgJjMhIUZ2V0VmFsdWVDb21taXRzQ291bnQaEgoCYzMSDGdldEtleVJldmVhbBoUCgJjNBIOZ2V0VmFsdWVSZXZlYWwaFgoCYzUSEGdldEtleUl0ZW1TdGF0dXMaGAoCYzYSEmdldFZhbHVlSXRlbVN0YXR1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WdlIHdoaXRlbGlzdAMDCQEAAAACIT0AAAACBQAAAAJnNAUAAAACZjIJAQAAAAIhPQAAAAIFAAAAAmc0BQAAAAJmMwcJAAACAAAAAQIAAAAMd3Jvbmcgc3RhdHVzCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAAAJlOQAAAAEFAAAAAmQ2BQAAAAJnNAUAAAADbmlsAAAAAPukN7U=", "height": 1605871, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Gdo4GUnS39yTCWJetL2r5JiYfcTvq6uCa5spgekujbD9 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
97 | 97 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
98 | 98 | ||
99 | 99 | ||
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 | + | ||
100 | 126 | @Callable(i) | |
101 | 127 | func addItem (title,price,data) = { | |
102 | 128 | let supplierAddress = toBase58String(i.caller.bytes) | |
103 | 129 | let item = getKeyItem(supplierAddress, title) | |
130 | + | let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
104 | 131 | if ((0 >= price)) | |
105 | 132 | then throw("Purchase amount cannot be less than item price") | |
106 | 133 | else if ((getValueItemSupplier(item) != NONE)) | |
107 | 134 | 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)] | |
109 | 138 | } | |
110 | 139 | ||
111 | 140 | ||
180 | 209 | } | |
181 | 210 | ||
182 | 211 | ||
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 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let VOTERS = 3 | |
5 | 5 | ||
6 | 6 | let QUORUM = 2 | |
7 | 7 | ||
8 | 8 | let VOTING = "voting" | |
9 | 9 | ||
10 | 10 | let REVEAL = "reveal" | |
11 | 11 | ||
12 | 12 | let FEATURED = "featured" | |
13 | 13 | ||
14 | 14 | let DELISTED = "delisted" | |
15 | 15 | ||
16 | 16 | let NONE = "none" | |
17 | 17 | ||
18 | 18 | func getNumberByKey (key) = { | |
19 | 19 | let num = match getInteger(this, key) { | |
20 | 20 | case a: Int => | |
21 | 21 | a | |
22 | 22 | case _ => | |
23 | 23 | 0 | |
24 | 24 | } | |
25 | 25 | num | |
26 | 26 | } | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func getStrByKey (key) = { | |
30 | 30 | let str = match getString(this, key) { | |
31 | 31 | case a: String => | |
32 | 32 | a | |
33 | 33 | case _ => | |
34 | 34 | NONE | |
35 | 35 | } | |
36 | 36 | str | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getKeyCommitsCount (item) = (item + "_comcnt") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func getKeyItemStatus (item) = (item + "_status") | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func getKeyVoteCount (item,vote) = ((item + "_res") + vote) | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func getKeyItemPrice (item) = (item + "_price") | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func getKeyItemData (item) = (item + "_data") | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func getKeyItemSupplier (item) = (item + "_owner") | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
98 | 98 | ||
99 | 99 | ||
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 | + | ||
100 | 126 | @Callable(i) | |
101 | 127 | func addItem (title,price,data) = { | |
102 | 128 | let supplierAddress = toBase58String(i.caller.bytes) | |
103 | 129 | let item = getKeyItem(supplierAddress, title) | |
130 | + | let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
104 | 131 | if ((0 >= price)) | |
105 | 132 | then throw("Purchase amount cannot be less than item price") | |
106 | 133 | else if ((getValueItemSupplier(item) != NONE)) | |
107 | 134 | 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)] | |
109 | 138 | } | |
110 | 139 | ||
111 | 140 | ||
112 | 141 | ||
113 | 142 | @Callable(i) | |
114 | 143 | func purchase (item) = { | |
115 | 144 | let pmt = i.payments[0] | |
116 | 145 | if (isDefined(pmt.assetId)) | |
117 | 146 | then throw("WAVES tokens only at moment") | |
118 | 147 | else { | |
119 | 148 | let userAddress = toBase58String(i.caller.bytes) | |
120 | 149 | let price = getValueItemPrice(item) | |
121 | 150 | let supplierAddress = getValueItemSupplier(item) | |
122 | 151 | if ((price > pmt.amount)) | |
123 | 152 | then throw("Purchase amount cannot be less than item price") | |
124 | 153 | else if ((supplierAddress == NONE)) | |
125 | 154 | then throw("Supplier does not exist") | |
126 | 155 | else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))] | |
127 | 156 | } | |
128 | 157 | } | |
129 | 158 | ||
130 | 159 | ||
131 | 160 | ||
132 | 161 | @Callable(i) | |
133 | 162 | func voteCommit (item,hash) = { | |
134 | 163 | let user = toBase58String(i.caller.bytes) | |
135 | 164 | let commits = getValueCommitsCount(item) | |
136 | 165 | let status = getValueItemStatus(item) | |
137 | 166 | if ((commits >= VOTERS)) | |
138 | 167 | then throw("reached max num of voters") | |
139 | 168 | else if ((getValueCommit(item, user) != NONE)) | |
140 | 169 | then throw("user has already participated") | |
141 | 170 | else if ((getKeyItemSupplier(item) == NONE)) | |
142 | 171 | then throw("item does not exist") | |
143 | 172 | else if (if ((status != NONE)) | |
144 | 173 | then (status != VOTING) | |
145 | 174 | else false) | |
146 | 175 | then throw("voting is not possible") | |
147 | 176 | else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
148 | 177 | then REVEAL | |
149 | 178 | else VOTING)] | |
150 | 179 | } | |
151 | 180 | ||
152 | 181 | ||
153 | 182 | ||
154 | 183 | @Callable(i) | |
155 | 184 | func voteReveal (item,vote,salt) = { | |
156 | 185 | let user = toBase58String(i.caller.bytes) | |
157 | 186 | let status = getValueItemStatus(item) | |
158 | 187 | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
159 | 188 | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
160 | 189 | then throw("reveal data is not valid") | |
161 | 190 | else if ((VOTERS > getValueCommitsCount(item))) | |
162 | 191 | then throw("max num of voters hasnt reached yet") | |
163 | 192 | else if ((getValueReveal(item, user) != NONE)) | |
164 | 193 | then throw("user has already participated") | |
165 | 194 | else if (if ((status != VOTING)) | |
166 | 195 | then (status != REVEAL) | |
167 | 196 | else false) | |
168 | 197 | then throw("wrong status") | |
169 | 198 | else if (if ((vote != FEATURED)) | |
170 | 199 | then (vote != DELISTED) | |
171 | 200 | else false) | |
172 | 201 | then throw("wrong vote") | |
173 | 202 | else if (if ((status == FEATURED)) | |
174 | 203 | then true | |
175 | 204 | else (status == DELISTED)) | |
176 | 205 | then throw("vote has finished") | |
177 | 206 | else [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVoteCount(item, vote), newVoteCount), StringEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
178 | 207 | then vote | |
179 | 208 | else REVEAL)] | |
180 | 209 | } | |
181 | 210 | ||
182 | 211 | ||
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 ◑