tx · GimJVshKznLByzmpTeYDp2tUz6hxBzVNwuKrAA4HBHGU 3MvrXJVzDMDcshazxn88FybxHV2JvWQBxTc: -0.01200000 Waves 2022.10.17 13:24 [2276246] smart account 3MvrXJVzDMDcshazxn88FybxHV2JvWQBxTc > SELF 0.00000000 Waves
{ "type": 13, "id": "GimJVshKznLByzmpTeYDp2tUz6hxBzVNwuKrAA4HBHGU", "fee": 1200000, "feeAssetId": null, "timestamp": 1666002288606, "version": 2, "chainId": 84, "sender": "3MvrXJVzDMDcshazxn88FybxHV2JvWQBxTc", "senderPublicKey": "Fq8P5ctrS7PNTX37bWWxvnwoB7C2FaNySZWnRmgPUaDH", "proofs": [ "5oUMn4Xh7m1eyUQMP4foVMGWhhJFGjctUKVXkvqndnTSKrxuLZwa5q7fCbFv2Gee8394sYMVZXhMiWUsvmZgm51o" ], "script": "base64:AAIFAAAAAAAAAEEIAhIDCgEBEgMKAQgSAwoBCBIDCgEIEgMKAQgSAwoBCBIDCgEIEgQKAggIEgMKAQgSAwoBCBIFCgMICAESAwoBCAAAACgBAAAAEGdldFN0cmluZ09yVGhyb3cAAAACAAAAB2FkZHJlc3MAAAADa2V5CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQdAAAAAgUAAAAHYWRkcmVzcwUAAAADa2V5CQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAxDYW4ndCByZWFkICcFAAAAA2tleQIAAAANJyBhdCBhZGRyZXNzIAkABCUAAAABBQAAAAdhZGRyZXNzAQAAABFnZXRJbnRlZ2VyT3JUaHJvdwAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABBoAAAACBQAAAAdhZGRyZXNzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAADENhbid0IHJlYWQgJwUAAAADa2V5AgAAAA0nIGF0IGFkZHJlc3MgCQAEJQAAAAEFAAAAB2FkZHJlc3MBAAAAE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G1hdGNoMAIAAAAFQXNzZXQEAAAABXRva2VuBQAAAAckbWF0Y2gwCQAAAAAAAAIIBQAAAAV0b2tlbgAAAAhxdWFudGl0eQAAAAAAAAAAAQcDAwUAAAAMaXNUb2tlbk93bmVyCQEAAAABIQAAAAEFAAAADWlzVG9rZW5FeGlzdHMHBAAAAA1pc3N1ZU5ld1Rva2VuCQEAAAAPX2lzc3VlTmFtZVRva2VuAAAAAQUAAAAEbmFtZQQAAAAKbmV3VG9rZW5JZAkABDgAAAABCQABkQAAAAIFAAAADWlzc3VlTmV3VG9rZW4AAAAAAAAAAAAEAAAAC25ld1Rva2VuU3RyCQACWAAAAAEFAAAACm5ld1Rva2VuSWQEAAAAF3Jlc3RvcmVOYW1lV2l0aE5ld1Rva2VuCQEAAAAVX3Jlc3RvcmVOYW1lV2l0aFRva2VuAAAAAgUAAAAEbmFtZQUAAAALbmV3VG9rZW5TdHIEAAAAF3RyYW5zZmVyTmV3VG9rZW5Ub093bmVyCQEAAAAVX3RyYW5zZmVyVG9rZW5Ub093bmVyAAAAAgUAAAALbmV3VG9rZW5TdHIFAAAAD25ld093bmVyQWRkcmVzcwkABE4AAAACCQAETgAAAAIFAAAADWlzc3VlTmV3VG9rZW4FAAAAF3Jlc3RvcmVOYW1lV2l0aE5ld1Rva2VuBQAAABd0cmFuc2Zlck5ld1Rva2VuVG9Pd25lcgMDBQAAAAxpc1Rva2VuT3duZXIFAAAACGhhc1Rva2VuBwkAAAIAAAABAgAAABxZb3UgYWxyZWFkeSBvd24gYSBuYW1lIHRva2VuAwkBAAAAASEAAAABBQAAAAhoYXNUb2tlbgkAAAIAAAABAgAAABtZb3UgZG9uJ3QgaGF2ZSBhIG5hbWUgdG9rZW4JAQAAAAlfc2V0T3duZXIAAAACBQAAAARuYW1lBQAAAA9uZXdPd25lckFkZHJlc3MAAAAA11C2UQ==", "height": 2276246, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DNEEQaMgQvw3dX5smj8DtK99VRarHThC7d3rbEWNhx2M Next: J6ptAN81AhnCvVFrodShtQLbVx9xeaR7KW4hdB8pBYHY Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | func getStringOrThrow (address,key) = valueOrErrorMessage(getString(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
5 | 5 | ||
6 | 6 | ||
7 | + | func getIntegerOrThrow (address,key) = valueOrErrorMessage(getInteger(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
8 | + | ||
9 | + | ||
7 | 10 | func parseAddressOrThrow (maybeAddress) = valueOrErrorMessage(addressFromString(maybeAddress), (("Can't parse address from '" + maybeAddress) + "'")) | |
8 | 11 | ||
9 | 12 | ||
10 | - | func key_ | |
13 | + | func key_entity (name,pk,property) = ((((name + "_") + pk) + "_") + property) | |
11 | 14 | ||
12 | 15 | ||
13 | - | ||
16 | + | func key_Token_name (tokenId) = key_entity("Token", tokenId, "name") | |
14 | 17 | ||
15 | - | let registry = parseAddressOrThrow(getStringOrThrow(this, key_registry)) | |
16 | 18 | ||
17 | - | func isAdmin (inv) = (inv.caller == this) | |
19 | + | func key_Name_token (name) = key_entity("Name", name, "token") | |
20 | + | ||
21 | + | ||
22 | + | func key_Name_owner (name) = key_entity("Name", name, "owner") | |
23 | + | ||
24 | + | ||
25 | + | func key_Name_resolver (name) = key_entity("Name", name, "resolver") | |
26 | + | ||
27 | + | ||
28 | + | func key_Name_expiresAt (name) = key_entity("Name", name, "expiresAt") | |
29 | + | ||
30 | + | ||
31 | + | func key_Name_createdAt (name) = key_entity("Name", name, "createdAt") | |
32 | + | ||
33 | + | ||
34 | + | let key_nameTTL = "nameTTL" | |
35 | + | ||
36 | + | let key_controllers = "controllers" | |
37 | + | ||
38 | + | func _setOwner (name,owner) = [StringEntry(key_Name_owner(name), owner)] | |
39 | + | ||
40 | + | ||
41 | + | func _getOwner (name) = getString(this, key_Name_owner(name)) | |
42 | + | ||
43 | + | ||
44 | + | func _setResolver (name,resolver) = [StringEntry(key_Name_resolver(name), resolver)] | |
45 | + | ||
46 | + | ||
47 | + | func _getResolver (name) = getString(this, key_Name_resolver(name)) | |
48 | + | ||
49 | + | ||
50 | + | func _getToken (name) = getString(this, key_Name_token(name)) | |
51 | + | ||
52 | + | ||
53 | + | func _getCreatedAt (name) = getInteger(this, key_Name_createdAt(name)) | |
54 | + | ||
55 | + | ||
56 | + | func _getExpiresAt (name) = getInteger(this, key_Name_expiresAt(name)) | |
57 | + | ||
58 | + | ||
59 | + | func _getControllers () = getString(this, key_controllers) | |
60 | + | ||
61 | + | ||
62 | + | let controllers = match _getControllers() { | |
63 | + | case repr: String => | |
64 | + | split(repr, ",") | |
65 | + | case _ => | |
66 | + | nil | |
67 | + | } | |
68 | + | ||
69 | + | let nameTTL = getIntegerOrThrow(this, key_nameTTL) | |
70 | + | ||
71 | + | func isRegisteredName (name) = isDefined(getString(this, key_Name_token(name))) | |
72 | + | ||
73 | + | ||
74 | + | func isCreatedName (name) = isDefined(_getCreatedAt(name)) | |
75 | + | ||
76 | + | ||
77 | + | func isExpiredName (name) = match _getExpiresAt(name) { | |
78 | + | case expiresAt: Int => | |
79 | + | (lastBlock.timestamp > expiresAt) | |
80 | + | case _ => | |
81 | + | false | |
82 | + | } | |
83 | + | ||
84 | + | ||
85 | + | func isActiveName (name) = if (if (isRegisteredName(name)) | |
86 | + | then isCreatedName(name) | |
87 | + | else false) | |
88 | + | then !(isExpiredName(name)) | |
89 | + | else false | |
90 | + | ||
91 | + | ||
92 | + | func isAvailableName (name) = { | |
93 | + | let symbols = "abcdefghijklmnopqrstuvwxyz1234567890-" | |
94 | + | func validateChars (isValid,char) = if (isValid) | |
95 | + | then contains(symbols, char) | |
96 | + | else false | |
97 | + | ||
98 | + | let isValidName = if (if (if (if (if ((size(name) > 0)) | |
99 | + | then (63 >= size(name)) | |
100 | + | else false) | |
101 | + | then (indexOf(name, "--") != 2) | |
102 | + | else false) | |
103 | + | then (indexOf(name, "-") != 0) | |
104 | + | else false) | |
105 | + | then (lastIndexOf(name, "-") != (size(name) - 1)) | |
106 | + | else false) | |
107 | + | then { | |
108 | + | let $l = split(name, "") | |
109 | + | let $s = size($l) | |
110 | + | let $acc0 = true | |
111 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
112 | + | then $a | |
113 | + | else validateChars($a, $l[$i]) | |
114 | + | ||
115 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
116 | + | then $a | |
117 | + | else throw("List size exceeds 63") | |
118 | + | ||
119 | + | $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) | |
120 | + | } | |
121 | + | else false | |
122 | + | let inUse = if (isRegisteredName(name)) | |
123 | + | then !(isExpiredName(name)) | |
124 | + | else false | |
125 | + | if (!(inUse)) | |
126 | + | then isValidName | |
127 | + | else false | |
128 | + | } | |
18 | 129 | ||
19 | 130 | ||
20 | 131 | func isValidAddress (maybeAddress) = isDefined(addressFromString(maybeAddress)) | |
21 | 132 | ||
22 | 133 | ||
23 | - | func | |
134 | + | func isAdmin (inv) = (inv.caller == this) | |
24 | 135 | ||
25 | 136 | ||
26 | - | func onlyAdmin (inv) = if (isAdmin(inv)) | |
27 | - | then unit | |
28 | - | else throw("Permission denied") | |
137 | + | func isOwner (inv,name) = (toString(inv.caller) == valueOrElse(_getOwner(name), "")) | |
29 | 138 | ||
30 | 139 | ||
31 | - | func _getOwner (name) = match invoke(registry, "owner", [name], nil) { | |
32 | - | case owner: String => | |
33 | - | owner | |
34 | - | case _ => | |
35 | - | unit | |
36 | - | } | |
37 | - | ||
38 | - | ||
39 | - | func _getAddr (name) = valueOrElse(getString(this, key_Name_addr(name)), _getOwner(name)) | |
40 | - | ||
41 | - | ||
42 | - | func _setAddr (name,address) = [StringEntry(key_Name_addr(name), address)] | |
140 | + | func isController (address) = containsElement(controllers, address) | |
43 | 141 | ||
44 | 142 | ||
45 | 143 | func _splitLastLabel (name) = { | |
51 | 149 | } | |
52 | 150 | ||
53 | 151 | ||
54 | - | func _findResolver (name) = { | |
55 | - | let $t016951746 = _splitLastLabel(name) | |
56 | - | let lastLabel = $t016951746._1 | |
57 | - | let restLabels = $t016951746._2 | |
58 | - | if ((size(restLabels) == 0)) | |
59 | - | then $Tuple2(unit, name) | |
60 | - | else match invoke(registry, "resolver", [lastLabel], nil) { | |
61 | - | case resolverAddress: String => | |
62 | - | $Tuple2(addressFromString(resolverAddress), restLabels) | |
63 | - | case _ => | |
64 | - | $Tuple2(unit, name) | |
65 | - | } | |
66 | - | } | |
152 | + | func _issueNameToken (name) = [Issue(if ((size(name) > 16)) | |
153 | + | then (take(name, 15) + "~") | |
154 | + | else take(name, 16), (name + ".waves"), 1, 0, false)] | |
67 | 155 | ||
68 | 156 | ||
69 | - | func _resolve (name,callData) = { | |
70 | - | let $t021242172 = _findResolver(name) | |
71 | - | let resolver = $t021242172._1 | |
72 | - | let restLabels = $t021242172._2 | |
73 | - | let $t021782354 = match callData { | |
74 | - | case _ => | |
75 | - | if (("addr" == $match0)) | |
76 | - | then $Tuple3("addr", [value(restLabels)], _getAddr(name)) | |
77 | - | else $Tuple3(unit, unit, unit) | |
78 | - | } | |
79 | - | let callFunction = $t021782354._1 | |
80 | - | let callArgs = $t021782354._2 | |
81 | - | let returnsDefault = $t021782354._3 | |
82 | - | let supportsInterface = match invoke(value(resolver), "supportsInterface", [callData], nil) { | |
83 | - | case supportsInterface: Boolean => | |
84 | - | supportsInterface | |
85 | - | case _ => | |
86 | - | false | |
87 | - | } | |
88 | - | if (!(isDefined(resolver))) | |
89 | - | then returnsDefault | |
90 | - | else if (!(supportsInterface)) | |
91 | - | then unit | |
92 | - | else match invoke(value(resolver), value(callFunction), value(callArgs), nil) { | |
93 | - | case maybeAddr: String => | |
94 | - | if (isValidAddress(maybeAddr)) | |
95 | - | then maybeAddr | |
96 | - | else unit | |
97 | - | case _ => | |
98 | - | unit | |
99 | - | } | |
100 | - | } | |
157 | + | 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))] | |
158 | + | ||
159 | + | ||
160 | + | func _restoreNameWithToken (name,tokenId) = [StringEntry(key_Name_token(name), tokenId), StringEntry(key_Token_name(tokenId), name)] | |
161 | + | ||
162 | + | ||
163 | + | func _transferTokenToOwner (tokenId,owner) = [ScriptTransfer(parseAddressOrThrow(owner), 1, fromBase58String(tokenId))] | |
164 | + | ||
165 | + | ||
166 | + | func modifiers (validations) = unit | |
167 | + | ||
168 | + | ||
169 | + | func onlyAdmin (inv) = if (isAdmin(inv)) | |
170 | + | then unit | |
171 | + | else throw("Permission denied") | |
172 | + | ||
173 | + | ||
174 | + | func onlyController (inv) = if (if (isAdmin(inv)) | |
175 | + | then true | |
176 | + | else isController(toString(inv.caller))) | |
177 | + | then unit | |
178 | + | else throw("Permission denied") | |
179 | + | ||
180 | + | ||
181 | + | func onlyOwner (inv,name) = if (if (isAdmin(inv)) | |
182 | + | then true | |
183 | + | else isOwner(inv, name)) | |
184 | + | then unit | |
185 | + | else throw("Permission denied") | |
101 | 186 | ||
102 | 187 | ||
103 | 188 | @Callable(inv) | |
104 | - | func init (registryAddress) = valueOrElse(modifiers([onlyAdmin(inv)]), [StringEntry(key_registry, registryAddress)]) | |
189 | + | func init (nameTTL) = valueOrElse(modifiers([onlyAdmin(inv), if ((nameTTL > 0)) | |
190 | + | then unit | |
191 | + | else throw("TTL cannot be negative")]), [IntegerEntry(key_nameTTL, nameTTL)]) | |
105 | 192 | ||
106 | 193 | ||
107 | 194 | ||
108 | 195 | @Callable(inv) | |
109 | - | func supportsInterface (interfaceId) = $Tuple2(nil, ( | |
196 | + | func supportsInterface (interfaceId) = $Tuple2(nil, containsElement(["owner", "resolver", "nameCreated", "nameExpires"], interfaceId)) | |
110 | 197 | ||
111 | 198 | ||
112 | 199 | ||
113 | 200 | @Callable(inv) | |
114 | - | func | |
201 | + | func addController (address) = valueOrElse(modifiers([onlyAdmin(inv), if (isValidAddress(address)) | |
115 | 202 | then unit | |
116 | - | else throw("Name cannot be empty")]), $Tuple2(nil, _resolve(name, "addr"))) | |
203 | + | else throw("Controller must be a valid address"), if (!(isController(address))) | |
204 | + | then unit | |
205 | + | else throw((("Controller `" + address) + "` is already registered"))]), [StringEntry(key_controllers, makeString((controllers :+ address), ","))]) | |
206 | + | ||
207 | + | ||
208 | + | ||
209 | + | @Callable(inv) | |
210 | + | func removeController (address) = valueOrElse(modifiers([onlyAdmin(inv), if (isController(address)) | |
211 | + | then unit | |
212 | + | else throw((("Controller `" + address) + "` is not registered"))]), { | |
213 | + | let controllerIndex = value(indexOf(controllers, address)) | |
214 | + | [StringEntry(key_controllers, makeString(removeByIndex(controllers, controllerIndex), ","))] | |
215 | + | }) | |
216 | + | ||
217 | + | ||
218 | + | ||
219 | + | @Callable(inv) | |
220 | + | func available (name) = $Tuple2(nil, isAvailableName(name)) | |
221 | + | ||
222 | + | ||
223 | + | ||
224 | + | @Callable(inv) | |
225 | + | func owner (name) = $Tuple2(nil, _getOwner(_splitLastLabel(name)._1)) | |
226 | + | ||
227 | + | ||
228 | + | ||
229 | + | @Callable(inv) | |
230 | + | func resolver (name) = $Tuple2(nil, _getResolver(_splitLastLabel(name)._1)) | |
231 | + | ||
232 | + | ||
233 | + | ||
234 | + | @Callable(inv) | |
235 | + | func setResolver (name,resolver) = valueOrElse(modifiers([if (isActiveName(name)) | |
236 | + | then unit | |
237 | + | else throw("Name expired or not registered"), onlyOwner(inv, name), if (isValidAddress(resolver)) | |
238 | + | then unit | |
239 | + | else throw("Resolver must be a valid contract address")]), $Tuple2(nil, _setResolver(name, resolver))) | |
240 | + | ||
241 | + | ||
242 | + | ||
243 | + | @Callable(inv) | |
244 | + | func nameCreated (name) = $Tuple2(nil, _getCreatedAt(_splitLastLabel(name)._1)) | |
245 | + | ||
246 | + | ||
247 | + | ||
248 | + | @Callable(inv) | |
249 | + | func nameExpires (name) = $Tuple2(nil, _getExpiresAt(_splitLastLabel(name)._1)) | |
250 | + | ||
251 | + | ||
252 | + | ||
253 | + | @Callable(inv) | |
254 | + | func register (name,owner,createdAt) = valueOrElse(modifiers([onlyController(inv), if (isAvailableName(name)) | |
255 | + | then unit | |
256 | + | else throw((("`" + name) + "` cannot be registered")), if (isValidAddress(owner)) | |
257 | + | then unit | |
258 | + | else throw("Owner must be a valid address"), if ((createdAt > 0)) | |
259 | + | then unit | |
260 | + | else throw("CreatedAt cannot be negative"), if ((lastBlock.timestamp >= createdAt)) | |
261 | + | then unit | |
262 | + | else throw("CreatedAt cannot be in the future")]), { | |
263 | + | let issueNameToken = _issueNameToken(name) | |
264 | + | let tokenId = calculateAssetId(issueNameToken[0]) | |
265 | + | let tokenStr = toBase58String(tokenId) | |
266 | + | let registerNameWithToken = _registerNameWithToken(name, tokenStr, createdAt) | |
267 | + | let transferTokenToOwner = _transferTokenToOwner(tokenStr, owner) | |
268 | + | let setOwnership = _setOwner(name, owner) | |
269 | + | (((issueNameToken ++ registerNameWithToken) ++ transferTokenToOwner) ++ setOwnership) | |
270 | + | }) | |
271 | + | ||
272 | + | ||
273 | + | ||
274 | + | @Callable(inv) | |
275 | + | func reclaim (name) = valueOrElse(modifiers([if (isActiveName(name)) | |
276 | + | then unit | |
277 | + | else throw((("`" + name) + "` is not active"))]), { | |
278 | + | let newOwner = inv.caller | |
279 | + | let newOwnerAddress = toString(newOwner) | |
280 | + | let tokenStr = valueOrErrorMessage(_getToken(name), (("No token is issued for `" + name) + "`")) | |
281 | + | let tokenId = fromBase58String(tokenStr) | |
282 | + | let hasToken = (assetBalance(newOwner, tokenId) == 1) | |
283 | + | let isTokenOwner = isOwner(inv, name) | |
284 | + | let isTokenExists = match assetInfo(tokenId) { | |
285 | + | case token: Asset => | |
286 | + | (token.quantity == 1) | |
287 | + | case _ => | |
288 | + | false | |
289 | + | } | |
290 | + | if (if (isTokenOwner) | |
291 | + | then !(isTokenExists) | |
292 | + | else false) | |
293 | + | then { | |
294 | + | let issueNewToken = _issueNameToken(name) | |
295 | + | let newTokenId = calculateAssetId(issueNewToken[0]) | |
296 | + | let newTokenStr = toBase58String(newTokenId) | |
297 | + | let restoreNameWithNewToken = _restoreNameWithToken(name, newTokenStr) | |
298 | + | let transferNewTokenToOwner = _transferTokenToOwner(newTokenStr, newOwnerAddress) | |
299 | + | ((issueNewToken ++ restoreNameWithNewToken) ++ transferNewTokenToOwner) | |
300 | + | } | |
301 | + | else if (if (isTokenOwner) | |
302 | + | then hasToken | |
303 | + | else false) | |
304 | + | then throw("You already own a name token") | |
305 | + | else if (!(hasToken)) | |
306 | + | then throw("You don't have a name token") | |
307 | + | else _setOwner(name, newOwnerAddress) | |
308 | + | }) | |
117 | 309 | ||
118 | 310 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getStringOrThrow (address,key) = valueOrErrorMessage(getString(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
5 | 5 | ||
6 | 6 | ||
7 | + | func getIntegerOrThrow (address,key) = valueOrErrorMessage(getInteger(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
8 | + | ||
9 | + | ||
7 | 10 | func parseAddressOrThrow (maybeAddress) = valueOrErrorMessage(addressFromString(maybeAddress), (("Can't parse address from '" + maybeAddress) + "'")) | |
8 | 11 | ||
9 | 12 | ||
10 | - | func key_ | |
13 | + | func key_entity (name,pk,property) = ((((name + "_") + pk) + "_") + property) | |
11 | 14 | ||
12 | 15 | ||
13 | - | ||
16 | + | func key_Token_name (tokenId) = key_entity("Token", tokenId, "name") | |
14 | 17 | ||
15 | - | let registry = parseAddressOrThrow(getStringOrThrow(this, key_registry)) | |
16 | 18 | ||
17 | - | func isAdmin (inv) = (inv.caller == this) | |
19 | + | func key_Name_token (name) = key_entity("Name", name, "token") | |
20 | + | ||
21 | + | ||
22 | + | func key_Name_owner (name) = key_entity("Name", name, "owner") | |
23 | + | ||
24 | + | ||
25 | + | func key_Name_resolver (name) = key_entity("Name", name, "resolver") | |
26 | + | ||
27 | + | ||
28 | + | func key_Name_expiresAt (name) = key_entity("Name", name, "expiresAt") | |
29 | + | ||
30 | + | ||
31 | + | func key_Name_createdAt (name) = key_entity("Name", name, "createdAt") | |
32 | + | ||
33 | + | ||
34 | + | let key_nameTTL = "nameTTL" | |
35 | + | ||
36 | + | let key_controllers = "controllers" | |
37 | + | ||
38 | + | func _setOwner (name,owner) = [StringEntry(key_Name_owner(name), owner)] | |
39 | + | ||
40 | + | ||
41 | + | func _getOwner (name) = getString(this, key_Name_owner(name)) | |
42 | + | ||
43 | + | ||
44 | + | func _setResolver (name,resolver) = [StringEntry(key_Name_resolver(name), resolver)] | |
45 | + | ||
46 | + | ||
47 | + | func _getResolver (name) = getString(this, key_Name_resolver(name)) | |
48 | + | ||
49 | + | ||
50 | + | func _getToken (name) = getString(this, key_Name_token(name)) | |
51 | + | ||
52 | + | ||
53 | + | func _getCreatedAt (name) = getInteger(this, key_Name_createdAt(name)) | |
54 | + | ||
55 | + | ||
56 | + | func _getExpiresAt (name) = getInteger(this, key_Name_expiresAt(name)) | |
57 | + | ||
58 | + | ||
59 | + | func _getControllers () = getString(this, key_controllers) | |
60 | + | ||
61 | + | ||
62 | + | let controllers = match _getControllers() { | |
63 | + | case repr: String => | |
64 | + | split(repr, ",") | |
65 | + | case _ => | |
66 | + | nil | |
67 | + | } | |
68 | + | ||
69 | + | let nameTTL = getIntegerOrThrow(this, key_nameTTL) | |
70 | + | ||
71 | + | func isRegisteredName (name) = isDefined(getString(this, key_Name_token(name))) | |
72 | + | ||
73 | + | ||
74 | + | func isCreatedName (name) = isDefined(_getCreatedAt(name)) | |
75 | + | ||
76 | + | ||
77 | + | func isExpiredName (name) = match _getExpiresAt(name) { | |
78 | + | case expiresAt: Int => | |
79 | + | (lastBlock.timestamp > expiresAt) | |
80 | + | case _ => | |
81 | + | false | |
82 | + | } | |
83 | + | ||
84 | + | ||
85 | + | func isActiveName (name) = if (if (isRegisteredName(name)) | |
86 | + | then isCreatedName(name) | |
87 | + | else false) | |
88 | + | then !(isExpiredName(name)) | |
89 | + | else false | |
90 | + | ||
91 | + | ||
92 | + | func isAvailableName (name) = { | |
93 | + | let symbols = "abcdefghijklmnopqrstuvwxyz1234567890-" | |
94 | + | func validateChars (isValid,char) = if (isValid) | |
95 | + | then contains(symbols, char) | |
96 | + | else false | |
97 | + | ||
98 | + | let isValidName = if (if (if (if (if ((size(name) > 0)) | |
99 | + | then (63 >= size(name)) | |
100 | + | else false) | |
101 | + | then (indexOf(name, "--") != 2) | |
102 | + | else false) | |
103 | + | then (indexOf(name, "-") != 0) | |
104 | + | else false) | |
105 | + | then (lastIndexOf(name, "-") != (size(name) - 1)) | |
106 | + | else false) | |
107 | + | then { | |
108 | + | let $l = split(name, "") | |
109 | + | let $s = size($l) | |
110 | + | let $acc0 = true | |
111 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
112 | + | then $a | |
113 | + | else validateChars($a, $l[$i]) | |
114 | + | ||
115 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
116 | + | then $a | |
117 | + | else throw("List size exceeds 63") | |
118 | + | ||
119 | + | $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) | |
120 | + | } | |
121 | + | else false | |
122 | + | let inUse = if (isRegisteredName(name)) | |
123 | + | then !(isExpiredName(name)) | |
124 | + | else false | |
125 | + | if (!(inUse)) | |
126 | + | then isValidName | |
127 | + | else false | |
128 | + | } | |
18 | 129 | ||
19 | 130 | ||
20 | 131 | func isValidAddress (maybeAddress) = isDefined(addressFromString(maybeAddress)) | |
21 | 132 | ||
22 | 133 | ||
23 | - | func | |
134 | + | func isAdmin (inv) = (inv.caller == this) | |
24 | 135 | ||
25 | 136 | ||
26 | - | func onlyAdmin (inv) = if (isAdmin(inv)) | |
27 | - | then unit | |
28 | - | else throw("Permission denied") | |
137 | + | func isOwner (inv,name) = (toString(inv.caller) == valueOrElse(_getOwner(name), "")) | |
29 | 138 | ||
30 | 139 | ||
31 | - | func _getOwner (name) = match invoke(registry, "owner", [name], nil) { | |
32 | - | case owner: String => | |
33 | - | owner | |
34 | - | case _ => | |
35 | - | unit | |
36 | - | } | |
37 | - | ||
38 | - | ||
39 | - | func _getAddr (name) = valueOrElse(getString(this, key_Name_addr(name)), _getOwner(name)) | |
40 | - | ||
41 | - | ||
42 | - | func _setAddr (name,address) = [StringEntry(key_Name_addr(name), address)] | |
140 | + | func isController (address) = containsElement(controllers, address) | |
43 | 141 | ||
44 | 142 | ||
45 | 143 | func _splitLastLabel (name) = { | |
46 | 144 | let labels = split(name, ".") | |
47 | 145 | let lastIndex = (size(labels) - 1) | |
48 | 146 | let lastLabel = labels[lastIndex] | |
49 | 147 | let restLabels = makeString(removeByIndex(labels, lastIndex), ".") | |
50 | 148 | $Tuple2(lastLabel, restLabels) | |
51 | 149 | } | |
52 | 150 | ||
53 | 151 | ||
54 | - | func _findResolver (name) = { | |
55 | - | let $t016951746 = _splitLastLabel(name) | |
56 | - | let lastLabel = $t016951746._1 | |
57 | - | let restLabels = $t016951746._2 | |
58 | - | if ((size(restLabels) == 0)) | |
59 | - | then $Tuple2(unit, name) | |
60 | - | else match invoke(registry, "resolver", [lastLabel], nil) { | |
61 | - | case resolverAddress: String => | |
62 | - | $Tuple2(addressFromString(resolverAddress), restLabels) | |
63 | - | case _ => | |
64 | - | $Tuple2(unit, name) | |
65 | - | } | |
66 | - | } | |
152 | + | func _issueNameToken (name) = [Issue(if ((size(name) > 16)) | |
153 | + | then (take(name, 15) + "~") | |
154 | + | else take(name, 16), (name + ".waves"), 1, 0, false)] | |
67 | 155 | ||
68 | 156 | ||
69 | - | func _resolve (name,callData) = { | |
70 | - | let $t021242172 = _findResolver(name) | |
71 | - | let resolver = $t021242172._1 | |
72 | - | let restLabels = $t021242172._2 | |
73 | - | let $t021782354 = match callData { | |
74 | - | case _ => | |
75 | - | if (("addr" == $match0)) | |
76 | - | then $Tuple3("addr", [value(restLabels)], _getAddr(name)) | |
77 | - | else $Tuple3(unit, unit, unit) | |
78 | - | } | |
79 | - | let callFunction = $t021782354._1 | |
80 | - | let callArgs = $t021782354._2 | |
81 | - | let returnsDefault = $t021782354._3 | |
82 | - | let supportsInterface = match invoke(value(resolver), "supportsInterface", [callData], nil) { | |
83 | - | case supportsInterface: Boolean => | |
84 | - | supportsInterface | |
85 | - | case _ => | |
86 | - | false | |
87 | - | } | |
88 | - | if (!(isDefined(resolver))) | |
89 | - | then returnsDefault | |
90 | - | else if (!(supportsInterface)) | |
91 | - | then unit | |
92 | - | else match invoke(value(resolver), value(callFunction), value(callArgs), nil) { | |
93 | - | case maybeAddr: String => | |
94 | - | if (isValidAddress(maybeAddr)) | |
95 | - | then maybeAddr | |
96 | - | else unit | |
97 | - | case _ => | |
98 | - | unit | |
99 | - | } | |
100 | - | } | |
157 | + | 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))] | |
158 | + | ||
159 | + | ||
160 | + | func _restoreNameWithToken (name,tokenId) = [StringEntry(key_Name_token(name), tokenId), StringEntry(key_Token_name(tokenId), name)] | |
161 | + | ||
162 | + | ||
163 | + | func _transferTokenToOwner (tokenId,owner) = [ScriptTransfer(parseAddressOrThrow(owner), 1, fromBase58String(tokenId))] | |
164 | + | ||
165 | + | ||
166 | + | func modifiers (validations) = unit | |
167 | + | ||
168 | + | ||
169 | + | func onlyAdmin (inv) = if (isAdmin(inv)) | |
170 | + | then unit | |
171 | + | else throw("Permission denied") | |
172 | + | ||
173 | + | ||
174 | + | func onlyController (inv) = if (if (isAdmin(inv)) | |
175 | + | then true | |
176 | + | else isController(toString(inv.caller))) | |
177 | + | then unit | |
178 | + | else throw("Permission denied") | |
179 | + | ||
180 | + | ||
181 | + | func onlyOwner (inv,name) = if (if (isAdmin(inv)) | |
182 | + | then true | |
183 | + | else isOwner(inv, name)) | |
184 | + | then unit | |
185 | + | else throw("Permission denied") | |
101 | 186 | ||
102 | 187 | ||
103 | 188 | @Callable(inv) | |
104 | - | func init (registryAddress) = valueOrElse(modifiers([onlyAdmin(inv)]), [StringEntry(key_registry, registryAddress)]) | |
189 | + | func init (nameTTL) = valueOrElse(modifiers([onlyAdmin(inv), if ((nameTTL > 0)) | |
190 | + | then unit | |
191 | + | else throw("TTL cannot be negative")]), [IntegerEntry(key_nameTTL, nameTTL)]) | |
105 | 192 | ||
106 | 193 | ||
107 | 194 | ||
108 | 195 | @Callable(inv) | |
109 | - | func supportsInterface (interfaceId) = $Tuple2(nil, ( | |
196 | + | func supportsInterface (interfaceId) = $Tuple2(nil, containsElement(["owner", "resolver", "nameCreated", "nameExpires"], interfaceId)) | |
110 | 197 | ||
111 | 198 | ||
112 | 199 | ||
113 | 200 | @Callable(inv) | |
114 | - | func | |
201 | + | func addController (address) = valueOrElse(modifiers([onlyAdmin(inv), if (isValidAddress(address)) | |
115 | 202 | then unit | |
116 | - | else throw("Name cannot be empty")]), $Tuple2(nil, _resolve(name, "addr"))) | |
203 | + | else throw("Controller must be a valid address"), if (!(isController(address))) | |
204 | + | then unit | |
205 | + | else throw((("Controller `" + address) + "` is already registered"))]), [StringEntry(key_controllers, makeString((controllers :+ address), ","))]) | |
206 | + | ||
207 | + | ||
208 | + | ||
209 | + | @Callable(inv) | |
210 | + | func removeController (address) = valueOrElse(modifiers([onlyAdmin(inv), if (isController(address)) | |
211 | + | then unit | |
212 | + | else throw((("Controller `" + address) + "` is not registered"))]), { | |
213 | + | let controllerIndex = value(indexOf(controllers, address)) | |
214 | + | [StringEntry(key_controllers, makeString(removeByIndex(controllers, controllerIndex), ","))] | |
215 | + | }) | |
216 | + | ||
217 | + | ||
218 | + | ||
219 | + | @Callable(inv) | |
220 | + | func available (name) = $Tuple2(nil, isAvailableName(name)) | |
221 | + | ||
222 | + | ||
223 | + | ||
224 | + | @Callable(inv) | |
225 | + | func owner (name) = $Tuple2(nil, _getOwner(_splitLastLabel(name)._1)) | |
226 | + | ||
227 | + | ||
228 | + | ||
229 | + | @Callable(inv) | |
230 | + | func resolver (name) = $Tuple2(nil, _getResolver(_splitLastLabel(name)._1)) | |
231 | + | ||
232 | + | ||
233 | + | ||
234 | + | @Callable(inv) | |
235 | + | func setResolver (name,resolver) = valueOrElse(modifiers([if (isActiveName(name)) | |
236 | + | then unit | |
237 | + | else throw("Name expired or not registered"), onlyOwner(inv, name), if (isValidAddress(resolver)) | |
238 | + | then unit | |
239 | + | else throw("Resolver must be a valid contract address")]), $Tuple2(nil, _setResolver(name, resolver))) | |
240 | + | ||
241 | + | ||
242 | + | ||
243 | + | @Callable(inv) | |
244 | + | func nameCreated (name) = $Tuple2(nil, _getCreatedAt(_splitLastLabel(name)._1)) | |
245 | + | ||
246 | + | ||
247 | + | ||
248 | + | @Callable(inv) | |
249 | + | func nameExpires (name) = $Tuple2(nil, _getExpiresAt(_splitLastLabel(name)._1)) | |
250 | + | ||
251 | + | ||
252 | + | ||
253 | + | @Callable(inv) | |
254 | + | func register (name,owner,createdAt) = valueOrElse(modifiers([onlyController(inv), if (isAvailableName(name)) | |
255 | + | then unit | |
256 | + | else throw((("`" + name) + "` cannot be registered")), if (isValidAddress(owner)) | |
257 | + | then unit | |
258 | + | else throw("Owner must be a valid address"), if ((createdAt > 0)) | |
259 | + | then unit | |
260 | + | else throw("CreatedAt cannot be negative"), if ((lastBlock.timestamp >= createdAt)) | |
261 | + | then unit | |
262 | + | else throw("CreatedAt cannot be in the future")]), { | |
263 | + | let issueNameToken = _issueNameToken(name) | |
264 | + | let tokenId = calculateAssetId(issueNameToken[0]) | |
265 | + | let tokenStr = toBase58String(tokenId) | |
266 | + | let registerNameWithToken = _registerNameWithToken(name, tokenStr, createdAt) | |
267 | + | let transferTokenToOwner = _transferTokenToOwner(tokenStr, owner) | |
268 | + | let setOwnership = _setOwner(name, owner) | |
269 | + | (((issueNameToken ++ registerNameWithToken) ++ transferTokenToOwner) ++ setOwnership) | |
270 | + | }) | |
271 | + | ||
272 | + | ||
273 | + | ||
274 | + | @Callable(inv) | |
275 | + | func reclaim (name) = valueOrElse(modifiers([if (isActiveName(name)) | |
276 | + | then unit | |
277 | + | else throw((("`" + name) + "` is not active"))]), { | |
278 | + | let newOwner = inv.caller | |
279 | + | let newOwnerAddress = toString(newOwner) | |
280 | + | let tokenStr = valueOrErrorMessage(_getToken(name), (("No token is issued for `" + name) + "`")) | |
281 | + | let tokenId = fromBase58String(tokenStr) | |
282 | + | let hasToken = (assetBalance(newOwner, tokenId) == 1) | |
283 | + | let isTokenOwner = isOwner(inv, name) | |
284 | + | let isTokenExists = match assetInfo(tokenId) { | |
285 | + | case token: Asset => | |
286 | + | (token.quantity == 1) | |
287 | + | case _ => | |
288 | + | false | |
289 | + | } | |
290 | + | if (if (isTokenOwner) | |
291 | + | then !(isTokenExists) | |
292 | + | else false) | |
293 | + | then { | |
294 | + | let issueNewToken = _issueNameToken(name) | |
295 | + | let newTokenId = calculateAssetId(issueNewToken[0]) | |
296 | + | let newTokenStr = toBase58String(newTokenId) | |
297 | + | let restoreNameWithNewToken = _restoreNameWithToken(name, newTokenStr) | |
298 | + | let transferNewTokenToOwner = _transferTokenToOwner(newTokenStr, newOwnerAddress) | |
299 | + | ((issueNewToken ++ restoreNameWithNewToken) ++ transferNewTokenToOwner) | |
300 | + | } | |
301 | + | else if (if (isTokenOwner) | |
302 | + | then hasToken | |
303 | + | else false) | |
304 | + | then throw("You already own a name token") | |
305 | + | else if (!(hasToken)) | |
306 | + | then throw("You don't have a name token") | |
307 | + | else _setOwner(name, newOwnerAddress) | |
308 | + | }) | |
117 | 309 | ||
118 | 310 |
github/deemru/w8io/026f985 42.91 ms ◑