tx · 2iENBcQDdDGtr3rHVfWZUoNYGF4WqLPB1xSVRjpcrsvd 3MvrXJVzDMDcshazxn88FybxHV2JvWQBxTc: -0.01100000 Waves 2022.11.30 17:16 [2339943] smart account 3MvrXJVzDMDcshazxn88FybxHV2JvWQBxTc > SELF 0.00000000 Waves
{ "type": 13, "id": "2iENBcQDdDGtr3rHVfWZUoNYGF4WqLPB1xSVRjpcrsvd", "fee": 1100000, "feeAssetId": null, "timestamp": 1669817773500, "version": 2, "chainId": 84, "sender": "3MvrXJVzDMDcshazxn88FybxHV2JvWQBxTc", "senderPublicKey": "Fq8P5ctrS7PNTX37bWWxvnwoB7C2FaNySZWnRmgPUaDH", "proofs": [ "65a4M45kxzvcTMBpGhj854Q8VM5aV7u5rGryxcpVek55CoXQRyCpwvceLWYbEgrxfemSo7wFhcyWCap1wb7CCCs6" ], "script": "base64:AAIFAAAAAAAAAC4IAhIDCgEBEgMKAQgSAwoBCBIDCgEIEgMKAQgSBQoDCAgfEgUKAwgIARIDCgEIAAAAJQEAAAAKa2V5X2VudGl0eQAAAAMAAAAEbmFtZQAAAAJwawAAAAhwcm9wZXJ0eQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAARuYW1lAgAAAAFfBQAAAAJwawIAAAABXwUAAAAIcHJvcGVydHkBAAAADmtleV9Ub2tlbl9uYW1lAAAAAQAAAAd0b2tlbklkCQEAAAAKa2V5X2VudGl0eQAAAAMCAAAABVRva2VuBQAAAAd0b2tlbklkAgAAAARuYW1lAQAAAA5rZXlfTmFtZV90b2tlbgAAAAEAAAAEbmFtZQkBAAAACmtleV9lbnRpdHkAAAADAgAAAAROYW1lBQAAAARuYW1lAgAAAAV0b2tlbgEAAAAOa2V5X05hbWVfb3duZXIAAAABAAAABG5hbWUJAQAAAAprZXlfZW50aXR5AAAAAwIAAAAETmFtZQUAAAAEbmFtZQIAAAAFb3duZXIBAAAAEWtleV9OYW1lX3Jlc29sdmVyAAAAAQAAAARuYW1lCQE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JBZGRyZXNzAAAAAIux30k=", "height": 2339943, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9gPhBgF8CucDsXS1nJwWsSW9W7ACDPx9VSHefMsiGpAz Next: none Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getStringOrThrow (address,key) = valueOrErrorMessage(getString(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
5 | - | ||
6 | - | ||
7 | - | func getIntegerOrThrow (address,key) = valueOrErrorMessage(getInteger(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
8 | - | ||
9 | - | ||
10 | - | func parseAddressOrThrow (maybeAddress) = valueOrErrorMessage(addressFromString(maybeAddress), (("Can't parse address from '" + maybeAddress) + "'")) | |
11 | - | ||
12 | - | ||
13 | 4 | func key_entity (name,pk,property) = ((((name + "_") + pk) + "_") + property) | |
14 | 5 | ||
15 | 6 | ||
20 | 11 | ||
21 | 12 | ||
22 | 13 | func key_Name_owner (name) = key_entity("Name", name, "owner") | |
23 | - | ||
24 | - | ||
25 | - | func key_Name_registrar (name) = key_entity("Name", name, "registrar") | |
26 | 14 | ||
27 | 15 | ||
28 | 16 | func key_Name_resolver (name) = key_entity("Name", name, "resolver") | |
44 | 32 | func _getOwner (name) = getString(this, key_Name_owner(name)) | |
45 | 33 | ||
46 | 34 | ||
47 | - | func _setRegistrar (name,registrar) = [StringEntry(key_Name_registrar(name), registrar)] | |
48 | - | ||
49 | - | ||
50 | - | func _getRegistrar (name) = getString(this, key_Name_registrar(name)) | |
51 | - | ||
52 | - | ||
53 | - | func _setResolver (name,resolver) = [StringEntry(key_Name_resolver(name), resolver)] | |
54 | - | ||
55 | - | ||
56 | 35 | func _getResolver (name) = getString(this, key_Name_resolver(name)) | |
57 | 36 | ||
58 | 37 | ||
65 | 44 | func _getExpiresAt (name) = getInteger(this, key_Name_expiresAt(name)) | |
66 | 45 | ||
67 | 46 | ||
68 | - | func _getControllers () = getString(this, key_controllers) | |
69 | - | ||
70 | - | ||
71 | - | let controllers = match _getControllers() { | |
47 | + | let controllers = match getString(this, key_controllers) { | |
72 | 48 | case repr: String => | |
73 | 49 | split(repr, ",") | |
74 | 50 | case _ => | |
75 | 51 | nil | |
76 | 52 | } | |
77 | 53 | ||
78 | - | let nameTTL = getIntegerOrThrow(this, key_nameTTL) | |
54 | + | let nameTTL = value(getInteger(this, key_nameTTL)) | |
55 | + | ||
56 | + | let isInitialized = isDefined(getInteger(this, key_nameTTL)) | |
79 | 57 | ||
80 | 58 | func isRegisteredName (name) = isDefined(getString(this, key_Name_token(name))) | |
81 | 59 | ||
104 | 82 | then contains(symbols, char) | |
105 | 83 | else false | |
106 | 84 | ||
107 | - | if (if (if (if (if ((size(name) > | |
85 | + | if (if (if (if (if ((size(name) > 3)) | |
108 | 86 | then (63 >= size(name)) | |
109 | 87 | else false) | |
110 | 88 | then (indexOf(name, "--") != 2) | |
132 | 110 | ||
133 | 111 | ||
134 | 112 | func isAvailableName (name) = if (isValidName(name)) | |
135 | - | then if (!(isRegisteredName(name))) | |
136 | - | then true | |
137 | - | else isExpiredName(name) | |
113 | + | then !(isActiveName(name)) | |
138 | 114 | else false | |
139 | 115 | ||
140 | 116 | ||
144 | 120 | func isAdmin (inv) = (inv.caller == this) | |
145 | 121 | ||
146 | 122 | ||
147 | - | func isOwner (inv,name) = (toString(inv. | |
123 | + | func isOwner (inv,name) = (toString(inv.originCaller) == valueOrElse(_getOwner(name), "")) | |
148 | 124 | ||
149 | 125 | ||
150 | 126 | func isController (address) = containsElement(controllers, address) | |
170 | 146 | func _restoreNameWithToken (name,tokenId) = [StringEntry(key_Name_token(name), tokenId), StringEntry(key_Token_name(tokenId), name)] | |
171 | 147 | ||
172 | 148 | ||
173 | - | func _transferTokenToOwner (tokenId,owner) = [ScriptTransfer( | |
149 | + | func _transferTokenToOwner (tokenId,owner) = [ScriptTransfer(addressFromStringValue(owner), 1, fromBase58String(tokenId))] | |
174 | 150 | ||
175 | 151 | ||
176 | 152 | func modifiers (validations) = unit | |
188 | 164 | else throw("Permission denied") | |
189 | 165 | ||
190 | 166 | ||
191 | - | func onlyOwner (inv,name) = if (if (isAdmin(inv)) | |
192 | - | then true | |
193 | - | else isOwner(inv, name)) | |
167 | + | func onlyInitialized () = if (isInitialized) | |
194 | 168 | then unit | |
195 | - | else throw("Permission denied") | |
196 | - | ||
197 | - | ||
198 | - | func _callSupportedInterface (registrant,interfaceId,restLabels) = match invoke(registrant, "supportsInterface", [interfaceId], nil) { | |
199 | - | case supportsInterface: Boolean => | |
200 | - | if (!(supportsInterface)) | |
201 | - | then unit | |
202 | - | else match invoke(registrant, interfaceId, [restLabels], nil) { | |
203 | - | case maybeString: String => | |
204 | - | maybeString | |
205 | - | case maybeInt: Int => | |
206 | - | maybeInt | |
207 | - | case _ => | |
208 | - | unit | |
209 | - | } | |
210 | - | case _ => | |
211 | - | unit | |
212 | - | } | |
169 | + | else throw("Contract is not initialized") | |
213 | 170 | ||
214 | 171 | ||
215 | 172 | @Callable(inv) | |
216 | 173 | func init (nameTTL) = valueOrElse(modifiers([onlyAdmin(inv), if ((nameTTL > 0)) | |
217 | 174 | then unit | |
218 | - | else throw("TTL cannot be negative")]), [IntegerEntry(key_nameTTL, nameTTL)]) | |
219 | - | ||
220 | - | ||
221 | - | ||
222 | - | @Callable(inv) | |
223 | - | func supportsInterface (interfaceId) = $Tuple2(nil, containsElement(["owner", "registrar", "resolver", "nameCreated", "nameExpires"], interfaceId)) | |
175 | + | else throw("TTL cannot be negative"), if (!(isInitialized)) | |
176 | + | then unit | |
177 | + | else throw("Contract has already been initialized")]), [IntegerEntry(key_nameTTL, nameTTL)]) | |
224 | 178 | ||
225 | 179 | ||
226 | 180 | ||
244 | 198 | ||
245 | 199 | ||
246 | 200 | @Callable(inv) | |
247 | - | func | |
201 | + | func isValid (name) = $Tuple2(nil, isValidName(name)) | |
248 | 202 | ||
249 | 203 | ||
250 | 204 | ||
251 | 205 | @Callable(inv) | |
252 | - | func | |
206 | + | func isAvailable (name) = $Tuple2(nil, isAvailableName(name)) | |
253 | 207 | ||
254 | 208 | ||
255 | 209 | ||
256 | 210 | @Callable(inv) | |
257 | - | func owner (name) = { | |
258 | - | let $t079157962 = _splitLastLabel(name) | |
259 | - | let label = $t079157962._1 | |
260 | - | let restLabels = $t079157962._2 | |
261 | - | let ownerAddress = _getOwner(label) | |
262 | - | let registrarAddress = _getRegistrar(label) | |
263 | - | let registrar = value(addressFromString(value(registrarAddress))) | |
264 | - | $Tuple2(nil, if (if ((size(restLabels) == 0)) | |
265 | - | then true | |
266 | - | else !(isDefined(registrarAddress))) | |
267 | - | then ownerAddress | |
268 | - | else match _callSupportedInterface(registrar, "owner", restLabels) { | |
269 | - | case maybeOwner: String => | |
270 | - | if (isValidAddress(maybeOwner)) | |
271 | - | then maybeOwner | |
272 | - | else unit | |
273 | - | case _ => | |
274 | - | unit | |
275 | - | }) | |
211 | + | func resolve (name,interfaceId,args) = { | |
212 | + | let $t065586605 = _splitLastLabel(name) | |
213 | + | let label = $t065586605._1 | |
214 | + | let restLabels = $t065586605._2 | |
215 | + | let owner = _getOwner(label) | |
216 | + | $Tuple2(nil, if ((size(restLabels) != 0)) | |
217 | + | then unit | |
218 | + | else if (containsElement(controllers, owner)) | |
219 | + | then unit | |
220 | + | else match interfaceId { | |
221 | + | case _ => | |
222 | + | if (("owner" == $match0)) | |
223 | + | then owner | |
224 | + | else if (("resolver" == $match0)) | |
225 | + | then _getResolver(label) | |
226 | + | else if (("createdAt" == $match0)) | |
227 | + | then _getCreatedAt(label) | |
228 | + | else if (("expiresAt" == $match0)) | |
229 | + | then _getExpiresAt(label) | |
230 | + | else if (("tokenId" == $match0)) | |
231 | + | then _getToken(label) | |
232 | + | else unit | |
233 | + | }) | |
276 | 234 | } | |
277 | 235 | ||
278 | 236 | ||
279 | 237 | ||
280 | 238 | @Callable(inv) | |
281 | - | func registrar (name) = { | |
282 | - | let $t085918638 = _splitLastLabel(name) | |
283 | - | let label = $t085918638._1 | |
284 | - | let restLabels = $t085918638._2 | |
285 | - | let registrarAddress = match _getRegistrar(label) { | |
286 | - | case maybeRegistrar: String => | |
287 | - | if (isValidAddress(maybeRegistrar)) | |
288 | - | then maybeRegistrar | |
289 | - | else unit | |
290 | - | case _ => | |
291 | - | unit | |
292 | - | } | |
293 | - | let registrar = value(addressFromString(value(registrarAddress))) | |
294 | - | $Tuple2(nil, if (if ((size(restLabels) == 0)) | |
295 | - | then true | |
296 | - | else !(isDefined(registrarAddress))) | |
297 | - | then registrarAddress | |
298 | - | else match _callSupportedInterface(registrar, "registrar", restLabels) { | |
299 | - | case maybeRegistrar: String => | |
300 | - | if (isValidAddress(maybeRegistrar)) | |
301 | - | then maybeRegistrar | |
302 | - | else unit | |
303 | - | case _ => | |
304 | - | unit | |
305 | - | }) | |
306 | - | } | |
307 | - | ||
308 | - | ||
309 | - | ||
310 | - | @Callable(inv) | |
311 | - | func setRegistrar (name,registrar) = valueOrElse(modifiers([if (isActiveName(name)) | |
312 | - | then unit | |
313 | - | else throw("Name expired or not registered"), onlyOwner(inv, name), if (isValidAddress(registrar)) | |
314 | - | then unit | |
315 | - | else throw("Registrar must be a valid contract address")]), _setRegistrar(name, registrar)) | |
316 | - | ||
317 | - | ||
318 | - | ||
319 | - | @Callable(inv) | |
320 | - | func resolver (name) = { | |
321 | - | let $t097969843 = _splitLastLabel(name) | |
322 | - | let label = $t097969843._1 | |
323 | - | let restLabels = $t097969843._2 | |
324 | - | let resolverAddress = _getResolver(label) | |
325 | - | let registrarAddress = _getRegistrar(label) | |
326 | - | let registrar = value(addressFromString(value(registrarAddress))) | |
327 | - | $Tuple2(nil, if (if ((size(restLabels) == 0)) | |
328 | - | then true | |
329 | - | else !(isDefined(registrarAddress))) | |
330 | - | then resolverAddress | |
331 | - | else match _callSupportedInterface(registrar, "resolver", restLabels) { | |
332 | - | case maybeResolver: String => | |
333 | - | if (isValidAddress(maybeResolver)) | |
334 | - | then maybeResolver | |
335 | - | else unit | |
336 | - | case _ => | |
337 | - | unit | |
338 | - | }) | |
339 | - | } | |
340 | - | ||
341 | - | ||
342 | - | ||
343 | - | @Callable(inv) | |
344 | - | func setResolver (name,resolver) = valueOrElse(modifiers([if (isActiveName(name)) | |
345 | - | then unit | |
346 | - | else throw("Name expired or not registered"), onlyOwner(inv, name), if (isValidAddress(resolver)) | |
347 | - | then unit | |
348 | - | else throw("Resolver must be a valid contract address")]), _setResolver(name, resolver)) | |
349 | - | ||
350 | - | ||
351 | - | ||
352 | - | @Callable(inv) | |
353 | - | func nameCreated (name) = { | |
354 | - | let $t01088110928 = _splitLastLabel(name) | |
355 | - | let label = $t01088110928._1 | |
356 | - | let restLabels = $t01088110928._2 | |
357 | - | let nameCreated = _getCreatedAt(label) | |
358 | - | let registrarAddress = _getRegistrar(label) | |
359 | - | let registrar = value(addressFromString(value(registrarAddress))) | |
360 | - | $Tuple2(nil, if (if ((size(restLabels) == 0)) | |
361 | - | then true | |
362 | - | else !(isDefined(registrarAddress))) | |
363 | - | then nameCreated | |
364 | - | else match _callSupportedInterface(registrar, "nameCreated", restLabels) { | |
365 | - | case maybeCreated: Int => | |
366 | - | if (if ((maybeCreated > 0)) | |
367 | - | then (lastBlock.timestamp > maybeCreated) | |
368 | - | else false) | |
369 | - | then maybeCreated | |
370 | - | else unit | |
371 | - | case _ => | |
372 | - | unit | |
373 | - | }) | |
374 | - | } | |
375 | - | ||
376 | - | ||
377 | - | ||
378 | - | @Callable(inv) | |
379 | - | func nameExpires (name) = { | |
380 | - | let $t01159611643 = _splitLastLabel(name) | |
381 | - | let label = $t01159611643._1 | |
382 | - | let restLabels = $t01159611643._2 | |
383 | - | let nameExpires = _getExpiresAt(label) | |
384 | - | let registrarAddress = _getRegistrar(label) | |
385 | - | let registrar = value(addressFromString(value(registrarAddress))) | |
386 | - | $Tuple2(nil, if (if ((size(restLabels) == 0)) | |
387 | - | then true | |
388 | - | else !(isDefined(registrarAddress))) | |
389 | - | then nameExpires | |
390 | - | else match _callSupportedInterface(registrar, "nameExpires", restLabels) { | |
391 | - | case maybeExpires: Int => | |
392 | - | if ((maybeExpires > 0)) | |
393 | - | then maybeExpires | |
394 | - | else unit | |
395 | - | case _ => | |
396 | - | unit | |
397 | - | }) | |
398 | - | } | |
399 | - | ||
400 | - | ||
401 | - | ||
402 | - | @Callable(inv) | |
403 | - | func register (name,owner,createdAt) = valueOrElse(modifiers([onlyController(inv), if (isAvailableName(name)) | |
239 | + | func register (name,owner,createdAt) = valueOrElse(modifiers([onlyInitialized(), onlyController(inv), if (isAvailableName(name)) | |
404 | 240 | then unit | |
405 | 241 | else throw((("`" + name) + "` cannot be registered")), if (isValidAddress(owner)) | |
406 | 242 | then unit | |
407 | 243 | else throw("Owner must be a valid address"), if ((createdAt > 0)) | |
408 | 244 | then unit | |
409 | - | else throw("CreatedAt | |
245 | + | else throw("CreatedAt must be positive"), if ((lastBlock.timestamp >= createdAt)) | |
410 | 246 | then unit | |
411 | 247 | else throw("CreatedAt cannot be in the future")]), { | |
412 | 248 | let issueNameToken = _issueNameToken(name) | |
421 | 257 | ||
422 | 258 | ||
423 | 259 | @Callable(inv) | |
424 | - | func reclaim (name) = valueOrElse(modifiers([if (isActiveName(name)) | |
260 | + | func reclaim (name) = valueOrElse(modifiers([onlyInitialized(), if (isActiveName(name)) | |
425 | 261 | then unit | |
426 | 262 | else throw((("`" + name) + "` is not active"))]), { | |
427 | - | let newOwner = inv. | |
263 | + | let newOwner = inv.originCaller | |
428 | 264 | let newOwnerAddress = toString(newOwner) | |
429 | 265 | let tokenStr = valueOrErrorMessage(_getToken(name), (("No token is issued for `" + name) + "`")) | |
430 | 266 | let tokenId = fromBase58String(tokenStr) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getStringOrThrow (address,key) = valueOrErrorMessage(getString(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
5 | - | ||
6 | - | ||
7 | - | func getIntegerOrThrow (address,key) = valueOrErrorMessage(getInteger(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
8 | - | ||
9 | - | ||
10 | - | func parseAddressOrThrow (maybeAddress) = valueOrErrorMessage(addressFromString(maybeAddress), (("Can't parse address from '" + maybeAddress) + "'")) | |
11 | - | ||
12 | - | ||
13 | 4 | func key_entity (name,pk,property) = ((((name + "_") + pk) + "_") + property) | |
14 | 5 | ||
15 | 6 | ||
16 | 7 | func key_Token_name (tokenId) = key_entity("Token", tokenId, "name") | |
17 | 8 | ||
18 | 9 | ||
19 | 10 | func key_Name_token (name) = key_entity("Name", name, "token") | |
20 | 11 | ||
21 | 12 | ||
22 | 13 | func key_Name_owner (name) = key_entity("Name", name, "owner") | |
23 | - | ||
24 | - | ||
25 | - | func key_Name_registrar (name) = key_entity("Name", name, "registrar") | |
26 | 14 | ||
27 | 15 | ||
28 | 16 | func key_Name_resolver (name) = key_entity("Name", name, "resolver") | |
29 | 17 | ||
30 | 18 | ||
31 | 19 | func key_Name_expiresAt (name) = key_entity("Name", name, "expiresAt") | |
32 | 20 | ||
33 | 21 | ||
34 | 22 | func key_Name_createdAt (name) = key_entity("Name", name, "createdAt") | |
35 | 23 | ||
36 | 24 | ||
37 | 25 | let key_nameTTL = "nameTTL" | |
38 | 26 | ||
39 | 27 | let key_controllers = "controllers" | |
40 | 28 | ||
41 | 29 | func _setOwner (name,owner) = [StringEntry(key_Name_owner(name), owner)] | |
42 | 30 | ||
43 | 31 | ||
44 | 32 | func _getOwner (name) = getString(this, key_Name_owner(name)) | |
45 | 33 | ||
46 | 34 | ||
47 | - | func _setRegistrar (name,registrar) = [StringEntry(key_Name_registrar(name), registrar)] | |
48 | - | ||
49 | - | ||
50 | - | func _getRegistrar (name) = getString(this, key_Name_registrar(name)) | |
51 | - | ||
52 | - | ||
53 | - | func _setResolver (name,resolver) = [StringEntry(key_Name_resolver(name), resolver)] | |
54 | - | ||
55 | - | ||
56 | 35 | func _getResolver (name) = getString(this, key_Name_resolver(name)) | |
57 | 36 | ||
58 | 37 | ||
59 | 38 | func _getToken (name) = getString(this, key_Name_token(name)) | |
60 | 39 | ||
61 | 40 | ||
62 | 41 | func _getCreatedAt (name) = getInteger(this, key_Name_createdAt(name)) | |
63 | 42 | ||
64 | 43 | ||
65 | 44 | func _getExpiresAt (name) = getInteger(this, key_Name_expiresAt(name)) | |
66 | 45 | ||
67 | 46 | ||
68 | - | func _getControllers () = getString(this, key_controllers) | |
69 | - | ||
70 | - | ||
71 | - | let controllers = match _getControllers() { | |
47 | + | let controllers = match getString(this, key_controllers) { | |
72 | 48 | case repr: String => | |
73 | 49 | split(repr, ",") | |
74 | 50 | case _ => | |
75 | 51 | nil | |
76 | 52 | } | |
77 | 53 | ||
78 | - | let nameTTL = getIntegerOrThrow(this, key_nameTTL) | |
54 | + | let nameTTL = value(getInteger(this, key_nameTTL)) | |
55 | + | ||
56 | + | let isInitialized = isDefined(getInteger(this, key_nameTTL)) | |
79 | 57 | ||
80 | 58 | func isRegisteredName (name) = isDefined(getString(this, key_Name_token(name))) | |
81 | 59 | ||
82 | 60 | ||
83 | 61 | func isCreatedName (name) = isDefined(_getCreatedAt(name)) | |
84 | 62 | ||
85 | 63 | ||
86 | 64 | func isExpiredName (name) = match _getExpiresAt(name) { | |
87 | 65 | case expiresAt: Int => | |
88 | 66 | (lastBlock.timestamp > expiresAt) | |
89 | 67 | case _ => | |
90 | 68 | false | |
91 | 69 | } | |
92 | 70 | ||
93 | 71 | ||
94 | 72 | func isActiveName (name) = if (if (isRegisteredName(name)) | |
95 | 73 | then isCreatedName(name) | |
96 | 74 | else false) | |
97 | 75 | then !(isExpiredName(name)) | |
98 | 76 | else false | |
99 | 77 | ||
100 | 78 | ||
101 | 79 | func isValidName (name) = { | |
102 | 80 | let symbols = "abcdefghijklmnopqrstuvwxyz1234567890-" | |
103 | 81 | func validateChars (isValid,char) = if (isValid) | |
104 | 82 | then contains(symbols, char) | |
105 | 83 | else false | |
106 | 84 | ||
107 | - | if (if (if (if (if ((size(name) > | |
85 | + | if (if (if (if (if ((size(name) > 3)) | |
108 | 86 | then (63 >= size(name)) | |
109 | 87 | else false) | |
110 | 88 | then (indexOf(name, "--") != 2) | |
111 | 89 | else false) | |
112 | 90 | then (indexOf(name, "-") != 0) | |
113 | 91 | else false) | |
114 | 92 | then (lastIndexOf(name, "-") != (size(name) - 1)) | |
115 | 93 | else false) | |
116 | 94 | then { | |
117 | 95 | let $l = split(name, "") | |
118 | 96 | let $s = size($l) | |
119 | 97 | let $acc0 = true | |
120 | 98 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
121 | 99 | then $a | |
122 | 100 | else validateChars($a, $l[$i]) | |
123 | 101 | ||
124 | 102 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
125 | 103 | then $a | |
126 | 104 | else throw("List size exceeds 63") | |
127 | 105 | ||
128 | 106 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56), 57), 58), 59), 60), 61), 62), 63) | |
129 | 107 | } | |
130 | 108 | else false | |
131 | 109 | } | |
132 | 110 | ||
133 | 111 | ||
134 | 112 | func isAvailableName (name) = if (isValidName(name)) | |
135 | - | then if (!(isRegisteredName(name))) | |
136 | - | then true | |
137 | - | else isExpiredName(name) | |
113 | + | then !(isActiveName(name)) | |
138 | 114 | else false | |
139 | 115 | ||
140 | 116 | ||
141 | 117 | func isValidAddress (maybeAddress) = isDefined(addressFromString(maybeAddress)) | |
142 | 118 | ||
143 | 119 | ||
144 | 120 | func isAdmin (inv) = (inv.caller == this) | |
145 | 121 | ||
146 | 122 | ||
147 | - | func isOwner (inv,name) = (toString(inv. | |
123 | + | func isOwner (inv,name) = (toString(inv.originCaller) == valueOrElse(_getOwner(name), "")) | |
148 | 124 | ||
149 | 125 | ||
150 | 126 | func isController (address) = containsElement(controllers, address) | |
151 | 127 | ||
152 | 128 | ||
153 | 129 | func _splitLastLabel (name) = { | |
154 | 130 | let labels = split(name, ".") | |
155 | 131 | let lastIndex = (size(labels) - 1) | |
156 | 132 | let lastLabel = labels[lastIndex] | |
157 | 133 | let restLabels = makeString(removeByIndex(labels, lastIndex), ".") | |
158 | 134 | $Tuple2(lastLabel, restLabels) | |
159 | 135 | } | |
160 | 136 | ||
161 | 137 | ||
162 | 138 | func _issueNameToken (name) = [Issue(if ((size(name) > 16)) | |
163 | 139 | then (take(name, 15) + "~") | |
164 | 140 | else take(name, 16), (name + ".waves"), 1, 0, false)] | |
165 | 141 | ||
166 | 142 | ||
167 | 143 | func _registerNameWithToken (name,tokenId,createdAt) = [StringEntry(key_Name_token(name), tokenId), StringEntry(key_Token_name(tokenId), name), IntegerEntry(key_Name_createdAt(name), createdAt), IntegerEntry(key_Name_expiresAt(name), (createdAt + nameTTL))] | |
168 | 144 | ||
169 | 145 | ||
170 | 146 | func _restoreNameWithToken (name,tokenId) = [StringEntry(key_Name_token(name), tokenId), StringEntry(key_Token_name(tokenId), name)] | |
171 | 147 | ||
172 | 148 | ||
173 | - | func _transferTokenToOwner (tokenId,owner) = [ScriptTransfer( | |
149 | + | func _transferTokenToOwner (tokenId,owner) = [ScriptTransfer(addressFromStringValue(owner), 1, fromBase58String(tokenId))] | |
174 | 150 | ||
175 | 151 | ||
176 | 152 | func modifiers (validations) = unit | |
177 | 153 | ||
178 | 154 | ||
179 | 155 | func onlyAdmin (inv) = if (isAdmin(inv)) | |
180 | 156 | then unit | |
181 | 157 | else throw("Permission denied") | |
182 | 158 | ||
183 | 159 | ||
184 | 160 | func onlyController (inv) = if (if (isAdmin(inv)) | |
185 | 161 | then true | |
186 | 162 | else isController(toString(inv.caller))) | |
187 | 163 | then unit | |
188 | 164 | else throw("Permission denied") | |
189 | 165 | ||
190 | 166 | ||
191 | - | func onlyOwner (inv,name) = if (if (isAdmin(inv)) | |
192 | - | then true | |
193 | - | else isOwner(inv, name)) | |
167 | + | func onlyInitialized () = if (isInitialized) | |
194 | 168 | then unit | |
195 | - | else throw("Permission denied") | |
196 | - | ||
197 | - | ||
198 | - | func _callSupportedInterface (registrant,interfaceId,restLabels) = match invoke(registrant, "supportsInterface", [interfaceId], nil) { | |
199 | - | case supportsInterface: Boolean => | |
200 | - | if (!(supportsInterface)) | |
201 | - | then unit | |
202 | - | else match invoke(registrant, interfaceId, [restLabels], nil) { | |
203 | - | case maybeString: String => | |
204 | - | maybeString | |
205 | - | case maybeInt: Int => | |
206 | - | maybeInt | |
207 | - | case _ => | |
208 | - | unit | |
209 | - | } | |
210 | - | case _ => | |
211 | - | unit | |
212 | - | } | |
169 | + | else throw("Contract is not initialized") | |
213 | 170 | ||
214 | 171 | ||
215 | 172 | @Callable(inv) | |
216 | 173 | func init (nameTTL) = valueOrElse(modifiers([onlyAdmin(inv), if ((nameTTL > 0)) | |
217 | 174 | then unit | |
218 | - | else throw("TTL cannot be negative")]), [IntegerEntry(key_nameTTL, nameTTL)]) | |
219 | - | ||
220 | - | ||
221 | - | ||
222 | - | @Callable(inv) | |
223 | - | func supportsInterface (interfaceId) = $Tuple2(nil, containsElement(["owner", "registrar", "resolver", "nameCreated", "nameExpires"], interfaceId)) | |
175 | + | else throw("TTL cannot be negative"), if (!(isInitialized)) | |
176 | + | then unit | |
177 | + | else throw("Contract has already been initialized")]), [IntegerEntry(key_nameTTL, nameTTL)]) | |
224 | 178 | ||
225 | 179 | ||
226 | 180 | ||
227 | 181 | @Callable(inv) | |
228 | 182 | func addController (address) = valueOrElse(modifiers([onlyAdmin(inv), if (isValidAddress(address)) | |
229 | 183 | then unit | |
230 | 184 | else throw("Controller must be a valid address"), if (!(isController(address))) | |
231 | 185 | then unit | |
232 | 186 | else throw((("Controller `" + address) + "` is already registered"))]), [StringEntry(key_controllers, makeString((controllers :+ address), ","))]) | |
233 | 187 | ||
234 | 188 | ||
235 | 189 | ||
236 | 190 | @Callable(inv) | |
237 | 191 | func removeController (address) = valueOrElse(modifiers([onlyAdmin(inv), if (isController(address)) | |
238 | 192 | then unit | |
239 | 193 | else throw((("Controller `" + address) + "` is not registered"))]), { | |
240 | 194 | let controllerIndex = value(indexOf(controllers, address)) | |
241 | 195 | [StringEntry(key_controllers, makeString(removeByIndex(controllers, controllerIndex), ","))] | |
242 | 196 | }) | |
243 | 197 | ||
244 | 198 | ||
245 | 199 | ||
246 | 200 | @Callable(inv) | |
247 | - | func | |
201 | + | func isValid (name) = $Tuple2(nil, isValidName(name)) | |
248 | 202 | ||
249 | 203 | ||
250 | 204 | ||
251 | 205 | @Callable(inv) | |
252 | - | func | |
206 | + | func isAvailable (name) = $Tuple2(nil, isAvailableName(name)) | |
253 | 207 | ||
254 | 208 | ||
255 | 209 | ||
256 | 210 | @Callable(inv) | |
257 | - | func owner (name) = { | |
258 | - | let $t079157962 = _splitLastLabel(name) | |
259 | - | let label = $t079157962._1 | |
260 | - | let restLabels = $t079157962._2 | |
261 | - | let ownerAddress = _getOwner(label) | |
262 | - | let registrarAddress = _getRegistrar(label) | |
263 | - | let registrar = value(addressFromString(value(registrarAddress))) | |
264 | - | $Tuple2(nil, if (if ((size(restLabels) == 0)) | |
265 | - | then true | |
266 | - | else !(isDefined(registrarAddress))) | |
267 | - | then ownerAddress | |
268 | - | else match _callSupportedInterface(registrar, "owner", restLabels) { | |
269 | - | case maybeOwner: String => | |
270 | - | if (isValidAddress(maybeOwner)) | |
271 | - | then maybeOwner | |
272 | - | else unit | |
273 | - | case _ => | |
274 | - | unit | |
275 | - | }) | |
211 | + | func resolve (name,interfaceId,args) = { | |
212 | + | let $t065586605 = _splitLastLabel(name) | |
213 | + | let label = $t065586605._1 | |
214 | + | let restLabels = $t065586605._2 | |
215 | + | let owner = _getOwner(label) | |
216 | + | $Tuple2(nil, if ((size(restLabels) != 0)) | |
217 | + | then unit | |
218 | + | else if (containsElement(controllers, owner)) | |
219 | + | then unit | |
220 | + | else match interfaceId { | |
221 | + | case _ => | |
222 | + | if (("owner" == $match0)) | |
223 | + | then owner | |
224 | + | else if (("resolver" == $match0)) | |
225 | + | then _getResolver(label) | |
226 | + | else if (("createdAt" == $match0)) | |
227 | + | then _getCreatedAt(label) | |
228 | + | else if (("expiresAt" == $match0)) | |
229 | + | then _getExpiresAt(label) | |
230 | + | else if (("tokenId" == $match0)) | |
231 | + | then _getToken(label) | |
232 | + | else unit | |
233 | + | }) | |
276 | 234 | } | |
277 | 235 | ||
278 | 236 | ||
279 | 237 | ||
280 | 238 | @Callable(inv) | |
281 | - | func registrar (name) = { | |
282 | - | let $t085918638 = _splitLastLabel(name) | |
283 | - | let label = $t085918638._1 | |
284 | - | let restLabels = $t085918638._2 | |
285 | - | let registrarAddress = match _getRegistrar(label) { | |
286 | - | case maybeRegistrar: String => | |
287 | - | if (isValidAddress(maybeRegistrar)) | |
288 | - | then maybeRegistrar | |
289 | - | else unit | |
290 | - | case _ => | |
291 | - | unit | |
292 | - | } | |
293 | - | let registrar = value(addressFromString(value(registrarAddress))) | |
294 | - | $Tuple2(nil, if (if ((size(restLabels) == 0)) | |
295 | - | then true | |
296 | - | else !(isDefined(registrarAddress))) | |
297 | - | then registrarAddress | |
298 | - | else match _callSupportedInterface(registrar, "registrar", restLabels) { | |
299 | - | case maybeRegistrar: String => | |
300 | - | if (isValidAddress(maybeRegistrar)) | |
301 | - | then maybeRegistrar | |
302 | - | else unit | |
303 | - | case _ => | |
304 | - | unit | |
305 | - | }) | |
306 | - | } | |
307 | - | ||
308 | - | ||
309 | - | ||
310 | - | @Callable(inv) | |
311 | - | func setRegistrar (name,registrar) = valueOrElse(modifiers([if (isActiveName(name)) | |
312 | - | then unit | |
313 | - | else throw("Name expired or not registered"), onlyOwner(inv, name), if (isValidAddress(registrar)) | |
314 | - | then unit | |
315 | - | else throw("Registrar must be a valid contract address")]), _setRegistrar(name, registrar)) | |
316 | - | ||
317 | - | ||
318 | - | ||
319 | - | @Callable(inv) | |
320 | - | func resolver (name) = { | |
321 | - | let $t097969843 = _splitLastLabel(name) | |
322 | - | let label = $t097969843._1 | |
323 | - | let restLabels = $t097969843._2 | |
324 | - | let resolverAddress = _getResolver(label) | |
325 | - | let registrarAddress = _getRegistrar(label) | |
326 | - | let registrar = value(addressFromString(value(registrarAddress))) | |
327 | - | $Tuple2(nil, if (if ((size(restLabels) == 0)) | |
328 | - | then true | |
329 | - | else !(isDefined(registrarAddress))) | |
330 | - | then resolverAddress | |
331 | - | else match _callSupportedInterface(registrar, "resolver", restLabels) { | |
332 | - | case maybeResolver: String => | |
333 | - | if (isValidAddress(maybeResolver)) | |
334 | - | then maybeResolver | |
335 | - | else unit | |
336 | - | case _ => | |
337 | - | unit | |
338 | - | }) | |
339 | - | } | |
340 | - | ||
341 | - | ||
342 | - | ||
343 | - | @Callable(inv) | |
344 | - | func setResolver (name,resolver) = valueOrElse(modifiers([if (isActiveName(name)) | |
345 | - | then unit | |
346 | - | else throw("Name expired or not registered"), onlyOwner(inv, name), if (isValidAddress(resolver)) | |
347 | - | then unit | |
348 | - | else throw("Resolver must be a valid contract address")]), _setResolver(name, resolver)) | |
349 | - | ||
350 | - | ||
351 | - | ||
352 | - | @Callable(inv) | |
353 | - | func nameCreated (name) = { | |
354 | - | let $t01088110928 = _splitLastLabel(name) | |
355 | - | let label = $t01088110928._1 | |
356 | - | let restLabels = $t01088110928._2 | |
357 | - | let nameCreated = _getCreatedAt(label) | |
358 | - | let registrarAddress = _getRegistrar(label) | |
359 | - | let registrar = value(addressFromString(value(registrarAddress))) | |
360 | - | $Tuple2(nil, if (if ((size(restLabels) == 0)) | |
361 | - | then true | |
362 | - | else !(isDefined(registrarAddress))) | |
363 | - | then nameCreated | |
364 | - | else match _callSupportedInterface(registrar, "nameCreated", restLabels) { | |
365 | - | case maybeCreated: Int => | |
366 | - | if (if ((maybeCreated > 0)) | |
367 | - | then (lastBlock.timestamp > maybeCreated) | |
368 | - | else false) | |
369 | - | then maybeCreated | |
370 | - | else unit | |
371 | - | case _ => | |
372 | - | unit | |
373 | - | }) | |
374 | - | } | |
375 | - | ||
376 | - | ||
377 | - | ||
378 | - | @Callable(inv) | |
379 | - | func nameExpires (name) = { | |
380 | - | let $t01159611643 = _splitLastLabel(name) | |
381 | - | let label = $t01159611643._1 | |
382 | - | let restLabels = $t01159611643._2 | |
383 | - | let nameExpires = _getExpiresAt(label) | |
384 | - | let registrarAddress = _getRegistrar(label) | |
385 | - | let registrar = value(addressFromString(value(registrarAddress))) | |
386 | - | $Tuple2(nil, if (if ((size(restLabels) == 0)) | |
387 | - | then true | |
388 | - | else !(isDefined(registrarAddress))) | |
389 | - | then nameExpires | |
390 | - | else match _callSupportedInterface(registrar, "nameExpires", restLabels) { | |
391 | - | case maybeExpires: Int => | |
392 | - | if ((maybeExpires > 0)) | |
393 | - | then maybeExpires | |
394 | - | else unit | |
395 | - | case _ => | |
396 | - | unit | |
397 | - | }) | |
398 | - | } | |
399 | - | ||
400 | - | ||
401 | - | ||
402 | - | @Callable(inv) | |
403 | - | func register (name,owner,createdAt) = valueOrElse(modifiers([onlyController(inv), if (isAvailableName(name)) | |
239 | + | func register (name,owner,createdAt) = valueOrElse(modifiers([onlyInitialized(), onlyController(inv), if (isAvailableName(name)) | |
404 | 240 | then unit | |
405 | 241 | else throw((("`" + name) + "` cannot be registered")), if (isValidAddress(owner)) | |
406 | 242 | then unit | |
407 | 243 | else throw("Owner must be a valid address"), if ((createdAt > 0)) | |
408 | 244 | then unit | |
409 | - | else throw("CreatedAt | |
245 | + | else throw("CreatedAt must be positive"), if ((lastBlock.timestamp >= createdAt)) | |
410 | 246 | then unit | |
411 | 247 | else throw("CreatedAt cannot be in the future")]), { | |
412 | 248 | let issueNameToken = _issueNameToken(name) | |
413 | 249 | let tokenId = calculateAssetId(issueNameToken[0]) | |
414 | 250 | let tokenStr = toBase58String(tokenId) | |
415 | 251 | let registerNameWithToken = _registerNameWithToken(name, tokenStr, createdAt) | |
416 | 252 | let transferTokenToOwner = _transferTokenToOwner(tokenStr, owner) | |
417 | 253 | let setOwnership = _setOwner(name, owner) | |
418 | 254 | (((issueNameToken ++ registerNameWithToken) ++ transferTokenToOwner) ++ setOwnership) | |
419 | 255 | }) | |
420 | 256 | ||
421 | 257 | ||
422 | 258 | ||
423 | 259 | @Callable(inv) | |
424 | - | func reclaim (name) = valueOrElse(modifiers([if (isActiveName(name)) | |
260 | + | func reclaim (name) = valueOrElse(modifiers([onlyInitialized(), if (isActiveName(name)) | |
425 | 261 | then unit | |
426 | 262 | else throw((("`" + name) + "` is not active"))]), { | |
427 | - | let newOwner = inv. | |
263 | + | let newOwner = inv.originCaller | |
428 | 264 | let newOwnerAddress = toString(newOwner) | |
429 | 265 | let tokenStr = valueOrErrorMessage(_getToken(name), (("No token is issued for `" + name) + "`")) | |
430 | 266 | let tokenId = fromBase58String(tokenStr) | |
431 | 267 | let hasToken = (assetBalance(newOwner, tokenId) == 1) | |
432 | 268 | let isTokenOwner = isOwner(inv, name) | |
433 | 269 | let isTokenExists = match assetInfo(tokenId) { | |
434 | 270 | case token: Asset => | |
435 | 271 | (token.quantity == 1) | |
436 | 272 | case _ => | |
437 | 273 | false | |
438 | 274 | } | |
439 | 275 | if (if (isTokenOwner) | |
440 | 276 | then !(isTokenExists) | |
441 | 277 | else false) | |
442 | 278 | then { | |
443 | 279 | let issueNewToken = _issueNameToken(name) | |
444 | 280 | let newTokenId = calculateAssetId(issueNewToken[0]) | |
445 | 281 | let newTokenStr = toBase58String(newTokenId) | |
446 | 282 | let restoreNameWithNewToken = _restoreNameWithToken(name, newTokenStr) | |
447 | 283 | let transferNewTokenToOwner = _transferTokenToOwner(newTokenStr, newOwnerAddress) | |
448 | 284 | ((issueNewToken ++ restoreNameWithNewToken) ++ transferNewTokenToOwner) | |
449 | 285 | } | |
450 | 286 | else if (if (isTokenOwner) | |
451 | 287 | then hasToken | |
452 | 288 | else false) | |
453 | 289 | then throw("You already own a name token") | |
454 | 290 | else if (!(hasToken)) | |
455 | 291 | then throw("You don't have a name token") | |
456 | 292 | else _setOwner(name, newOwnerAddress) | |
457 | 293 | }) | |
458 | 294 | ||
459 | 295 |
github/deemru/w8io/026f985 67.24 ms ◑