tx · CxATTQkJGwMW5NJnMhwXzm2Kowba6fCNhY2U4qbNpbhx 3NBynfbXC2KastUxhukcMUaE58K9cBdB9UY: -0.01100000 Waves 2023.01.20 07:27 [2412785] smart account 3NBynfbXC2KastUxhukcMUaE58K9cBdB9UY > SELF 0.00000000 Waves
{ "type": 13, "id": "CxATTQkJGwMW5NJnMhwXzm2Kowba6fCNhY2U4qbNpbhx", "fee": 1100000, "feeAssetId": null, "timestamp": 1674188845692, "version": 2, "chainId": 84, "sender": "3NBynfbXC2KastUxhukcMUaE58K9cBdB9UY", "senderPublicKey": "J9DCtJJxJBWZdtDR12BA1U94Q3cZzMi4R6k5hYkAzmzC", "proofs": [ "4Wm5HCaDtKFG8RYy6mu6PRbwBvpKvrZPH6dds7KHzUxjAxPv3ukYU1CkcvE68vUqtU7KvADJn8DbYnJbT7yMpNqQ" ], "script": "base64:BgJMCAISBAoCCAgSBAoCBAgSAwoBBBIICgYICAgIAQgSCAoGCAgICAEIEgQKAggIEgUKAwgICBIDCgEIEgYKBAgIAQESBAoCCAgSAwoBCCgAB1ZFUlNJT04CAzEuNQEOZ2V0U3RyaW5nQnlLZXkBA2tleQkBC3ZhbHVlT3JFbHNlAgkAnQgCBQR0aGlzBQNrZXkCAAEPZ2V0Qm9vbGVhbkJ5S2V5AQNrZXkJAQt2YWx1ZU9yRWxzZQIJAJsIAgUEdGhpcwUDa2V5BwEPZ2V0SW50ZWdlckJ5S2V5AQNrZXkJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwUDa2V5AAAABWNocmlzCQEOZ2V0U3RyaW5nQnlLZXkBAgxjb25mX2FkbWluXzEADmRhcHBSdW5uaW5nS2V5AhRjb25mX2RhcHBfaXNfcnVubmluZwARbWFpbnRlbmFuY2VNU0dLZXkCFGNvbmZfbWFpbnRlbmFuY2VfbXNnABJ3aGl0ZWxpc3RlZG9ubHlLZXkCFWNvbmZfd2hpdGVsaXN0ZWRfb25seQALZGFwcFJ1bm5pbmcJAQt2YWx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View: original | compacted Prev: BR6iYctGAvENpofigfsQev1TPf7j3Hk4A3CfuXKirwim Next: 93JCaHiMe8d3iUnAkzqD2ThmDqzwA16MmdTgZY851yti Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let VERSION = "1. | |
4 | + | let VERSION = "1.5" | |
5 | 5 | ||
6 | 6 | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
7 | 7 | ||
8 | 8 | ||
9 | - | let unitTest = false | |
10 | - | ||
11 | - | let oracleFee = value(addressFromString(getStringByKey("conf_oracle_fee"))) | |
12 | - | ||
13 | - | let signDapp = value(addressFromString(getStringByKey("conf_signweb_dapp"))) | |
14 | - | ||
15 | - | let feeReceiver = getStringByKey("conf_fee_receiver") | |
16 | - | ||
17 | - | let userDapp = if (unitTest) | |
18 | - | then value(addressFromString("3Mt4RGMEyjSWYAocTPqd55wdHQQB3PU2UCm")) | |
19 | - | else value(addressFromString(getStringByKey("conf_users_dapp"))) | |
20 | - | ||
21 | - | let whitelistDapp = value(addressFromString(getStringByKey("conf_whitelist_dapp"))) | |
22 | - | ||
23 | - | let signAssetId = fromBase58String(getStringByKey("conf_accepted_asset_SIGN")) | |
24 | - | ||
25 | - | let usdnAssetId = fromBase58String(getStringByKey("conf_accepted_asset_USDN")) | |
26 | - | ||
27 | - | let usdtAssetId = fromBase58String(getStringByKey("conf_accepted_asset_USDT")) | |
28 | - | ||
29 | - | let wavesAssetId = base58'' | |
30 | - | ||
31 | - | let chris = getStringByKey("conf_admin_1") | |
32 | - | ||
33 | - | func getIntegerByKeyFromOracle (key) = valueOrErrorMessage(getInteger(oracleFee, key), "Integer undefine or 0 in oracle") | |
9 | + | func getBooleanByKey (key) = valueOrElse(getBoolean(this, key), false) | |
34 | 10 | ||
35 | 11 | ||
36 | 12 | func getIntegerByKey (key) = valueOrElse(getInteger(this, key), 0) | |
37 | 13 | ||
38 | 14 | ||
39 | - | ||
15 | + | let chris = getStringByKey("conf_admin_1") | |
40 | 16 | ||
17 | + | let dappRunningKey = "conf_dapp_is_running" | |
41 | 18 | ||
42 | - | ||
19 | + | let maintenanceMSGKey = "conf_maintenance_msg" | |
43 | 20 | ||
21 | + | let whitelistedonlyKey = "conf_whitelisted_only" | |
44 | 22 | ||
45 | - | let | |
23 | + | let dappRunning = valueOrElse(getBoolean(this, dappRunningKey), true) | |
46 | 24 | ||
47 | - | let | |
25 | + | let maintenanceMSG = valueOrElse(getString(this, maintenanceMSGKey), "") | |
48 | 26 | ||
49 | - | let | |
27 | + | let whitelistedonly = valueOrElse(getBoolean(this, whitelistedonlyKey), true) | |
50 | 28 | ||
51 | - | let | |
29 | + | let whitelistDapp = value(addressFromString(getStringByKey("conf_whitelist_dapp"))) | |
52 | 30 | ||
53 | - | let | |
31 | + | let userAllowed = "ALLOWED" | |
54 | 32 | ||
55 | - | let maintenanceMSG = valueOrElse(getString(userDapp, "conf_maintenance_msg"), "") | |
33 | + | let userRegistered = "REGISTERED" | |
34 | + | ||
35 | + | let userVerified = "VERIFIED" | |
56 | 36 | ||
57 | 37 | let userSuspended = "SUSPENDED" | |
58 | 38 | ||
59 | 39 | let userRemoved = "REMOVED" | |
60 | 40 | ||
41 | + | let userChangeRequired = "CHANGE_REQUIRED" | |
42 | + | ||
61 | 43 | let userUnregistered = "UNREGISTERED" | |
62 | 44 | ||
63 | - | let | |
45 | + | let userReset = "RESET" | |
64 | 46 | ||
65 | - | let currentCertificationPrice = getIntegerByKeyFromOracle(("certification_fee_" + toBase58String(signAssetId))) | |
66 | - | ||
67 | - | func getArtworkRoyalties (key) = valueOrElse(getInteger(this, key), 1000) | |
47 | + | func keyUserAddr (caller) = ("user_" + caller) | |
68 | 48 | ||
69 | 49 | ||
70 | - | func checkSignCertificate (signID,Owner,sha256Hash) = match getString(signDapp, ((("data_fc_" + signID) + "_") + Owner)) { | |
71 | - | case a: String => | |
72 | - | if (contains(a, sha256Hash)) | |
73 | - | then true | |
74 | - | else false | |
75 | - | case _ => | |
76 | - | false | |
77 | - | } | |
50 | + | func keyUserName (caller) = ("user_name_" + caller) | |
51 | + | ||
52 | + | ||
53 | + | func keyUserDesc (caller) = ("user_desc_" + caller) | |
54 | + | ||
55 | + | ||
56 | + | func keyUserSocial (caller) = ("user_social_" + caller) | |
57 | + | ||
58 | + | ||
59 | + | func keyUserThumb (caller) = ("user_thumb_" + caller) | |
60 | + | ||
61 | + | ||
62 | + | func keyUserStatus (caller) = ("user_status_" + caller) | |
63 | + | ||
64 | + | ||
65 | + | func keyUserRoyalties (caller) = ("user_royalties_" + caller) | |
66 | + | ||
67 | + | ||
68 | + | func keyUserDate (caller) = ("user_date_" + caller) | |
69 | + | ||
70 | + | ||
71 | + | func keyUserERC20 (caller) = ("user_ERC20_" + caller) | |
72 | + | ||
73 | + | ||
74 | + | func keyArtistAgentAddr (artistAddr) = ("artist_agent_" + artistAddr) | |
75 | + | ||
76 | + | ||
77 | + | func keyAgentArtistAddr (agentAddr,artistAddr) = ((("agent_" + agentAddr) + "_") + artistAddr) | |
78 | + | ||
79 | + | ||
80 | + | func keyPrimaryShare (artistAddr) = ("artist_agent_primary_" + artistAddr) | |
81 | + | ||
82 | + | ||
83 | + | func keySecondaryShare (artistAddr) = ("artist_agent_secondary_" + artistAddr) | |
84 | + | ||
85 | + | ||
86 | + | func checkWhitelist (key) = valueOrElse(getInteger(whitelistDapp, key), 0) | |
78 | 87 | ||
79 | 88 | ||
80 | 89 | func validateCID (cid) = if (contains(cid, "/")) | |
86 | 95 | else false | |
87 | 96 | ||
88 | 97 | ||
89 | - | func validateHash (hash) = (size(hash) == 64) | |
90 | - | ||
91 | - | ||
92 | - | func keyUserStatus (caller) = ("user_status_" + caller) | |
93 | - | ||
94 | - | ||
95 | - | func keyDate (caller,artId) = ((("art_date_" + artId) + "_") + caller) | |
96 | - | ||
97 | - | ||
98 | - | func keyName (caller,artId) = ((("art_name_" + artId) + "_") + caller) | |
99 | - | ||
100 | - | ||
101 | - | func keyDesc (caller,artId) = ((("art_desc_" + artId) + "_") + caller) | |
102 | - | ||
103 | - | ||
104 | - | func keyDisplayCid (caller,artId) = ((("art_display_cid_" + artId) + "_") + caller) | |
105 | - | ||
106 | - | ||
107 | - | func keyExportHash (caller,artId) = ((("art_export_hash_" + artId) + "_") + caller) | |
108 | - | ||
109 | - | ||
110 | - | func keyExportCid (caller,artId) = ((("art_export_cid_" + artId) + "_") + caller) | |
111 | - | ||
112 | - | ||
113 | - | func keyMaxMint (caller,artId) = ((("art_maxmint_" + artId) + "_") + caller) | |
114 | - | ||
115 | - | ||
116 | - | func keySignID (caller,artId) = ((("art_signid_" + artId) + "_") + caller) | |
117 | - | ||
118 | - | ||
119 | - | func keyIssued (caller,artId) = ((("art_issued_" + artId) + "_") + caller) | |
120 | - | ||
121 | - | ||
122 | - | func keyOnSale (caller,artId) = ((("art_onsale_" + artId) + "_") + caller) | |
123 | - | ||
124 | - | ||
125 | - | func keyLicenceHash (caller,artId) = ((("art_licence_hash_" + artId) + "_") + caller) | |
126 | - | ||
127 | - | ||
128 | - | func keyLicenceCid (caller,artId) = ((("art_licence_cid_" + artId) + "_") + caller) | |
129 | - | ||
130 | - | ||
131 | - | func keyTags (caller,artId) = ((("art_tags_" + artId) + "_") + caller) | |
132 | - | ||
133 | - | ||
134 | - | func keyType (caller,artId) = ((("art_type_" + artId) + "_") + caller) | |
135 | - | ||
136 | - | ||
137 | - | func keyNote (caller,artId) = ((("art_note_" + artId) + "_") + caller) | |
138 | - | ||
139 | - | ||
140 | - | func keyCrawler (caller,artId) = ((("art_crawler_cid_" + artId) + "_") + caller) | |
141 | - | ||
142 | - | ||
143 | - | func keyRoyalties (caller,artId) = ((("art_royalties_" + artId) + "_") + caller) | |
144 | - | ||
145 | - | ||
146 | - | func keyPrice (caller,artId) = ((("art_price_" + artId) + "_") + caller) | |
147 | - | ||
148 | - | ||
149 | - | func keyEndSale (caller,artId) = ((("art_endsale_" + artId) + "_") + caller) | |
150 | - | ||
151 | - | ||
152 | - | func keyAssetIdAccepted (caller,artId) = ((("art_assetAccepted_" + artId) + "_") + caller) | |
153 | - | ||
154 | - | ||
155 | - | func keyFlag (caller,artId) = ((("art_flag_" + artId) + "_") + caller) | |
156 | - | ||
157 | - | ||
158 | - | func keyArtistAgentAddr (artistAddr) = ("artist_agent_" + artistAddr) | |
159 | - | ||
160 | - | ||
161 | - | func keyPrimaryShare (artistAddr) = ("artist_agent_primary_" + artistAddr) | |
162 | - | ||
163 | - | ||
164 | - | func keyHashByTxidAddr (caller,txid) = ((("get_hashbytxidaddr_" + txid) + "_") + caller) | |
165 | - | ||
166 | - | ||
167 | - | func keyOwnerByHash (sha256Hash) = ("get_owner_by_hash_" + sha256Hash) | |
168 | - | ||
169 | - | ||
170 | - | func keyidBySignid (caller,signId) = ((("get_artidbysignid_" + signId) + "_") + caller) | |
171 | - | ||
172 | - | ||
173 | - | func keyTxidByHashOwner (sha256Hash,caller) = ("get_txid_by_hash_owner_" + toBase58String(sha256_16Kb(toBytes((sha256Hash + caller))))) | |
174 | - | ||
175 | - | ||
176 | - | func validateAllCID (cidDisplay,cidExport,cidLicence) = if (!(validateCID(cidDisplay))) | |
177 | - | then throw("Wrong Display CID") | |
178 | - | else if (!(validateCID(cidExport))) | |
179 | - | then throw("Wrong Export CID") | |
180 | - | else if (if ((cidLicence != "")) | |
181 | - | then !(validateCID(cidLicence)) | |
182 | - | else false) | |
183 | - | then throw("Wrong Licence CID") | |
184 | - | else true | |
185 | - | ||
186 | - | ||
187 | - | func validateAllHash (sha256Export,sha256Licence) = if (!(validateHash(sha256Export))) | |
188 | - | then throw("Export Hash 64 char. max") | |
189 | - | else if (!(validateHash(sha256Licence))) | |
190 | - | then throw("Licence Hash 64 char. max") | |
98 | + | func validUserData (caller,name,description,thumb,isAnUpdate) = { | |
99 | + | let validCID = if ((size(thumb) != 0)) | |
100 | + | then validateCID(thumb) | |
191 | 101 | else true | |
192 | - | ||
193 | - | ||
194 | - | func validateString (str,max) = if ((size(str) == 0)) | |
195 | - | then throw("Field cannot be is empty") | |
196 | - | else if ((size(str) > max)) | |
197 | - | then throw((str + " is too long")) | |
198 | - | else true | |
199 | - | ||
200 | - | ||
201 | - | func validateUser (caller) = { | |
202 | - | let userStatus = valueOrElse(getString(userDapp, keyUserStatus(caller)), userUnregistered) | |
203 | - | if (if ((userStatus == userUnregistered)) | |
204 | - | then true | |
205 | - | else (userStatus == userAllowed)) | |
206 | - | then "Register this account first with \"Account\" tab" | |
207 | - | else if ((userStatus == userSuspended)) | |
208 | - | then "Account suspended" | |
209 | - | else if ((userStatus == userRemoved)) | |
210 | - | then "Account removed" | |
211 | - | else "" | |
102 | + | if (!(validCID)) | |
103 | + | then throw("CID don't match requirement!") | |
104 | + | else if (if ((name == "")) | |
105 | + | then true | |
106 | + | else (description == "")) | |
107 | + | then throw("Name and description cannot be empty") | |
108 | + | else if ((size(description) > 600)) | |
109 | + | then throw("600 Char. max description") | |
110 | + | else if ((size(name) > 45)) | |
111 | + | then throw("45 Char. max name") | |
112 | + | else { | |
113 | + | let status = getStringByKey(keyUserStatus(caller)) | |
114 | + | if (if ((status == userSuspended)) | |
115 | + | then true | |
116 | + | else (status == userRemoved)) | |
117 | + | then throw("Account suspended/ removed.") | |
118 | + | else if (if (!(isAnUpdate)) | |
119 | + | then (status == userRegistered) | |
120 | + | else false) | |
121 | + | then throw("Already registered") | |
122 | + | else if (if (if (!(isAnUpdate)) | |
123 | + | then (status == "") | |
124 | + | else false) | |
125 | + | then whitelistedonly | |
126 | + | else false) | |
127 | + | then throw("Can't register, get approved first.") | |
128 | + | else if (if (if (isAnUpdate) | |
129 | + | then (status == "") | |
130 | + | else false) | |
131 | + | then true | |
132 | + | else if (isAnUpdate) | |
133 | + | then (status == userAllowed) | |
134 | + | else false) | |
135 | + | then throw("Register first") | |
136 | + | else true | |
137 | + | } | |
212 | 138 | } | |
213 | 139 | ||
214 | 140 | ||
215 | - | func setLIcence (cidLicence,sha256Licence) = { | |
216 | - | let cid = if ((size(cidLicence) == 0)) | |
217 | - | then defaultLicence | |
218 | - | else cidLicence | |
219 | - | let hash = if ((size(sha256Licence) == 0)) | |
220 | - | then defaultHashLicence | |
221 | - | else sha256Licence | |
222 | - | $Tuple2(cid, hash) | |
141 | + | func validateNewStatus (status,address,currentStatus) = { | |
142 | + | let allStatus = [userVerified, userRegistered, userSuspended, userRemoved, userAllowed, userChangeRequired] | |
143 | + | let statusToSet = if (containsElement(allStatus, status)) | |
144 | + | then status | |
145 | + | else if (if ((status == userReset)) | |
146 | + | then (currentStatus == userAllowed) | |
147 | + | else false) | |
148 | + | then "" | |
149 | + | else throw("Unknown status") | |
150 | + | let userIsRegistered = getIntegerByKey(keyUserDate(address)) | |
151 | + | if (if ((userIsRegistered == 0)) | |
152 | + | then (statusToSet != userAllowed) | |
153 | + | else false) | |
154 | + | then throw("You cant set this status, user is not registered.") | |
155 | + | else if (if ((currentStatus == userAllowed)) | |
156 | + | then (statusToSet == userAllowed) | |
157 | + | else false) | |
158 | + | then throw("User already allowed") | |
159 | + | else if (if ((currentStatus == userRegistered)) | |
160 | + | then (statusToSet == userAllowed) | |
161 | + | else false) | |
162 | + | then throw("User already allowed & registered") | |
163 | + | else if (if ((currentStatus == userVerified)) | |
164 | + | then (statusToSet == userAllowed) | |
165 | + | else false) | |
166 | + | then throw("User already allowed & verified") | |
167 | + | else statusToSet | |
223 | 168 | } | |
224 | 169 | ||
225 | 170 | ||
226 | - | func validateArtworkData (caller,cidDisplay,cidExport,licenceCID,sha256Export,licenceHash,name,description,tags,royalties) = { | |
227 | - | let checkUser = validateUser(caller) | |
228 | - | if ((checkUser != "")) | |
229 | - | then throw(checkUser) | |
230 | - | else if ((size(cidDisplay) == 0)) | |
231 | - | then throw("Display CID cannot be empty") | |
232 | - | else if (!(validateAllCID(cidDisplay, cidExport, licenceCID))) | |
233 | - | then throw("Problem with CID") | |
234 | - | else if (!(validateAllHash(sha256Export, licenceHash))) | |
235 | - | then throw("Problem with Hashes") | |
236 | - | else if (!(validateString(name, 100))) | |
237 | - | then throw("100 Char. max name") | |
238 | - | else if (!(validateString(description, 1000))) | |
239 | - | then throw("1000 Char. max description") | |
240 | - | else if (if ((0 > royalties)) | |
241 | - | then true | |
242 | - | else (royalties > 1000)) | |
243 | - | then throw("Royalties cannot be less than 0% or higher than 10%") | |
244 | - | else if ((size(split(tags, ",")) > 5)) | |
245 | - | then throw("5 tags max.") | |
246 | - | else "" | |
247 | - | } | |
248 | - | ||
249 | - | ||
250 | - | func isPayment (i) = if ((size(i.payments) == 0)) | |
251 | - | then throw("No payment attached") | |
252 | - | else { | |
253 | - | let payment = value(i.payments[0]) | |
254 | - | let amount = value(payment.amount) | |
255 | - | $Tuple2(payment, amount) | |
256 | - | } | |
257 | - | ||
258 | - | ||
259 | - | func validatePayment (i) = { | |
260 | - | let $t089078943 = isPayment(i) | |
261 | - | let payment = $t089078943._1 | |
262 | - | let amount = $t089078943._2 | |
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 as transaction fee") | |
268 | - | if ((amount != currentCertificationPrice)) | |
269 | - | then throw(("Payment amount should be " + toString(currentCertificationPrice))) | |
270 | - | else $Tuple2(amount, assetId) | |
271 | - | } | |
272 | - | ||
273 | - | ||
274 | - | func isArtMinted (addrToUse,artId) = match getInteger(this, keyIssued(addrToUse, artId)) { | |
275 | - | case b: Int => | |
276 | - | if ((b != 0)) | |
277 | - | then true | |
278 | - | else false | |
279 | - | case _ => | |
280 | - | false | |
281 | - | } | |
282 | - | ||
283 | - | ||
284 | - | func validatePriceAssetId (i,priceAssetId,artworkPrice) = { | |
285 | - | let $t095319567 = isPayment(i) | |
286 | - | let payment = $t095319567._1 | |
287 | - | let amount = $t095319567._2 | |
288 | - | let assetId = if (!(isDefined(payment.assetId))) | |
289 | - | then unit | |
290 | - | else if (if ((size(priceAssetId) > 0)) | |
291 | - | then (toBase58String(value(payment.assetId)) == priceAssetId) | |
292 | - | else false) | |
293 | - | then payment.assetId | |
294 | - | else throw("Wrong asset id") | |
295 | - | if (if ((assetId == unit)) | |
296 | - | then (priceAssetId != "") | |
297 | - | else false) | |
298 | - | then throw("Wrong asset id") | |
299 | - | else if ((artworkPrice != amount)) | |
300 | - | then throw("Payment don't match") | |
301 | - | else $Tuple2(amount, assetId) | |
302 | - | } | |
303 | - | ||
304 | - | ||
305 | - | func acceptedAssetIds (assetId) = if (if (if (if (if ((assetId != toBase58String(signAssetId))) | |
306 | - | then (assetId != toBase58String(wavesAssetId)) | |
307 | - | else false) | |
308 | - | then (assetId != "WAVES") | |
309 | - | else false) | |
310 | - | then (assetId != toBase58String(usdnAssetId)) | |
311 | - | else false) | |
312 | - | then (assetId != toBase58String(usdtAssetId)) | |
313 | - | else false) | |
314 | - | then throw("Only SIGN, USDN,USDT or WAVES accepted") | |
315 | - | else true | |
316 | - | ||
317 | - | ||
318 | - | func validateMinSell (assetId,price) = { | |
319 | - | let minSellWaves = if (unitTest) | |
320 | - | then 10 | |
321 | - | else getIntegerByKeyFromOracle("waves_min_sell") | |
322 | - | let minSellUsdn = 1000000 | |
323 | - | let minSellSign = if (unitTest) | |
324 | - | then 1 | |
325 | - | else (currentCertificationPrice * 2) | |
326 | - | if (if (if (if (if (if ((assetId == toBase58String(usdnAssetId))) | |
327 | - | then (minSellUsdn > price) | |
328 | - | else false) | |
329 | - | then (price != 0) | |
330 | - | else false) | |
331 | - | then true | |
332 | - | else if (if ((assetId == toBase58String(usdtAssetId))) | |
333 | - | then (minSellUsdn > price) | |
334 | - | else false) | |
335 | - | then (price != 0) | |
336 | - | else false) | |
337 | - | then true | |
338 | - | else if (if ((assetId == toBase58String(signAssetId))) | |
339 | - | then (minSellSign > price) | |
340 | - | else false) | |
341 | - | then (price != 0) | |
342 | - | else false) | |
343 | - | then true | |
344 | - | else if (if (if ((assetId == toBase58String(wavesAssetId))) | |
345 | - | then true | |
346 | - | else (assetId == "WAVES")) | |
347 | - | then (minSellWaves > price) | |
348 | - | else false) | |
349 | - | then (price != 0) | |
350 | - | else false) | |
351 | - | then throw("Wrong minimum sell price") | |
352 | - | else true | |
353 | - | } | |
354 | - | ||
355 | - | ||
356 | - | func getBidAssetId (assetId) = if ((assetId == "WAVES")) | |
357 | - | then unit | |
358 | - | else fromBase58String(assetId) | |
359 | - | ||
360 | - | ||
361 | - | func getPriceAssetIdFromBid (bidDataKey) = { | |
362 | - | let bidData = getStringByKey((bidDataKey + "_OPEN")) | |
363 | - | if ((bidData == "")) | |
364 | - | then throw("Bid not found") | |
365 | - | else { | |
366 | - | let bidDataArr = split(bidData, "_") | |
367 | - | let bidAmount = parseIntValue(bidDataArr[1]) | |
368 | - | let bidAssetId = getBidAssetId(bidDataArr[0]) | |
369 | - | if ((0 >= bidAmount)) | |
370 | - | then throw("Wrong amount") | |
371 | - | else $Tuple2(bidAmount, bidAssetId) | |
372 | - | } | |
373 | - | } | |
374 | - | ||
375 | - | ||
376 | - | func idCallerDateSponsored (i,pubKey) = if (!(dappRunning)) | |
377 | - | then throw(maintenanceMSG) | |
378 | - | else { | |
379 | - | let isSponsored = valueOrElse(checkWhitelist((toString(addressFromPublicKey(fromBase58String(pubKey))) + "_free_txs")), 0) | |
380 | - | let caller = if (if (if ((toBase58String(i.caller.bytes) == toString(this))) | |
381 | - | then (size(i.payments) == 0) | |
382 | - | else false) | |
383 | - | then (isSponsored > 0) | |
384 | - | else false) | |
385 | - | then toString(addressFromPublicKey(fromBase58String(pubKey))) | |
386 | - | else toBase58String(i.caller.bytes) | |
387 | - | let get_sponsored_waves = if ((pubKey != "")) | |
388 | - | then invoke(whitelistDapp, "useFreeTx", [toString(addressFromPublicKey(fromBase58String(pubKey)))], nil) | |
389 | - | else unit | |
390 | - | if ((get_sponsored_waves == get_sponsored_waves)) | |
391 | - | then $Tuple4(toBase58String(i.transactionId), caller, lastBlock.timestamp, (isSponsored > 0)) | |
392 | - | else throw("Strict value is not equal to itself.") | |
393 | - | } | |
394 | - | ||
395 | - | ||
396 | - | func idCallerDate (i) = if (!(dappRunning)) | |
397 | - | then throw(maintenanceMSG) | |
398 | - | else $Tuple3(toBase58String(i.transactionId), toBase58String(i.caller.bytes), lastBlock.timestamp) | |
399 | - | ||
400 | - | ||
401 | - | func buyMint (i,artId,issuer,bidId,bidOwner) = { | |
402 | - | let $t01291912978 = idCallerDate(i) | |
403 | - | let id = $t01291912978._1 | |
404 | - | let caller = $t01291912978._2 | |
405 | - | let date = $t01291912978._3 | |
406 | - | let isBid = if (if (if ((caller == issuer)) | |
407 | - | then (bidOwner != "") | |
408 | - | else false) | |
409 | - | then (bidId != "") | |
410 | - | else false) | |
411 | - | then true | |
412 | - | else false | |
413 | - | let blockEnd = getIntegerByKey(keyEndSale(caller, artId)) | |
414 | - | if (if (if ((blockEnd != 0)) | |
415 | - | then (height >= blockEnd) | |
416 | - | else false) | |
417 | - | then !(isBid) | |
418 | - | else false) | |
419 | - | then throw("Sale ended.") | |
420 | - | else { | |
421 | - | let callerIsIssuer = (caller == issuer) | |
422 | - | let totalNFT = getIntegerByKey("total_nft_issued") | |
423 | - | let signID = getStringByKey(keySignID(issuer, artId)) | |
424 | - | let artworkName = getStringByKey(keyName(issuer, artId)) | |
425 | - | if ((artworkName == "")) | |
426 | - | then throw("Art doesn't exist") | |
427 | - | else { | |
428 | - | let isOnSale = getBooleanByKey(keyOnSale(issuer, artId)) | |
429 | - | let amountSold = getIntegerByKey(keyIssued(issuer, artId)) | |
430 | - | let artworkPrice = if (callerIsIssuer) | |
431 | - | then (currentCertificationPrice * 2) | |
432 | - | else getIntegerByKey(keyPrice(issuer, artId)) | |
433 | - | let priceAssetId = if (callerIsIssuer) | |
434 | - | then toBase58String(signAssetId) | |
435 | - | else getStringByKey(keyAssetIdAccepted(issuer, artId)) | |
436 | - | let maxCanSell = getIntegerByKey(keyMaxMint(issuer, artId)) | |
437 | - | if (if (if (!(isBid)) | |
438 | - | then !(callerIsIssuer) | |
439 | - | else false) | |
440 | - | then if (if ((0 >= artworkPrice)) | |
441 | - | then true | |
442 | - | else !(isOnSale)) | |
443 | - | then true | |
444 | - | else (0 >= maxCanSell) | |
445 | - | else false) | |
446 | - | then throw("Art not for sale") | |
447 | - | else if (if (if (!(isBid)) | |
448 | - | then callerIsIssuer | |
449 | - | else false) | |
450 | - | then (0 >= maxCanSell) | |
451 | - | else false) | |
452 | - | then throw("Max issuable not set") | |
453 | - | else { | |
454 | - | let checkUser = validateUser(issuer) | |
455 | - | if (if (isBid) | |
456 | - | then (checkUser != "") | |
457 | - | else false) | |
458 | - | then throw(checkUser) | |
459 | - | else { | |
460 | - | let bidDataKey = ((((((("bid_" + artId) + "_") + issuer) + "_") + bidOwner) + "_") + bidId) | |
461 | - | let $t01468114848 = if (isBid) | |
462 | - | then getPriceAssetIdFromBid(bidDataKey) | |
463 | - | else validatePriceAssetId(i, priceAssetId, artworkPrice) | |
464 | - | let amount = $t01468114848._1 | |
465 | - | let assetId = $t01468114848._2 | |
466 | - | let agent = valueOrElse(getString(userDapp, keyArtistAgentAddr(issuer)), feeReceiver) | |
467 | - | let agentShare = valueOrElse(getInteger(userDapp, keyPrimaryShare(issuer)), 0) | |
468 | - | let isWhitelisted = checkWhitelist(issuer) | |
469 | - | let cut = if ((isWhitelisted > height)) | |
470 | - | then 0 | |
471 | - | else if ((assetId == signAssetId)) | |
472 | - | then signCut | |
473 | - | else usdnWaveCut | |
474 | - | let amountForSign = fraction(amount, cut, 100) | |
475 | - | let amountForAgent = if (if (if ((agent != feeReceiver)) | |
476 | - | then (agentShare > 0) | |
477 | - | else false) | |
478 | - | then (height > isWhitelisted) | |
479 | - | else false) | |
480 | - | then fraction(amount, agentShare, 100) | |
481 | - | else 0 | |
482 | - | let amountForCreator = (amount - amountForSign) | |
483 | - | if ((amountSold == maxCanSell)) | |
484 | - | then throw("Art sold out") | |
485 | - | else { | |
486 | - | let newAmountSold = (amountSold + 1) | |
487 | - | let issueMeta = ((((((((((("Creator: " + issuer) + ", | |
488 | - | ArtID: ") + artId) + ", | |
489 | - | SignID: ") + signID) + ", | |
490 | - | Artwork name: ") + artworkName) + ", | |
491 | - | Issue: ") + toString(newAmountSold)) + "/") + toString(maxCanSell)) | |
492 | - | let issueNFT = Issue(("SA_" + toString((totalNFT + 1))), issueMeta, 1, 0, false) | |
493 | - | let idNFT = calculateAssetId(issueNFT) | |
494 | - | let sellStatus = if (if ((newAmountSold == maxCanSell)) | |
495 | - | then true | |
496 | - | else !(isOnSale)) | |
497 | - | then false | |
498 | - | else true | |
499 | - | let receiveNFT = if (if (if ((caller == issuer)) | |
500 | - | then (bidOwner != "") | |
501 | - | else false) | |
502 | - | then (bidId != "") | |
503 | - | else false) | |
504 | - | then addressFromStringValue(bidOwner) | |
505 | - | else i.caller | |
506 | - | let assetIdBid = if (!(isDefined(assetId))) | |
507 | - | then "WAVES" | |
508 | - | else toBase58String(value(assetId)) | |
509 | - | let bidData = getStringByKey((bidDataKey + "_OPEN")) | |
510 | - | let bidDelOld = DeleteEntry((bidDataKey + "_OPEN")) | |
511 | - | let bidUpdate = StringEntry((bidDataKey + "_CLOSED"), ((bidData + "_") + toString(date))) | |
512 | - | let soldKey = ((((((("art_sold_" + toString(newAmountSold)) + "_of_") + toString(maxCanSell)) + "_") + artId) + "_") + issuer) | |
513 | - | let soldValue = if (!(isBid)) | |
514 | - | then ((((((((((caller + "_") + toString(date)) + "_") + id) + "_") + toString(artworkPrice)) + "_") + priceAssetId) + "_") + toBase58String(idNFT)) | |
515 | - | else ((((((((((toString(receiveNFT) + "_") + toString(date)) + "_") + id) + "_") + toString(amount)) + "_") + assetIdBid) + "_") + toBase58String(idNFT)) | |
516 | - | let soldData = StringEntry(soldKey, soldValue) | |
517 | - | let commissions = if ((amountForAgent != 0)) | |
518 | - | then [ScriptTransfer(Address(fromBase58String(feeReceiver)), (amountForSign - amountForAgent), assetId), ScriptTransfer(Address(fromBase58String(agent)), amountForAgent, assetId)] | |
519 | - | else [ScriptTransfer(Address(fromBase58String(feeReceiver)), amountForSign, assetId)] | |
520 | - | let buyRes = ([IntegerEntry(keyIssued(issuer, artId), newAmountSold), StringEntry(("nft_" + toBase58String(idNFT)), soldKey), IntegerEntry("total_nft_issued", (totalNFT + 1)), IntegerEntry(keyEndSale(issuer, artId), 0), BooleanEntry(keyOnSale(issuer, artId), sellStatus), issueNFT, ScriptTransfer(Address(fromBase58String(issuer)), amountForCreator, assetId), ScriptTransfer(receiveNFT, 1, idNFT)] ++ commissions) | |
521 | - | if (isBid) | |
522 | - | then [soldData, bidUpdate, bidDelOld] :: buyRes | |
523 | - | else soldData :: buyRes | |
524 | - | } | |
525 | - | } | |
526 | - | } | |
527 | - | } | |
528 | - | } | |
529 | - | } | |
171 | + | func makeJSON (name,thumb,date) = (((((("{\"user_name\": \"" + name) + "\", \"user_thumb\":\"") + thumb) + "\",\"user_date\":\"") + date) + "\"}") | |
530 | 172 | ||
531 | 173 | ||
532 | 174 | func asString (bv) = match bv { | |
537 | 179 | } | |
538 | 180 | ||
539 | 181 | ||
182 | + | func getCaller (i,pubKey) = { | |
183 | + | let isSponsored = valueOrElse(checkWhitelist((toString(addressFromPublicKey(fromBase58String(pubKey))) + "_free_txs")), 0) | |
184 | + | let caller = if (if (if ((toBase58String(i.caller.bytes) == toString(this))) | |
185 | + | then (size(i.payments) == 0) | |
186 | + | else false) | |
187 | + | then (isSponsored > 0) | |
188 | + | else false) | |
189 | + | then toString(addressFromPublicKey(fromBase58String(pubKey))) | |
190 | + | else toBase58String(i.caller.bytes) | |
191 | + | let get_sponsored_waves = if ((pubKey != "")) | |
192 | + | then invoke(whitelistDapp, "useFreeTx", [toString(addressFromPublicKey(fromBase58String(pubKey)))], nil) | |
193 | + | else unit | |
194 | + | if ((get_sponsored_waves == get_sponsored_waves)) | |
195 | + | then $Tuple2(caller, (isSponsored > 0)) | |
196 | + | else throw("Strict value is not equal to itself.") | |
197 | + | } | |
198 | + | ||
199 | + | ||
540 | 200 | @Callable(invoke) | |
541 | 201 | func setConf (key,val) = { | |
542 | 202 | let caller = toString(invoke.caller) | |
543 | 203 | if (containsElement([chris, toString(this)], caller)) | |
544 | - | then if (contains(key, "conf_")) | |
545 | - | then [StringEntry(key, val)] | |
546 | - | else throw("Entries starting with conf_ only") | |
204 | + | then [StringEntry(key, val)] | |
547 | 205 | else throw("You are not allowed to change this") | |
548 | 206 | } | |
549 | 207 | ||
550 | 208 | ||
551 | 209 | ||
552 | - | @Callable(i) | |
553 | - | func addArtwork (sha256Hash,signID,name,description,tags,type,cidDisplay,sha256Export,cidExport,sha256Licence,cidLicence,crawler,royalties,pubKey) = { | |
554 | - | let $t01888118954 = idCallerDateSponsored(i, pubKey) | |
555 | - | let artId = $t01888118954._1 | |
556 | - | let caller = $t01888118954._2 | |
557 | - | let date = $t01888118954._3 | |
558 | - | let isSponsored = $t01888118954._4 | |
559 | - | if (!(validateHash(sha256Hash))) | |
560 | - | then throw("Hash should be 64 characters maximum") | |
561 | - | else { | |
562 | - | let $t01905519124 = setLIcence(cidLicence, sha256Licence) | |
563 | - | let licenceCID = $t01905519124._1 | |
564 | - | let licenceHash = $t01905519124._2 | |
565 | - | let validateArtwork = validateArtworkData(caller, cidDisplay, cidExport, licenceCID, sha256Export, licenceHash, name, description, tags, royalties) | |
566 | - | if ((validateArtwork != "")) | |
567 | - | then throw("Something went wrong!") | |
568 | - | else { | |
569 | - | let whitelisted_drop = (checkWhitelist((caller + "_free_drops")) > 0) | |
570 | - | let $t01942319507 = if (whitelisted_drop) | |
571 | - | then $Tuple2(0, signID) | |
572 | - | else validatePayment(i) | |
573 | - | let amount = $t01942319507._1 | |
574 | - | let assetId = $t01942319507._2 | |
575 | - | if (!(isDefined(amount))) | |
576 | - | then throw("Something went wrong") | |
577 | - | else { | |
578 | - | let entryExist = getStringByKey(keyTxidByHashOwner(sha256Hash, caller)) | |
579 | - | if ((entryExist != "")) | |
580 | - | then throw("You already added it") | |
581 | - | else { | |
582 | - | let hashExist = getStringByKey(keyOwnerByHash(sha256Hash)) | |
583 | - | if ((hashExist != "")) | |
584 | - | then throw("Hash already registered") | |
585 | - | else { | |
586 | - | let isSignCertified = checkSignCertificate(signID, caller, sha256Hash) | |
587 | - | if (!(isSignCertified)) | |
588 | - | then throw("Sign Certificate not found for this address.") | |
589 | - | else { | |
590 | - | let decrease_whitelist_drop = if (whitelisted_drop) | |
591 | - | then invoke(whitelistDapp, "useFreeDrop", [caller], nil) | |
592 | - | else unit | |
593 | - | if ((decrease_whitelist_drop == decrease_whitelist_drop)) | |
594 | - | then { | |
595 | - | let txToCaller = if (isSponsored) | |
596 | - | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
597 | - | else nil | |
598 | - | ([StringEntry(keyOwnerByHash(sha256Hash), caller), StringEntry(keyTxidByHashOwner(sha256Hash, caller), artId), IntegerEntry(keyDate(caller, artId), date), StringEntry(keyName(caller, artId), name), StringEntry(keyDesc(caller, artId), description), StringEntry(keyDisplayCid(caller, artId), cidDisplay), StringEntry(keyExportCid(caller, artId), cidExport), StringEntry(keyExportHash(caller, artId), sha256Export), StringEntry(keyLicenceHash(caller, artId), licenceHash), StringEntry(keyLicenceCid(caller, artId), licenceCID), StringEntry(keyType(caller, artId), type), StringEntry(keyTags(caller, artId), tags), IntegerEntry(keyMaxMint(caller, artId), 0), StringEntry(keySignID(caller, artId), signID), IntegerEntry(keyIssued(caller, artId), 0), BooleanEntry(keyOnSale(caller, artId), false), StringEntry(keyidBySignid(caller, signID), artId), StringEntry(keyHashByTxidAddr(caller, artId), sha256Hash), StringEntry(keyCrawler(caller, artId), crawler), IntegerEntry(keyRoyalties(caller, artId), royalties), ScriptTransfer(Address(fromBase58String(feeReceiver)), amount, signAssetId)] ++ txToCaller) | |
599 | - | } | |
600 | - | else throw("Strict value is not equal to itself.") | |
601 | - | } | |
602 | - | } | |
603 | - | } | |
604 | - | } | |
605 | - | } | |
606 | - | } | |
210 | + | @Callable(invoke) | |
211 | + | func appRunning (isLive,message) = { | |
212 | + | let caller = toString(invoke.caller) | |
213 | + | if (containsElement([chris, toString(this)], caller)) | |
214 | + | then [BooleanEntry(dappRunningKey, isLive), StringEntry(maintenanceMSGKey, message)] | |
215 | + | else throw("You are not allowed to change this") | |
607 | 216 | } | |
608 | 217 | ||
609 | 218 | ||
610 | 219 | ||
611 | - | @Callable(i) | |
612 | - | func updateArtwork (txid,name,description,tags,type,cidDisplay,sha256Export,cidExport,sha256Licence,cidLicence,crawler,royalties,pubKey) = if (!(dappRunning)) | |
220 | + | @Callable(invoke) | |
221 | + | func registrationMode (WLonly) = { | |
222 | + | let caller = toString(invoke.caller) | |
223 | + | if (containsElement([chris, toString(this)], caller)) | |
224 | + | then [BooleanEntry(whitelistedonlyKey, WLonly)] | |
225 | + | else throw("You are not allowed to change this") | |
226 | + | } | |
227 | + | ||
228 | + | ||
229 | + | ||
230 | + | @Callable(invoke) | |
231 | + | func registerUser (name,description,thumb,social,royalties,pubKey) = if (!(dappRunning)) | |
613 | 232 | then throw(maintenanceMSG) | |
614 | 233 | else { | |
615 | - | let $t02254122611 = idCallerDateSponsored(i, pubKey) | |
616 | - | let id = $t02254122611._1 | |
617 | - | let caller = $t02254122611._2 | |
618 | - | let date = $t02254122611._3 | |
619 | - | let isSponsored = $t02254122611._4 | |
620 | - | let $t02262122690 = setLIcence(cidLicence, sha256Licence) | |
621 | - | let licenceCID = $t02262122690._1 | |
622 | - | let licenceHash = $t02262122690._2 | |
623 | - | let validateArtwork = validateArtworkData(caller, cidDisplay, cidExport, licenceCID, sha256Export, licenceHash, name, description, tags, royalties) | |
624 | - | if ((validateArtwork != "")) | |
625 | - | then throw("Something went wrong!") | |
234 | + | let $t072777329 = getCaller(invoke, pubKey) | |
235 | + | let caller = $t072777329._1 | |
236 | + | let isSponsored = $t072777329._2 | |
237 | + | let id = toBase58String(invoke.transactionId) | |
238 | + | let timestamp = lastBlock.timestamp | |
239 | + | if (!(validUserData(caller, name, description, thumb, false))) | |
240 | + | then throw("Something went wrong") | |
626 | 241 | else { | |
627 | - | let entryExist = getStringByKey(keyName(caller, txid)) | |
628 | - | if ((entryExist == "")) | |
629 | - | then throw("Entry not found") | |
242 | + | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(thumb)), toString(timestamp)) | |
243 | + | if (if ((0 > royalties)) | |
244 | + | then true | |
245 | + | else (royalties > 1000)) | |
246 | + | then throw("Royalties cannot be less than 0% or higher than 10%") | |
630 | 247 | else { | |
631 | - | let flag = getStringByKey(keyFlag(caller, txid)) | |
632 | - | if ((flag == "ILLEGAL")) | |
633 | - | then throw("Cannot update ILLEGAL artwork") | |
634 | - | else if (!(isArtMinted(caller, txid))) | |
635 | - | then { | |
636 | - | let txToCaller = if (isSponsored) | |
637 | - | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
638 | - | else nil | |
639 | - | ([StringEntry(keyName(caller, txid), name), StringEntry(keyDesc(caller, txid), description), StringEntry(keyDisplayCid(caller, txid), cidDisplay), StringEntry(keyExportCid(caller, txid), cidExport), StringEntry(keyExportHash(caller, txid), sha256Export), StringEntry(keyLicenceCid(caller, txid), licenceCID), StringEntry(keyLicenceHash(caller, txid), licenceHash), StringEntry(keyTags(caller, txid), tags), StringEntry(keyType(caller, txid), type), StringEntry(keyCrawler(caller, txid), crawler), IntegerEntry(keyRoyalties(caller, txid), royalties)] ++ txToCaller) | |
640 | - | } | |
641 | - | else throw("Already minted") | |
248 | + | let txToCaller = if (isSponsored) | |
249 | + | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
250 | + | else nil | |
251 | + | ([IntegerEntry(keyUserDate(caller), timestamp), StringEntry(keyUserAddr(caller), ((id + "_") + toString(timestamp))), StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb), StringEntry(keyUserStatus(caller), userRegistered), IntegerEntry(keyUserRoyalties(caller), royalties), DeleteEntry(("ALLOWED_" + caller)), StringEntry(((userRegistered + "_") + caller), json)] ++ txToCaller) | |
642 | 252 | } | |
643 | 253 | } | |
644 | 254 | } | |
645 | 255 | ||
646 | 256 | ||
647 | 257 | ||
648 | - | @Callable(i) | |
649 | - | func flagArtwork (artId,addr,flag,note) = { | |
650 | - | let $t02431724351 = idCallerDate(i) | |
651 | - | let id = $t02431724351._1 | |
652 | - | let caller = $t02431724351._2 | |
258 | + | @Callable(invoke) | |
259 | + | func updateUser (name,description,thumb,social,royalties,pubKey) = if (!(dappRunning)) | |
260 | + | then throw(maintenanceMSG) | |
261 | + | else { | |
262 | + | let $t087728876 = getCaller(invoke, pubKey) | |
263 | + | let caller = $t087728876._1 | |
264 | + | let isSponsored = $t087728876._2 | |
265 | + | let status = getStringByKey(keyUserStatus(caller)) | |
266 | + | if (!(validUserData(caller, name, description, thumb, true))) | |
267 | + | then throw("Something went wrong") | |
268 | + | else { | |
269 | + | let date = getIntegerByKey(keyUserDate(caller)) | |
270 | + | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(thumb)), toString(date)) | |
271 | + | if (if ((0 > royalties)) | |
272 | + | then true | |
273 | + | else (royalties > 1000)) | |
274 | + | then throw("Royalties cannot be less than 0% or higher than 10%") | |
275 | + | else { | |
276 | + | let txToCaller = if (isSponsored) | |
277 | + | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
278 | + | else nil | |
279 | + | ([StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb), IntegerEntry(keyUserRoyalties(caller), royalties), StringEntry(((status + "_") + caller), json)] ++ txToCaller) | |
280 | + | } | |
281 | + | } | |
282 | + | } | |
283 | + | ||
284 | + | ||
285 | + | ||
286 | + | @Callable(invoke) | |
287 | + | func setERC20User (erc20,pubKey) = if (!(dappRunning)) | |
288 | + | then throw(maintenanceMSG) | |
289 | + | else { | |
290 | + | let $t01006310166 = getCaller(invoke, pubKey) | |
291 | + | let caller = $t01006310166._1 | |
292 | + | let isSponsored = $t01006310166._2 | |
293 | + | let status = getStringByKey(keyUserStatus(caller)) | |
294 | + | if (if ((status != userRegistered)) | |
295 | + | then (status != userVerified) | |
296 | + | else false) | |
297 | + | then throw("Not allowed to set ERC20 address") | |
298 | + | else { | |
299 | + | let firstTwo = take(erc20, 2) | |
300 | + | if (if ((firstTwo != "0x")) | |
301 | + | then true | |
302 | + | else (size(erc20) != 42)) | |
303 | + | then throw("This is not an erc20 address") | |
304 | + | else { | |
305 | + | let txToCaller = if (isSponsored) | |
306 | + | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
307 | + | else nil | |
308 | + | ([StringEntry(keyUserERC20(caller), erc20)] ++ txToCaller) | |
309 | + | } | |
310 | + | } | |
311 | + | } | |
312 | + | ||
313 | + | ||
314 | + | ||
315 | + | @Callable(invoke) | |
316 | + | func changeUserStatus (address,status,note) = { | |
317 | + | let caller = toString(invoke.caller) | |
318 | + | let currentStatus = getStringByKey(keyUserStatus(address)) | |
319 | + | let statusToSet = validateNewStatus(status, address, currentStatus) | |
320 | + | let name = toBase64String(toBytes(getStringByKey(keyUserName(address)))) | |
321 | + | let thumb = toBase64String(toBytes(getStringByKey(keyUserThumb(address)))) | |
322 | + | let date = getIntegerByKey(keyUserDate(address)) | |
323 | + | let json = makeJSON(name, thumb, toString(date)) | |
653 | 324 | if (containsElement([chris, toString(this)], caller)) | |
654 | - | then if (containsElement(["CONSENT", "", "CHANGE_REQUIRED", "FLAGGED", "ILLEGAL"], flag)) | |
655 | - | then [StringEntry(keyFlag(addr, artId), flag), StringEntry(keyNote(addr, artId), note)] | |
656 | - | else throw(("Unknow status " + flag)) | |
657 | - | else throw("You are not allowed") | |
325 | + | then [StringEntry(keyUserStatus(address), statusToSet), DeleteEntry(((currentStatus + "_") + address)), StringEntry(((statusToSet + "_") + address), json), StringEntry(("user_note_" + address), note)] | |
326 | + | else throw("Not allowed to change user status") | |
327 | + | } | |
328 | + | ||
329 | + | ||
330 | + | ||
331 | + | @Callable(invoke) | |
332 | + | func deleteUser (address) = { | |
333 | + | let caller = toString(invoke.caller) | |
334 | + | let currentStatus = getStringByKey(keyUserStatus(address)) | |
335 | + | if (containsElement([chris, toString(this)], caller)) | |
336 | + | then [DeleteEntry(keyUserDate(address)), DeleteEntry(keyUserAddr(address)), DeleteEntry(keyUserName(address)), DeleteEntry(keyUserDesc(address)), DeleteEntry(keyUserSocial(address)), DeleteEntry(keyUserThumb(address)), DeleteEntry(("user_note_" + address)), DeleteEntry(((currentStatus + "_") + address)), DeleteEntry(keyUserRoyalties(address)), StringEntry(keyUserStatus(address), userRemoved)] | |
337 | + | else throw("Not allowed") | |
658 | 338 | } | |
659 | 339 | ||
660 | 340 | ||
661 | 341 | ||
662 | 342 | @Callable(i) | |
663 | - | func deleteArtwork (artId,addr) = { | |
664 | - | let $t02478724821 = idCallerDate(i) | |
665 | - | let id = $t02478724821._1 | |
666 | - | let caller = $t02478724821._2 | |
667 | - | let addrToUse = if (containsElement([chris, toString(this)], caller)) | |
668 | - | then addr | |
669 | - | else caller | |
670 | - | let entryExist = valueOrErrorMessage(getStringByKey(keyName(addrToUse, artId)), "No art matching for this address") | |
671 | - | if ((entryExist == "")) | |
672 | - | then throw("No art matching for this address") | |
673 | - | else { | |
674 | - | let sha256Hash = getStringByKey(keyHashByTxidAddr(addrToUse, artId)) | |
675 | - | if ((sha256Hash == "")) | |
676 | - | then throw("No art hash matching for this address") | |
677 | - | else { | |
678 | - | let signID = getStringByKey(keySignID(addrToUse, artId)) | |
679 | - | if ((signID == "")) | |
680 | - | then throw("No SIGN ID matching") | |
681 | - | else { | |
682 | - | let dataToDelete = [DeleteEntry(keyDate(addrToUse, artId)), DeleteEntry(keyName(addrToUse, artId)), DeleteEntry(keyDesc(addrToUse, artId)), DeleteEntry(keyDisplayCid(addrToUse, artId)), DeleteEntry(keyExportCid(addrToUse, artId)), DeleteEntry(keyExportHash(addrToUse, artId)), DeleteEntry(keyLicenceHash(addrToUse, artId)), DeleteEntry(keyLicenceCid(addrToUse, artId)), DeleteEntry(keyType(addrToUse, artId)), DeleteEntry(keyTags(addrToUse, artId)), DeleteEntry(keyMaxMint(addrToUse, artId)), DeleteEntry(keySignID(addrToUse, artId)), DeleteEntry(keyIssued(addrToUse, artId)), DeleteEntry(keyOnSale(addrToUse, artId)), DeleteEntry(keyFlag(addrToUse, artId)), DeleteEntry(keyPrice(addrToUse, artId)), DeleteEntry(keyAssetIdAccepted(addrToUse, artId)), DeleteEntry(keyOwnerByHash(sha256Hash)), DeleteEntry(keyidBySignid(addrToUse, signID)), DeleteEntry(keyTxidByHashOwner(sha256Hash, addrToUse)), DeleteEntry(keyEndSale(addrToUse, artId)), DeleteEntry(keyNote(addrToUse, artId)), DeleteEntry(keyCrawler(addrToUse, artId)), DeleteEntry(keyRoyalties(addrToUse, artId))] | |
683 | - | if (!(isArtMinted(addrToUse, artId))) | |
684 | - | then if (!(dappRunning)) | |
685 | - | then throw(maintenanceMSG) | |
686 | - | else dataToDelete | |
687 | - | else if (containsElement([chris, toString(this)], caller)) | |
688 | - | then dataToDelete | |
689 | - | else throw("Art already minted, you cannot delete it") | |
690 | - | } | |
691 | - | } | |
692 | - | } | |
693 | - | } | |
343 | + | func setAgent (artistAddr,agentAddr,primaryShare,secondaryShare) = if (!(dappRunning)) | |
344 | + | then throw(maintenanceMSG) | |
345 | + | else { | |
346 | + | let caller = toString(i.caller) | |
347 | + | if (containsElement([chris, toString(this)], caller)) | |
348 | + | then if (if ((size(artistAddr) != 35)) | |
349 | + | then true | |
350 | + | else (size(agentAddr) != 35)) | |
351 | + | then throw("Wrong address") | |
352 | + | else [StringEntry(keyArtistAgentAddr(artistAddr), agentAddr), StringEntry(keyAgentArtistAddr(agentAddr, artistAddr), artistAddr), IntegerEntry(keyPrimaryShare(artistAddr), primaryShare), IntegerEntry(keySecondaryShare(artistAddr), secondaryShare)] | |
353 | + | else throw("You are not allowed") | |
354 | + | } | |
694 | 355 | ||
695 | 356 | ||
696 | 357 | ||
697 | 358 | @Callable(i) | |
698 | - | func sellArtwork (artId,price,maxMint,assetId,blockEnd,pubKey) = { | |
699 | - | let $t02765727727 = idCallerDateSponsored(i, pubKey) | |
700 | - | let id = $t02765727727._1 | |
701 | - | let caller = $t02765727727._2 | |
702 | - | let date = $t02765727727._3 | |
703 | - | let isSponsored = $t02765727727._4 | |
704 | - | let artworkName = getStringByKey(keyName(caller, artId)) | |
705 | - | if ((artworkName == "")) | |
706 | - | then throw("This art doesn't match your account") | |
707 | - | else { | |
708 | - | let flag = getStringByKey(keyFlag(caller, artId)) | |
709 | - | if (containsElement(["CHANGE_REQUIRED", "FLAGGED", "ILLEGAL"], flag)) | |
710 | - | then throw("Flagged artwork") | |
711 | - | else { | |
712 | - | let bidNbr = getIntegerByKey(("current_bidamount_" + artId)) | |
713 | - | if ((0 > blockEnd)) | |
714 | - | then throw("Negative end") | |
715 | - | else if (if ((blockEnd > 0)) | |
716 | - | then if ((maxMint != 1)) | |
717 | - | then true | |
718 | - | else (price != 0) | |
719 | - | else false) | |
720 | - | then throw("Timed offer only allowed for unique edition and offer only") | |
721 | - | else { | |
722 | - | let baseHeight = if ((blockEnd == 0)) | |
723 | - | then 0 | |
724 | - | else height | |
725 | - | if (!(acceptedAssetIds(assetId))) | |
726 | - | then throw("Something went wrong!") | |
727 | - | else if (!(validateMinSell(assetId, price))) | |
728 | - | then throw("Something went wrong!") | |
729 | - | else { | |
730 | - | let checkUser = validateUser(caller) | |
731 | - | if ((checkUser != "")) | |
732 | - | then throw(checkUser) | |
733 | - | else { | |
734 | - | let amountSold = getIntegerByKey(keyIssued(caller, artId)) | |
735 | - | let maxCanSell = getIntegerByKey(keyMaxMint(caller, artId)) | |
736 | - | if ((maxMint > 100)) | |
737 | - | then throw("100 editions max per artwork") | |
738 | - | else if (if ((amountSold != 0)) | |
739 | - | then (amountSold == maxCanSell) | |
740 | - | else false) | |
741 | - | then throw("Max edition reached.") | |
742 | - | else if (if ((amountSold > 0)) | |
743 | - | then (maxCanSell != maxMint) | |
744 | - | else false) | |
745 | - | then throw("Cannot change maximum issuable anymore") | |
746 | - | else if (if ((bidNbr > 0)) | |
747 | - | then (maxCanSell != maxMint) | |
748 | - | else false) | |
749 | - | then throw("Cannot change maximum issuable with active orders") | |
750 | - | else { | |
751 | - | let sellStatus = if (if ((price > 0)) | |
752 | - | then (maxMint > 0) | |
753 | - | else false) | |
754 | - | then true | |
755 | - | else false | |
756 | - | let txToCaller = if (isSponsored) | |
757 | - | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
758 | - | else nil | |
759 | - | ([BooleanEntry(keyOnSale(caller, artId), sellStatus), IntegerEntry(keyPrice(caller, artId), price), IntegerEntry(keyMaxMint(caller, artId), maxMint), StringEntry(keyAssetIdAccepted(caller, artId), assetId), IntegerEntry(keyEndSale(caller, artId), (baseHeight + blockEnd))] ++ txToCaller) | |
760 | - | } | |
761 | - | } | |
762 | - | } | |
763 | - | } | |
764 | - | } | |
765 | - | } | |
766 | - | } | |
359 | + | func unsetAgent (artistAddr,agentAddr) = if (!(dappRunning)) | |
360 | + | then throw(maintenanceMSG) | |
361 | + | else { | |
362 | + | let caller = toString(i.caller) | |
363 | + | if (containsElement([chris, toString(this)], caller)) | |
364 | + | then if (if ((size(artistAddr) != 35)) | |
365 | + | then true | |
366 | + | else (size(agentAddr) != 35)) | |
367 | + | then throw("Wrong address") | |
368 | + | else [DeleteEntry(keyArtistAgentAddr(artistAddr)), DeleteEntry(keyAgentArtistAddr(agentAddr, artistAddr)), DeleteEntry(keyPrimaryShare(artistAddr)), DeleteEntry(keySecondaryShare(artistAddr))] | |
369 | + | else throw("You are not allowed") | |
370 | + | } | |
767 | 371 | ||
768 | 372 | ||
769 | 373 | ||
770 | 374 | @Callable(i) | |
771 | - | func buyArtwork (artId,issuer) = buyMint(i, artId, issuer, "", "") | |
772 | - | ||
773 | - | ||
774 | - | ||
775 | - | @Callable(i) | |
776 | - | func setBid (artId,issuer) = { | |
777 | - | let $t03010530145 = idCallerDate(i) | |
778 | - | let id = $t03010530145._1 | |
779 | - | let caller = $t03010530145._2 | |
780 | - | let date = $t03010530145._3 | |
781 | - | let $t03015030186 = isPayment(i) | |
782 | - | let payment = $t03015030186._1 | |
783 | - | let amount = $t03015030186._2 | |
784 | - | let assetId = if (!(isDefined(payment.assetId))) | |
785 | - | then "WAVES" | |
786 | - | else toBase58String(value(payment.assetId)) | |
787 | - | let blockEnd = getIntegerByKey(keyEndSale(issuer, artId)) | |
788 | - | if (if ((blockEnd != 0)) | |
789 | - | then (height >= blockEnd) | |
790 | - | else false) | |
791 | - | then throw("Sale ended.") | |
792 | - | else { | |
793 | - | let bidNbr = getIntegerByKey(("current_bidamount_" + artId)) | |
794 | - | if (!(acceptedAssetIds(assetId))) | |
795 | - | then throw("asset not accepted") | |
796 | - | else if (!(validateMinSell(assetId, amount))) | |
797 | - | then throw("Wrong min sell") | |
798 | - | else { | |
799 | - | let amountSold = getIntegerByKey(keyIssued(issuer, artId)) | |
800 | - | let maxCanSell = getIntegerByKey(keyMaxMint(issuer, artId)) | |
801 | - | if ((0 >= maxCanSell)) | |
802 | - | then throw("No max edition set for this artwork") | |
803 | - | else if ((amountSold >= maxCanSell)) | |
804 | - | then throw("Sold out, you cannot bid") | |
805 | - | else [StringEntry((((((((("bid_" + artId) + "_") + issuer) + "_") + caller) + "_") + id) + "_OPEN"), ((((assetId + "_") + toString(amount)) + "_") + toString(date))), IntegerEntry(("current_bidamount_" + artId), (bidNbr + 1))] | |
806 | - | } | |
807 | - | } | |
808 | - | } | |
809 | - | ||
810 | - | ||
811 | - | ||
812 | - | @Callable(i) | |
813 | - | func acceptBid (artId,issuer,bidId,bidOwner) = { | |
814 | - | let $t03134431384 = idCallerDate(i) | |
815 | - | let id = $t03134431384._1 | |
816 | - | let caller = $t03134431384._2 | |
817 | - | let date = $t03134431384._3 | |
818 | - | if ((caller != issuer)) | |
819 | - | then throw("You cannot do this action") | |
820 | - | else buyMint(i, artId, issuer, bidId, bidOwner) | |
821 | - | } | |
822 | - | ||
823 | - | ||
824 | - | ||
825 | - | @Callable(i) | |
826 | - | func cancelBid (artId,issuer,bidId,bidOwner) = { | |
827 | - | let $t03161031671 = idCallerDate(i) | |
828 | - | let id = $t03161031671._1 | |
829 | - | let caller = $t03161031671._2 | |
830 | - | let date = $t03161031671._3 | |
831 | - | if (if ((caller != bidOwner)) | |
832 | - | then (caller != issuer) | |
833 | - | else false) | |
834 | - | then throw("You cannot do this action") | |
835 | - | else { | |
836 | - | let returnMoneyTo = if ((caller == issuer)) | |
837 | - | then bidOwner | |
838 | - | else caller | |
839 | - | let bidNbr = getIntegerByKey(("current_bidamount_" + artId)) | |
840 | - | let bidDataKey = ((((((("bid_" + artId) + "_") + issuer) + "_") + bidOwner) + "_") + bidId) | |
841 | - | let bidData = getStringByKey((bidDataKey + "_OPEN")) | |
842 | - | if ((bidData == "")) | |
843 | - | then throw("Bid not found") | |
844 | - | else { | |
845 | - | let bidDataArr = split(bidData, "_") | |
846 | - | let assetId = getBidAssetId(bidDataArr[0]) | |
847 | - | let bidStatus = "CANCELED" | |
848 | - | [DeleteEntry((bidDataKey + "_OPEN")), StringEntry(((bidDataKey + "_") + bidStatus), ((bidData + "_") + toString(date))), IntegerEntry(("current_bidamount_" + artId), (bidNbr - 1)), ScriptTransfer(Address(fromBase58String(returnMoneyTo)), parseIntValue(bidDataArr[1]), assetId)] | |
849 | - | } | |
850 | - | } | |
375 | + | func deleteEntry (entry) = { | |
376 | + | let caller = toString(i.caller) | |
377 | + | if ((caller == chris)) | |
378 | + | then [DeleteEntry(entry)] | |
379 | + | else throw("no") | |
851 | 380 | } | |
852 | 381 | ||
853 | 382 | ||
854 | 383 | @Verifier(tx) | |
855 | 384 | func verifier () = match tx { | |
856 | 385 | case inv: InvokeScriptTransaction => | |
857 | - | if (if (if ((inv.function == " | |
386 | + | if (if (if ((inv.function == "registerUser")) | |
858 | 387 | then (inv.dApp == this) | |
859 | 388 | else false) | |
860 | 389 | then (inv.fee == 500000) | |
861 | 390 | else false) | |
862 | - | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[ | |
863 | - | else if (if (if ((inv.function == " | |
391 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[5]))) | |
392 | + | else if (if (if ((inv.function == "updateUser")) | |
864 | 393 | then (inv.dApp == this) | |
865 | 394 | else false) | |
866 | 395 | then (inv.fee == 500000) | |
867 | 396 | else false) | |
868 | - | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[ | |
869 | - | else if (if (if ((inv.function == " | |
397 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[5]))) | |
398 | + | else if (if (if ((inv.function == "setERC20User")) | |
870 | 399 | then (inv.dApp == this) | |
871 | 400 | else false) | |
872 | 401 | then (inv.fee == 500000) | |
873 | 402 | else false) | |
874 | - | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[ | |
403 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[2]))) | |
875 | 404 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
876 | 405 | case _ => | |
877 | 406 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let VERSION = "1. | |
4 | + | let VERSION = "1.5" | |
5 | 5 | ||
6 | 6 | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
7 | 7 | ||
8 | 8 | ||
9 | - | let unitTest = false | |
10 | - | ||
11 | - | let oracleFee = value(addressFromString(getStringByKey("conf_oracle_fee"))) | |
12 | - | ||
13 | - | let signDapp = value(addressFromString(getStringByKey("conf_signweb_dapp"))) | |
14 | - | ||
15 | - | let feeReceiver = getStringByKey("conf_fee_receiver") | |
16 | - | ||
17 | - | let userDapp = if (unitTest) | |
18 | - | then value(addressFromString("3Mt4RGMEyjSWYAocTPqd55wdHQQB3PU2UCm")) | |
19 | - | else value(addressFromString(getStringByKey("conf_users_dapp"))) | |
20 | - | ||
21 | - | let whitelistDapp = value(addressFromString(getStringByKey("conf_whitelist_dapp"))) | |
22 | - | ||
23 | - | let signAssetId = fromBase58String(getStringByKey("conf_accepted_asset_SIGN")) | |
24 | - | ||
25 | - | let usdnAssetId = fromBase58String(getStringByKey("conf_accepted_asset_USDN")) | |
26 | - | ||
27 | - | let usdtAssetId = fromBase58String(getStringByKey("conf_accepted_asset_USDT")) | |
28 | - | ||
29 | - | let wavesAssetId = base58'' | |
30 | - | ||
31 | - | let chris = getStringByKey("conf_admin_1") | |
32 | - | ||
33 | - | func getIntegerByKeyFromOracle (key) = valueOrErrorMessage(getInteger(oracleFee, key), "Integer undefine or 0 in oracle") | |
9 | + | func getBooleanByKey (key) = valueOrElse(getBoolean(this, key), false) | |
34 | 10 | ||
35 | 11 | ||
36 | 12 | func getIntegerByKey (key) = valueOrElse(getInteger(this, key), 0) | |
37 | 13 | ||
38 | 14 | ||
39 | - | ||
15 | + | let chris = getStringByKey("conf_admin_1") | |
40 | 16 | ||
17 | + | let dappRunningKey = "conf_dapp_is_running" | |
41 | 18 | ||
42 | - | ||
19 | + | let maintenanceMSGKey = "conf_maintenance_msg" | |
43 | 20 | ||
21 | + | let whitelistedonlyKey = "conf_whitelisted_only" | |
44 | 22 | ||
45 | - | let | |
23 | + | let dappRunning = valueOrElse(getBoolean(this, dappRunningKey), true) | |
46 | 24 | ||
47 | - | let | |
25 | + | let maintenanceMSG = valueOrElse(getString(this, maintenanceMSGKey), "") | |
48 | 26 | ||
49 | - | let | |
27 | + | let whitelistedonly = valueOrElse(getBoolean(this, whitelistedonlyKey), true) | |
50 | 28 | ||
51 | - | let | |
29 | + | let whitelistDapp = value(addressFromString(getStringByKey("conf_whitelist_dapp"))) | |
52 | 30 | ||
53 | - | let | |
31 | + | let userAllowed = "ALLOWED" | |
54 | 32 | ||
55 | - | let maintenanceMSG = valueOrElse(getString(userDapp, "conf_maintenance_msg"), "") | |
33 | + | let userRegistered = "REGISTERED" | |
34 | + | ||
35 | + | let userVerified = "VERIFIED" | |
56 | 36 | ||
57 | 37 | let userSuspended = "SUSPENDED" | |
58 | 38 | ||
59 | 39 | let userRemoved = "REMOVED" | |
60 | 40 | ||
41 | + | let userChangeRequired = "CHANGE_REQUIRED" | |
42 | + | ||
61 | 43 | let userUnregistered = "UNREGISTERED" | |
62 | 44 | ||
63 | - | let | |
45 | + | let userReset = "RESET" | |
64 | 46 | ||
65 | - | let currentCertificationPrice = getIntegerByKeyFromOracle(("certification_fee_" + toBase58String(signAssetId))) | |
66 | - | ||
67 | - | func getArtworkRoyalties (key) = valueOrElse(getInteger(this, key), 1000) | |
47 | + | func keyUserAddr (caller) = ("user_" + caller) | |
68 | 48 | ||
69 | 49 | ||
70 | - | func checkSignCertificate (signID,Owner,sha256Hash) = match getString(signDapp, ((("data_fc_" + signID) + "_") + Owner)) { | |
71 | - | case a: String => | |
72 | - | if (contains(a, sha256Hash)) | |
73 | - | then true | |
74 | - | else false | |
75 | - | case _ => | |
76 | - | false | |
77 | - | } | |
50 | + | func keyUserName (caller) = ("user_name_" + caller) | |
51 | + | ||
52 | + | ||
53 | + | func keyUserDesc (caller) = ("user_desc_" + caller) | |
54 | + | ||
55 | + | ||
56 | + | func keyUserSocial (caller) = ("user_social_" + caller) | |
57 | + | ||
58 | + | ||
59 | + | func keyUserThumb (caller) = ("user_thumb_" + caller) | |
60 | + | ||
61 | + | ||
62 | + | func keyUserStatus (caller) = ("user_status_" + caller) | |
63 | + | ||
64 | + | ||
65 | + | func keyUserRoyalties (caller) = ("user_royalties_" + caller) | |
66 | + | ||
67 | + | ||
68 | + | func keyUserDate (caller) = ("user_date_" + caller) | |
69 | + | ||
70 | + | ||
71 | + | func keyUserERC20 (caller) = ("user_ERC20_" + caller) | |
72 | + | ||
73 | + | ||
74 | + | func keyArtistAgentAddr (artistAddr) = ("artist_agent_" + artistAddr) | |
75 | + | ||
76 | + | ||
77 | + | func keyAgentArtistAddr (agentAddr,artistAddr) = ((("agent_" + agentAddr) + "_") + artistAddr) | |
78 | + | ||
79 | + | ||
80 | + | func keyPrimaryShare (artistAddr) = ("artist_agent_primary_" + artistAddr) | |
81 | + | ||
82 | + | ||
83 | + | func keySecondaryShare (artistAddr) = ("artist_agent_secondary_" + artistAddr) | |
84 | + | ||
85 | + | ||
86 | + | func checkWhitelist (key) = valueOrElse(getInteger(whitelistDapp, key), 0) | |
78 | 87 | ||
79 | 88 | ||
80 | 89 | func validateCID (cid) = if (contains(cid, "/")) | |
81 | 90 | then if (if ((76 > size(cid))) | |
82 | 91 | then (size(split(cid, "/")[0]) == 59) | |
83 | 92 | else false) | |
84 | 93 | then (16 > size(split(cid, "/")[1])) | |
85 | 94 | else false | |
86 | 95 | else false | |
87 | 96 | ||
88 | 97 | ||
89 | - | func validateHash (hash) = (size(hash) == 64) | |
90 | - | ||
91 | - | ||
92 | - | func keyUserStatus (caller) = ("user_status_" + caller) | |
93 | - | ||
94 | - | ||
95 | - | func keyDate (caller,artId) = ((("art_date_" + artId) + "_") + caller) | |
96 | - | ||
97 | - | ||
98 | - | func keyName (caller,artId) = ((("art_name_" + artId) + "_") + caller) | |
99 | - | ||
100 | - | ||
101 | - | func keyDesc (caller,artId) = ((("art_desc_" + artId) + "_") + caller) | |
102 | - | ||
103 | - | ||
104 | - | func keyDisplayCid (caller,artId) = ((("art_display_cid_" + artId) + "_") + caller) | |
105 | - | ||
106 | - | ||
107 | - | func keyExportHash (caller,artId) = ((("art_export_hash_" + artId) + "_") + caller) | |
108 | - | ||
109 | - | ||
110 | - | func keyExportCid (caller,artId) = ((("art_export_cid_" + artId) + "_") + caller) | |
111 | - | ||
112 | - | ||
113 | - | func keyMaxMint (caller,artId) = ((("art_maxmint_" + artId) + "_") + caller) | |
114 | - | ||
115 | - | ||
116 | - | func keySignID (caller,artId) = ((("art_signid_" + artId) + "_") + caller) | |
117 | - | ||
118 | - | ||
119 | - | func keyIssued (caller,artId) = ((("art_issued_" + artId) + "_") + caller) | |
120 | - | ||
121 | - | ||
122 | - | func keyOnSale (caller,artId) = ((("art_onsale_" + artId) + "_") + caller) | |
123 | - | ||
124 | - | ||
125 | - | func keyLicenceHash (caller,artId) = ((("art_licence_hash_" + artId) + "_") + caller) | |
126 | - | ||
127 | - | ||
128 | - | func keyLicenceCid (caller,artId) = ((("art_licence_cid_" + artId) + "_") + caller) | |
129 | - | ||
130 | - | ||
131 | - | func keyTags (caller,artId) = ((("art_tags_" + artId) + "_") + caller) | |
132 | - | ||
133 | - | ||
134 | - | func keyType (caller,artId) = ((("art_type_" + artId) + "_") + caller) | |
135 | - | ||
136 | - | ||
137 | - | func keyNote (caller,artId) = ((("art_note_" + artId) + "_") + caller) | |
138 | - | ||
139 | - | ||
140 | - | func keyCrawler (caller,artId) = ((("art_crawler_cid_" + artId) + "_") + caller) | |
141 | - | ||
142 | - | ||
143 | - | func keyRoyalties (caller,artId) = ((("art_royalties_" + artId) + "_") + caller) | |
144 | - | ||
145 | - | ||
146 | - | func keyPrice (caller,artId) = ((("art_price_" + artId) + "_") + caller) | |
147 | - | ||
148 | - | ||
149 | - | func keyEndSale (caller,artId) = ((("art_endsale_" + artId) + "_") + caller) | |
150 | - | ||
151 | - | ||
152 | - | func keyAssetIdAccepted (caller,artId) = ((("art_assetAccepted_" + artId) + "_") + caller) | |
153 | - | ||
154 | - | ||
155 | - | func keyFlag (caller,artId) = ((("art_flag_" + artId) + "_") + caller) | |
156 | - | ||
157 | - | ||
158 | - | func keyArtistAgentAddr (artistAddr) = ("artist_agent_" + artistAddr) | |
159 | - | ||
160 | - | ||
161 | - | func keyPrimaryShare (artistAddr) = ("artist_agent_primary_" + artistAddr) | |
162 | - | ||
163 | - | ||
164 | - | func keyHashByTxidAddr (caller,txid) = ((("get_hashbytxidaddr_" + txid) + "_") + caller) | |
165 | - | ||
166 | - | ||
167 | - | func keyOwnerByHash (sha256Hash) = ("get_owner_by_hash_" + sha256Hash) | |
168 | - | ||
169 | - | ||
170 | - | func keyidBySignid (caller,signId) = ((("get_artidbysignid_" + signId) + "_") + caller) | |
171 | - | ||
172 | - | ||
173 | - | func keyTxidByHashOwner (sha256Hash,caller) = ("get_txid_by_hash_owner_" + toBase58String(sha256_16Kb(toBytes((sha256Hash + caller))))) | |
174 | - | ||
175 | - | ||
176 | - | func validateAllCID (cidDisplay,cidExport,cidLicence) = if (!(validateCID(cidDisplay))) | |
177 | - | then throw("Wrong Display CID") | |
178 | - | else if (!(validateCID(cidExport))) | |
179 | - | then throw("Wrong Export CID") | |
180 | - | else if (if ((cidLicence != "")) | |
181 | - | then !(validateCID(cidLicence)) | |
182 | - | else false) | |
183 | - | then throw("Wrong Licence CID") | |
184 | - | else true | |
185 | - | ||
186 | - | ||
187 | - | func validateAllHash (sha256Export,sha256Licence) = if (!(validateHash(sha256Export))) | |
188 | - | then throw("Export Hash 64 char. max") | |
189 | - | else if (!(validateHash(sha256Licence))) | |
190 | - | then throw("Licence Hash 64 char. max") | |
98 | + | func validUserData (caller,name,description,thumb,isAnUpdate) = { | |
99 | + | let validCID = if ((size(thumb) != 0)) | |
100 | + | then validateCID(thumb) | |
191 | 101 | else true | |
192 | - | ||
193 | - | ||
194 | - | func validateString (str,max) = if ((size(str) == 0)) | |
195 | - | then throw("Field cannot be is empty") | |
196 | - | else if ((size(str) > max)) | |
197 | - | then throw((str + " is too long")) | |
198 | - | else true | |
199 | - | ||
200 | - | ||
201 | - | func validateUser (caller) = { | |
202 | - | let userStatus = valueOrElse(getString(userDapp, keyUserStatus(caller)), userUnregistered) | |
203 | - | if (if ((userStatus == userUnregistered)) | |
204 | - | then true | |
205 | - | else (userStatus == userAllowed)) | |
206 | - | then "Register this account first with \"Account\" tab" | |
207 | - | else if ((userStatus == userSuspended)) | |
208 | - | then "Account suspended" | |
209 | - | else if ((userStatus == userRemoved)) | |
210 | - | then "Account removed" | |
211 | - | else "" | |
102 | + | if (!(validCID)) | |
103 | + | then throw("CID don't match requirement!") | |
104 | + | else if (if ((name == "")) | |
105 | + | then true | |
106 | + | else (description == "")) | |
107 | + | then throw("Name and description cannot be empty") | |
108 | + | else if ((size(description) > 600)) | |
109 | + | then throw("600 Char. max description") | |
110 | + | else if ((size(name) > 45)) | |
111 | + | then throw("45 Char. max name") | |
112 | + | else { | |
113 | + | let status = getStringByKey(keyUserStatus(caller)) | |
114 | + | if (if ((status == userSuspended)) | |
115 | + | then true | |
116 | + | else (status == userRemoved)) | |
117 | + | then throw("Account suspended/ removed.") | |
118 | + | else if (if (!(isAnUpdate)) | |
119 | + | then (status == userRegistered) | |
120 | + | else false) | |
121 | + | then throw("Already registered") | |
122 | + | else if (if (if (!(isAnUpdate)) | |
123 | + | then (status == "") | |
124 | + | else false) | |
125 | + | then whitelistedonly | |
126 | + | else false) | |
127 | + | then throw("Can't register, get approved first.") | |
128 | + | else if (if (if (isAnUpdate) | |
129 | + | then (status == "") | |
130 | + | else false) | |
131 | + | then true | |
132 | + | else if (isAnUpdate) | |
133 | + | then (status == userAllowed) | |
134 | + | else false) | |
135 | + | then throw("Register first") | |
136 | + | else true | |
137 | + | } | |
212 | 138 | } | |
213 | 139 | ||
214 | 140 | ||
215 | - | func setLIcence (cidLicence,sha256Licence) = { | |
216 | - | let cid = if ((size(cidLicence) == 0)) | |
217 | - | then defaultLicence | |
218 | - | else cidLicence | |
219 | - | let hash = if ((size(sha256Licence) == 0)) | |
220 | - | then defaultHashLicence | |
221 | - | else sha256Licence | |
222 | - | $Tuple2(cid, hash) | |
141 | + | func validateNewStatus (status,address,currentStatus) = { | |
142 | + | let allStatus = [userVerified, userRegistered, userSuspended, userRemoved, userAllowed, userChangeRequired] | |
143 | + | let statusToSet = if (containsElement(allStatus, status)) | |
144 | + | then status | |
145 | + | else if (if ((status == userReset)) | |
146 | + | then (currentStatus == userAllowed) | |
147 | + | else false) | |
148 | + | then "" | |
149 | + | else throw("Unknown status") | |
150 | + | let userIsRegistered = getIntegerByKey(keyUserDate(address)) | |
151 | + | if (if ((userIsRegistered == 0)) | |
152 | + | then (statusToSet != userAllowed) | |
153 | + | else false) | |
154 | + | then throw("You cant set this status, user is not registered.") | |
155 | + | else if (if ((currentStatus == userAllowed)) | |
156 | + | then (statusToSet == userAllowed) | |
157 | + | else false) | |
158 | + | then throw("User already allowed") | |
159 | + | else if (if ((currentStatus == userRegistered)) | |
160 | + | then (statusToSet == userAllowed) | |
161 | + | else false) | |
162 | + | then throw("User already allowed & registered") | |
163 | + | else if (if ((currentStatus == userVerified)) | |
164 | + | then (statusToSet == userAllowed) | |
165 | + | else false) | |
166 | + | then throw("User already allowed & verified") | |
167 | + | else statusToSet | |
223 | 168 | } | |
224 | 169 | ||
225 | 170 | ||
226 | - | func validateArtworkData (caller,cidDisplay,cidExport,licenceCID,sha256Export,licenceHash,name,description,tags,royalties) = { | |
227 | - | let checkUser = validateUser(caller) | |
228 | - | if ((checkUser != "")) | |
229 | - | then throw(checkUser) | |
230 | - | else if ((size(cidDisplay) == 0)) | |
231 | - | then throw("Display CID cannot be empty") | |
232 | - | else if (!(validateAllCID(cidDisplay, cidExport, licenceCID))) | |
233 | - | then throw("Problem with CID") | |
234 | - | else if (!(validateAllHash(sha256Export, licenceHash))) | |
235 | - | then throw("Problem with Hashes") | |
236 | - | else if (!(validateString(name, 100))) | |
237 | - | then throw("100 Char. max name") | |
238 | - | else if (!(validateString(description, 1000))) | |
239 | - | then throw("1000 Char. max description") | |
240 | - | else if (if ((0 > royalties)) | |
241 | - | then true | |
242 | - | else (royalties > 1000)) | |
243 | - | then throw("Royalties cannot be less than 0% or higher than 10%") | |
244 | - | else if ((size(split(tags, ",")) > 5)) | |
245 | - | then throw("5 tags max.") | |
246 | - | else "" | |
247 | - | } | |
248 | - | ||
249 | - | ||
250 | - | func isPayment (i) = if ((size(i.payments) == 0)) | |
251 | - | then throw("No payment attached") | |
252 | - | else { | |
253 | - | let payment = value(i.payments[0]) | |
254 | - | let amount = value(payment.amount) | |
255 | - | $Tuple2(payment, amount) | |
256 | - | } | |
257 | - | ||
258 | - | ||
259 | - | func validatePayment (i) = { | |
260 | - | let $t089078943 = isPayment(i) | |
261 | - | let payment = $t089078943._1 | |
262 | - | let amount = $t089078943._2 | |
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 as transaction fee") | |
268 | - | if ((amount != currentCertificationPrice)) | |
269 | - | then throw(("Payment amount should be " + toString(currentCertificationPrice))) | |
270 | - | else $Tuple2(amount, assetId) | |
271 | - | } | |
272 | - | ||
273 | - | ||
274 | - | func isArtMinted (addrToUse,artId) = match getInteger(this, keyIssued(addrToUse, artId)) { | |
275 | - | case b: Int => | |
276 | - | if ((b != 0)) | |
277 | - | then true | |
278 | - | else false | |
279 | - | case _ => | |
280 | - | false | |
281 | - | } | |
282 | - | ||
283 | - | ||
284 | - | func validatePriceAssetId (i,priceAssetId,artworkPrice) = { | |
285 | - | let $t095319567 = isPayment(i) | |
286 | - | let payment = $t095319567._1 | |
287 | - | let amount = $t095319567._2 | |
288 | - | let assetId = if (!(isDefined(payment.assetId))) | |
289 | - | then unit | |
290 | - | else if (if ((size(priceAssetId) > 0)) | |
291 | - | then (toBase58String(value(payment.assetId)) == priceAssetId) | |
292 | - | else false) | |
293 | - | then payment.assetId | |
294 | - | else throw("Wrong asset id") | |
295 | - | if (if ((assetId == unit)) | |
296 | - | then (priceAssetId != "") | |
297 | - | else false) | |
298 | - | then throw("Wrong asset id") | |
299 | - | else if ((artworkPrice != amount)) | |
300 | - | then throw("Payment don't match") | |
301 | - | else $Tuple2(amount, assetId) | |
302 | - | } | |
303 | - | ||
304 | - | ||
305 | - | func acceptedAssetIds (assetId) = if (if (if (if (if ((assetId != toBase58String(signAssetId))) | |
306 | - | then (assetId != toBase58String(wavesAssetId)) | |
307 | - | else false) | |
308 | - | then (assetId != "WAVES") | |
309 | - | else false) | |
310 | - | then (assetId != toBase58String(usdnAssetId)) | |
311 | - | else false) | |
312 | - | then (assetId != toBase58String(usdtAssetId)) | |
313 | - | else false) | |
314 | - | then throw("Only SIGN, USDN,USDT or WAVES accepted") | |
315 | - | else true | |
316 | - | ||
317 | - | ||
318 | - | func validateMinSell (assetId,price) = { | |
319 | - | let minSellWaves = if (unitTest) | |
320 | - | then 10 | |
321 | - | else getIntegerByKeyFromOracle("waves_min_sell") | |
322 | - | let minSellUsdn = 1000000 | |
323 | - | let minSellSign = if (unitTest) | |
324 | - | then 1 | |
325 | - | else (currentCertificationPrice * 2) | |
326 | - | if (if (if (if (if (if ((assetId == toBase58String(usdnAssetId))) | |
327 | - | then (minSellUsdn > price) | |
328 | - | else false) | |
329 | - | then (price != 0) | |
330 | - | else false) | |
331 | - | then true | |
332 | - | else if (if ((assetId == toBase58String(usdtAssetId))) | |
333 | - | then (minSellUsdn > price) | |
334 | - | else false) | |
335 | - | then (price != 0) | |
336 | - | else false) | |
337 | - | then true | |
338 | - | else if (if ((assetId == toBase58String(signAssetId))) | |
339 | - | then (minSellSign > price) | |
340 | - | else false) | |
341 | - | then (price != 0) | |
342 | - | else false) | |
343 | - | then true | |
344 | - | else if (if (if ((assetId == toBase58String(wavesAssetId))) | |
345 | - | then true | |
346 | - | else (assetId == "WAVES")) | |
347 | - | then (minSellWaves > price) | |
348 | - | else false) | |
349 | - | then (price != 0) | |
350 | - | else false) | |
351 | - | then throw("Wrong minimum sell price") | |
352 | - | else true | |
353 | - | } | |
354 | - | ||
355 | - | ||
356 | - | func getBidAssetId (assetId) = if ((assetId == "WAVES")) | |
357 | - | then unit | |
358 | - | else fromBase58String(assetId) | |
359 | - | ||
360 | - | ||
361 | - | func getPriceAssetIdFromBid (bidDataKey) = { | |
362 | - | let bidData = getStringByKey((bidDataKey + "_OPEN")) | |
363 | - | if ((bidData == "")) | |
364 | - | then throw("Bid not found") | |
365 | - | else { | |
366 | - | let bidDataArr = split(bidData, "_") | |
367 | - | let bidAmount = parseIntValue(bidDataArr[1]) | |
368 | - | let bidAssetId = getBidAssetId(bidDataArr[0]) | |
369 | - | if ((0 >= bidAmount)) | |
370 | - | then throw("Wrong amount") | |
371 | - | else $Tuple2(bidAmount, bidAssetId) | |
372 | - | } | |
373 | - | } | |
374 | - | ||
375 | - | ||
376 | - | func idCallerDateSponsored (i,pubKey) = if (!(dappRunning)) | |
377 | - | then throw(maintenanceMSG) | |
378 | - | else { | |
379 | - | let isSponsored = valueOrElse(checkWhitelist((toString(addressFromPublicKey(fromBase58String(pubKey))) + "_free_txs")), 0) | |
380 | - | let caller = if (if (if ((toBase58String(i.caller.bytes) == toString(this))) | |
381 | - | then (size(i.payments) == 0) | |
382 | - | else false) | |
383 | - | then (isSponsored > 0) | |
384 | - | else false) | |
385 | - | then toString(addressFromPublicKey(fromBase58String(pubKey))) | |
386 | - | else toBase58String(i.caller.bytes) | |
387 | - | let get_sponsored_waves = if ((pubKey != "")) | |
388 | - | then invoke(whitelistDapp, "useFreeTx", [toString(addressFromPublicKey(fromBase58String(pubKey)))], nil) | |
389 | - | else unit | |
390 | - | if ((get_sponsored_waves == get_sponsored_waves)) | |
391 | - | then $Tuple4(toBase58String(i.transactionId), caller, lastBlock.timestamp, (isSponsored > 0)) | |
392 | - | else throw("Strict value is not equal to itself.") | |
393 | - | } | |
394 | - | ||
395 | - | ||
396 | - | func idCallerDate (i) = if (!(dappRunning)) | |
397 | - | then throw(maintenanceMSG) | |
398 | - | else $Tuple3(toBase58String(i.transactionId), toBase58String(i.caller.bytes), lastBlock.timestamp) | |
399 | - | ||
400 | - | ||
401 | - | func buyMint (i,artId,issuer,bidId,bidOwner) = { | |
402 | - | let $t01291912978 = idCallerDate(i) | |
403 | - | let id = $t01291912978._1 | |
404 | - | let caller = $t01291912978._2 | |
405 | - | let date = $t01291912978._3 | |
406 | - | let isBid = if (if (if ((caller == issuer)) | |
407 | - | then (bidOwner != "") | |
408 | - | else false) | |
409 | - | then (bidId != "") | |
410 | - | else false) | |
411 | - | then true | |
412 | - | else false | |
413 | - | let blockEnd = getIntegerByKey(keyEndSale(caller, artId)) | |
414 | - | if (if (if ((blockEnd != 0)) | |
415 | - | then (height >= blockEnd) | |
416 | - | else false) | |
417 | - | then !(isBid) | |
418 | - | else false) | |
419 | - | then throw("Sale ended.") | |
420 | - | else { | |
421 | - | let callerIsIssuer = (caller == issuer) | |
422 | - | let totalNFT = getIntegerByKey("total_nft_issued") | |
423 | - | let signID = getStringByKey(keySignID(issuer, artId)) | |
424 | - | let artworkName = getStringByKey(keyName(issuer, artId)) | |
425 | - | if ((artworkName == "")) | |
426 | - | then throw("Art doesn't exist") | |
427 | - | else { | |
428 | - | let isOnSale = getBooleanByKey(keyOnSale(issuer, artId)) | |
429 | - | let amountSold = getIntegerByKey(keyIssued(issuer, artId)) | |
430 | - | let artworkPrice = if (callerIsIssuer) | |
431 | - | then (currentCertificationPrice * 2) | |
432 | - | else getIntegerByKey(keyPrice(issuer, artId)) | |
433 | - | let priceAssetId = if (callerIsIssuer) | |
434 | - | then toBase58String(signAssetId) | |
435 | - | else getStringByKey(keyAssetIdAccepted(issuer, artId)) | |
436 | - | let maxCanSell = getIntegerByKey(keyMaxMint(issuer, artId)) | |
437 | - | if (if (if (!(isBid)) | |
438 | - | then !(callerIsIssuer) | |
439 | - | else false) | |
440 | - | then if (if ((0 >= artworkPrice)) | |
441 | - | then true | |
442 | - | else !(isOnSale)) | |
443 | - | then true | |
444 | - | else (0 >= maxCanSell) | |
445 | - | else false) | |
446 | - | then throw("Art not for sale") | |
447 | - | else if (if (if (!(isBid)) | |
448 | - | then callerIsIssuer | |
449 | - | else false) | |
450 | - | then (0 >= maxCanSell) | |
451 | - | else false) | |
452 | - | then throw("Max issuable not set") | |
453 | - | else { | |
454 | - | let checkUser = validateUser(issuer) | |
455 | - | if (if (isBid) | |
456 | - | then (checkUser != "") | |
457 | - | else false) | |
458 | - | then throw(checkUser) | |
459 | - | else { | |
460 | - | let bidDataKey = ((((((("bid_" + artId) + "_") + issuer) + "_") + bidOwner) + "_") + bidId) | |
461 | - | let $t01468114848 = if (isBid) | |
462 | - | then getPriceAssetIdFromBid(bidDataKey) | |
463 | - | else validatePriceAssetId(i, priceAssetId, artworkPrice) | |
464 | - | let amount = $t01468114848._1 | |
465 | - | let assetId = $t01468114848._2 | |
466 | - | let agent = valueOrElse(getString(userDapp, keyArtistAgentAddr(issuer)), feeReceiver) | |
467 | - | let agentShare = valueOrElse(getInteger(userDapp, keyPrimaryShare(issuer)), 0) | |
468 | - | let isWhitelisted = checkWhitelist(issuer) | |
469 | - | let cut = if ((isWhitelisted > height)) | |
470 | - | then 0 | |
471 | - | else if ((assetId == signAssetId)) | |
472 | - | then signCut | |
473 | - | else usdnWaveCut | |
474 | - | let amountForSign = fraction(amount, cut, 100) | |
475 | - | let amountForAgent = if (if (if ((agent != feeReceiver)) | |
476 | - | then (agentShare > 0) | |
477 | - | else false) | |
478 | - | then (height > isWhitelisted) | |
479 | - | else false) | |
480 | - | then fraction(amount, agentShare, 100) | |
481 | - | else 0 | |
482 | - | let amountForCreator = (amount - amountForSign) | |
483 | - | if ((amountSold == maxCanSell)) | |
484 | - | then throw("Art sold out") | |
485 | - | else { | |
486 | - | let newAmountSold = (amountSold + 1) | |
487 | - | let issueMeta = ((((((((((("Creator: " + issuer) + ", | |
488 | - | ArtID: ") + artId) + ", | |
489 | - | SignID: ") + signID) + ", | |
490 | - | Artwork name: ") + artworkName) + ", | |
491 | - | Issue: ") + toString(newAmountSold)) + "/") + toString(maxCanSell)) | |
492 | - | let issueNFT = Issue(("SA_" + toString((totalNFT + 1))), issueMeta, 1, 0, false) | |
493 | - | let idNFT = calculateAssetId(issueNFT) | |
494 | - | let sellStatus = if (if ((newAmountSold == maxCanSell)) | |
495 | - | then true | |
496 | - | else !(isOnSale)) | |
497 | - | then false | |
498 | - | else true | |
499 | - | let receiveNFT = if (if (if ((caller == issuer)) | |
500 | - | then (bidOwner != "") | |
501 | - | else false) | |
502 | - | then (bidId != "") | |
503 | - | else false) | |
504 | - | then addressFromStringValue(bidOwner) | |
505 | - | else i.caller | |
506 | - | let assetIdBid = if (!(isDefined(assetId))) | |
507 | - | then "WAVES" | |
508 | - | else toBase58String(value(assetId)) | |
509 | - | let bidData = getStringByKey((bidDataKey + "_OPEN")) | |
510 | - | let bidDelOld = DeleteEntry((bidDataKey + "_OPEN")) | |
511 | - | let bidUpdate = StringEntry((bidDataKey + "_CLOSED"), ((bidData + "_") + toString(date))) | |
512 | - | let soldKey = ((((((("art_sold_" + toString(newAmountSold)) + "_of_") + toString(maxCanSell)) + "_") + artId) + "_") + issuer) | |
513 | - | let soldValue = if (!(isBid)) | |
514 | - | then ((((((((((caller + "_") + toString(date)) + "_") + id) + "_") + toString(artworkPrice)) + "_") + priceAssetId) + "_") + toBase58String(idNFT)) | |
515 | - | else ((((((((((toString(receiveNFT) + "_") + toString(date)) + "_") + id) + "_") + toString(amount)) + "_") + assetIdBid) + "_") + toBase58String(idNFT)) | |
516 | - | let soldData = StringEntry(soldKey, soldValue) | |
517 | - | let commissions = if ((amountForAgent != 0)) | |
518 | - | then [ScriptTransfer(Address(fromBase58String(feeReceiver)), (amountForSign - amountForAgent), assetId), ScriptTransfer(Address(fromBase58String(agent)), amountForAgent, assetId)] | |
519 | - | else [ScriptTransfer(Address(fromBase58String(feeReceiver)), amountForSign, assetId)] | |
520 | - | let buyRes = ([IntegerEntry(keyIssued(issuer, artId), newAmountSold), StringEntry(("nft_" + toBase58String(idNFT)), soldKey), IntegerEntry("total_nft_issued", (totalNFT + 1)), IntegerEntry(keyEndSale(issuer, artId), 0), BooleanEntry(keyOnSale(issuer, artId), sellStatus), issueNFT, ScriptTransfer(Address(fromBase58String(issuer)), amountForCreator, assetId), ScriptTransfer(receiveNFT, 1, idNFT)] ++ commissions) | |
521 | - | if (isBid) | |
522 | - | then [soldData, bidUpdate, bidDelOld] :: buyRes | |
523 | - | else soldData :: buyRes | |
524 | - | } | |
525 | - | } | |
526 | - | } | |
527 | - | } | |
528 | - | } | |
529 | - | } | |
171 | + | func makeJSON (name,thumb,date) = (((((("{\"user_name\": \"" + name) + "\", \"user_thumb\":\"") + thumb) + "\",\"user_date\":\"") + date) + "\"}") | |
530 | 172 | ||
531 | 173 | ||
532 | 174 | func asString (bv) = match bv { | |
533 | 175 | case bv0: String => | |
534 | 176 | bv0 | |
535 | 177 | case _ => | |
536 | 178 | throw("Sponsored Public Key String expected") | |
537 | 179 | } | |
538 | 180 | ||
539 | 181 | ||
182 | + | func getCaller (i,pubKey) = { | |
183 | + | let isSponsored = valueOrElse(checkWhitelist((toString(addressFromPublicKey(fromBase58String(pubKey))) + "_free_txs")), 0) | |
184 | + | let caller = if (if (if ((toBase58String(i.caller.bytes) == toString(this))) | |
185 | + | then (size(i.payments) == 0) | |
186 | + | else false) | |
187 | + | then (isSponsored > 0) | |
188 | + | else false) | |
189 | + | then toString(addressFromPublicKey(fromBase58String(pubKey))) | |
190 | + | else toBase58String(i.caller.bytes) | |
191 | + | let get_sponsored_waves = if ((pubKey != "")) | |
192 | + | then invoke(whitelistDapp, "useFreeTx", [toString(addressFromPublicKey(fromBase58String(pubKey)))], nil) | |
193 | + | else unit | |
194 | + | if ((get_sponsored_waves == get_sponsored_waves)) | |
195 | + | then $Tuple2(caller, (isSponsored > 0)) | |
196 | + | else throw("Strict value is not equal to itself.") | |
197 | + | } | |
198 | + | ||
199 | + | ||
540 | 200 | @Callable(invoke) | |
541 | 201 | func setConf (key,val) = { | |
542 | 202 | let caller = toString(invoke.caller) | |
543 | 203 | if (containsElement([chris, toString(this)], caller)) | |
544 | - | then if (contains(key, "conf_")) | |
545 | - | then [StringEntry(key, val)] | |
546 | - | else throw("Entries starting with conf_ only") | |
204 | + | then [StringEntry(key, val)] | |
547 | 205 | else throw("You are not allowed to change this") | |
548 | 206 | } | |
549 | 207 | ||
550 | 208 | ||
551 | 209 | ||
552 | - | @Callable(i) | |
553 | - | func addArtwork (sha256Hash,signID,name,description,tags,type,cidDisplay,sha256Export,cidExport,sha256Licence,cidLicence,crawler,royalties,pubKey) = { | |
554 | - | let $t01888118954 = idCallerDateSponsored(i, pubKey) | |
555 | - | let artId = $t01888118954._1 | |
556 | - | let caller = $t01888118954._2 | |
557 | - | let date = $t01888118954._3 | |
558 | - | let isSponsored = $t01888118954._4 | |
559 | - | if (!(validateHash(sha256Hash))) | |
560 | - | then throw("Hash should be 64 characters maximum") | |
561 | - | else { | |
562 | - | let $t01905519124 = setLIcence(cidLicence, sha256Licence) | |
563 | - | let licenceCID = $t01905519124._1 | |
564 | - | let licenceHash = $t01905519124._2 | |
565 | - | let validateArtwork = validateArtworkData(caller, cidDisplay, cidExport, licenceCID, sha256Export, licenceHash, name, description, tags, royalties) | |
566 | - | if ((validateArtwork != "")) | |
567 | - | then throw("Something went wrong!") | |
568 | - | else { | |
569 | - | let whitelisted_drop = (checkWhitelist((caller + "_free_drops")) > 0) | |
570 | - | let $t01942319507 = if (whitelisted_drop) | |
571 | - | then $Tuple2(0, signID) | |
572 | - | else validatePayment(i) | |
573 | - | let amount = $t01942319507._1 | |
574 | - | let assetId = $t01942319507._2 | |
575 | - | if (!(isDefined(amount))) | |
576 | - | then throw("Something went wrong") | |
577 | - | else { | |
578 | - | let entryExist = getStringByKey(keyTxidByHashOwner(sha256Hash, caller)) | |
579 | - | if ((entryExist != "")) | |
580 | - | then throw("You already added it") | |
581 | - | else { | |
582 | - | let hashExist = getStringByKey(keyOwnerByHash(sha256Hash)) | |
583 | - | if ((hashExist != "")) | |
584 | - | then throw("Hash already registered") | |
585 | - | else { | |
586 | - | let isSignCertified = checkSignCertificate(signID, caller, sha256Hash) | |
587 | - | if (!(isSignCertified)) | |
588 | - | then throw("Sign Certificate not found for this address.") | |
589 | - | else { | |
590 | - | let decrease_whitelist_drop = if (whitelisted_drop) | |
591 | - | then invoke(whitelistDapp, "useFreeDrop", [caller], nil) | |
592 | - | else unit | |
593 | - | if ((decrease_whitelist_drop == decrease_whitelist_drop)) | |
594 | - | then { | |
595 | - | let txToCaller = if (isSponsored) | |
596 | - | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
597 | - | else nil | |
598 | - | ([StringEntry(keyOwnerByHash(sha256Hash), caller), StringEntry(keyTxidByHashOwner(sha256Hash, caller), artId), IntegerEntry(keyDate(caller, artId), date), StringEntry(keyName(caller, artId), name), StringEntry(keyDesc(caller, artId), description), StringEntry(keyDisplayCid(caller, artId), cidDisplay), StringEntry(keyExportCid(caller, artId), cidExport), StringEntry(keyExportHash(caller, artId), sha256Export), StringEntry(keyLicenceHash(caller, artId), licenceHash), StringEntry(keyLicenceCid(caller, artId), licenceCID), StringEntry(keyType(caller, artId), type), StringEntry(keyTags(caller, artId), tags), IntegerEntry(keyMaxMint(caller, artId), 0), StringEntry(keySignID(caller, artId), signID), IntegerEntry(keyIssued(caller, artId), 0), BooleanEntry(keyOnSale(caller, artId), false), StringEntry(keyidBySignid(caller, signID), artId), StringEntry(keyHashByTxidAddr(caller, artId), sha256Hash), StringEntry(keyCrawler(caller, artId), crawler), IntegerEntry(keyRoyalties(caller, artId), royalties), ScriptTransfer(Address(fromBase58String(feeReceiver)), amount, signAssetId)] ++ txToCaller) | |
599 | - | } | |
600 | - | else throw("Strict value is not equal to itself.") | |
601 | - | } | |
602 | - | } | |
603 | - | } | |
604 | - | } | |
605 | - | } | |
606 | - | } | |
210 | + | @Callable(invoke) | |
211 | + | func appRunning (isLive,message) = { | |
212 | + | let caller = toString(invoke.caller) | |
213 | + | if (containsElement([chris, toString(this)], caller)) | |
214 | + | then [BooleanEntry(dappRunningKey, isLive), StringEntry(maintenanceMSGKey, message)] | |
215 | + | else throw("You are not allowed to change this") | |
607 | 216 | } | |
608 | 217 | ||
609 | 218 | ||
610 | 219 | ||
611 | - | @Callable(i) | |
612 | - | func updateArtwork (txid,name,description,tags,type,cidDisplay,sha256Export,cidExport,sha256Licence,cidLicence,crawler,royalties,pubKey) = if (!(dappRunning)) | |
220 | + | @Callable(invoke) | |
221 | + | func registrationMode (WLonly) = { | |
222 | + | let caller = toString(invoke.caller) | |
223 | + | if (containsElement([chris, toString(this)], caller)) | |
224 | + | then [BooleanEntry(whitelistedonlyKey, WLonly)] | |
225 | + | else throw("You are not allowed to change this") | |
226 | + | } | |
227 | + | ||
228 | + | ||
229 | + | ||
230 | + | @Callable(invoke) | |
231 | + | func registerUser (name,description,thumb,social,royalties,pubKey) = if (!(dappRunning)) | |
613 | 232 | then throw(maintenanceMSG) | |
614 | 233 | else { | |
615 | - | let $t02254122611 = idCallerDateSponsored(i, pubKey) | |
616 | - | let id = $t02254122611._1 | |
617 | - | let caller = $t02254122611._2 | |
618 | - | let date = $t02254122611._3 | |
619 | - | let isSponsored = $t02254122611._4 | |
620 | - | let $t02262122690 = setLIcence(cidLicence, sha256Licence) | |
621 | - | let licenceCID = $t02262122690._1 | |
622 | - | let licenceHash = $t02262122690._2 | |
623 | - | let validateArtwork = validateArtworkData(caller, cidDisplay, cidExport, licenceCID, sha256Export, licenceHash, name, description, tags, royalties) | |
624 | - | if ((validateArtwork != "")) | |
625 | - | then throw("Something went wrong!") | |
234 | + | let $t072777329 = getCaller(invoke, pubKey) | |
235 | + | let caller = $t072777329._1 | |
236 | + | let isSponsored = $t072777329._2 | |
237 | + | let id = toBase58String(invoke.transactionId) | |
238 | + | let timestamp = lastBlock.timestamp | |
239 | + | if (!(validUserData(caller, name, description, thumb, false))) | |
240 | + | then throw("Something went wrong") | |
626 | 241 | else { | |
627 | - | let entryExist = getStringByKey(keyName(caller, txid)) | |
628 | - | if ((entryExist == "")) | |
629 | - | then throw("Entry not found") | |
242 | + | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(thumb)), toString(timestamp)) | |
243 | + | if (if ((0 > royalties)) | |
244 | + | then true | |
245 | + | else (royalties > 1000)) | |
246 | + | then throw("Royalties cannot be less than 0% or higher than 10%") | |
630 | 247 | else { | |
631 | - | let flag = getStringByKey(keyFlag(caller, txid)) | |
632 | - | if ((flag == "ILLEGAL")) | |
633 | - | then throw("Cannot update ILLEGAL artwork") | |
634 | - | else if (!(isArtMinted(caller, txid))) | |
635 | - | then { | |
636 | - | let txToCaller = if (isSponsored) | |
637 | - | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
638 | - | else nil | |
639 | - | ([StringEntry(keyName(caller, txid), name), StringEntry(keyDesc(caller, txid), description), StringEntry(keyDisplayCid(caller, txid), cidDisplay), StringEntry(keyExportCid(caller, txid), cidExport), StringEntry(keyExportHash(caller, txid), sha256Export), StringEntry(keyLicenceCid(caller, txid), licenceCID), StringEntry(keyLicenceHash(caller, txid), licenceHash), StringEntry(keyTags(caller, txid), tags), StringEntry(keyType(caller, txid), type), StringEntry(keyCrawler(caller, txid), crawler), IntegerEntry(keyRoyalties(caller, txid), royalties)] ++ txToCaller) | |
640 | - | } | |
641 | - | else throw("Already minted") | |
248 | + | let txToCaller = if (isSponsored) | |
249 | + | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
250 | + | else nil | |
251 | + | ([IntegerEntry(keyUserDate(caller), timestamp), StringEntry(keyUserAddr(caller), ((id + "_") + toString(timestamp))), StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb), StringEntry(keyUserStatus(caller), userRegistered), IntegerEntry(keyUserRoyalties(caller), royalties), DeleteEntry(("ALLOWED_" + caller)), StringEntry(((userRegistered + "_") + caller), json)] ++ txToCaller) | |
642 | 252 | } | |
643 | 253 | } | |
644 | 254 | } | |
645 | 255 | ||
646 | 256 | ||
647 | 257 | ||
648 | - | @Callable(i) | |
649 | - | func flagArtwork (artId,addr,flag,note) = { | |
650 | - | let $t02431724351 = idCallerDate(i) | |
651 | - | let id = $t02431724351._1 | |
652 | - | let caller = $t02431724351._2 | |
258 | + | @Callable(invoke) | |
259 | + | func updateUser (name,description,thumb,social,royalties,pubKey) = if (!(dappRunning)) | |
260 | + | then throw(maintenanceMSG) | |
261 | + | else { | |
262 | + | let $t087728876 = getCaller(invoke, pubKey) | |
263 | + | let caller = $t087728876._1 | |
264 | + | let isSponsored = $t087728876._2 | |
265 | + | let status = getStringByKey(keyUserStatus(caller)) | |
266 | + | if (!(validUserData(caller, name, description, thumb, true))) | |
267 | + | then throw("Something went wrong") | |
268 | + | else { | |
269 | + | let date = getIntegerByKey(keyUserDate(caller)) | |
270 | + | let json = makeJSON(toBase64String(toBytes(name)), toBase64String(toBytes(thumb)), toString(date)) | |
271 | + | if (if ((0 > royalties)) | |
272 | + | then true | |
273 | + | else (royalties > 1000)) | |
274 | + | then throw("Royalties cannot be less than 0% or higher than 10%") | |
275 | + | else { | |
276 | + | let txToCaller = if (isSponsored) | |
277 | + | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
278 | + | else nil | |
279 | + | ([StringEntry(keyUserName(caller), name), StringEntry(keyUserDesc(caller), description), StringEntry(keyUserSocial(caller), social), StringEntry(keyUserThumb(caller), thumb), IntegerEntry(keyUserRoyalties(caller), royalties), StringEntry(((status + "_") + caller), json)] ++ txToCaller) | |
280 | + | } | |
281 | + | } | |
282 | + | } | |
283 | + | ||
284 | + | ||
285 | + | ||
286 | + | @Callable(invoke) | |
287 | + | func setERC20User (erc20,pubKey) = if (!(dappRunning)) | |
288 | + | then throw(maintenanceMSG) | |
289 | + | else { | |
290 | + | let $t01006310166 = getCaller(invoke, pubKey) | |
291 | + | let caller = $t01006310166._1 | |
292 | + | let isSponsored = $t01006310166._2 | |
293 | + | let status = getStringByKey(keyUserStatus(caller)) | |
294 | + | if (if ((status != userRegistered)) | |
295 | + | then (status != userVerified) | |
296 | + | else false) | |
297 | + | then throw("Not allowed to set ERC20 address") | |
298 | + | else { | |
299 | + | let firstTwo = take(erc20, 2) | |
300 | + | if (if ((firstTwo != "0x")) | |
301 | + | then true | |
302 | + | else (size(erc20) != 42)) | |
303 | + | then throw("This is not an erc20 address") | |
304 | + | else { | |
305 | + | let txToCaller = if (isSponsored) | |
306 | + | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
307 | + | else nil | |
308 | + | ([StringEntry(keyUserERC20(caller), erc20)] ++ txToCaller) | |
309 | + | } | |
310 | + | } | |
311 | + | } | |
312 | + | ||
313 | + | ||
314 | + | ||
315 | + | @Callable(invoke) | |
316 | + | func changeUserStatus (address,status,note) = { | |
317 | + | let caller = toString(invoke.caller) | |
318 | + | let currentStatus = getStringByKey(keyUserStatus(address)) | |
319 | + | let statusToSet = validateNewStatus(status, address, currentStatus) | |
320 | + | let name = toBase64String(toBytes(getStringByKey(keyUserName(address)))) | |
321 | + | let thumb = toBase64String(toBytes(getStringByKey(keyUserThumb(address)))) | |
322 | + | let date = getIntegerByKey(keyUserDate(address)) | |
323 | + | let json = makeJSON(name, thumb, toString(date)) | |
653 | 324 | if (containsElement([chris, toString(this)], caller)) | |
654 | - | then if (containsElement(["CONSENT", "", "CHANGE_REQUIRED", "FLAGGED", "ILLEGAL"], flag)) | |
655 | - | then [StringEntry(keyFlag(addr, artId), flag), StringEntry(keyNote(addr, artId), note)] | |
656 | - | else throw(("Unknow status " + flag)) | |
657 | - | else throw("You are not allowed") | |
325 | + | then [StringEntry(keyUserStatus(address), statusToSet), DeleteEntry(((currentStatus + "_") + address)), StringEntry(((statusToSet + "_") + address), json), StringEntry(("user_note_" + address), note)] | |
326 | + | else throw("Not allowed to change user status") | |
327 | + | } | |
328 | + | ||
329 | + | ||
330 | + | ||
331 | + | @Callable(invoke) | |
332 | + | func deleteUser (address) = { | |
333 | + | let caller = toString(invoke.caller) | |
334 | + | let currentStatus = getStringByKey(keyUserStatus(address)) | |
335 | + | if (containsElement([chris, toString(this)], caller)) | |
336 | + | then [DeleteEntry(keyUserDate(address)), DeleteEntry(keyUserAddr(address)), DeleteEntry(keyUserName(address)), DeleteEntry(keyUserDesc(address)), DeleteEntry(keyUserSocial(address)), DeleteEntry(keyUserThumb(address)), DeleteEntry(("user_note_" + address)), DeleteEntry(((currentStatus + "_") + address)), DeleteEntry(keyUserRoyalties(address)), StringEntry(keyUserStatus(address), userRemoved)] | |
337 | + | else throw("Not allowed") | |
658 | 338 | } | |
659 | 339 | ||
660 | 340 | ||
661 | 341 | ||
662 | 342 | @Callable(i) | |
663 | - | func deleteArtwork (artId,addr) = { | |
664 | - | let $t02478724821 = idCallerDate(i) | |
665 | - | let id = $t02478724821._1 | |
666 | - | let caller = $t02478724821._2 | |
667 | - | let addrToUse = if (containsElement([chris, toString(this)], caller)) | |
668 | - | then addr | |
669 | - | else caller | |
670 | - | let entryExist = valueOrErrorMessage(getStringByKey(keyName(addrToUse, artId)), "No art matching for this address") | |
671 | - | if ((entryExist == "")) | |
672 | - | then throw("No art matching for this address") | |
673 | - | else { | |
674 | - | let sha256Hash = getStringByKey(keyHashByTxidAddr(addrToUse, artId)) | |
675 | - | if ((sha256Hash == "")) | |
676 | - | then throw("No art hash matching for this address") | |
677 | - | else { | |
678 | - | let signID = getStringByKey(keySignID(addrToUse, artId)) | |
679 | - | if ((signID == "")) | |
680 | - | then throw("No SIGN ID matching") | |
681 | - | else { | |
682 | - | let dataToDelete = [DeleteEntry(keyDate(addrToUse, artId)), DeleteEntry(keyName(addrToUse, artId)), DeleteEntry(keyDesc(addrToUse, artId)), DeleteEntry(keyDisplayCid(addrToUse, artId)), DeleteEntry(keyExportCid(addrToUse, artId)), DeleteEntry(keyExportHash(addrToUse, artId)), DeleteEntry(keyLicenceHash(addrToUse, artId)), DeleteEntry(keyLicenceCid(addrToUse, artId)), DeleteEntry(keyType(addrToUse, artId)), DeleteEntry(keyTags(addrToUse, artId)), DeleteEntry(keyMaxMint(addrToUse, artId)), DeleteEntry(keySignID(addrToUse, artId)), DeleteEntry(keyIssued(addrToUse, artId)), DeleteEntry(keyOnSale(addrToUse, artId)), DeleteEntry(keyFlag(addrToUse, artId)), DeleteEntry(keyPrice(addrToUse, artId)), DeleteEntry(keyAssetIdAccepted(addrToUse, artId)), DeleteEntry(keyOwnerByHash(sha256Hash)), DeleteEntry(keyidBySignid(addrToUse, signID)), DeleteEntry(keyTxidByHashOwner(sha256Hash, addrToUse)), DeleteEntry(keyEndSale(addrToUse, artId)), DeleteEntry(keyNote(addrToUse, artId)), DeleteEntry(keyCrawler(addrToUse, artId)), DeleteEntry(keyRoyalties(addrToUse, artId))] | |
683 | - | if (!(isArtMinted(addrToUse, artId))) | |
684 | - | then if (!(dappRunning)) | |
685 | - | then throw(maintenanceMSG) | |
686 | - | else dataToDelete | |
687 | - | else if (containsElement([chris, toString(this)], caller)) | |
688 | - | then dataToDelete | |
689 | - | else throw("Art already minted, you cannot delete it") | |
690 | - | } | |
691 | - | } | |
692 | - | } | |
693 | - | } | |
343 | + | func setAgent (artistAddr,agentAddr,primaryShare,secondaryShare) = if (!(dappRunning)) | |
344 | + | then throw(maintenanceMSG) | |
345 | + | else { | |
346 | + | let caller = toString(i.caller) | |
347 | + | if (containsElement([chris, toString(this)], caller)) | |
348 | + | then if (if ((size(artistAddr) != 35)) | |
349 | + | then true | |
350 | + | else (size(agentAddr) != 35)) | |
351 | + | then throw("Wrong address") | |
352 | + | else [StringEntry(keyArtistAgentAddr(artistAddr), agentAddr), StringEntry(keyAgentArtistAddr(agentAddr, artistAddr), artistAddr), IntegerEntry(keyPrimaryShare(artistAddr), primaryShare), IntegerEntry(keySecondaryShare(artistAddr), secondaryShare)] | |
353 | + | else throw("You are not allowed") | |
354 | + | } | |
694 | 355 | ||
695 | 356 | ||
696 | 357 | ||
697 | 358 | @Callable(i) | |
698 | - | func sellArtwork (artId,price,maxMint,assetId,blockEnd,pubKey) = { | |
699 | - | let $t02765727727 = idCallerDateSponsored(i, pubKey) | |
700 | - | let id = $t02765727727._1 | |
701 | - | let caller = $t02765727727._2 | |
702 | - | let date = $t02765727727._3 | |
703 | - | let isSponsored = $t02765727727._4 | |
704 | - | let artworkName = getStringByKey(keyName(caller, artId)) | |
705 | - | if ((artworkName == "")) | |
706 | - | then throw("This art doesn't match your account") | |
707 | - | else { | |
708 | - | let flag = getStringByKey(keyFlag(caller, artId)) | |
709 | - | if (containsElement(["CHANGE_REQUIRED", "FLAGGED", "ILLEGAL"], flag)) | |
710 | - | then throw("Flagged artwork") | |
711 | - | else { | |
712 | - | let bidNbr = getIntegerByKey(("current_bidamount_" + artId)) | |
713 | - | if ((0 > blockEnd)) | |
714 | - | then throw("Negative end") | |
715 | - | else if (if ((blockEnd > 0)) | |
716 | - | then if ((maxMint != 1)) | |
717 | - | then true | |
718 | - | else (price != 0) | |
719 | - | else false) | |
720 | - | then throw("Timed offer only allowed for unique edition and offer only") | |
721 | - | else { | |
722 | - | let baseHeight = if ((blockEnd == 0)) | |
723 | - | then 0 | |
724 | - | else height | |
725 | - | if (!(acceptedAssetIds(assetId))) | |
726 | - | then throw("Something went wrong!") | |
727 | - | else if (!(validateMinSell(assetId, price))) | |
728 | - | then throw("Something went wrong!") | |
729 | - | else { | |
730 | - | let checkUser = validateUser(caller) | |
731 | - | if ((checkUser != "")) | |
732 | - | then throw(checkUser) | |
733 | - | else { | |
734 | - | let amountSold = getIntegerByKey(keyIssued(caller, artId)) | |
735 | - | let maxCanSell = getIntegerByKey(keyMaxMint(caller, artId)) | |
736 | - | if ((maxMint > 100)) | |
737 | - | then throw("100 editions max per artwork") | |
738 | - | else if (if ((amountSold != 0)) | |
739 | - | then (amountSold == maxCanSell) | |
740 | - | else false) | |
741 | - | then throw("Max edition reached.") | |
742 | - | else if (if ((amountSold > 0)) | |
743 | - | then (maxCanSell != maxMint) | |
744 | - | else false) | |
745 | - | then throw("Cannot change maximum issuable anymore") | |
746 | - | else if (if ((bidNbr > 0)) | |
747 | - | then (maxCanSell != maxMint) | |
748 | - | else false) | |
749 | - | then throw("Cannot change maximum issuable with active orders") | |
750 | - | else { | |
751 | - | let sellStatus = if (if ((price > 0)) | |
752 | - | then (maxMint > 0) | |
753 | - | else false) | |
754 | - | then true | |
755 | - | else false | |
756 | - | let txToCaller = if (isSponsored) | |
757 | - | then [ScriptTransfer(Address(fromBase58String(caller)), 0, unit)] | |
758 | - | else nil | |
759 | - | ([BooleanEntry(keyOnSale(caller, artId), sellStatus), IntegerEntry(keyPrice(caller, artId), price), IntegerEntry(keyMaxMint(caller, artId), maxMint), StringEntry(keyAssetIdAccepted(caller, artId), assetId), IntegerEntry(keyEndSale(caller, artId), (baseHeight + blockEnd))] ++ txToCaller) | |
760 | - | } | |
761 | - | } | |
762 | - | } | |
763 | - | } | |
764 | - | } | |
765 | - | } | |
766 | - | } | |
359 | + | func unsetAgent (artistAddr,agentAddr) = if (!(dappRunning)) | |
360 | + | then throw(maintenanceMSG) | |
361 | + | else { | |
362 | + | let caller = toString(i.caller) | |
363 | + | if (containsElement([chris, toString(this)], caller)) | |
364 | + | then if (if ((size(artistAddr) != 35)) | |
365 | + | then true | |
366 | + | else (size(agentAddr) != 35)) | |
367 | + | then throw("Wrong address") | |
368 | + | else [DeleteEntry(keyArtistAgentAddr(artistAddr)), DeleteEntry(keyAgentArtistAddr(agentAddr, artistAddr)), DeleteEntry(keyPrimaryShare(artistAddr)), DeleteEntry(keySecondaryShare(artistAddr))] | |
369 | + | else throw("You are not allowed") | |
370 | + | } | |
767 | 371 | ||
768 | 372 | ||
769 | 373 | ||
770 | 374 | @Callable(i) | |
771 | - | func buyArtwork (artId,issuer) = buyMint(i, artId, issuer, "", "") | |
772 | - | ||
773 | - | ||
774 | - | ||
775 | - | @Callable(i) | |
776 | - | func setBid (artId,issuer) = { | |
777 | - | let $t03010530145 = idCallerDate(i) | |
778 | - | let id = $t03010530145._1 | |
779 | - | let caller = $t03010530145._2 | |
780 | - | let date = $t03010530145._3 | |
781 | - | let $t03015030186 = isPayment(i) | |
782 | - | let payment = $t03015030186._1 | |
783 | - | let amount = $t03015030186._2 | |
784 | - | let assetId = if (!(isDefined(payment.assetId))) | |
785 | - | then "WAVES" | |
786 | - | else toBase58String(value(payment.assetId)) | |
787 | - | let blockEnd = getIntegerByKey(keyEndSale(issuer, artId)) | |
788 | - | if (if ((blockEnd != 0)) | |
789 | - | then (height >= blockEnd) | |
790 | - | else false) | |
791 | - | then throw("Sale ended.") | |
792 | - | else { | |
793 | - | let bidNbr = getIntegerByKey(("current_bidamount_" + artId)) | |
794 | - | if (!(acceptedAssetIds(assetId))) | |
795 | - | then throw("asset not accepted") | |
796 | - | else if (!(validateMinSell(assetId, amount))) | |
797 | - | then throw("Wrong min sell") | |
798 | - | else { | |
799 | - | let amountSold = getIntegerByKey(keyIssued(issuer, artId)) | |
800 | - | let maxCanSell = getIntegerByKey(keyMaxMint(issuer, artId)) | |
801 | - | if ((0 >= maxCanSell)) | |
802 | - | then throw("No max edition set for this artwork") | |
803 | - | else if ((amountSold >= maxCanSell)) | |
804 | - | then throw("Sold out, you cannot bid") | |
805 | - | else [StringEntry((((((((("bid_" + artId) + "_") + issuer) + "_") + caller) + "_") + id) + "_OPEN"), ((((assetId + "_") + toString(amount)) + "_") + toString(date))), IntegerEntry(("current_bidamount_" + artId), (bidNbr + 1))] | |
806 | - | } | |
807 | - | } | |
808 | - | } | |
809 | - | ||
810 | - | ||
811 | - | ||
812 | - | @Callable(i) | |
813 | - | func acceptBid (artId,issuer,bidId,bidOwner) = { | |
814 | - | let $t03134431384 = idCallerDate(i) | |
815 | - | let id = $t03134431384._1 | |
816 | - | let caller = $t03134431384._2 | |
817 | - | let date = $t03134431384._3 | |
818 | - | if ((caller != issuer)) | |
819 | - | then throw("You cannot do this action") | |
820 | - | else buyMint(i, artId, issuer, bidId, bidOwner) | |
821 | - | } | |
822 | - | ||
823 | - | ||
824 | - | ||
825 | - | @Callable(i) | |
826 | - | func cancelBid (artId,issuer,bidId,bidOwner) = { | |
827 | - | let $t03161031671 = idCallerDate(i) | |
828 | - | let id = $t03161031671._1 | |
829 | - | let caller = $t03161031671._2 | |
830 | - | let date = $t03161031671._3 | |
831 | - | if (if ((caller != bidOwner)) | |
832 | - | then (caller != issuer) | |
833 | - | else false) | |
834 | - | then throw("You cannot do this action") | |
835 | - | else { | |
836 | - | let returnMoneyTo = if ((caller == issuer)) | |
837 | - | then bidOwner | |
838 | - | else caller | |
839 | - | let bidNbr = getIntegerByKey(("current_bidamount_" + artId)) | |
840 | - | let bidDataKey = ((((((("bid_" + artId) + "_") + issuer) + "_") + bidOwner) + "_") + bidId) | |
841 | - | let bidData = getStringByKey((bidDataKey + "_OPEN")) | |
842 | - | if ((bidData == "")) | |
843 | - | then throw("Bid not found") | |
844 | - | else { | |
845 | - | let bidDataArr = split(bidData, "_") | |
846 | - | let assetId = getBidAssetId(bidDataArr[0]) | |
847 | - | let bidStatus = "CANCELED" | |
848 | - | [DeleteEntry((bidDataKey + "_OPEN")), StringEntry(((bidDataKey + "_") + bidStatus), ((bidData + "_") + toString(date))), IntegerEntry(("current_bidamount_" + artId), (bidNbr - 1)), ScriptTransfer(Address(fromBase58String(returnMoneyTo)), parseIntValue(bidDataArr[1]), assetId)] | |
849 | - | } | |
850 | - | } | |
375 | + | func deleteEntry (entry) = { | |
376 | + | let caller = toString(i.caller) | |
377 | + | if ((caller == chris)) | |
378 | + | then [DeleteEntry(entry)] | |
379 | + | else throw("no") | |
851 | 380 | } | |
852 | 381 | ||
853 | 382 | ||
854 | 383 | @Verifier(tx) | |
855 | 384 | func verifier () = match tx { | |
856 | 385 | case inv: InvokeScriptTransaction => | |
857 | - | if (if (if ((inv.function == " | |
386 | + | if (if (if ((inv.function == "registerUser")) | |
858 | 387 | then (inv.dApp == this) | |
859 | 388 | else false) | |
860 | 389 | then (inv.fee == 500000) | |
861 | 390 | else false) | |
862 | - | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[ | |
863 | - | else if (if (if ((inv.function == " | |
391 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[5]))) | |
392 | + | else if (if (if ((inv.function == "updateUser")) | |
864 | 393 | then (inv.dApp == this) | |
865 | 394 | else false) | |
866 | 395 | then (inv.fee == 500000) | |
867 | 396 | else false) | |
868 | - | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[ | |
869 | - | else if (if (if ((inv.function == " | |
397 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[5]))) | |
398 | + | else if (if (if ((inv.function == "setERC20User")) | |
870 | 399 | then (inv.dApp == this) | |
871 | 400 | else false) | |
872 | 401 | then (inv.fee == 500000) | |
873 | 402 | else false) | |
874 | - | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[ | |
403 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(asString(inv.args[2]))) | |
875 | 404 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
876 | 405 | case _ => | |
877 | 406 | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
878 | 407 | } | |
879 | 408 |
github/deemru/w8io/169f3d6 89.99 ms ◑