tx · HJs69bGWLZoxDjkYVFWb8CtmkRXR3TQnB3348YFQSrXm 3MvCgypmBZFTRqL5HuRwCgS7maC7Fkv7pZY: -0.01000000 Waves 2022.10.25 12:39 [2287750] smart account 3MvCgypmBZFTRqL5HuRwCgS7maC7Fkv7pZY > SELF 0.00000000 Waves
{ "type": 13, "id": "HJs69bGWLZoxDjkYVFWb8CtmkRXR3TQnB3348YFQSrXm", "fee": 1000000, "feeAssetId": null, "timestamp": 1666690815608, "version": 2, "chainId": 84, "sender": "3MvCgypmBZFTRqL5HuRwCgS7maC7Fkv7pZY", "senderPublicKey": "BqGSAiYghM27RZ2Axx3bmTudq9koHT4575AeK31Wx2Pp", "proofs": [ "564tJsxG5iAYDEoKevyAjpBmipKPXTyQMcazqzmmTLyziaruZ2pqZsyEZk15z1ZhwjWiguNo3R97qgm1ddN9Ambb" ], "script": "base64:AAIFAAAAAAAAACkIAhIDCgEIEgQKAggIEgMKAQgSBAoCCAgSAwoBCBIFCgMICAgSAwoBCAAAABUBAAAAEGdldFN0cmluZ09yVGhyb3cAAAACAAAAB2FkZHJlc3MAAAADa2V5CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQdAAAAAgUAAAAHYWRkcmVzcwUAAAADa2V5CQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAxDYW4ndCByZWFkICcFAAAAA2tleQIAAAANJyBhdCBhZGRyZXNzIAkABCUAAAABBQAAAAdhZGRyZXNzAQAAABFnZXRJbnRlZ2VyT3JUaHJvdwAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABBoAAAACBQAAAAdhZGRyZXNzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAADENhbid0IHJlYWQgJwUAAAADa2V5AgAAAA0nIGF0IGFkZHJlc3MgCQAEJQAAAAEFAAAAB2FkZHJlc3MBAAAAE3BhcnNlQWRkcmVzc09yVGhyb3cAA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0aW1lc3RhbXAFAAAAC25hbWVDcmVhdGVkBwUAAAALbmFtZUNyZWF0ZWQFAAAABHVuaXQFAAAABHVuaXQEAAAAC25hbWVFeHBpcmVzBAAAAAckbWF0Y2gwCQEAAAAXX2NhbGxTdXBwb3J0ZWRJbnRlcmZhY2UAAAADBQAAAApyZWdpc3RyYW50AgAAAA5nZXROYW1lRXhwaXJlcwUAAAAKcmVzdExhYmVscwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAtuYW1lRXhwaXJlcwUAAAAHJG1hdGNoMAMJAABmAAAAAgUAAAALbmFtZUV4cGlyZXMAAAAAAAAAAAAFAAAAC25hbWVFeHBpcmVzBQAAAAR1bml0BQAAAAR1bml0BAAAAAppc1Jvb3ROYW1lAwkAAGYAAAACCQABMQAAAAEFAAAACWxhc3RMYWJlbAAAAAAAAAAAAAkAAAAAAAACCQABMQAAAAEFAAAACnJlc3RMYWJlbHMAAAAAAAAAAAAHAwMFAAAACmlzUm9vdE5hbWUGCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABBQAAAA9tYXliZVJlZ2lzdHJhbnQJAAUUAAAAAgUAAAADbmlsCQAFFgAAAAQFAAAAEXJlZ2lzdHJhbnRBZGRyZXNzBQAAAA5wYXJlbnRSZXNvbHZlcgUAAAANcGFyZW50Q3JlYXRlZAUAAAAEdW5pdAkABRQAAAACBQAAAANuaWwJAAUWAAAABAUAAAAFb3duZXIFAAAACHJlc29sdmVyBQAAAAtuYW1lQ3JlYXRlZAUAAAALbmFtZUV4cGlyZXMAAAAAck3qBw==", "height": 2287750, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HQKJNcgRN3YhsZ2sAG5HFQ6LGi9FbojNaB2yCrm51qis Next: 9KvWEzhLVMZZ5EzZdcz6cpoG6P1KyXzJh34posmuipBP Diff:
Old | New | Differences | |
---|---|---|---|
91 | 91 | ||
92 | 92 | ||
93 | 93 | @Callable(inv) | |
94 | + | func getOwner (node) = $Tuple2(nil, _getOwner(node)) | |
95 | + | ||
96 | + | ||
97 | + | ||
98 | + | @Callable(inv) | |
94 | 99 | func setOwner (node,owner) = valueOrElse(modifiers([onlyOwner(inv, node), if (isValidAddress(owner)) | |
95 | 100 | then unit | |
96 | 101 | else throw("Owner must be a valid address")]), _setOwner(node, owner)) | |
98 | 103 | ||
99 | 104 | ||
100 | 105 | @Callable(inv) | |
101 | - | func owner (node) = $Tuple2(nil, _getOwner(node)) | |
102 | - | ||
103 | - | ||
104 | - | ||
105 | - | @Callable(inv) | |
106 | - | func resolver (node) = $Tuple2(nil, _getResolver(node)) | |
106 | + | func getResolver (node) = $Tuple2(nil, _getResolver(node)) | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
115 | 115 | ||
116 | 116 | ||
117 | 117 | @Callable(inv) | |
118 | - | func | |
118 | + | func getNameCreated (node) = $Tuple2(nil, _getCreatedAt(node)) | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | ||
128 | 128 | func whoIs (name) = valueOrElse(modifiers([if ((size(name) > 0)) | |
129 | 129 | then unit | |
130 | 130 | else throw("Name cannot be empty")]), { | |
131 | - | let $ | |
132 | - | let lastLabel = $ | |
133 | - | let restLabels = $ | |
131 | + | let $t045214572 = _splitLastLabel(name) | |
132 | + | let lastLabel = $t045214572._1 | |
133 | + | let restLabels = $t045214572._2 | |
134 | 134 | let registrantAddress = _getOwner(lastLabel) | |
135 | 135 | let maybeRegistrant = match registrantAddress { | |
136 | 136 | case owner: String => | |
141 | 141 | let registrant = value(maybeRegistrant) | |
142 | 142 | let parentResolver = _getResolver(lastLabel) | |
143 | 143 | let parentCreated = _getCreatedAt(lastLabel) | |
144 | - | let owner = match _callSupportedInterface(registrant, " | |
144 | + | let owner = match _callSupportedInterface(registrant, "getOwner", restLabels) { | |
145 | 145 | case owner: String => | |
146 | 146 | if (isValidAddress(owner)) | |
147 | 147 | then owner | |
149 | 149 | case _ => | |
150 | 150 | unit | |
151 | 151 | } | |
152 | - | let resolver = match _callSupportedInterface(registrant, " | |
152 | + | let resolver = match _callSupportedInterface(registrant, "getResolver", restLabels) { | |
153 | 153 | case resolver: String => | |
154 | 154 | if (isValidAddress(resolver)) | |
155 | 155 | then resolver | |
157 | 157 | case _ => | |
158 | 158 | unit | |
159 | 159 | } | |
160 | - | let nameCreated = match _callSupportedInterface(registrant, " | |
160 | + | let nameCreated = match _callSupportedInterface(registrant, "getNameCreated", restLabels) { | |
161 | 161 | case nameCreated: Int => | |
162 | 162 | if (if ((nameCreated > 0)) | |
163 | 163 | then (lastBlock.timestamp > nameCreated) | |
167 | 167 | case _ => | |
168 | 168 | unit | |
169 | 169 | } | |
170 | - | let nameExpires = match _callSupportedInterface(registrant, " | |
170 | + | let nameExpires = match _callSupportedInterface(registrant, "getNameExpires", restLabels) { | |
171 | 171 | case nameExpires: Int => | |
172 | 172 | if ((nameExpires > 0)) | |
173 | 173 | then nameExpires |
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 getIntegerOrThrow (address,key) = valueOrErrorMessage(getInteger(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func parseAddressOrThrow (maybeAddress) = valueOrErrorMessage(addressFromString(maybeAddress), (("Can't parse address from '" + maybeAddress) + "'")) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func key_entity (name,pk,property) = ((((name + "_") + pk) + "_") + property) | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func key_Name_owner (node) = key_entity("Name", node, "owner") | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func key_Name_resolver (node) = key_entity("Name", node, "resolver") | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func key_Name_createdAt (node) = key_entity("Name", node, "createdAt") | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func _getOwner (node) = getString(this, key_Name_owner(node)) | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func _setOwner (node,owner) = [StringEntry(key_Name_owner(node), owner)] | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func _getResolver (node) = getString(this, key_Name_resolver(node)) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func _setResolver (node,resolver) = [StringEntry(key_Name_resolver(node), resolver)] | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func _getCreatedAt (node) = getInteger(this, key_Name_createdAt(node)) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func _setCreatedAt (node,createdAt) = [IntegerEntry(key_Name_createdAt(node), createdAt)] | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func isAdmin (inv) = (inv.caller == this) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func isOwner (inv,node) = (toString(inv.caller) == valueOrElse(_getOwner(node), "")) | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func isValidAddress (maybeAddress) = isDefined(addressFromString(maybeAddress)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func _splitLastLabel (name) = { | |
53 | 53 | let labels = split(name, ".") | |
54 | 54 | let lastIndex = (size(labels) - 1) | |
55 | 55 | let lastLabel = labels[lastIndex] | |
56 | 56 | let restLabels = makeString(removeByIndex(labels, lastIndex), ".") | |
57 | 57 | $Tuple2(lastLabel, restLabels) | |
58 | 58 | } | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func _callSupportedInterface (registrant,interfaceId,restLabels) = match invoke(registrant, "supportsInterface", [interfaceId], nil) { | |
62 | 62 | case supportsInterface: Boolean => | |
63 | 63 | if (!(supportsInterface)) | |
64 | 64 | then unit | |
65 | 65 | else match invoke(value(registrant), interfaceId, [restLabels], nil) { | |
66 | 66 | case maybeString: String => | |
67 | 67 | maybeString | |
68 | 68 | case maybeInt: Int => | |
69 | 69 | maybeInt | |
70 | 70 | case _ => | |
71 | 71 | unit | |
72 | 72 | } | |
73 | 73 | case _ => | |
74 | 74 | unit | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func modifiers (validations) = unit | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func onlyAdmin (inv) = if (isAdmin(inv)) | |
82 | 82 | then unit | |
83 | 83 | else throw("Permission denied") | |
84 | 84 | ||
85 | 85 | ||
86 | 86 | func onlyOwner (inv,node) = if (if (isAdmin(inv)) | |
87 | 87 | then true | |
88 | 88 | else isOwner(inv, node)) | |
89 | 89 | then unit | |
90 | 90 | else throw("Permission denied") | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | @Callable(inv) | |
94 | + | func getOwner (node) = $Tuple2(nil, _getOwner(node)) | |
95 | + | ||
96 | + | ||
97 | + | ||
98 | + | @Callable(inv) | |
94 | 99 | func setOwner (node,owner) = valueOrElse(modifiers([onlyOwner(inv, node), if (isValidAddress(owner)) | |
95 | 100 | then unit | |
96 | 101 | else throw("Owner must be a valid address")]), _setOwner(node, owner)) | |
97 | 102 | ||
98 | 103 | ||
99 | 104 | ||
100 | 105 | @Callable(inv) | |
101 | - | func owner (node) = $Tuple2(nil, _getOwner(node)) | |
102 | - | ||
103 | - | ||
104 | - | ||
105 | - | @Callable(inv) | |
106 | - | func resolver (node) = $Tuple2(nil, _getResolver(node)) | |
106 | + | func getResolver (node) = $Tuple2(nil, _getResolver(node)) | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | @Callable(inv) | |
111 | 111 | func setResolver (node,resolver) = valueOrElse(modifiers([onlyOwner(inv, node), if (isValidAddress(resolver)) | |
112 | 112 | then unit | |
113 | 113 | else throw("Resolver must be a valid contract address")]), _setResolver(node, resolver)) | |
114 | 114 | ||
115 | 115 | ||
116 | 116 | ||
117 | 117 | @Callable(inv) | |
118 | - | func | |
118 | + | func getNameCreated (node) = $Tuple2(nil, _getCreatedAt(node)) | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | ||
122 | 122 | @Callable(inv) | |
123 | 123 | func setRecord (node,owner,resolver) = valueOrElse(modifiers([onlyAdmin(inv)]), ((_setOwner(node, owner) ++ _setResolver(node, resolver)) ++ _setCreatedAt(node, lastBlock.timestamp))) | |
124 | 124 | ||
125 | 125 | ||
126 | 126 | ||
127 | 127 | @Callable(inv) | |
128 | 128 | func whoIs (name) = valueOrElse(modifiers([if ((size(name) > 0)) | |
129 | 129 | then unit | |
130 | 130 | else throw("Name cannot be empty")]), { | |
131 | - | let $ | |
132 | - | let lastLabel = $ | |
133 | - | let restLabels = $ | |
131 | + | let $t045214572 = _splitLastLabel(name) | |
132 | + | let lastLabel = $t045214572._1 | |
133 | + | let restLabels = $t045214572._2 | |
134 | 134 | let registrantAddress = _getOwner(lastLabel) | |
135 | 135 | let maybeRegistrant = match registrantAddress { | |
136 | 136 | case owner: String => | |
137 | 137 | addressFromString(owner) | |
138 | 138 | case _ => | |
139 | 139 | unit | |
140 | 140 | } | |
141 | 141 | let registrant = value(maybeRegistrant) | |
142 | 142 | let parentResolver = _getResolver(lastLabel) | |
143 | 143 | let parentCreated = _getCreatedAt(lastLabel) | |
144 | - | let owner = match _callSupportedInterface(registrant, " | |
144 | + | let owner = match _callSupportedInterface(registrant, "getOwner", restLabels) { | |
145 | 145 | case owner: String => | |
146 | 146 | if (isValidAddress(owner)) | |
147 | 147 | then owner | |
148 | 148 | else unit | |
149 | 149 | case _ => | |
150 | 150 | unit | |
151 | 151 | } | |
152 | - | let resolver = match _callSupportedInterface(registrant, " | |
152 | + | let resolver = match _callSupportedInterface(registrant, "getResolver", restLabels) { | |
153 | 153 | case resolver: String => | |
154 | 154 | if (isValidAddress(resolver)) | |
155 | 155 | then resolver | |
156 | 156 | else unit | |
157 | 157 | case _ => | |
158 | 158 | unit | |
159 | 159 | } | |
160 | - | let nameCreated = match _callSupportedInterface(registrant, " | |
160 | + | let nameCreated = match _callSupportedInterface(registrant, "getNameCreated", restLabels) { | |
161 | 161 | case nameCreated: Int => | |
162 | 162 | if (if ((nameCreated > 0)) | |
163 | 163 | then (lastBlock.timestamp > nameCreated) | |
164 | 164 | else false) | |
165 | 165 | then nameCreated | |
166 | 166 | else unit | |
167 | 167 | case _ => | |
168 | 168 | unit | |
169 | 169 | } | |
170 | - | let nameExpires = match _callSupportedInterface(registrant, " | |
170 | + | let nameExpires = match _callSupportedInterface(registrant, "getNameExpires", restLabels) { | |
171 | 171 | case nameExpires: Int => | |
172 | 172 | if ((nameExpires > 0)) | |
173 | 173 | then nameExpires | |
174 | 174 | else unit | |
175 | 175 | case _ => | |
176 | 176 | unit | |
177 | 177 | } | |
178 | 178 | let isRootName = if ((size(lastLabel) > 0)) | |
179 | 179 | then (size(restLabels) == 0) | |
180 | 180 | else false | |
181 | 181 | if (if (isRootName) | |
182 | 182 | then true | |
183 | 183 | else !(isDefined(maybeRegistrant))) | |
184 | 184 | then $Tuple2(nil, $Tuple4(registrantAddress, parentResolver, parentCreated, unit)) | |
185 | 185 | else $Tuple2(nil, $Tuple4(owner, resolver, nameCreated, nameExpires)) | |
186 | 186 | }) | |
187 | 187 | ||
188 | 188 |
github/deemru/w8io/169f3d6 41.91 ms ◑