tx · GXkeD5savvTZaUmHbq9Fvzg34UobRMsdNmEHLGgHgdqJ 3MrF6QFGLaSKfoNPMd8L3u7KYNm7cE43Ydw: -0.01000000 Waves 2022.10.14 13:02 [2271870] smart account 3MrF6QFGLaSKfoNPMd8L3u7KYNm7cE43Ydw > SELF 0.00000000 Waves
{ "type": 13, "id": "GXkeD5savvTZaUmHbq9Fvzg34UobRMsdNmEHLGgHgdqJ", "fee": 1000000, "feeAssetId": null, "timestamp": 1665741759817, "version": 2, "chainId": 84, "sender": "3MrF6QFGLaSKfoNPMd8L3u7KYNm7cE43Ydw", "senderPublicKey": "6NSakbUsm1WyESQ8yj3qpc1kQUfHWNd5C6CHVpbs4X7c", "proofs": [ "4dxbSV3oYmNWuBhMHWNpm2qora94rxN6fWWc2ciicVaqUKUzmFyRJBeshe1kwD5rQyBWVbJ8F1zTFB5jGuHYC6Cv" ], "script": "base64:AAIFAAAAAAAAABEIAhIDCgEIEgMKAQgSAwoBCAAAAAkBAAAAEGdldFN0cmluZ09yVGhyb3cAAAACAAAAB2FkZHJlc3MAAAADa2V5CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQdAAAAAgUAAAAHYWRkcmVzcwUAAAADa2V5CQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAxDYW4ndCByZWFkICcFAAAAA2tleQIAAAANJyBhdCBhZGRyZXNzIAkABCUAAAABBQAAAAdhZGRyZXNzAQAAABNwYXJzZUFkZHJlc3NPclRocm93AAAAAQAAAAxtYXliZUFkZHJlc3MJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABCYAAAABBQAAAAxtYXliZUFkZHJlc3MJAAEsAAAAAgkAASwAAAACAgAAABpDYW4ndCBwYXJzZSBhZGRyZXNzIGZyb20gJwUAAAAMbWF5YmVBZGRyZXNzAgAAAAEnAAAAAAxrZXlfcmVnaXN0cnkCAAAACHJlZ2lzdHJ5AAAAAAhyZWdpc3RyeQkBAAAAE3BhcnNlQWR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2ludgUAAAADbmlsCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIFAAAADGtleV9yZWdpc3RyeQUAAAAPcmVnaXN0cnlBZGRyZXNzBQAAAANuaWwAAAADaW52AQAAAARhZGRyAAAAAQAAAAVsYWJlbAkABRQAAAACBQAAAANuaWwJAQAAAAVfYWRkcgAAAAEFAAAABWxhYmVsAAAAA2ludgEAAAAHcmVzb2x2ZQAAAAEAAAAEbmFtZQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkBAAAACW1vZGlmaWVycwAAAAEJAARMAAAAAgMJAABmAAAAAgkAATEAAAABBQAAAARuYW1lAAAAAAAAAAAABQAAAAR1bml0CQAAAgAAAAECAAAAFE5hbWUgY2Fubm90IGJlIGVtcHR5BQAAAANuaWwEAAAACWxhc3RMYWJlbAgJAQAAAA9fc3BsaXRMYXN0TGFiZWwAAAABBQAAAARuYW1lAAAAAl8xCQAFFAAAAAIFAAAAA25pbAkBAAAABV9hZGRyAAAAAQUAAAAJbGFzdExhYmVsAAAAAG9K5Zs=", "height": 2271870, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2dNL8wTkPethmFkTzpV6TR7ZLzQVPKC2MqjaEUDjnrXS Next: EDzDn558J72E33j4SsXowLKBqT31kfcbCN1dc5P9L26f Diff:
Old | New | Differences | |
---|---|---|---|
30 | 30 | } | |
31 | 31 | ||
32 | 32 | ||
33 | + | func _splitLastLabel (name) = { | |
34 | + | let labels = split(name, ".") | |
35 | + | let lastIndex = (size(labels) - 1) | |
36 | + | let lastLabel = labels[lastIndex] | |
37 | + | let restLabels = makeString(removeByIndex(labels, lastIndex), ".") | |
38 | + | $Tuple2(lastLabel, restLabels) | |
39 | + | } | |
40 | + | ||
41 | + | ||
33 | 42 | @Callable(inv) | |
34 | 43 | func init (registryAddress) = valueOrElse(modifiers([onlyAdmin(inv)]), [StringEntry(key_registry, registryAddress)]) | |
35 | 44 | ||
41 | 50 | ||
42 | 51 | ||
43 | 52 | @Callable(inv) | |
44 | - | func resolve (name) = { | |
45 | - | let labels = if ((size(name) == 0)) | |
46 | - | then throw("Name cannot be empty") | |
47 | - | else split(name, ".") | |
48 | - | let lastLabel = labels[(size(labels) - 1)] | |
49 | - | $Tuple2(nil, _addr(lastLabel)) | |
50 | - | } | |
51 | - | ||
52 | - | ||
53 | - | ||
54 | - | @Callable(inv) | |
55 | - | func whoIs (name) = valueOrElse(modifiers([if ((size(name) > 0)) | |
53 | + | func resolve (name) = valueOrElse(modifiers([if ((size(name) > 0)) | |
56 | 54 | then unit | |
57 | 55 | else throw("Name cannot be empty")]), { | |
58 | - | let labels = split(name, ".") | |
59 | - | let lastLabel = labels[(size(labels) - 1)] | |
60 | - | let registrant = match invoke(registry, "owner", [lastLabel], nil) { | |
61 | - | case owner: String => | |
62 | - | owner | |
63 | - | case _ => | |
64 | - | unit | |
65 | - | } | |
66 | - | let resolver = unit | |
67 | - | let nameCreated = match invoke(registry, "nameCreated", [lastLabel], nil) { | |
68 | - | case createdAt: Int => | |
69 | - | createdAt | |
70 | - | case _ => | |
71 | - | unit | |
72 | - | } | |
73 | - | let nameExpires = match invoke(registry, "nameExpires", [lastLabel], nil) { | |
74 | - | case expiresAt: Int => | |
75 | - | expiresAt | |
76 | - | case _ => | |
77 | - | unit | |
78 | - | } | |
79 | - | let nameStatus = match invoke(registry, "nameStatus", [lastLabel], nil) { | |
80 | - | case status: String => | |
81 | - | status | |
82 | - | case _ => | |
83 | - | unit | |
84 | - | } | |
85 | - | $Tuple2(nil, $Tuple5(registrant, resolver, nameCreated, nameExpires, nameStatus)) | |
56 | + | let lastLabel = _splitLastLabel(name)._1 | |
57 | + | $Tuple2(nil, _addr(lastLabel)) | |
86 | 58 | }) | |
87 | 59 | ||
88 | 60 |
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 | 7 | func parseAddressOrThrow (maybeAddress) = valueOrErrorMessage(addressFromString(maybeAddress), (("Can't parse address from '" + maybeAddress) + "'")) | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | let key_registry = "registry" | |
11 | 11 | ||
12 | 12 | let registry = parseAddressOrThrow(getStringOrThrow(this, key_registry)) | |
13 | 13 | ||
14 | 14 | func isAdmin (inv) = (inv.caller == this) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func modifiers (validations) = unit | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func onlyAdmin (inv) = if (isAdmin(inv)) | |
21 | 21 | then unit | |
22 | 22 | else throw("Permission denied") | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func _addr (label) = match invoke(registry, "owner", [label], nil) { | |
26 | 26 | case owner: String => | |
27 | 27 | owner | |
28 | 28 | case _ => | |
29 | 29 | unit | |
30 | 30 | } | |
31 | 31 | ||
32 | 32 | ||
33 | + | func _splitLastLabel (name) = { | |
34 | + | let labels = split(name, ".") | |
35 | + | let lastIndex = (size(labels) - 1) | |
36 | + | let lastLabel = labels[lastIndex] | |
37 | + | let restLabels = makeString(removeByIndex(labels, lastIndex), ".") | |
38 | + | $Tuple2(lastLabel, restLabels) | |
39 | + | } | |
40 | + | ||
41 | + | ||
33 | 42 | @Callable(inv) | |
34 | 43 | func init (registryAddress) = valueOrElse(modifiers([onlyAdmin(inv)]), [StringEntry(key_registry, registryAddress)]) | |
35 | 44 | ||
36 | 45 | ||
37 | 46 | ||
38 | 47 | @Callable(inv) | |
39 | 48 | func addr (label) = $Tuple2(nil, _addr(label)) | |
40 | 49 | ||
41 | 50 | ||
42 | 51 | ||
43 | 52 | @Callable(inv) | |
44 | - | func resolve (name) = { | |
45 | - | let labels = if ((size(name) == 0)) | |
46 | - | then throw("Name cannot be empty") | |
47 | - | else split(name, ".") | |
48 | - | let lastLabel = labels[(size(labels) - 1)] | |
49 | - | $Tuple2(nil, _addr(lastLabel)) | |
50 | - | } | |
51 | - | ||
52 | - | ||
53 | - | ||
54 | - | @Callable(inv) | |
55 | - | func whoIs (name) = valueOrElse(modifiers([if ((size(name) > 0)) | |
53 | + | func resolve (name) = valueOrElse(modifiers([if ((size(name) > 0)) | |
56 | 54 | then unit | |
57 | 55 | else throw("Name cannot be empty")]), { | |
58 | - | let labels = split(name, ".") | |
59 | - | let lastLabel = labels[(size(labels) - 1)] | |
60 | - | let registrant = match invoke(registry, "owner", [lastLabel], nil) { | |
61 | - | case owner: String => | |
62 | - | owner | |
63 | - | case _ => | |
64 | - | unit | |
65 | - | } | |
66 | - | let resolver = unit | |
67 | - | let nameCreated = match invoke(registry, "nameCreated", [lastLabel], nil) { | |
68 | - | case createdAt: Int => | |
69 | - | createdAt | |
70 | - | case _ => | |
71 | - | unit | |
72 | - | } | |
73 | - | let nameExpires = match invoke(registry, "nameExpires", [lastLabel], nil) { | |
74 | - | case expiresAt: Int => | |
75 | - | expiresAt | |
76 | - | case _ => | |
77 | - | unit | |
78 | - | } | |
79 | - | let nameStatus = match invoke(registry, "nameStatus", [lastLabel], nil) { | |
80 | - | case status: String => | |
81 | - | status | |
82 | - | case _ => | |
83 | - | unit | |
84 | - | } | |
85 | - | $Tuple2(nil, $Tuple5(registrant, resolver, nameCreated, nameExpires, nameStatus)) | |
56 | + | let lastLabel = _splitLastLabel(name)._1 | |
57 | + | $Tuple2(nil, _addr(lastLabel)) | |
86 | 58 | }) | |
87 | 59 | ||
88 | 60 |
github/deemru/w8io/026f985 49.59 ms ◑