tx · 7H2Yog2zo6FHjSd5mfaetsHXP9FSqYQaniPVvayKEySK 3N1CYgyJqi5s7uHqiAuGnb86PxXAPBEJ2hg: -0.01400000 Waves 2020.12.30 07:29 [1330951] smart account 3N1CYgyJqi5s7uHqiAuGnb86PxXAPBEJ2hg > SELF 0.00000000 Waves
{ "type": 13, "id": "7H2Yog2zo6FHjSd5mfaetsHXP9FSqYQaniPVvayKEySK", "fee": 1400000, "feeAssetId": null, "timestamp": 1609302643393, "version": 2, "chainId": 84, "sender": "3N1CYgyJqi5s7uHqiAuGnb86PxXAPBEJ2hg", "senderPublicKey": "75wzrSTzcF5qMYeuwuLWeziy4CgffobpM7wFcCFcCTkU", "proofs": [ "2arGKvvw5pu9nt38WhzEkZXGKiwSzLqLevBe4KJwuVzCXhFfE8htmtyvAX5fvoCsnRNXnzh5VksLxVz7Cw6Jiq69" ], "script": "base64:AAIEAAAAAAAAABIIAhIOCgwICAgICAgBCAgICAgAAAAaAAAAAAh1c2VyRGFwcAkBAAAABXZhbHVlAAAAAQkABCYAAAABAgAAACMzTXpWaHNtbVU4bjFheGVrRkprMUJSTndybW5DTUg2TW44RgAAAAAOZGVmYXVsdExpY2VuY2UCAAAAR2JhZnliZWlnaXNmcXR5bzJxZGZzY2VoNWZwY3A3ZWV5bXJwZWdscDZlZGFvMmJteWhpamJheXZhdXN5L2xpY2VuY2UucGRmAAAAABJkZWZhdWx0SGFzaExpY2VuY2UCAAAAQDNkZjc5ZDM0YWJiY2E5OTMwOGU3OWNiOTQ0NjFjMTg5MzU4MjYwNGQ2ODMyOWE0MWZkNGJlYzE4ODVlNmFkYjQBAAAADmdldFN0cmluZ0J5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWECAAAAAAEAAAANa2V5VXNlclN0YXR1cwAAAAEAA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yeQAAAAIJAQAAAAxrZXlBcnRTaWduSUQAAAACBQAAAAZjYWxsZXIFAAAABWFydElkBQAAAAZzaWduSUQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAAAxrZXlBcnRJc3N1ZWQAAAACBQAAAAZjYWxsZXIFAAAABWFydElkAAAAAAAAAAAACQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACCQEAAAAMa2V5QXJ0T25TYWxlAAAAAgUAAAAGY2FsbGVyBQAAAAVhcnRJZAcJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAAE2tleUFydEFydGlkQnlTaWduaWQAAAACBQAAAAZjYWxsZXIFAAAABnNpZ25JRAUAAAAFYXJ0SWQJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAAFGtleUFydEhhc2hCeVR4aWRBZGRyAAAAAgUAAAAGY2FsbGVyBQAAAAVhcnRJZAUAAAAKc2hhMjU2SGFzaAUAAAADbmlsAAAAABNrhnw=", "height": 1330951, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FoEfcvp3e5kpbL6Ei9E54u1PXaTMqeVh6F9YS7Z3Fz8U Next: LeAs6EkKcbnkVbEXbQ2oEJU4yZwr5RWcRSaDAC6UdUf Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let unitTest = false | |
5 | - | ||
6 | - | let oracleFee = value(addressFromString("3N2s5RtaHPBenCsx2ECcoFRbYHx3noZhXW1")) | |
7 | - | ||
8 | - | let signDapp = value(addressFromString("3NC28hSivrmsTUXaYD1x6L362J4ZpUnoTdB")) | |
9 | - | ||
10 | - | let feeReceiver = "3N1E6tXddRoVaRfQ9dQ3vg5LaW2fsd8HKub" | |
11 | - | ||
12 | - | let userDapp = if (unitTest) | |
13 | - | then value(addressFromString("3Mt4RGMEyjSWYAocTPqd55wdHQQB3PU2UCm")) | |
14 | - | else value(addressFromString("3N8xXaYjE27Aa79d5hHrhHu9HaFoTBmhDEj")) | |
15 | - | ||
16 | - | let whitelistDapp = value(addressFromString("3Mt6jj1WUYqd7DT7dHEubs9jETLUXMcAB8k")) | |
17 | - | ||
18 | - | let signAssetId = base58'Gf9t8FA4H3ssoZPCwrg3KwUFCci8zuUFP9ssRsUY3s6a' | |
19 | - | ||
20 | - | let usdnAssetId = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT' | |
21 | - | ||
22 | - | let wavesAssetId = base58'' | |
23 | - | ||
24 | - | let chris = "3MsG6jPNCrVJUtYB7XJBxS7utWsXAf4n9Vp" | |
25 | - | ||
26 | - | let joep = "3Mzm4VLwsN9uZwbTMzPj3XuxV6kEfAR8UDN" | |
27 | - | ||
28 | - | let signCut = 7 | |
29 | - | ||
30 | - | let usdnCut = 10 | |
31 | - | ||
32 | - | let wavesCut = 10 | |
4 | + | let userDapp = value(addressFromString("3MzVhsmmU8n1axekFJk1BRNwrmnCMH6Mn8F")) | |
33 | 5 | ||
34 | 6 | let defaultLicence = "bafybeigisfqtyo2qdfsceh5fpcp7eeymrpeglp6edao2bmyhijbayvausy/licence.pdf" | |
35 | 7 | ||
36 | 8 | let defaultHashLicence = "3df79d34abbca99308e79cb94461c1893582604d68329a41fd4bec1885e6adb4" | |
37 | - | ||
38 | - | let dappRunning = match getBoolean(userDapp, "conf_dapp_is_running") { | |
39 | - | case a: Boolean => | |
40 | - | a | |
41 | - | case _ => | |
42 | - | true | |
43 | - | } | |
44 | - | ||
45 | - | let maintenanceMSG = match getString(userDapp, "conf_maintenance_msg") { | |
46 | - | case a: String => | |
47 | - | a | |
48 | - | case _ => | |
49 | - | "" | |
50 | - | } | |
51 | - | ||
52 | - | let userSuspended = "SUSPENDED" | |
53 | - | ||
54 | - | let userRemoved = "REMOVED" | |
55 | - | ||
56 | - | let userUnregistered = "UNREGISTERED" | |
57 | - | ||
58 | - | let userAllowed = "ALLOWED" | |
59 | - | ||
60 | - | func getStringByKeyFromUsers (key) = match getString(userDapp, key) { | |
61 | - | case a: String => | |
62 | - | a | |
63 | - | case _ => | |
64 | - | "" | |
65 | - | } | |
66 | - | ||
67 | 9 | ||
68 | 10 | func getStringByKey (key) = match getString(this, key) { | |
69 | 11 | case a: String => | |
71 | 13 | case _ => | |
72 | 14 | "" | |
73 | 15 | } | |
74 | - | ||
75 | - | ||
76 | - | func getIntegerByKeyFromOracle (key) = match getInteger(oracleFee, key) { | |
77 | - | case a: Int => | |
78 | - | a | |
79 | - | case _ => | |
80 | - | throw("Integer undefine or 0 in oracle") | |
81 | - | } | |
82 | - | ||
83 | - | ||
84 | - | func getIntegerByKey (key) = match getInteger(this, key) { | |
85 | - | case i: Int => | |
86 | - | i | |
87 | - | case _ => | |
88 | - | 0 | |
89 | - | } | |
90 | - | ||
91 | - | ||
92 | - | func checkWhitelist (key) = match getInteger(whitelistDapp, key) { | |
93 | - | case a: Int => | |
94 | - | if ((a >= height)) | |
95 | - | then 1 | |
96 | - | else 0 | |
97 | - | case _ => | |
98 | - | 0 | |
99 | - | } | |
100 | - | ||
101 | - | ||
102 | - | func getBooleanByKey (key) = match getBoolean(this, key) { | |
103 | - | case i: Boolean => | |
104 | - | i | |
105 | - | case _ => | |
106 | - | false | |
107 | - | } | |
108 | - | ||
109 | - | ||
110 | - | func checkSignCertificate (signID,Owner,sha256Hash) = match getString(signDapp, ((("data_fc_" + signID) + "_") + Owner)) { | |
111 | - | case a: String => | |
112 | - | if (contains(a, sha256Hash)) | |
113 | - | then true | |
114 | - | else false | |
115 | - | case _ => | |
116 | - | false | |
117 | - | } | |
118 | - | ||
119 | - | ||
120 | - | func validateCID (cid) = if (contains(cid, "/")) | |
121 | - | then if (if ((75 > size(cid))) | |
122 | - | then (60 > size(split(cid, "/")[0])) | |
123 | - | else false) | |
124 | - | then (16 > size(split(cid, "/")[1])) | |
125 | - | else false | |
126 | - | else false | |
127 | - | ||
128 | - | ||
129 | - | func validateHash (hash) = (65 > size(hash)) | |
130 | 16 | ||
131 | 17 | ||
132 | 18 | func keyUserStatus (caller) = ("user_status_" + caller) | |
195 | 81 | func keyArtTxidByHashOwner (sha256Hash,caller) = ("get_txid_by_hash_owner_" + toBase58String(sha256_16Kb(toBytes((sha256Hash + caller))))) | |
196 | 82 | ||
197 | 83 | ||
198 | - | func validateAllCID (cidDisplay,cidExport,cidLicence) = if (!(validateCID(cidDisplay))) | |
199 | - | then throw("Wrong Display CID") | |
200 | - | else if (!(validateCID(cidExport))) | |
201 | - | then throw("Wrong Export CID") | |
202 | - | else if (if ((cidLicence != "")) | |
203 | - | then !(validateCID(cidLicence)) | |
204 | - | else false) | |
205 | - | then throw("Wrong Licence CID") | |
206 | - | else true | |
207 | - | ||
208 | - | ||
209 | - | func validateAllHash (sha256Export,sha256Licence) = if (!(validateHash(sha256Export))) | |
210 | - | then throw("Export Hash 64 char. max") | |
211 | - | else if (!(validateHash(sha256Licence))) | |
212 | - | then throw("Licence Hash 64 char. max") | |
213 | - | else true | |
214 | - | ||
215 | - | ||
216 | - | func validateString (str,max) = if ((size(str) == 0)) | |
217 | - | then throw("Field cannot be is empty") | |
218 | - | else if ((size(str) > max)) | |
219 | - | then throw((str + " is too long")) | |
220 | - | else true | |
221 | - | ||
222 | - | ||
223 | 84 | @Callable(invoke) | |
224 | - | func addArtwork (sha256Hash,signID,name,description,tags,type,maxmint,cidDisplay,sha256Export,cidExport,sha256Licence,cidLicence) = if (!(dappRunning)) | |
225 | - | then throw(maintenanceMSG) | |
226 | - | else { | |
227 | - | let artId = toBase58String(invoke.transactionId) | |
228 | - | let caller = toBase58String(invoke.caller.bytes) | |
229 | - | let timestamp = lastBlock.timestamp | |
230 | - | let licenceCID = if ((size(cidLicence) == 0)) | |
231 | - | then defaultLicence | |
232 | - | else cidLicence | |
233 | - | let licenceHash = if ((size(sha256Licence) == 0)) | |
234 | - | then defaultHashLicence | |
235 | - | else sha256Licence | |
236 | - | let userIsRegistered = match getString(userDapp, ("user_status_" + caller)) { | |
237 | - | case s: String => | |
238 | - | s | |
239 | - | case _ => | |
240 | - | userUnregistered | |
241 | - | } | |
242 | - | if (if (isDefined(userIsRegistered)) | |
243 | - | then if ((userIsRegistered == userUnregistered)) | |
244 | - | then true | |
245 | - | else (userIsRegistered == userAllowed) | |
246 | - | else false) | |
247 | - | then throw("Register this account first with \"Account\" tab") | |
248 | - | else if ((userIsRegistered == userSuspended)) | |
249 | - | then throw("Account suspended") | |
250 | - | else if ((userIsRegistered == userRemoved)) | |
251 | - | then throw("Account removed") | |
252 | - | else if (!(validateAllCID(cidDisplay, cidExport, licenceCID))) | |
253 | - | then throw("Problem with CID") | |
254 | - | else if (!(validateHash(sha256Hash))) | |
255 | - | then throw("Hash should be 64 characters maximum") | |
256 | - | else if (!(validateAllHash(sha256Export, licenceHash))) | |
257 | - | then throw("Problem with Hashes") | |
258 | - | else if ((size(invoke.payments) == 0)) | |
259 | - | then throw("No payment attached") | |
260 | - | else { | |
261 | - | let payment = value(invoke.payments[0]) | |
262 | - | let amount = value(payment.amount) | |
263 | - | let assetId = if (if (isDefined(payment.assetId)) | |
264 | - | then (payment.assetId == signAssetId) | |
265 | - | else false) | |
266 | - | then payment.assetId | |
267 | - | else throw("Only SIGN token accepted") | |
268 | - | let currentCertificationPrice = getIntegerByKeyFromOracle(("certification_fee_" + toBase58String(signAssetId))) | |
269 | - | if ((amount != currentCertificationPrice)) | |
270 | - | then throw(("Payment amount should be " + toString(currentCertificationPrice))) | |
271 | - | else { | |
272 | - | let entryExist = getStringByKey(keyArtTxidByHashOwner(sha256Hash, caller)) | |
273 | - | if ((entryExist != "")) | |
274 | - | then throw("You already added it") | |
275 | - | else { | |
276 | - | let hashExist = getStringByKey(keyArtOwnerByHash(sha256Hash)) | |
277 | - | if ((hashExist != "")) | |
278 | - | then throw("Hash already registered") | |
279 | - | else { | |
280 | - | let isSignCertified = checkSignCertificate(signID, caller, sha256Hash) | |
281 | - | if (!(isSignCertified)) | |
282 | - | then throw("Sign Certificate not found for this address.") | |
283 | - | else if ((size(cidDisplay) == 0)) | |
284 | - | then throw("Display CID cannot be empty") | |
285 | - | else if (!(validateString(name, 100))) | |
286 | - | then throw("100 Char. max name") | |
287 | - | else if (!(validateString(description, 1000))) | |
288 | - | then throw("1000 Char. max description") | |
289 | - | else if ((size(split(tags, ",")) > 5)) | |
290 | - | then throw("5 tags max.") | |
291 | - | else if ((maxmint > 10)) | |
292 | - | then throw("10 editions max") | |
293 | - | else [StringEntry(keyArtOwnerByHash(sha256Hash), caller), StringEntry(keyArtTxidByHashOwner(sha256Hash, caller), artId), IntegerEntry(keyArtDate(caller, artId), timestamp), StringEntry(keyArtName(caller, artId), name), StringEntry(keyArtDesc(caller, artId), description), StringEntry(keyArtDisplayCid(caller, artId), cidDisplay), StringEntry(keyArtExportCid(caller, artId), cidExport), StringEntry(keyArtExportHash(caller, artId), sha256Export), StringEntry(keyArtLicenceHash(caller, artId), licenceHash), StringEntry(keyArtLicenceCid(caller, artId), licenceCID), StringEntry(keyArtType(caller, artId), type), StringEntry(keyArtTags(caller, artId), tags), IntegerEntry(keyArtMaxMint(caller, artId), maxmint), StringEntry(keyArtSignID(caller, artId), signID), IntegerEntry(keyArtIssued(caller, artId), 0), BooleanEntry(keyArtOnSale(caller, artId), false), StringEntry(keyArtArtidBySignid(caller, signID), artId), StringEntry(keyArtHashByTxidAddr(caller, artId), sha256Hash), ScriptTransfer(Address(fromBase58String(feeReceiver)), amount, assetId)] | |
294 | - | } | |
295 | - | } | |
296 | - | } | |
297 | - | } | |
298 | - | } | |
299 | - | ||
300 | - | ||
301 | - | ||
302 | - | @Callable(invoke) | |
303 | - | func updateArtwork (txid,name,description,tags,type,maxmint,cidDisplay,sha256Export,cidExport,sha256Licence,cidLicence) = if (!(dappRunning)) | |
304 | - | then throw(maintenanceMSG) | |
305 | - | else { | |
306 | - | let updateId = toBase58String(invoke.transactionId) | |
307 | - | let caller = toBase58String(invoke.caller.bytes) | |
308 | - | let licenceCID = if ((size(cidLicence) == 0)) | |
309 | - | then defaultLicence | |
310 | - | else cidLicence | |
311 | - | let licenceHash = if ((size(sha256Licence) == 0)) | |
312 | - | then defaultHashLicence | |
313 | - | else sha256Licence | |
314 | - | let userIsRegistered = getStringByKeyFromUsers(keyUserStatus(caller)) | |
315 | - | if (if ((userIsRegistered == "")) | |
316 | - | then true | |
317 | - | else (userIsRegistered == userAllowed)) | |
318 | - | then throw("Register first with \"User infos\"") | |
319 | - | else if ((userIsRegistered == userSuspended)) | |
320 | - | then throw("Account suspended") | |
321 | - | else if ((userIsRegistered == userRemoved)) | |
322 | - | then throw("Account removed") | |
323 | - | else if (!(validateAllCID(cidDisplay, cidExport, licenceCID))) | |
324 | - | then throw("Problem with CID") | |
325 | - | else if (!(validateAllHash(sha256Export, licenceHash))) | |
326 | - | then throw("Problem with Hashes") | |
327 | - | else { | |
328 | - | let entryExist = getStringByKey(keyArtName(caller, txid)) | |
329 | - | if ((entryExist == "")) | |
330 | - | then throw("Entry not found") | |
331 | - | else if (!(validateString(name, 100))) | |
332 | - | then throw("100 Char. max name") | |
333 | - | else if (!(validateString(description, 1000))) | |
334 | - | then throw("1000 Char. max description") | |
335 | - | else { | |
336 | - | let flag = getStringByKey(keyArtFlag(caller, txid)) | |
337 | - | if ((flag == "ILLEGAL")) | |
338 | - | then throw("Cannot update ILLEGAL artwork") | |
339 | - | else { | |
340 | - | let artworkMinted = match getInteger(this, keyArtIssued(caller, txid)) { | |
341 | - | case b: Int => | |
342 | - | if ((b == 0)) | |
343 | - | then false | |
344 | - | else true | |
345 | - | case _ => | |
346 | - | false | |
347 | - | } | |
348 | - | if ((size(split(tags, ",")) > 5)) | |
349 | - | then throw("5 tags max.") | |
350 | - | else if ((maxmint > 10)) | |
351 | - | then throw("10 editions max per artwork") | |
352 | - | else if (!(artworkMinted)) | |
353 | - | then [StringEntry(keyArtName(caller, txid), name), StringEntry(keyArtDesc(caller, txid), description), StringEntry(keyArtDisplayCid(caller, txid), cidDisplay), StringEntry(keyArtExportCid(caller, txid), cidExport), StringEntry(keyArtExportHash(caller, txid), sha256Export), StringEntry(keyArtLicenceCid(caller, txid), licenceCID), StringEntry(keyArtLicenceHash(caller, txid), licenceHash), IntegerEntry(keyArtMaxMint(caller, txid), maxmint), StringEntry(keyArtTags(caller, txid), tags), StringEntry(keyArtType(caller, txid), type)] | |
354 | - | else throw("Already minted") | |
355 | - | } | |
356 | - | } | |
357 | - | } | |
358 | - | } | |
359 | - | ||
360 | - | ||
361 | - | ||
362 | - | @Callable(i) | |
363 | - | func flagArtwork (artId,addr,flag) = { | |
364 | - | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
365 | - | let id = toBase58String(i.transactionId) | |
366 | - | if (containsElement([chris, joep, toString(this)], caller)) | |
367 | - | then if ((flag == "CONSENT")) | |
368 | - | then [StringEntry(keyArtFlag(addr, artId), flag)] | |
369 | - | else if ((flag == "")) | |
370 | - | then [StringEntry(keyArtFlag(addr, artId), flag)] | |
371 | - | else if ((flag == "ILLEGAL")) | |
372 | - | then [StringEntry(keyArtFlag(addr, artId), flag), StringEntry(keyArtName(addr, artId), "ILLEGAL CONTENT"), StringEntry(keyArtDesc(addr, artId), "ILLEGAL CONTENT"), StringEntry(keyArtDisplayCid(addr, artId), ""), StringEntry(keyArtExportCid(addr, artId), ""), StringEntry(keyArtLicenceCid(addr, artId), "")] | |
373 | - | else throw(("Unknow status " + flag)) | |
374 | - | else throw("You are not allowed") | |
375 | - | } | |
376 | - | ||
377 | - | ||
378 | - | ||
379 | - | @Callable(i) | |
380 | - | func deleteArtwork (artId,addr) = { | |
381 | - | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
382 | - | let id = toBase58String(i.transactionId) | |
383 | - | let addressToUse = if (containsElement([chris, joep, toString(this)], caller)) | |
384 | - | then addr | |
385 | - | else caller | |
386 | - | let entryExist = getStringByKey(keyArtName(addressToUse, artId)) | |
387 | - | if ((entryExist == "")) | |
388 | - | then throw("No art matching for this address") | |
389 | - | else { | |
390 | - | let artworkMinted = match getInteger(this, keyArtIssued(addressToUse, artId)) { | |
391 | - | case b: Int => | |
392 | - | if ((b != 0)) | |
393 | - | then true | |
394 | - | else false | |
395 | - | case _ => | |
396 | - | false | |
397 | - | } | |
398 | - | let maxMint = getIntegerByKey(keyArtMaxMint(addressToUse, artId)) | |
399 | - | let sha256Hash = getStringByKey(keyArtHashByTxidAddr(addressToUse, artId)) | |
400 | - | if ((sha256Hash == "")) | |
401 | - | then throw("No art hash matching for this address") | |
402 | - | else { | |
403 | - | let signID = getStringByKey(keyArtSignID(addressToUse, artId)) | |
404 | - | if ((signID == "")) | |
405 | - | then throw("No SIGN ID matching") | |
406 | - | else { | |
407 | - | let dataToDelete = [DeleteEntry(keyArtDate(addressToUse, artId)), DeleteEntry(keyArtName(addressToUse, artId)), DeleteEntry(keyArtDesc(addressToUse, artId)), DeleteEntry(keyArtDisplayCid(addressToUse, artId)), DeleteEntry(keyArtExportCid(addressToUse, artId)), DeleteEntry(keyArtExportHash(addressToUse, artId)), DeleteEntry(keyArtLicenceHash(addressToUse, artId)), DeleteEntry(keyArtLicenceCid(addressToUse, artId)), DeleteEntry(keyArtType(addressToUse, artId)), DeleteEntry(keyArtTags(addressToUse, artId)), DeleteEntry(keyArtMaxMint(addressToUse, artId)), DeleteEntry(keyArtSignID(addressToUse, artId)), DeleteEntry(keyArtIssued(addressToUse, artId)), DeleteEntry(keyArtOnSale(addressToUse, artId)), DeleteEntry(keyArtFlag(addr, artId)), DeleteEntry(keyArtOwnerByHash(sha256Hash)), DeleteEntry(keyArtArtidBySignid(addressToUse, signID)), DeleteEntry(keyArtTxidByHashOwner(sha256Hash, addressToUse))] | |
408 | - | if (!(artworkMinted)) | |
409 | - | then if (!(dappRunning)) | |
410 | - | then throw(maintenanceMSG) | |
411 | - | else dataToDelete | |
412 | - | else if (containsElement([chris, toString(this)], caller)) | |
413 | - | then dataToDelete | |
414 | - | else throw("Art already minted, cannot delete") | |
415 | - | } | |
416 | - | } | |
417 | - | } | |
418 | - | } | |
419 | - | ||
420 | - | ||
421 | - | ||
422 | - | @Callable(i) | |
423 | - | func sellArtwork (artId,price,maxMint,assetId) = if (!(dappRunning)) | |
424 | - | then throw(maintenanceMSG) | |
425 | - | else { | |
426 | - | let id = toBase58String(i.transactionId) | |
427 | - | let caller = toBase58String(i.caller.bytes) | |
428 | - | let sellDate = lastBlock.timestamp | |
429 | - | let artworkName = getStringByKey(keyArtName(caller, artId)) | |
430 | - | if ((artworkName == "")) | |
431 | - | then throw("This art doesn't match match your account") | |
432 | - | else { | |
433 | - | let exportCID = getStringByKey(keyArtExportCid(caller, artId)) | |
434 | - | if ((size(split(exportCID, "/")[0]) != 59)) | |
435 | - | then throw("You cannot sell art with no export file") | |
436 | - | else { | |
437 | - | let exportHash = getStringByKey(keyArtExportHash(caller, artId)) | |
438 | - | if ((size(exportHash) != 64)) | |
439 | - | then throw("You cannot sell art with no export hash") | |
440 | - | else if (if (if ((assetId != toBase58String(signAssetId))) | |
441 | - | then (assetId != toBase58String(wavesAssetId)) | |
442 | - | else false) | |
443 | - | then (assetId != toBase58String(usdnAssetId)) | |
444 | - | else false) | |
445 | - | then throw("Only SIGN, USDN or WAVES accepted") | |
446 | - | else { | |
447 | - | let minSellWaves = if (unitTest) | |
448 | - | then 1 | |
449 | - | else getIntegerByKeyFromOracle("waves_min_sell") | |
450 | - | let minSellUsdn = 1000000 | |
451 | - | let minSellSign = if (unitTest) | |
452 | - | then 1 | |
453 | - | else (getIntegerByKeyFromOracle(("certification_fee_" + toBase58String(signAssetId))) * 2) | |
454 | - | if (if (if (if (if ((assetId == toBase58String(usdnAssetId))) | |
455 | - | then (minSellUsdn > price) | |
456 | - | else false) | |
457 | - | then (price != 0) | |
458 | - | else false) | |
459 | - | then true | |
460 | - | else if (if ((assetId == toBase58String(signAssetId))) | |
461 | - | then (minSellSign > price) | |
462 | - | else false) | |
463 | - | then (price != 0) | |
464 | - | else false) | |
465 | - | then true | |
466 | - | else if (if ((assetId == toBase58String(wavesAssetId))) | |
467 | - | then (minSellWaves > price) | |
468 | - | else false) | |
469 | - | then (price != 0) | |
470 | - | else false) | |
471 | - | then throw("Wrong minimum sell price") | |
472 | - | else { | |
473 | - | let userIsRegistered = getStringByKeyFromUsers(keyUserStatus(caller)) | |
474 | - | if (if ((userIsRegistered == "")) | |
475 | - | then true | |
476 | - | else (userIsRegistered == userAllowed)) | |
477 | - | then throw("Register this account first") | |
478 | - | else if ((userIsRegistered == userSuspended)) | |
479 | - | then throw("Account suspended") | |
480 | - | else if ((userIsRegistered == userRemoved)) | |
481 | - | then throw("Account deleted") | |
482 | - | else { | |
483 | - | let amountSold = getIntegerByKey(keyArtIssued(caller, artId)) | |
484 | - | let maxCanSell = getIntegerByKey(keyArtMaxMint(caller, artId)) | |
485 | - | if ((maxMint > 10)) | |
486 | - | then throw("10 editions max per artwork") | |
487 | - | else if (if ((amountSold != 0)) | |
488 | - | then (amountSold == maxCanSell) | |
489 | - | else false) | |
490 | - | then throw("Max edition reached.") | |
491 | - | else if (if ((amountSold > 0)) | |
492 | - | then (maxCanSell != maxMint) | |
493 | - | else false) | |
494 | - | then throw("Cannot change maximum issuable anymore") | |
495 | - | else { | |
496 | - | let sellStatus = if (if ((price > 0)) | |
497 | - | then (maxMint > 0) | |
498 | - | else false) | |
499 | - | then true | |
500 | - | else false | |
501 | - | [BooleanEntry(keyArtOnSale(caller, artId), sellStatus), IntegerEntry(keyArtPrice(caller, artId), price), IntegerEntry(keyArtMaxMint(caller, artId), maxMint), StringEntry(keyArtAssetIdAccepted(caller, artId), assetId)] | |
502 | - | } | |
503 | - | } | |
504 | - | } | |
505 | - | } | |
506 | - | } | |
507 | - | } | |
508 | - | } | |
509 | - | ||
510 | - | ||
511 | - | ||
512 | - | @Callable(i) | |
513 | - | func buyArtwork (artId,issuer) = if (!(dappRunning)) | |
514 | - | then throw(maintenanceMSG) | |
515 | - | else { | |
516 | - | let id = toBase58String(i.transactionId) | |
517 | - | let caller = toBase58String(i.caller.bytes) | |
518 | - | let totalNFT = getIntegerByKey("total_nft_issued") | |
519 | - | let signID = getStringByKey(keyArtSignID(issuer, artId)) | |
520 | - | let artworkName = getStringByKey(keyArtName(issuer, artId)) | |
521 | - | if ((artworkName == "")) | |
522 | - | then throw("Art doesn't exist") | |
523 | - | else { | |
524 | - | let displayCID = getStringByKey(keyArtDisplayCid(issuer, artId)) | |
525 | - | let exportCID = getStringByKey(keyArtExportCid(issuer, artId)) | |
526 | - | let exportHash = getStringByKey(keyArtExportHash(issuer, artId)) | |
527 | - | let licenceCID = getStringByKey(keyArtLicenceCid(issuer, artId)) | |
528 | - | let licenceHash = getStringByKey(keyArtLicenceHash(issuer, artId)) | |
529 | - | let description = take(getStringByKey(keyArtDesc(issuer, artId)), 50) | |
530 | - | let amountSold = getIntegerByKey(keyArtIssued(issuer, artId)) | |
531 | - | let artworkPrice = getIntegerByKey(keyArtPrice(issuer, artId)) | |
532 | - | let isOnSale = getBooleanByKey(keyArtOnSale(issuer, artId)) | |
533 | - | let priceAssetId = getStringByKey(keyArtAssetIdAccepted(issuer, artId)) | |
534 | - | let sourceHash = getStringByKey(keyArtHashByTxidAddr(issuer, artId)) | |
535 | - | let maxCanSell = getIntegerByKey(keyArtMaxMint(issuer, artId)) | |
536 | - | if (if (if ((0 >= artworkPrice)) | |
537 | - | then true | |
538 | - | else !(isOnSale)) | |
539 | - | then true | |
540 | - | else (0 >= maxCanSell)) | |
541 | - | then throw("Art not for sale") | |
542 | - | else { | |
543 | - | let payment = value(i.payments[0]) | |
544 | - | let amount = value(payment.amount) | |
545 | - | let assetId = if (!(isDefined(payment.assetId))) | |
546 | - | then unit | |
547 | - | else if (if ((size(priceAssetId) > 0)) | |
548 | - | then (toBase58String(value(payment.assetId)) == priceAssetId) | |
549 | - | else false) | |
550 | - | then payment.assetId | |
551 | - | else throw("Wrong asset id") | |
552 | - | if (if ((assetId == unit)) | |
553 | - | then (priceAssetId != "") | |
554 | - | else false) | |
555 | - | then throw("Wrong asset id") | |
556 | - | else { | |
557 | - | let isWhitelisted = checkWhitelist(issuer) | |
558 | - | let cut = if ((isWhitelisted == 1)) | |
559 | - | then 0 | |
560 | - | else if ((priceAssetId == toBase58String(signAssetId))) | |
561 | - | then 8 | |
562 | - | else 10 | |
563 | - | let amountForSign = fraction(amount, cut, 100) | |
564 | - | let amountForCreator = (amount - amountForSign) | |
565 | - | if ((amountSold == maxCanSell)) | |
566 | - | then throw("Art sold out") | |
567 | - | else if ((artworkPrice != amount)) | |
568 | - | then throw("Payment don't match") | |
569 | - | else { | |
570 | - | let newAmountSold = (amountSold + 1) | |
571 | - | let entryDate = lastBlock.timestamp | |
572 | - | let issueMeta = ((((((((((((((((((((((((((("Creator: " + issuer) + ", | |
573 | - | ArtID: ") + artId) + ", | |
574 | - | SignID: ") + signID) + ", | |
575 | - | Artwork name: ") + artworkName) + ", | |
576 | - | Artwork description: ") + description) + ", | |
577 | - | Issue: ") + toString(newAmountSold)) + "/") + toString(maxCanSell)) + ", | |
578 | - | Max issuable: ") + toString(maxCanSell)) + ", | |
579 | - | Source hash: ") + sourceHash) + ", | |
580 | - | Display cid: ") + displayCID) + ", | |
581 | - | Export cid: ") + exportCID) + ", | |
582 | - | Export hash: ") + exportHash) + ", | |
583 | - | Licence cid: ") + licenceCID) + ", | |
584 | - | Licence hash: ") + licenceHash) | |
585 | - | let issueNFT = Issue(("SA_" + toString((totalNFT + 1))), issueMeta, 1, 0, false) | |
586 | - | let idNFT = calculateAssetId(issueNFT) | |
587 | - | let sellStatus = if ((newAmountSold == maxCanSell)) | |
588 | - | then false | |
589 | - | else true | |
590 | - | [IntegerEntry(keyArtIssued(issuer, artId), newAmountSold), StringEntry(("nft_" + toBase58String(idNFT)), ((((((("art_sold_" + toString(newAmountSold)) + "_of_") + toString(maxCanSell)) + "_") + artId) + "_") + issuer)), StringEntry(((((((("art_sold_" + toString(newAmountSold)) + "_of_") + toString(maxCanSell)) + "_") + artId) + "_") + issuer), ((((((((((caller + "_") + toString(entryDate)) + "_") + id) + "_") + toString(artworkPrice)) + "_") + priceAssetId) + "_") + toBase58String(idNFT))), IntegerEntry("total_nft_issued", (totalNFT + 1)), BooleanEntry(keyArtOnSale(issuer, artId), sellStatus), issueNFT, ScriptTransfer(Address(fromBase58String(issuer)), amountForCreator, assetId), ScriptTransfer(Address(fromBase58String(feeReceiver)), amountForSign, assetId), ScriptTransfer(i.caller, 1, idNFT)] | |
591 | - | } | |
592 | - | } | |
593 | - | } | |
594 | - | } | |
595 | - | } | |
596 | - | ||
597 | - | ||
598 | - | ||
599 | - | @Callable(i) | |
600 | - | func deleteEntry (entry) = { | |
601 | - | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
602 | - | if ((caller == chris)) | |
603 | - | then [DeleteEntry(entry)] | |
604 | - | else throw("no") | |
85 | + | func addArtwork (sha256Hash,signID,name,description,tags,type,maxmint,cidDisplay,sha256Export,cidExport,sha256Licence,cidLicence) = { | |
86 | + | let artId = toBase58String(invoke.transactionId) | |
87 | + | let caller = toBase58String(invoke.caller.bytes) | |
88 | + | let timestamp = lastBlock.timestamp | |
89 | + | let licenceCID = if ((size(cidLicence) == 0)) | |
90 | + | then defaultLicence | |
91 | + | else cidLicence | |
92 | + | let licenceHash = if ((size(sha256Licence) == 0)) | |
93 | + | then defaultHashLicence | |
94 | + | else sha256Licence | |
95 | + | [StringEntry(keyArtOwnerByHash(sha256Hash), caller), StringEntry(keyArtTxidByHashOwner(sha256Hash, caller), artId), IntegerEntry(keyArtDate(caller, artId), timestamp), StringEntry(keyArtName(caller, artId), name), StringEntry(keyArtDesc(caller, artId), description), StringEntry(keyArtDisplayCid(caller, artId), cidDisplay), StringEntry(keyArtExportCid(caller, artId), cidExport), StringEntry(keyArtExportHash(caller, artId), sha256Export), StringEntry(keyArtLicenceHash(caller, artId), licenceHash), StringEntry(keyArtLicenceCid(caller, artId), licenceCID), StringEntry(keyArtType(caller, artId), type), StringEntry(keyArtTags(caller, artId), tags), IntegerEntry(keyArtMaxMint(caller, artId), maxmint), StringEntry(keyArtSignID(caller, artId), signID), IntegerEntry(keyArtIssued(caller, artId), 0), BooleanEntry(keyArtOnSale(caller, artId), false), StringEntry(keyArtArtidBySignid(caller, signID), artId), StringEntry(keyArtHashByTxidAddr(caller, artId), sha256Hash)] | |
605 | 96 | } | |
606 | 97 | ||
607 | 98 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let unitTest = false | |
5 | - | ||
6 | - | let oracleFee = value(addressFromString("3N2s5RtaHPBenCsx2ECcoFRbYHx3noZhXW1")) | |
7 | - | ||
8 | - | let signDapp = value(addressFromString("3NC28hSivrmsTUXaYD1x6L362J4ZpUnoTdB")) | |
9 | - | ||
10 | - | let feeReceiver = "3N1E6tXddRoVaRfQ9dQ3vg5LaW2fsd8HKub" | |
11 | - | ||
12 | - | let userDapp = if (unitTest) | |
13 | - | then value(addressFromString("3Mt4RGMEyjSWYAocTPqd55wdHQQB3PU2UCm")) | |
14 | - | else value(addressFromString("3N8xXaYjE27Aa79d5hHrhHu9HaFoTBmhDEj")) | |
15 | - | ||
16 | - | let whitelistDapp = value(addressFromString("3Mt6jj1WUYqd7DT7dHEubs9jETLUXMcAB8k")) | |
17 | - | ||
18 | - | let signAssetId = base58'Gf9t8FA4H3ssoZPCwrg3KwUFCci8zuUFP9ssRsUY3s6a' | |
19 | - | ||
20 | - | let usdnAssetId = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT' | |
21 | - | ||
22 | - | let wavesAssetId = base58'' | |
23 | - | ||
24 | - | let chris = "3MsG6jPNCrVJUtYB7XJBxS7utWsXAf4n9Vp" | |
25 | - | ||
26 | - | let joep = "3Mzm4VLwsN9uZwbTMzPj3XuxV6kEfAR8UDN" | |
27 | - | ||
28 | - | let signCut = 7 | |
29 | - | ||
30 | - | let usdnCut = 10 | |
31 | - | ||
32 | - | let wavesCut = 10 | |
4 | + | let userDapp = value(addressFromString("3MzVhsmmU8n1axekFJk1BRNwrmnCMH6Mn8F")) | |
33 | 5 | ||
34 | 6 | let defaultLicence = "bafybeigisfqtyo2qdfsceh5fpcp7eeymrpeglp6edao2bmyhijbayvausy/licence.pdf" | |
35 | 7 | ||
36 | 8 | let defaultHashLicence = "3df79d34abbca99308e79cb94461c1893582604d68329a41fd4bec1885e6adb4" | |
37 | - | ||
38 | - | let dappRunning = match getBoolean(userDapp, "conf_dapp_is_running") { | |
39 | - | case a: Boolean => | |
40 | - | a | |
41 | - | case _ => | |
42 | - | true | |
43 | - | } | |
44 | - | ||
45 | - | let maintenanceMSG = match getString(userDapp, "conf_maintenance_msg") { | |
46 | - | case a: String => | |
47 | - | a | |
48 | - | case _ => | |
49 | - | "" | |
50 | - | } | |
51 | - | ||
52 | - | let userSuspended = "SUSPENDED" | |
53 | - | ||
54 | - | let userRemoved = "REMOVED" | |
55 | - | ||
56 | - | let userUnregistered = "UNREGISTERED" | |
57 | - | ||
58 | - | let userAllowed = "ALLOWED" | |
59 | - | ||
60 | - | func getStringByKeyFromUsers (key) = match getString(userDapp, key) { | |
61 | - | case a: String => | |
62 | - | a | |
63 | - | case _ => | |
64 | - | "" | |
65 | - | } | |
66 | - | ||
67 | 9 | ||
68 | 10 | func getStringByKey (key) = match getString(this, key) { | |
69 | 11 | case a: String => | |
70 | 12 | a | |
71 | 13 | case _ => | |
72 | 14 | "" | |
73 | 15 | } | |
74 | - | ||
75 | - | ||
76 | - | func getIntegerByKeyFromOracle (key) = match getInteger(oracleFee, key) { | |
77 | - | case a: Int => | |
78 | - | a | |
79 | - | case _ => | |
80 | - | throw("Integer undefine or 0 in oracle") | |
81 | - | } | |
82 | - | ||
83 | - | ||
84 | - | func getIntegerByKey (key) = match getInteger(this, key) { | |
85 | - | case i: Int => | |
86 | - | i | |
87 | - | case _ => | |
88 | - | 0 | |
89 | - | } | |
90 | - | ||
91 | - | ||
92 | - | func checkWhitelist (key) = match getInteger(whitelistDapp, key) { | |
93 | - | case a: Int => | |
94 | - | if ((a >= height)) | |
95 | - | then 1 | |
96 | - | else 0 | |
97 | - | case _ => | |
98 | - | 0 | |
99 | - | } | |
100 | - | ||
101 | - | ||
102 | - | func getBooleanByKey (key) = match getBoolean(this, key) { | |
103 | - | case i: Boolean => | |
104 | - | i | |
105 | - | case _ => | |
106 | - | false | |
107 | - | } | |
108 | - | ||
109 | - | ||
110 | - | func checkSignCertificate (signID,Owner,sha256Hash) = match getString(signDapp, ((("data_fc_" + signID) + "_") + Owner)) { | |
111 | - | case a: String => | |
112 | - | if (contains(a, sha256Hash)) | |
113 | - | then true | |
114 | - | else false | |
115 | - | case _ => | |
116 | - | false | |
117 | - | } | |
118 | - | ||
119 | - | ||
120 | - | func validateCID (cid) = if (contains(cid, "/")) | |
121 | - | then if (if ((75 > size(cid))) | |
122 | - | then (60 > size(split(cid, "/")[0])) | |
123 | - | else false) | |
124 | - | then (16 > size(split(cid, "/")[1])) | |
125 | - | else false | |
126 | - | else false | |
127 | - | ||
128 | - | ||
129 | - | func validateHash (hash) = (65 > size(hash)) | |
130 | 16 | ||
131 | 17 | ||
132 | 18 | func keyUserStatus (caller) = ("user_status_" + caller) | |
133 | 19 | ||
134 | 20 | ||
135 | 21 | func keyArtDate (caller,artId) = ((("art_date_" + artId) + "_") + caller) | |
136 | 22 | ||
137 | 23 | ||
138 | 24 | func keyArtName (caller,artId) = ((("art_name_" + artId) + "_") + caller) | |
139 | 25 | ||
140 | 26 | ||
141 | 27 | func keyArtDesc (caller,artId) = ((("art_desc_" + artId) + "_") + caller) | |
142 | 28 | ||
143 | 29 | ||
144 | 30 | func keyArtDisplayCid (caller,artId) = ((("art_display_cid_" + artId) + "_") + caller) | |
145 | 31 | ||
146 | 32 | ||
147 | 33 | func keyArtExportHash (caller,artId) = ((("art_export_hash_" + artId) + "_") + caller) | |
148 | 34 | ||
149 | 35 | ||
150 | 36 | func keyArtExportCid (caller,artId) = ((("art_export_cid_" + artId) + "_") + caller) | |
151 | 37 | ||
152 | 38 | ||
153 | 39 | func keyArtMaxMint (caller,artId) = ((("art_maxmint_" + artId) + "_") + caller) | |
154 | 40 | ||
155 | 41 | ||
156 | 42 | func keyArtSignID (caller,artId) = ((("art_signid_" + artId) + "_") + caller) | |
157 | 43 | ||
158 | 44 | ||
159 | 45 | func keyArtIssued (caller,artId) = ((("art_issued_" + artId) + "_") + caller) | |
160 | 46 | ||
161 | 47 | ||
162 | 48 | func keyArtOnSale (caller,artId) = ((("art_onsale_" + artId) + "_") + caller) | |
163 | 49 | ||
164 | 50 | ||
165 | 51 | func keyArtLicenceHash (caller,artId) = ((("art_licence_hash_" + artId) + "_") + caller) | |
166 | 52 | ||
167 | 53 | ||
168 | 54 | func keyArtLicenceCid (caller,artId) = ((("art_licence_cid_" + artId) + "_") + caller) | |
169 | 55 | ||
170 | 56 | ||
171 | 57 | func keyArtTags (caller,artId) = ((("art_tags_" + artId) + "_") + caller) | |
172 | 58 | ||
173 | 59 | ||
174 | 60 | func keyArtType (caller,artId) = ((("art_type_" + artId) + "_") + caller) | |
175 | 61 | ||
176 | 62 | ||
177 | 63 | func keyArtPrice (caller,artId) = ((("art_price_" + artId) + "_") + caller) | |
178 | 64 | ||
179 | 65 | ||
180 | 66 | func keyArtAssetIdAccepted (caller,artId) = ((("art_assetAccepted_" + artId) + "_") + caller) | |
181 | 67 | ||
182 | 68 | ||
183 | 69 | func keyArtFlag (caller,artId) = ((("art_flag_" + artId) + "_") + caller) | |
184 | 70 | ||
185 | 71 | ||
186 | 72 | func keyArtHashByTxidAddr (caller,txid) = ((("get_hashbytxidaddr_" + txid) + "_") + caller) | |
187 | 73 | ||
188 | 74 | ||
189 | 75 | func keyArtOwnerByHash (sha256Hash) = ("get_owner_by_hash_" + sha256Hash) | |
190 | 76 | ||
191 | 77 | ||
192 | 78 | func keyArtArtidBySignid (caller,signId) = ((("get_artidbysignid_" + signId) + "_") + caller) | |
193 | 79 | ||
194 | 80 | ||
195 | 81 | func keyArtTxidByHashOwner (sha256Hash,caller) = ("get_txid_by_hash_owner_" + toBase58String(sha256_16Kb(toBytes((sha256Hash + caller))))) | |
196 | 82 | ||
197 | 83 | ||
198 | - | func validateAllCID (cidDisplay,cidExport,cidLicence) = if (!(validateCID(cidDisplay))) | |
199 | - | then throw("Wrong Display CID") | |
200 | - | else if (!(validateCID(cidExport))) | |
201 | - | then throw("Wrong Export CID") | |
202 | - | else if (if ((cidLicence != "")) | |
203 | - | then !(validateCID(cidLicence)) | |
204 | - | else false) | |
205 | - | then throw("Wrong Licence CID") | |
206 | - | else true | |
207 | - | ||
208 | - | ||
209 | - | func validateAllHash (sha256Export,sha256Licence) = if (!(validateHash(sha256Export))) | |
210 | - | then throw("Export Hash 64 char. max") | |
211 | - | else if (!(validateHash(sha256Licence))) | |
212 | - | then throw("Licence Hash 64 char. max") | |
213 | - | else true | |
214 | - | ||
215 | - | ||
216 | - | func validateString (str,max) = if ((size(str) == 0)) | |
217 | - | then throw("Field cannot be is empty") | |
218 | - | else if ((size(str) > max)) | |
219 | - | then throw((str + " is too long")) | |
220 | - | else true | |
221 | - | ||
222 | - | ||
223 | 84 | @Callable(invoke) | |
224 | - | func addArtwork (sha256Hash,signID,name,description,tags,type,maxmint,cidDisplay,sha256Export,cidExport,sha256Licence,cidLicence) = if (!(dappRunning)) | |
225 | - | then throw(maintenanceMSG) | |
226 | - | else { | |
227 | - | let artId = toBase58String(invoke.transactionId) | |
228 | - | let caller = toBase58String(invoke.caller.bytes) | |
229 | - | let timestamp = lastBlock.timestamp | |
230 | - | let licenceCID = if ((size(cidLicence) == 0)) | |
231 | - | then defaultLicence | |
232 | - | else cidLicence | |
233 | - | let licenceHash = if ((size(sha256Licence) == 0)) | |
234 | - | then defaultHashLicence | |
235 | - | else sha256Licence | |
236 | - | let userIsRegistered = match getString(userDapp, ("user_status_" + caller)) { | |
237 | - | case s: String => | |
238 | - | s | |
239 | - | case _ => | |
240 | - | userUnregistered | |
241 | - | } | |
242 | - | if (if (isDefined(userIsRegistered)) | |
243 | - | then if ((userIsRegistered == userUnregistered)) | |
244 | - | then true | |
245 | - | else (userIsRegistered == userAllowed) | |
246 | - | else false) | |
247 | - | then throw("Register this account first with \"Account\" tab") | |
248 | - | else if ((userIsRegistered == userSuspended)) | |
249 | - | then throw("Account suspended") | |
250 | - | else if ((userIsRegistered == userRemoved)) | |
251 | - | then throw("Account removed") | |
252 | - | else if (!(validateAllCID(cidDisplay, cidExport, licenceCID))) | |
253 | - | then throw("Problem with CID") | |
254 | - | else if (!(validateHash(sha256Hash))) | |
255 | - | then throw("Hash should be 64 characters maximum") | |
256 | - | else if (!(validateAllHash(sha256Export, licenceHash))) | |
257 | - | then throw("Problem with Hashes") | |
258 | - | else if ((size(invoke.payments) == 0)) | |
259 | - | then throw("No payment attached") | |
260 | - | else { | |
261 | - | let payment = value(invoke.payments[0]) | |
262 | - | let amount = value(payment.amount) | |
263 | - | let assetId = if (if (isDefined(payment.assetId)) | |
264 | - | then (payment.assetId == signAssetId) | |
265 | - | else false) | |
266 | - | then payment.assetId | |
267 | - | else throw("Only SIGN token accepted") | |
268 | - | let currentCertificationPrice = getIntegerByKeyFromOracle(("certification_fee_" + toBase58String(signAssetId))) | |
269 | - | if ((amount != currentCertificationPrice)) | |
270 | - | then throw(("Payment amount should be " + toString(currentCertificationPrice))) | |
271 | - | else { | |
272 | - | let entryExist = getStringByKey(keyArtTxidByHashOwner(sha256Hash, caller)) | |
273 | - | if ((entryExist != "")) | |
274 | - | then throw("You already added it") | |
275 | - | else { | |
276 | - | let hashExist = getStringByKey(keyArtOwnerByHash(sha256Hash)) | |
277 | - | if ((hashExist != "")) | |
278 | - | then throw("Hash already registered") | |
279 | - | else { | |
280 | - | let isSignCertified = checkSignCertificate(signID, caller, sha256Hash) | |
281 | - | if (!(isSignCertified)) | |
282 | - | then throw("Sign Certificate not found for this address.") | |
283 | - | else if ((size(cidDisplay) == 0)) | |
284 | - | then throw("Display CID cannot be empty") | |
285 | - | else if (!(validateString(name, 100))) | |
286 | - | then throw("100 Char. max name") | |
287 | - | else if (!(validateString(description, 1000))) | |
288 | - | then throw("1000 Char. max description") | |
289 | - | else if ((size(split(tags, ",")) > 5)) | |
290 | - | then throw("5 tags max.") | |
291 | - | else if ((maxmint > 10)) | |
292 | - | then throw("10 editions max") | |
293 | - | else [StringEntry(keyArtOwnerByHash(sha256Hash), caller), StringEntry(keyArtTxidByHashOwner(sha256Hash, caller), artId), IntegerEntry(keyArtDate(caller, artId), timestamp), StringEntry(keyArtName(caller, artId), name), StringEntry(keyArtDesc(caller, artId), description), StringEntry(keyArtDisplayCid(caller, artId), cidDisplay), StringEntry(keyArtExportCid(caller, artId), cidExport), StringEntry(keyArtExportHash(caller, artId), sha256Export), StringEntry(keyArtLicenceHash(caller, artId), licenceHash), StringEntry(keyArtLicenceCid(caller, artId), licenceCID), StringEntry(keyArtType(caller, artId), type), StringEntry(keyArtTags(caller, artId), tags), IntegerEntry(keyArtMaxMint(caller, artId), maxmint), StringEntry(keyArtSignID(caller, artId), signID), IntegerEntry(keyArtIssued(caller, artId), 0), BooleanEntry(keyArtOnSale(caller, artId), false), StringEntry(keyArtArtidBySignid(caller, signID), artId), StringEntry(keyArtHashByTxidAddr(caller, artId), sha256Hash), ScriptTransfer(Address(fromBase58String(feeReceiver)), amount, assetId)] | |
294 | - | } | |
295 | - | } | |
296 | - | } | |
297 | - | } | |
298 | - | } | |
299 | - | ||
300 | - | ||
301 | - | ||
302 | - | @Callable(invoke) | |
303 | - | func updateArtwork (txid,name,description,tags,type,maxmint,cidDisplay,sha256Export,cidExport,sha256Licence,cidLicence) = if (!(dappRunning)) | |
304 | - | then throw(maintenanceMSG) | |
305 | - | else { | |
306 | - | let updateId = toBase58String(invoke.transactionId) | |
307 | - | let caller = toBase58String(invoke.caller.bytes) | |
308 | - | let licenceCID = if ((size(cidLicence) == 0)) | |
309 | - | then defaultLicence | |
310 | - | else cidLicence | |
311 | - | let licenceHash = if ((size(sha256Licence) == 0)) | |
312 | - | then defaultHashLicence | |
313 | - | else sha256Licence | |
314 | - | let userIsRegistered = getStringByKeyFromUsers(keyUserStatus(caller)) | |
315 | - | if (if ((userIsRegistered == "")) | |
316 | - | then true | |
317 | - | else (userIsRegistered == userAllowed)) | |
318 | - | then throw("Register first with \"User infos\"") | |
319 | - | else if ((userIsRegistered == userSuspended)) | |
320 | - | then throw("Account suspended") | |
321 | - | else if ((userIsRegistered == userRemoved)) | |
322 | - | then throw("Account removed") | |
323 | - | else if (!(validateAllCID(cidDisplay, cidExport, licenceCID))) | |
324 | - | then throw("Problem with CID") | |
325 | - | else if (!(validateAllHash(sha256Export, licenceHash))) | |
326 | - | then throw("Problem with Hashes") | |
327 | - | else { | |
328 | - | let entryExist = getStringByKey(keyArtName(caller, txid)) | |
329 | - | if ((entryExist == "")) | |
330 | - | then throw("Entry not found") | |
331 | - | else if (!(validateString(name, 100))) | |
332 | - | then throw("100 Char. max name") | |
333 | - | else if (!(validateString(description, 1000))) | |
334 | - | then throw("1000 Char. max description") | |
335 | - | else { | |
336 | - | let flag = getStringByKey(keyArtFlag(caller, txid)) | |
337 | - | if ((flag == "ILLEGAL")) | |
338 | - | then throw("Cannot update ILLEGAL artwork") | |
339 | - | else { | |
340 | - | let artworkMinted = match getInteger(this, keyArtIssued(caller, txid)) { | |
341 | - | case b: Int => | |
342 | - | if ((b == 0)) | |
343 | - | then false | |
344 | - | else true | |
345 | - | case _ => | |
346 | - | false | |
347 | - | } | |
348 | - | if ((size(split(tags, ",")) > 5)) | |
349 | - | then throw("5 tags max.") | |
350 | - | else if ((maxmint > 10)) | |
351 | - | then throw("10 editions max per artwork") | |
352 | - | else if (!(artworkMinted)) | |
353 | - | then [StringEntry(keyArtName(caller, txid), name), StringEntry(keyArtDesc(caller, txid), description), StringEntry(keyArtDisplayCid(caller, txid), cidDisplay), StringEntry(keyArtExportCid(caller, txid), cidExport), StringEntry(keyArtExportHash(caller, txid), sha256Export), StringEntry(keyArtLicenceCid(caller, txid), licenceCID), StringEntry(keyArtLicenceHash(caller, txid), licenceHash), IntegerEntry(keyArtMaxMint(caller, txid), maxmint), StringEntry(keyArtTags(caller, txid), tags), StringEntry(keyArtType(caller, txid), type)] | |
354 | - | else throw("Already minted") | |
355 | - | } | |
356 | - | } | |
357 | - | } | |
358 | - | } | |
359 | - | ||
360 | - | ||
361 | - | ||
362 | - | @Callable(i) | |
363 | - | func flagArtwork (artId,addr,flag) = { | |
364 | - | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
365 | - | let id = toBase58String(i.transactionId) | |
366 | - | if (containsElement([chris, joep, toString(this)], caller)) | |
367 | - | then if ((flag == "CONSENT")) | |
368 | - | then [StringEntry(keyArtFlag(addr, artId), flag)] | |
369 | - | else if ((flag == "")) | |
370 | - | then [StringEntry(keyArtFlag(addr, artId), flag)] | |
371 | - | else if ((flag == "ILLEGAL")) | |
372 | - | then [StringEntry(keyArtFlag(addr, artId), flag), StringEntry(keyArtName(addr, artId), "ILLEGAL CONTENT"), StringEntry(keyArtDesc(addr, artId), "ILLEGAL CONTENT"), StringEntry(keyArtDisplayCid(addr, artId), ""), StringEntry(keyArtExportCid(addr, artId), ""), StringEntry(keyArtLicenceCid(addr, artId), "")] | |
373 | - | else throw(("Unknow status " + flag)) | |
374 | - | else throw("You are not allowed") | |
375 | - | } | |
376 | - | ||
377 | - | ||
378 | - | ||
379 | - | @Callable(i) | |
380 | - | func deleteArtwork (artId,addr) = { | |
381 | - | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
382 | - | let id = toBase58String(i.transactionId) | |
383 | - | let addressToUse = if (containsElement([chris, joep, toString(this)], caller)) | |
384 | - | then addr | |
385 | - | else caller | |
386 | - | let entryExist = getStringByKey(keyArtName(addressToUse, artId)) | |
387 | - | if ((entryExist == "")) | |
388 | - | then throw("No art matching for this address") | |
389 | - | else { | |
390 | - | let artworkMinted = match getInteger(this, keyArtIssued(addressToUse, artId)) { | |
391 | - | case b: Int => | |
392 | - | if ((b != 0)) | |
393 | - | then true | |
394 | - | else false | |
395 | - | case _ => | |
396 | - | false | |
397 | - | } | |
398 | - | let maxMint = getIntegerByKey(keyArtMaxMint(addressToUse, artId)) | |
399 | - | let sha256Hash = getStringByKey(keyArtHashByTxidAddr(addressToUse, artId)) | |
400 | - | if ((sha256Hash == "")) | |
401 | - | then throw("No art hash matching for this address") | |
402 | - | else { | |
403 | - | let signID = getStringByKey(keyArtSignID(addressToUse, artId)) | |
404 | - | if ((signID == "")) | |
405 | - | then throw("No SIGN ID matching") | |
406 | - | else { | |
407 | - | let dataToDelete = [DeleteEntry(keyArtDate(addressToUse, artId)), DeleteEntry(keyArtName(addressToUse, artId)), DeleteEntry(keyArtDesc(addressToUse, artId)), DeleteEntry(keyArtDisplayCid(addressToUse, artId)), DeleteEntry(keyArtExportCid(addressToUse, artId)), DeleteEntry(keyArtExportHash(addressToUse, artId)), DeleteEntry(keyArtLicenceHash(addressToUse, artId)), DeleteEntry(keyArtLicenceCid(addressToUse, artId)), DeleteEntry(keyArtType(addressToUse, artId)), DeleteEntry(keyArtTags(addressToUse, artId)), DeleteEntry(keyArtMaxMint(addressToUse, artId)), DeleteEntry(keyArtSignID(addressToUse, artId)), DeleteEntry(keyArtIssued(addressToUse, artId)), DeleteEntry(keyArtOnSale(addressToUse, artId)), DeleteEntry(keyArtFlag(addr, artId)), DeleteEntry(keyArtOwnerByHash(sha256Hash)), DeleteEntry(keyArtArtidBySignid(addressToUse, signID)), DeleteEntry(keyArtTxidByHashOwner(sha256Hash, addressToUse))] | |
408 | - | if (!(artworkMinted)) | |
409 | - | then if (!(dappRunning)) | |
410 | - | then throw(maintenanceMSG) | |
411 | - | else dataToDelete | |
412 | - | else if (containsElement([chris, toString(this)], caller)) | |
413 | - | then dataToDelete | |
414 | - | else throw("Art already minted, cannot delete") | |
415 | - | } | |
416 | - | } | |
417 | - | } | |
418 | - | } | |
419 | - | ||
420 | - | ||
421 | - | ||
422 | - | @Callable(i) | |
423 | - | func sellArtwork (artId,price,maxMint,assetId) = if (!(dappRunning)) | |
424 | - | then throw(maintenanceMSG) | |
425 | - | else { | |
426 | - | let id = toBase58String(i.transactionId) | |
427 | - | let caller = toBase58String(i.caller.bytes) | |
428 | - | let sellDate = lastBlock.timestamp | |
429 | - | let artworkName = getStringByKey(keyArtName(caller, artId)) | |
430 | - | if ((artworkName == "")) | |
431 | - | then throw("This art doesn't match match your account") | |
432 | - | else { | |
433 | - | let exportCID = getStringByKey(keyArtExportCid(caller, artId)) | |
434 | - | if ((size(split(exportCID, "/")[0]) != 59)) | |
435 | - | then throw("You cannot sell art with no export file") | |
436 | - | else { | |
437 | - | let exportHash = getStringByKey(keyArtExportHash(caller, artId)) | |
438 | - | if ((size(exportHash) != 64)) | |
439 | - | then throw("You cannot sell art with no export hash") | |
440 | - | else if (if (if ((assetId != toBase58String(signAssetId))) | |
441 | - | then (assetId != toBase58String(wavesAssetId)) | |
442 | - | else false) | |
443 | - | then (assetId != toBase58String(usdnAssetId)) | |
444 | - | else false) | |
445 | - | then throw("Only SIGN, USDN or WAVES accepted") | |
446 | - | else { | |
447 | - | let minSellWaves = if (unitTest) | |
448 | - | then 1 | |
449 | - | else getIntegerByKeyFromOracle("waves_min_sell") | |
450 | - | let minSellUsdn = 1000000 | |
451 | - | let minSellSign = if (unitTest) | |
452 | - | then 1 | |
453 | - | else (getIntegerByKeyFromOracle(("certification_fee_" + toBase58String(signAssetId))) * 2) | |
454 | - | if (if (if (if (if ((assetId == toBase58String(usdnAssetId))) | |
455 | - | then (minSellUsdn > price) | |
456 | - | else false) | |
457 | - | then (price != 0) | |
458 | - | else false) | |
459 | - | then true | |
460 | - | else if (if ((assetId == toBase58String(signAssetId))) | |
461 | - | then (minSellSign > price) | |
462 | - | else false) | |
463 | - | then (price != 0) | |
464 | - | else false) | |
465 | - | then true | |
466 | - | else if (if ((assetId == toBase58String(wavesAssetId))) | |
467 | - | then (minSellWaves > price) | |
468 | - | else false) | |
469 | - | then (price != 0) | |
470 | - | else false) | |
471 | - | then throw("Wrong minimum sell price") | |
472 | - | else { | |
473 | - | let userIsRegistered = getStringByKeyFromUsers(keyUserStatus(caller)) | |
474 | - | if (if ((userIsRegistered == "")) | |
475 | - | then true | |
476 | - | else (userIsRegistered == userAllowed)) | |
477 | - | then throw("Register this account first") | |
478 | - | else if ((userIsRegistered == userSuspended)) | |
479 | - | then throw("Account suspended") | |
480 | - | else if ((userIsRegistered == userRemoved)) | |
481 | - | then throw("Account deleted") | |
482 | - | else { | |
483 | - | let amountSold = getIntegerByKey(keyArtIssued(caller, artId)) | |
484 | - | let maxCanSell = getIntegerByKey(keyArtMaxMint(caller, artId)) | |
485 | - | if ((maxMint > 10)) | |
486 | - | then throw("10 editions max per artwork") | |
487 | - | else if (if ((amountSold != 0)) | |
488 | - | then (amountSold == maxCanSell) | |
489 | - | else false) | |
490 | - | then throw("Max edition reached.") | |
491 | - | else if (if ((amountSold > 0)) | |
492 | - | then (maxCanSell != maxMint) | |
493 | - | else false) | |
494 | - | then throw("Cannot change maximum issuable anymore") | |
495 | - | else { | |
496 | - | let sellStatus = if (if ((price > 0)) | |
497 | - | then (maxMint > 0) | |
498 | - | else false) | |
499 | - | then true | |
500 | - | else false | |
501 | - | [BooleanEntry(keyArtOnSale(caller, artId), sellStatus), IntegerEntry(keyArtPrice(caller, artId), price), IntegerEntry(keyArtMaxMint(caller, artId), maxMint), StringEntry(keyArtAssetIdAccepted(caller, artId), assetId)] | |
502 | - | } | |
503 | - | } | |
504 | - | } | |
505 | - | } | |
506 | - | } | |
507 | - | } | |
508 | - | } | |
509 | - | ||
510 | - | ||
511 | - | ||
512 | - | @Callable(i) | |
513 | - | func buyArtwork (artId,issuer) = if (!(dappRunning)) | |
514 | - | then throw(maintenanceMSG) | |
515 | - | else { | |
516 | - | let id = toBase58String(i.transactionId) | |
517 | - | let caller = toBase58String(i.caller.bytes) | |
518 | - | let totalNFT = getIntegerByKey("total_nft_issued") | |
519 | - | let signID = getStringByKey(keyArtSignID(issuer, artId)) | |
520 | - | let artworkName = getStringByKey(keyArtName(issuer, artId)) | |
521 | - | if ((artworkName == "")) | |
522 | - | then throw("Art doesn't exist") | |
523 | - | else { | |
524 | - | let displayCID = getStringByKey(keyArtDisplayCid(issuer, artId)) | |
525 | - | let exportCID = getStringByKey(keyArtExportCid(issuer, artId)) | |
526 | - | let exportHash = getStringByKey(keyArtExportHash(issuer, artId)) | |
527 | - | let licenceCID = getStringByKey(keyArtLicenceCid(issuer, artId)) | |
528 | - | let licenceHash = getStringByKey(keyArtLicenceHash(issuer, artId)) | |
529 | - | let description = take(getStringByKey(keyArtDesc(issuer, artId)), 50) | |
530 | - | let amountSold = getIntegerByKey(keyArtIssued(issuer, artId)) | |
531 | - | let artworkPrice = getIntegerByKey(keyArtPrice(issuer, artId)) | |
532 | - | let isOnSale = getBooleanByKey(keyArtOnSale(issuer, artId)) | |
533 | - | let priceAssetId = getStringByKey(keyArtAssetIdAccepted(issuer, artId)) | |
534 | - | let sourceHash = getStringByKey(keyArtHashByTxidAddr(issuer, artId)) | |
535 | - | let maxCanSell = getIntegerByKey(keyArtMaxMint(issuer, artId)) | |
536 | - | if (if (if ((0 >= artworkPrice)) | |
537 | - | then true | |
538 | - | else !(isOnSale)) | |
539 | - | then true | |
540 | - | else (0 >= maxCanSell)) | |
541 | - | then throw("Art not for sale") | |
542 | - | else { | |
543 | - | let payment = value(i.payments[0]) | |
544 | - | let amount = value(payment.amount) | |
545 | - | let assetId = if (!(isDefined(payment.assetId))) | |
546 | - | then unit | |
547 | - | else if (if ((size(priceAssetId) > 0)) | |
548 | - | then (toBase58String(value(payment.assetId)) == priceAssetId) | |
549 | - | else false) | |
550 | - | then payment.assetId | |
551 | - | else throw("Wrong asset id") | |
552 | - | if (if ((assetId == unit)) | |
553 | - | then (priceAssetId != "") | |
554 | - | else false) | |
555 | - | then throw("Wrong asset id") | |
556 | - | else { | |
557 | - | let isWhitelisted = checkWhitelist(issuer) | |
558 | - | let cut = if ((isWhitelisted == 1)) | |
559 | - | then 0 | |
560 | - | else if ((priceAssetId == toBase58String(signAssetId))) | |
561 | - | then 8 | |
562 | - | else 10 | |
563 | - | let amountForSign = fraction(amount, cut, 100) | |
564 | - | let amountForCreator = (amount - amountForSign) | |
565 | - | if ((amountSold == maxCanSell)) | |
566 | - | then throw("Art sold out") | |
567 | - | else if ((artworkPrice != amount)) | |
568 | - | then throw("Payment don't match") | |
569 | - | else { | |
570 | - | let newAmountSold = (amountSold + 1) | |
571 | - | let entryDate = lastBlock.timestamp | |
572 | - | let issueMeta = ((((((((((((((((((((((((((("Creator: " + issuer) + ", | |
573 | - | ArtID: ") + artId) + ", | |
574 | - | SignID: ") + signID) + ", | |
575 | - | Artwork name: ") + artworkName) + ", | |
576 | - | Artwork description: ") + description) + ", | |
577 | - | Issue: ") + toString(newAmountSold)) + "/") + toString(maxCanSell)) + ", | |
578 | - | Max issuable: ") + toString(maxCanSell)) + ", | |
579 | - | Source hash: ") + sourceHash) + ", | |
580 | - | Display cid: ") + displayCID) + ", | |
581 | - | Export cid: ") + exportCID) + ", | |
582 | - | Export hash: ") + exportHash) + ", | |
583 | - | Licence cid: ") + licenceCID) + ", | |
584 | - | Licence hash: ") + licenceHash) | |
585 | - | let issueNFT = Issue(("SA_" + toString((totalNFT + 1))), issueMeta, 1, 0, false) | |
586 | - | let idNFT = calculateAssetId(issueNFT) | |
587 | - | let sellStatus = if ((newAmountSold == maxCanSell)) | |
588 | - | then false | |
589 | - | else true | |
590 | - | [IntegerEntry(keyArtIssued(issuer, artId), newAmountSold), StringEntry(("nft_" + toBase58String(idNFT)), ((((((("art_sold_" + toString(newAmountSold)) + "_of_") + toString(maxCanSell)) + "_") + artId) + "_") + issuer)), StringEntry(((((((("art_sold_" + toString(newAmountSold)) + "_of_") + toString(maxCanSell)) + "_") + artId) + "_") + issuer), ((((((((((caller + "_") + toString(entryDate)) + "_") + id) + "_") + toString(artworkPrice)) + "_") + priceAssetId) + "_") + toBase58String(idNFT))), IntegerEntry("total_nft_issued", (totalNFT + 1)), BooleanEntry(keyArtOnSale(issuer, artId), sellStatus), issueNFT, ScriptTransfer(Address(fromBase58String(issuer)), amountForCreator, assetId), ScriptTransfer(Address(fromBase58String(feeReceiver)), amountForSign, assetId), ScriptTransfer(i.caller, 1, idNFT)] | |
591 | - | } | |
592 | - | } | |
593 | - | } | |
594 | - | } | |
595 | - | } | |
596 | - | ||
597 | - | ||
598 | - | ||
599 | - | @Callable(i) | |
600 | - | func deleteEntry (entry) = { | |
601 | - | let caller = toString(addressFromPublicKey(i.callerPublicKey)) | |
602 | - | if ((caller == chris)) | |
603 | - | then [DeleteEntry(entry)] | |
604 | - | else throw("no") | |
85 | + | func addArtwork (sha256Hash,signID,name,description,tags,type,maxmint,cidDisplay,sha256Export,cidExport,sha256Licence,cidLicence) = { | |
86 | + | let artId = toBase58String(invoke.transactionId) | |
87 | + | let caller = toBase58String(invoke.caller.bytes) | |
88 | + | let timestamp = lastBlock.timestamp | |
89 | + | let licenceCID = if ((size(cidLicence) == 0)) | |
90 | + | then defaultLicence | |
91 | + | else cidLicence | |
92 | + | let licenceHash = if ((size(sha256Licence) == 0)) | |
93 | + | then defaultHashLicence | |
94 | + | else sha256Licence | |
95 | + | [StringEntry(keyArtOwnerByHash(sha256Hash), caller), StringEntry(keyArtTxidByHashOwner(sha256Hash, caller), artId), IntegerEntry(keyArtDate(caller, artId), timestamp), StringEntry(keyArtName(caller, artId), name), StringEntry(keyArtDesc(caller, artId), description), StringEntry(keyArtDisplayCid(caller, artId), cidDisplay), StringEntry(keyArtExportCid(caller, artId), cidExport), StringEntry(keyArtExportHash(caller, artId), sha256Export), StringEntry(keyArtLicenceHash(caller, artId), licenceHash), StringEntry(keyArtLicenceCid(caller, artId), licenceCID), StringEntry(keyArtType(caller, artId), type), StringEntry(keyArtTags(caller, artId), tags), IntegerEntry(keyArtMaxMint(caller, artId), maxmint), StringEntry(keyArtSignID(caller, artId), signID), IntegerEntry(keyArtIssued(caller, artId), 0), BooleanEntry(keyArtOnSale(caller, artId), false), StringEntry(keyArtArtidBySignid(caller, signID), artId), StringEntry(keyArtHashByTxidAddr(caller, artId), sha256Hash)] | |
605 | 96 | } | |
606 | 97 | ||
607 | 98 |
github/deemru/w8io/169f3d6 50.30 ms ◑