1 | | - | {-# STDLIB_VERSION 3 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let oracleWhiteListAddress = Address(base58'3MvJMBxdrVAf1nCHiarJcQVnKy91HhBKe6w') |
---|
5 | | - | |
---|
6 | | - | let thisAddressPublicKey = base58'7A8H5cWfJVSpSrnB71CzWqyNm8KMxZPjwFcj1mDUU8an' |
---|
7 | | - | |
---|
8 | | - | let DAPPADDRESS = "3N2FjnCq4gcpewsYQVT4scz9MjTgD6a4kQK" |
---|
9 | | - | |
---|
10 | | - | let ADMIN = "3NCKoFQxRf7zsDNbivLFw1oJ7y8qJzLmEs4" |
---|
11 | | - | |
---|
12 | | - | let WUSD = base58'Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck' |
---|
13 | | - | |
---|
14 | | - | let WEUR = base58'Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU' |
---|
15 | | - | |
---|
16 | | - | let WBTC = base58'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS' |
---|
17 | | - | |
---|
18 | | - | let KOLIN = base58'FiKspxSpkpzT4pMUA9ccZkbJmVXTdu4JhFDXNNXr5noW' |
---|
19 | | - | |
---|
20 | | - | let WETH = base58'474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu' |
---|
21 | | - | |
---|
22 | | - | let WLTC = base58'HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk' |
---|
23 | | - | |
---|
24 | | - | let LISTINGFEE = (1 * 1000000) |
---|
25 | | - | |
---|
26 | | - | let NONE = "none" |
---|
27 | | - | |
---|
28 | | - | func getNumberByKey (key) = { |
---|
29 | | - | let num = match getInteger(this, key) { |
---|
30 | | - | case a: Int => |
---|
31 | | - | a |
---|
32 | | - | case _ => |
---|
33 | | - | 0 |
---|
34 | | - | } |
---|
35 | | - | num |
---|
36 | | - | } |
---|
37 | | - | |
---|
38 | | - | |
---|
39 | | - | func getStrByKey (key) = { |
---|
40 | | - | let str = match getString(this, key) { |
---|
41 | | - | case a: String => |
---|
42 | | - | a |
---|
43 | | - | case _ => |
---|
44 | | - | NONE |
---|
45 | | - | } |
---|
46 | | - | str |
---|
47 | | - | } |
---|
48 | | - | |
---|
49 | | - | |
---|
50 | | - | let WHITELISTED = "registered" |
---|
51 | | - | |
---|
52 | | - | let BLACKLISTED = "blacklisted" |
---|
53 | | - | |
---|
54 | | - | let INVITED = "invited" |
---|
55 | | - | |
---|
56 | | - | let SPENDINVITE = "spend_invite" |
---|
57 | | - | |
---|
58 | | - | let MODERATOR = "moderator" |
---|
59 | | - | |
---|
60 | | - | let QUORUM = 5 |
---|
61 | | - | |
---|
62 | | - | func getKeyItem (user,item) = ("item_" + toBase58String(sha256(toBytes((user + item))))) |
---|
63 | | - | |
---|
64 | | - | |
---|
65 | | - | func getKeyItemDocument (document) = ("document_" + document) |
---|
66 | | - | |
---|
67 | | - | |
---|
68 | | - | func getValueItemDocument (item) = getStrByKey(getKeyItemDocument(item)) |
---|
69 | | - | |
---|
70 | | - | |
---|
71 | | - | func getKeyWhitelistRef (account) = ("wl_ref_" + account) |
---|
72 | | - | |
---|
73 | | - | |
---|
74 | | - | func getValueWhitelistRef (account) = getStrByKey(getKeyWhitelistRef(account)) |
---|
75 | | - | |
---|
76 | | - | |
---|
77 | | - | func getKeyWhitelistStatus (account) = ("wl_sts_" + account) |
---|
78 | | - | |
---|
79 | | - | |
---|
80 | | - | func getKeyBalance (account) = ("balance_" + account) |
---|
81 | | - | |
---|
82 | | - | |
---|
83 | | - | func getKeyWhitelistBio (account) = ("wl_bio_" + account) |
---|
84 | | - | |
---|
85 | | - | |
---|
86 | | - | func getKeyWhitelistBlock (account) = ("wl_blk_" + account) |
---|
87 | | - | |
---|
88 | | - | |
---|
89 | | - | func getKeyItemAccReportData (item,account) = ((("report_" + item) + "_") + account) |
---|
90 | | - | |
---|
91 | | - | |
---|
92 | | - | func getValueBalance (account) = getNumberByKey(getKeyBalance(account)) |
---|
93 | | - | |
---|
94 | | - | |
---|
95 | | - | func getValueWhitelistStatus (account) = getStrByKey(getKeyWhitelistStatus(account)) |
---|
96 | | - | |
---|
97 | | - | |
---|
98 | | - | func getKeyItemAuthor (item) = ("author_" + item) |
---|
99 | | - | |
---|
100 | | - | |
---|
101 | | - | func getValueItemAuthor (item) = getStrByKey(getKeyItemAuthor(item)) |
---|
102 | | - | |
---|
103 | | - | |
---|
104 | | - | func getKeyItemDeadline (item) = ("deadlineblock_" + item) |
---|
105 | | - | |
---|
106 | | - | |
---|
107 | | - | func getValueItemDeadline (item) = getNumberByKey(getKeyItemDeadline(item)) |
---|
108 | | - | |
---|
109 | | - | |
---|
110 | | - | func getKeyItemBlock (item) = ("block_" + item) |
---|
111 | | - | |
---|
112 | | - | |
---|
113 | | - | func getValueItemBlock (item) = getNumberByKey(getKeyItemBlock(item)) |
---|
114 | | - | |
---|
115 | | - | |
---|
116 | | - | func getKeyItemTypeOfWork (item) = ("typeofwork_" + item) |
---|
117 | | - | |
---|
118 | | - | |
---|
119 | | - | func getValueItemTypeOfWork (item) = getNumberByKey(getKeyItemTypeOfWork(item)) |
---|
120 | | - | |
---|
121 | | - | |
---|
122 | | - | func getKeyItemWordCount (item) = ("wordcount_" + item) |
---|
123 | | - | |
---|
124 | | - | |
---|
125 | | - | func getValueItemWordCount (item) = getNumberByKey(getKeyItemWordCount(item)) |
---|
126 | | - | |
---|
127 | | - | |
---|
128 | | - | func getKeyItemPriceUSD (item) = ("priceUSD_" + item) |
---|
129 | | - | |
---|
130 | | - | |
---|
131 | | - | func getValueItemPriceUSD (item) = getNumberByKey(getKeyItemPriceUSD(item)) |
---|
132 | | - | |
---|
133 | | - | |
---|
134 | | - | func getKeyItemAssetID (item) = ("pmtassetID_" + item) |
---|
135 | | - | |
---|
136 | | - | |
---|
137 | | - | func getValueItemAssetID (item) = getStrByKey(getKeyItemAssetID(item)) |
---|
138 | | - | |
---|
139 | | - | |
---|
140 | | - | func getKeyItemPriceAssetID (item) = ("priceassetID_" + item) |
---|
141 | | - | |
---|
142 | | - | |
---|
143 | | - | func getValueItemPriceAssetID (item) = getNumberByKey(getKeyItemPriceAssetID(item)) |
---|
144 | | - | |
---|
145 | | - | |
---|
146 | | - | func getKeyItemData (item) = ("datajson_" + item) |
---|
147 | | - | |
---|
148 | | - | |
---|
149 | | - | func getValueItemData (item) = getStrByKey(getKeyItemData(item)) |
---|
150 | | - | |
---|
151 | | - | |
---|
152 | | - | func getKeyItemStatus (item) = ("status_" + item) |
---|
153 | | - | |
---|
154 | | - | |
---|
155 | | - | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) |
---|
156 | | - | |
---|
157 | | - | |
---|
158 | | - | func getKeyItemTranslator (item) = ("translator_" + item) |
---|
159 | | - | |
---|
160 | | - | |
---|
161 | | - | func getValueItemTranslator (item) = getStrByKey(getKeyItemTranslator(item)) |
---|
162 | | - | |
---|
163 | | - | |
---|
164 | | - | func getKeyItemDueFor (item) = ("due_for_" + item) |
---|
165 | | - | |
---|
166 | | - | |
---|
167 | | - | func getValueItemDueFor (item) = getNumberByKey(getKeyItemDueFor(item)) |
---|
168 | | - | |
---|
169 | | - | |
---|
170 | | - | func getKeyItemDisputeInitiatedBy (item) = ("disputedby_" + item) |
---|
171 | | - | |
---|
172 | | - | |
---|
173 | | - | func getValueItemDisputeInitiatedBy (item) = getStrByKey(getKeyItemDisputeInitiatedBy(item)) |
---|
174 | | - | |
---|
175 | | - | |
---|
176 | | - | func getKeyItemDisputeClosedBy (item) = ("disputeclosedby_" + item) |
---|
177 | | - | |
---|
178 | | - | |
---|
179 | | - | func getValueItemDisputeClosedBy (item) = getStrByKey(getKeyItemDisputeClosedBy(item)) |
---|
180 | | - | |
---|
181 | | - | |
---|
182 | | - | func getKeyItemDisputeClosedWinner (item) = "dispute_winner_" |
---|
183 | | - | |
---|
184 | | - | |
---|
185 | | - | func getKeyValueDisputeClosedWinner (item) = getStrByKey(getKeyItemDisputeClosedWinner(item)) |
---|
186 | | - | |
---|
187 | | - | |
---|
188 | | - | func getKeyItemLastUpdate (item) = ("last_update_" + item) |
---|
189 | | - | |
---|
190 | | - | |
---|
191 | | - | func getValueItemLastUpdate (item) = getNumberByKey(getKeyItemLastUpdate(item)) |
---|
192 | | - | |
---|
193 | | - | |
---|
194 | | - | func getKeyItemDisputeVotesTranslator (item) = ("cnt_translator_" + item) |
---|
195 | | - | |
---|
196 | | - | |
---|
197 | | - | func getValueItemDisputeVotesTranslator (item) = getNumberByKey(getKeyItemDisputeVotesTranslator(item)) |
---|
198 | | - | |
---|
199 | | - | |
---|
200 | | - | func getKeyItemDisputeVotesUser (item) = ("cnt_user_" + item) |
---|
201 | | - | |
---|
202 | | - | |
---|
203 | | - | func getValueItemDisputeVotesUser (item) = getNumberByKey(getKeyItemDisputeVotesUser(item)) |
---|
204 | | - | |
---|
205 | | - | |
---|
206 | | - | func getKeyItemBalance (item) = ("balance_" + item) |
---|
207 | | - | |
---|
208 | | - | |
---|
209 | | - | func getValueItemBalance (item) = getNumberByKey(getKeyItemBalance(item)) |
---|
210 | | - | |
---|
211 | | - | |
---|
212 | | - | func getKeyItemBalanceAssetID (item) = ("balance_assetID" + item) |
---|
213 | | - | |
---|
214 | | - | |
---|
215 | | - | func getValueItemBalanceAssetID (item) = getNumberByKey(getKeyItemBalanceAssetID(item)) |
---|
216 | | - | |
---|
217 | | - | |
---|
218 | | - | func getExtKeyItemWhiteListStatus (account) = ("verifier_status_" + account) |
---|
219 | | - | |
---|
220 | | - | |
---|
221 | | - | func getExtValueItemWhitelistStatus (oracle,account) = { |
---|
222 | | - | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { |
---|
223 | | - | case a: String => |
---|
224 | | - | a |
---|
225 | | - | case _ => |
---|
226 | | - | NONE |
---|
227 | | - | } |
---|
228 | | - | str |
---|
229 | | - | } |
---|
230 | | - | |
---|
231 | | - | |
---|
232 | | - | @Callable(i) |
---|
233 | | - | func submitTranslation (document,data,assetID,futureBlocks,wordCount,typeOfWork,priceAssetID) = { |
---|
234 | | - | let user = toBase58String(i.caller.bytes) |
---|
235 | | - | let item = getKeyItem(user, document) |
---|
236 | | - | let pmt = extract(i.payment) |
---|
237 | | - | let deadlineblock = (lastBlock.height + futureBlocks) |
---|
238 | | - | let currstatus = getExtValueItemWhitelistStatus(oracleWhiteListAddress, user) |
---|
239 | | - | if (if (if ((currstatus != WHITELISTED)) |
---|
240 | | - | then (user != DAPPADDRESS) |
---|
241 | | - | else false) |
---|
242 | | - | then (currstatus != ADMIN) |
---|
243 | | - | else false) |
---|
244 | | - | then throw(("Your account is not registered. status: " + currstatus)) |
---|
245 | | - | else if (if (if (if (if (if ((pmt.assetId != WETH)) |
---|
246 | | - | then true |
---|
247 | | - | else (pmt.assetId != WLTC)) |
---|
248 | | - | then true |
---|
249 | | - | else (pmt.assetId != WEUR)) |
---|
250 | | - | then true |
---|
251 | | - | else (pmt.assetId != WUSD)) |
---|
252 | | - | then true |
---|
253 | | - | else (pmt.assetId != WBTC)) |
---|
254 | | - | then true |
---|
255 | | - | else (pmt.assetId != KOLIN)) |
---|
256 | | - | then throw("can only use WAVES, USD, EUR, BTC, ETH, LTC and KOLIN as payment methods") |
---|
257 | | - | else if ((pmt.amount != LISTINGFEE)) |
---|
258 | | - | then throw(((("Please pay exact amount for the listing: " + toString(LISTINGFEE)) + ", actual payment is: ") + toString(pmt.amount))) |
---|
259 | | - | else if ((getValueItemAuthor(item) != NONE)) |
---|
260 | | - | then throw("Item already exist") |
---|
261 | | - | else if ((1440 > futureBlocks)) |
---|
262 | | - | then throw("please allow at least 24 h (~1440 blocks) for the translation work to be published properly") |
---|
263 | | - | else if ((futureBlocks > 44640)) |
---|
264 | | - | then throw("a translation work can not be posted for longer than 31 days (~44640 blocks) ") |
---|
265 | | - | else WriteSet([DataEntry(getKeyItemDocument(document), item), DataEntry(getKeyItemAuthor(item), user), DataEntry(getKeyItemBlock(item), height), DataEntry(getKeyItemLastUpdate(item), height), DataEntry(getKeyItemDeadline(item), deadlineblock), DataEntry(getKeyItemTypeOfWork(item), typeOfWork), DataEntry(getKeyItemWordCount(item), wordCount), DataEntry(getKeyItemPriceUSD(item), (typeOfWork * wordCount)), DataEntry(getKeyItemAssetID(item), assetID), DataEntry(getKeyItemPriceAssetID(item), priceAssetID), DataEntry(getKeyItemStatus(item), "new post"), DataEntry(getKeyItemData(item), data)]) |
---|
266 | | - | } |
---|
267 | | - | |
---|
268 | | - | |
---|
269 | | - | |
---|
270 | | - | @Callable(i) |
---|
271 | | - | func escrow (item,translator,futureBlocks) = { |
---|
272 | | - | let user = toBase58String(i.caller.bytes) |
---|
273 | | - | let pmt = extract(i.payment) |
---|
274 | | - | let deadlineblock = (lastBlock.height + futureBlocks) |
---|
275 | | - | let price = getValueItemPriceAssetID(item) |
---|
276 | | - | let registeredAssetID = getValueItemAssetID(item) |
---|
277 | | - | let translatorStatus = getExtValueItemWhitelistStatus(oracleWhiteListAddress, translator) |
---|
278 | | - | let userStatus = getExtValueItemWhitelistStatus(oracleWhiteListAddress, user) |
---|
279 | | - | let currstatus = getValueWhitelistStatus(user) |
---|
280 | | - | if (if (if ((currstatus != WHITELISTED)) |
---|
281 | | - | then (user != DAPPADDRESS) |
---|
282 | | - | else false) |
---|
283 | | - | then (currstatus != ADMIN) |
---|
284 | | - | else false) |
---|
285 | | - | then throw(("Your account is not registered. status: " + currstatus)) |
---|
286 | | - | else if ((getValueItemDocument(item) != item)) |
---|
287 | | - | then throw("translation work not found") |
---|
288 | | - | else if ((getValueItemDeadline(item) >= lastBlock.height)) |
---|
289 | | - | then throw("deadline for this work has been already achieved") |
---|
290 | | - | else if ((price > pmt.amount)) |
---|
291 | | - | then throw("price lower than posted for this translation work") |
---|
292 | | - | else if ((pmt.amount > price)) |
---|
293 | | - | then throw("money payed is higher than this translation work, no need to overspend") |
---|
294 | | - | else if ((user != getValueItemAuthor(item))) |
---|
295 | | - | then throw("User is different than translation's post creator") |
---|
296 | | - | else if ((userStatus == BLACKLISTED)) |
---|
297 | | - | then throw("user's account has been blacklisted") |
---|
298 | | - | else if ((translatorStatus == BLACKLISTED)) |
---|
299 | | - | then throw("translator's account has been blacklisted") |
---|
300 | | - | else if ((1440 > futureBlocks)) |
---|
301 | | - | then throw("please allow at least 24 h (~1440 blocks) for the translation work to be published properly") |
---|
302 | | - | else if ((futureBlocks > 44640)) |
---|
303 | | - | then throw("a translation work can not be posted for longer than 31 days (~44640 blocks) ") |
---|
304 | | - | else if ((getValueItemStatus(item) != "new post")) |
---|
305 | | - | then throw("escrow for this work already present") |
---|
306 | | - | else ScriptResult(WriteSet([DataEntry(getKeyItemStatus(item), "work allocated to translator"), DataEntry(getKeyItemTranslator(item), translator), DataEntry(getKeyItemDueFor(item), deadlineblock), DataEntry(getKeyItemLastUpdate(item), height), DataEntry(getKeyItemBalance(item), pmt.amount), DataEntry(getKeyItemBalanceAssetID(item), registeredAssetID)]), TransferSet(nil)) |
---|
307 | | - | } |
---|
308 | | - | |
---|
309 | | - | |
---|
310 | | - | |
---|
311 | | - | @Callable(i) |
---|
312 | | - | func disputeEscrow (item) = { |
---|
313 | | - | let caller = toBase58String(i.caller.bytes) |
---|
314 | | - | let amount = getValueItemPriceAssetID(item) |
---|
315 | | - | let assetID = getValueItemAssetID(item) |
---|
316 | | - | let blockUnlocked = getValueItemDueFor(item) |
---|
317 | | - | let translatorStatus = getExtValueItemWhitelistStatus(oracleWhiteListAddress, getValueItemTranslator(item)) |
---|
318 | | - | let userStatus = getExtValueItemWhitelistStatus(oracleWhiteListAddress, getValueItemAuthor(item)) |
---|
319 | | - | let currstatus = getValueWhitelistStatus(caller) |
---|
320 | | - | if (if (if ((currstatus != WHITELISTED)) |
---|
321 | | - | then (caller != DAPPADDRESS) |
---|
322 | | - | else false) |
---|
323 | | - | then (currstatus != ADMIN) |
---|
324 | | - | else false) |
---|
325 | | - | then throw(("Your account is not registered. status: " + currstatus)) |
---|
326 | | - | else if (if (if ((caller != getValueItemTranslator(item))) |
---|
327 | | - | then true |
---|
328 | | - | else (caller != getValueItemAuthor(item))) |
---|
329 | | - | then true |
---|
330 | | - | else (caller != ADMIN)) |
---|
331 | | - | then throw("just work creator, translator or an admin can initiate a dispute") |
---|
332 | | - | else if ((getKeyItemStatus(item) == "dispute in progress")) |
---|
333 | | - | then throw("This work is currently under dispute") |
---|
334 | | - | else if ((userStatus == BLACKLISTED)) |
---|
335 | | - | then throw("user's account has been blacklisted") |
---|
336 | | - | else if ((translatorStatus == BLACKLISTED)) |
---|
337 | | - | then throw("translator's account has been blacklisted") |
---|
338 | | - | else ScriptResult(WriteSet([DataEntry(getKeyItemStatus(item), "dispute in progress"), DataEntry(getKeyItemDisputeInitiatedBy(item), caller), DataEntry(getKeyItemDueFor(item), (lastBlock.height + 1440)), DataEntry(getKeyItemLastUpdate(item), height), DataEntry(getKeyItemDisputeClosedBy(item), NONE), DataEntry(getKeyItemDisputeClosedWinner(item), NONE)]), TransferSet(nil)) |
---|
339 | | - | } |
---|
340 | | - | |
---|
341 | | - | |
---|
342 | | - | |
---|
343 | | - | @Callable(i) |
---|
344 | | - | func disputeCloseEscrow (item) = { |
---|
345 | | - | let caller = toBase58String(i.caller.bytes) |
---|
346 | | - | let amount = getValueItemPriceAssetID(item) |
---|
347 | | - | let assetID = getValueItemAssetID(item) |
---|
348 | | - | let blockUnlocked = getValueItemDueFor(item) |
---|
349 | | - | let translatorStatus = getExtValueItemWhitelistStatus(oracleWhiteListAddress, getValueItemTranslator(item)) |
---|
350 | | - | let userStatus = getExtValueItemWhitelistStatus(oracleWhiteListAddress, getValueItemAuthor(item)) |
---|
351 | | - | let currstatus = getValueWhitelistStatus(caller) |
---|
352 | | - | if (if (if ((currstatus != WHITELISTED)) |
---|
353 | | - | then (caller != DAPPADDRESS) |
---|
354 | | - | else false) |
---|
355 | | - | then (currstatus != ADMIN) |
---|
356 | | - | else false) |
---|
357 | | - | then throw(("Your account is not registered. status: " + currstatus)) |
---|
358 | | - | else if ((currstatus != ADMIN)) |
---|
359 | | - | then throw("just admins can close a dispute") |
---|
360 | | - | else if ((getKeyItemStatus(item) != "dispute in progress")) |
---|
361 | | - | then throw("This work is not under dispute") |
---|
362 | | - | else if ((userStatus == BLACKLISTED)) |
---|
363 | | - | then throw("user's account has been blacklisted") |
---|
364 | | - | else if ((translatorStatus == BLACKLISTED)) |
---|
365 | | - | then throw("translator's account has been blacklisted") |
---|
366 | | - | else if (if ((QUORUM > getValueItemDisputeVotesTranslator(item))) |
---|
367 | | - | then (QUORUM > getValueItemDisputeVotesUser(item)) |
---|
368 | | - | else false) |
---|
369 | | - | then throw("Votes are not enough to favour any involved part") |
---|
370 | | - | else if ((getValueItemDisputeVotesTranslator(item) >= QUORUM)) |
---|
371 | | - | then ScriptResult(WriteSet([DataEntry(getKeyItemStatus(item), "dispute closed"), DataEntry(getKeyItemDisputeClosedBy(item), caller), DataEntry(getKeyItemDisputeClosedWinner(item), getValueItemTranslator(item)), DataEntry(getKeyItemLastUpdate(item), height)]), TransferSet([ScriptTransfer(addressFromStringValue(getValueItemTranslator(item)), amount, fromBase58String(assetID))])) |
---|
372 | | - | else if ((getValueItemDisputeVotesUser(item) >= QUORUM)) |
---|
373 | | - | then ScriptResult(WriteSet([DataEntry(getKeyItemStatus(item), "dispute closed"), DataEntry(getKeyItemDisputeClosedBy(item), caller), DataEntry(getKeyItemDisputeClosedWinner(item), getValueItemAuthor(item)), DataEntry(getKeyItemLastUpdate(item), height)]), TransferSet([ScriptTransfer(addressFromStringValue(getValueItemAuthor(item)), amount, fromBase58String(assetID))])) |
---|
374 | | - | else ScriptResult(WriteSet([DataEntry(getKeyItemStatus(item), "dispute still under review"), DataEntry(getKeyItemDisputeClosedBy(item), NONE), DataEntry(getKeyItemDisputeClosedWinner(item), NONE), DataEntry(getKeyItemLastUpdate(item), height), DataEntry(getKeyItemDueFor(item), (lastBlock.height + 1440))]), TransferSet(nil)) |
---|
375 | | - | } |
---|
376 | | - | |
---|
377 | | - | |
---|
378 | | - | |
---|
379 | | - | @Callable(i) |
---|
380 | | - | func voteDisputeEscrow (item,vote) = { |
---|
381 | | - | let caller = toBase58String(i.caller.bytes) |
---|
382 | | - | if ((getValueItemStatus(item) == "dispute closed")) |
---|
383 | | - | then throw("this dispute is closed") |
---|
384 | | - | else if (if ((getValueWhitelistStatus(caller) != MODERATOR)) |
---|
385 | | - | then true |
---|
386 | | - | else (getValueWhitelistStatus(caller) != ADMIN)) |
---|
387 | | - | then throw("you either need to be an ADMIN or a MODERATOR to vote in disputes") |
---|
388 | | - | else if (if ((getValueItemStatus(item) != "dispute in progress")) |
---|
389 | | - | then true |
---|
390 | | - | else (getValueItemStatus(item) != "dispute still under review")) |
---|
391 | | - | then throw("translation work not under dispute") |
---|
392 | | - | else if ((getValueItemDisputeVotesTranslator(item) >= QUORUM)) |
---|
393 | | - | then throw("Votes are enough to favour the Translator") |
---|
394 | | - | else if ((getValueItemDisputeVotesUser(item) >= QUORUM)) |
---|
395 | | - | then throw("Votes are enough to favour the User") |
---|
396 | | - | else if ((vote == getValueItemAuthor(item))) |
---|
397 | | - | then WriteSet([DataEntry(getKeyItemDisputeVotesUser(item), (getValueItemDisputeVotesUser(item) + 1))]) |
---|
398 | | - | else if ((vote == getValueItemTranslator(item))) |
---|
399 | | - | then WriteSet([DataEntry(getKeyItemDisputeVotesTranslator(item), (getValueItemDisputeVotesTranslator(item) + 1))]) |
---|
400 | | - | else throw("vote not submitted") |
---|
401 | | - | } |
---|
402 | | - | |
---|
403 | | - | |
---|
404 | | - | |
---|
405 | | - | @Callable(i) |
---|
406 | | - | func withdrawEscrow (address,item) = { |
---|
407 | | - | let caller = toBase58String(i.caller.bytes) |
---|
408 | | - | let assetID = getValueItemAssetID(item) |
---|
409 | | - | let amount = getValueItemPriceAssetID(item) |
---|
410 | | - | let currstatus = getValueWhitelistStatus(caller) |
---|
411 | | - | let translatorStatus = getExtValueItemWhitelistStatus(oracleWhiteListAddress, getValueItemTranslator(item)) |
---|
412 | | - | let userStatus = getExtValueItemWhitelistStatus(oracleWhiteListAddress, getValueItemAuthor(item)) |
---|
413 | | - | if (if (if ((currstatus != WHITELISTED)) |
---|
414 | | - | then (caller != DAPPADDRESS) |
---|
415 | | - | else false) |
---|
416 | | - | then (currstatus != ADMIN) |
---|
417 | | - | else false) |
---|
418 | | - | then throw(("Your account is not registered. status: " + currstatus)) |
---|
419 | | - | else if ((getValueItemDueFor(item) > lastBlock.height)) |
---|
420 | | - | then throw("Deadline has not finished yet") |
---|
421 | | - | else if ((getKeyItemStatus(item) == "dispute in progress")) |
---|
422 | | - | then throw("This work is currently under dispute") |
---|
423 | | - | else if (if ((caller != getValueItemTranslator(item))) |
---|
424 | | - | then true |
---|
425 | | - | else (caller != getValueItemAuthor(item))) |
---|
426 | | - | then throw("just work creator or translator can withdraw funds. Admins must initiate a dispute") |
---|
427 | | - | else if (if ((caller == getValueItemAuthor(item))) |
---|
428 | | - | then (userStatus == BLACKLISTED) |
---|
429 | | - | else false) |
---|
430 | | - | then throw("user's account has been blacklisted") |
---|
431 | | - | else if (if ((caller == getValueItemTranslator(item))) |
---|
432 | | - | then (translatorStatus == BLACKLISTED) |
---|
433 | | - | else false) |
---|
434 | | - | then throw("translator's account has been blacklisted") |
---|
435 | | - | else ScriptResult(WriteSet([DataEntry(getKeyItemBalance(item), 0), DataEntry(getKeyItemStatus(item), ("money withdrawn by " + caller)), DataEntry(getKeyItemLastUpdate(item), height)]), TransferSet([ScriptTransfer(addressFromStringValue(caller), amount, fromBase58String(assetID))])) |
---|
436 | | - | } |
---|
437 | | - | |
---|
438 | | - | |
---|
439 | | - | |
---|
440 | | - | @Callable(i) |
---|
441 | | - | func inviteuser (newaccount,data) = { |
---|
442 | | - | let caller = toBase58String(i.caller.bytes) |
---|
443 | | - | let newstatus = getValueWhitelistStatus(newaccount) |
---|
444 | | - | let currstatus = getValueWhitelistStatus(caller) |
---|
445 | | - | if (if (if ((newstatus == WHITELISTED)) |
---|
446 | | - | then true |
---|
447 | | - | else (newstatus == MODERATOR)) |
---|
448 | | - | then true |
---|
449 | | - | else (newstatus == ADMIN)) |
---|
450 | | - | then throw("User has already been registered") |
---|
451 | | - | else if ((newstatus == BLACKLISTED)) |
---|
452 | | - | then throw("The user you want to invite is already Blacklisted") |
---|
453 | | - | else if (if (if ((currstatus != WHITELISTED)) |
---|
454 | | - | then (caller != DAPPADDRESS) |
---|
455 | | - | else false) |
---|
456 | | - | then (currstatus != ADMIN) |
---|
457 | | - | else false) |
---|
458 | | - | then throw(("Your account should be whitelisted. status: " + currstatus)) |
---|
459 | | - | else WriteSet([DataEntry(getKeyWhitelistRef(newaccount), caller), DataEntry(getKeyWhitelistBio(newaccount), data), DataEntry(getKeyWhitelistStatus(newaccount), INVITED)]) |
---|
460 | | - | } |
---|
461 | | - | |
---|
462 | | - | |
---|
463 | | - | |
---|
464 | | - | @Callable(i) |
---|
465 | | - | func userupdate (data,type) = { |
---|
466 | | - | let account = toBase58String(i.caller.bytes) |
---|
467 | | - | if (if (if ((type == MODERATOR)) |
---|
468 | | - | then true |
---|
469 | | - | else (type == ADMIN)) |
---|
470 | | - | then (getValueWhitelistStatus(account) == WHITELISTED) |
---|
471 | | - | else false) |
---|
472 | | - | then throw("an ADMIN or MODERATOR account can be created by an ADMIN only") |
---|
473 | | - | else if (if ((type == ADMIN)) |
---|
474 | | - | then (getValueWhitelistStatus(account) != ADMIN) |
---|
475 | | - | else false) |
---|
476 | | - | then throw("an ADMIN account can be created by another ADMIN only") |
---|
477 | | - | else WriteSet([DataEntry(getKeyWhitelistBio(account), data), DataEntry(getKeyWhitelistStatus(account), if ((type == MODERATOR)) |
---|
478 | | - | then MODERATOR |
---|
479 | | - | else if ((type == ADMIN)) |
---|
480 | | - | then ADMIN |
---|
481 | | - | else WHITELISTED)]) |
---|
482 | | - | } |
---|
483 | | - | |
---|
484 | | - | |
---|
485 | | - | |
---|
486 | | - | @Callable(i) |
---|
487 | | - | func signupbylink (hash,data,type) = { |
---|
488 | | - | let account = toBase58String(i.caller.bytes) |
---|
489 | | - | let status = getValueWhitelistStatus(hash) |
---|
490 | | - | if ((status != INVITED)) |
---|
491 | | - | then throw(((((("Referral invite needed. Current status: " + status) + ", key:") + getKeyWhitelistStatus(hash)) + ", account:") + hash)) |
---|
492 | | - | else WriteSet([DataEntry(getKeyWhitelistBio(account), data), DataEntry(getKeyWhitelistBlock(account), height), DataEntry(getKeyWhitelistStatus(account), if ((type == MODERATOR)) |
---|
493 | | - | then MODERATOR |
---|
494 | | - | else WHITELISTED), DataEntry(getKeyWhitelistStatus(hash), SPENDINVITE), DataEntry(getKeyWhitelistRef(account), getValueWhitelistRef(hash))]) |
---|
495 | | - | } |
---|
496 | | - | |
---|
497 | | - | |
---|
498 | | - | |
---|
499 | | - | @Callable(i) |
---|
500 | | - | func signup (data,type) = { |
---|
501 | | - | let account = toBase58String(i.caller.bytes) |
---|
502 | | - | let status = getValueWhitelistStatus(account) |
---|
503 | | - | if ((status == NONE)) |
---|
504 | | - | then throw(((((("Referral invite needed. Current status: " + status) + ", key:") + getKeyWhitelistStatus(account)) + ", account:") + account)) |
---|
505 | | - | else WriteSet([DataEntry(getKeyWhitelistBio(account), data), DataEntry(getKeyWhitelistBlock(account), height), DataEntry(getKeyWhitelistStatus(account), if ((type == MODERATOR)) |
---|
506 | | - | then MODERATOR |
---|
507 | | - | else WHITELISTED)]) |
---|
508 | | - | } |
---|
509 | | - | |
---|
510 | | - | |
---|
511 | | - | |
---|
512 | | - | @Callable(i) |
---|
513 | | - | func reportProject (item,data) = { |
---|
514 | | - | let account = toBase58String(i.caller.bytes) |
---|
515 | | - | WriteSet([DataEntry(getKeyItemAccReportData(item, account), data)]) |
---|
516 | | - | } |
---|
517 | | - | |
---|
518 | | - | |
---|
| 1 | + | # no script |
---|