tx · CdzFFy7Pjmgb7jj5GCzknGoAqecURz7aT797X5uWZCFy

3MxquWQhzpqXgbqunnFqHFJXTjasEznd1tN:  -0.01000000 Waves

2022.10.14 12:54 [2271864] smart account 3MxquWQhzpqXgbqunnFqHFJXTjasEznd1tN > SELF 0.00000000 Waves

{ "type": 13, "id": "CdzFFy7Pjmgb7jj5GCzknGoAqecURz7aT797X5uWZCFy", "fee": 1000000, "feeAssetId": null, "timestamp": 1665741328320, "version": 2, "chainId": 84, "sender": "3MxquWQhzpqXgbqunnFqHFJXTjasEznd1tN", "senderPublicKey": "GDjexdefwEhShjRTvHgazn3gTrDo74eHpJCAz14cAEeh", "proofs": [ "4gQB9MMyRZxS6mcAGhexLu5MJTDq9Gm3kn362XBhwezkVzbAMeyxpfAHFXDkJJq5fuXXQap54a4RFbWWot4LH1FB" ], "script": "base64:AAIFAAAAAAAAACkIAhIECgIICBIDCgEIEgQKAggIEgMKAQgSAwoBCBIFCgMICAgSAwoBCAAAABUBAAAAEGdldFN0cmluZ09yVGhyb3cAAAACAAAAB2FkZHJlc3MAAAADa2V5CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQdAAAAAgUAAAAHYWRkcmVzcwUAAAADa2V5CQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAxDYW4ndCByZWFkICcFAAAAA2tleQIAAAANJyBhdCBhZGRyZXNzIAkABCUAAAABBQAAAAdhZGRyZXNzAQAAABFnZXRJbnRlZ2VyT3JUaHJvdwAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABBoAAAACBQAAAAdhZGRyZXNzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAADENhbid0IHJlYWQgJwUAAAADa2V5AgAAAA0nIGF0IGFkZHJlc3MgCQAEJQAAAAEFAAAAB2FkZHJlc3MBAAAAE3BhcnNlQWRkcmVzc09yVGhyb3cAAAABAAAADG1heWJl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AAADG5hbWVDcmVhdGVkXwgFAAAAByRtYXRjaDAAAAACXzMEAAAADG5hbWVFeHBpcmVzXwgFAAAAByRtYXRjaDAAAAACXzQJAAUUAAAAAgUAAAADbmlsCQAFFgAAAAQFAAAAC3JlZ2lzdHJhbnRfBQAAAAlyZXNvbHZlcl8FAAAADG5hbWVDcmVhdGVkXwUAAAAMbmFtZUV4cGlyZXNfCQAFFAAAAAIFAAAAA25pbAUAAAAKcGFyZW50SW5mbwAAAAADRSLl", "height": 2271864, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2DKr2Yn8WA1WGyyLRdQiHUfaEbSP3uBy5s6tXkPrBKMZ Next: 9V5FEWthAjCphmbTpDv41DZXbbycHi4XUooSBUtBDLVJ Diff:
OldNewDifferences
4343 func isAdmin (inv) = (inv.caller == this)
4444
4545
46-func isOwner (inv,node) = (toString(inv.caller) == valueOrErrorMessage(_getOwner(node), (("Owner for the `" + node) + "` was not found")))
46+func isOwner (inv,node) = (toString(inv.caller) == valueOrElse(_getOwner(node), ""))
47+
48+
49+func _splitLastLabel (name) = {
50+ let labels = split(name, ".")
51+ let lastIndex = (size(labels) - 1)
52+ let lastLabel = labels[lastIndex]
53+ let restLabels = makeString(removeByIndex(labels, lastIndex), ".")
54+ $Tuple2(lastLabel, restLabels)
55+ }
56+
57+
58+func _findResolver (name) = {
59+ let $t021972248 = _splitLastLabel(name)
60+ let lastLabel = $t021972248._1
61+ let restLabels = $t021972248._2
62+ match invoke(this, "resolver", [lastLabel], nil) {
63+ case resolverAddress: String =>
64+ $Tuple2(addressFromString(resolverAddress), restLabels)
65+ case _ =>
66+ $Tuple2(unit, name)
67+ }
68+ }
4769
4870
4971 func modifiers (validations) = unit
6183 else throw("Permission denied")
6284
6385
86+func validAddress (address) = if (isDefined(addressFromString(address)))
87+ then unit
88+ else throw("The address must be valid")
89+
90+
6491 @Callable(inv)
65-func setOwner (node,owner) = valueOrElse(modifiers([onlyOwner(inv, node)]), _setOwner(node, owner))
92+func setOwner (node,owner) = valueOrElse(modifiers([onlyOwner(inv, node), validAddress(owner)]), _setOwner(node, owner))
6693
6794
6895
7299
73100
74101 @Callable(inv)
75-func setResolver (node,resolver) = valueOrElse(modifiers([onlyOwner(inv, node)]), _setResolver(node, resolver))
102+func setResolver (node,resolver) = valueOrElse(modifiers([onlyOwner(inv, node), validAddress(resolver)]), _setResolver(node, resolver))
76103
77104
78105
90117 func setRecord (node,owner,resolver) = valueOrElse(modifiers([onlyAdmin(inv)]), ((_setOwner(node, owner) ++ _setResolver(node, resolver)) ++ _setCreatedAt(node, lastBlock.timestamp)))
91118
92119
120+
121+@Callable(inv)
122+func whoIs (name) = valueOrElse(modifiers([if ((size(name) > 0))
123+ then unit
124+ else throw("Name cannot be empty")]), {
125+ let $t040804131 = _splitLastLabel(name)
126+ let lastLabel = $t040804131._1
127+ let restLabels = $t040804131._2
128+ let registrantAddress = _getOwner(lastLabel)
129+ let registrant = match registrantAddress {
130+ case owner: String =>
131+ addressFromString(owner)
132+ case _ =>
133+ unit
134+ }
135+ let resolver = _getResolver(lastLabel)
136+ let nameCreated = _getCreatedAt(lastLabel)
137+ let parentInfo = $Tuple4(registrantAddress, resolver, nameCreated, unit)
138+ let isRootName = if ((size(lastLabel) > 0))
139+ then (size(restLabels) == 0)
140+ else false
141+ let supportsInterface = match invoke(value(registrant), "supportsInterface", ["whoIs"], nil) {
142+ case supportsInterface: Boolean =>
143+ supportsInterface
144+ case _ =>
145+ false
146+ }
147+ if (if (if (isRootName)
148+ then true
149+ else !(isDefined(registrant)))
150+ then true
151+ else !(supportsInterface))
152+ then $Tuple2(nil, parentInfo)
153+ else match invoke(value(registrant), "whoIs", [value(restLabels)], nil) {
154+ case _ =>
155+ if (if (if (if ($isInstanceOf($match0._1, "String"))
156+ then true
157+ else $isInstanceOf($match0._1, "Unit"))
158+ then if (if ($isInstanceOf($match0._2, "String"))
159+ then true
160+ else $isInstanceOf($match0._2, "Unit"))
161+ then if (if ($isInstanceOf($match0._3, "Int"))
162+ then true
163+ else $isInstanceOf($match0._3, "Unit"))
164+ then if ($isInstanceOf($match0._4, "Int"))
165+ then true
166+ else $isInstanceOf($match0._4, "Unit")
167+ else false
168+ else false
169+ else false)
170+ then if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ($isInstanceOf($match0, "(Unit, Unit, Unit, Unit)"))
171+ then true
172+ else $isInstanceOf($match0, "(Unit, Unit, Unit, Int)"))
173+ then true
174+ else $isInstanceOf($match0, "(Unit, Unit, Int, Unit)"))
175+ then true
176+ else $isInstanceOf($match0, "(Unit, Unit, Int, Int)"))
177+ then true
178+ else $isInstanceOf($match0, "(Unit, String, Unit, Unit)"))
179+ then true
180+ else $isInstanceOf($match0, "(Unit, String, Unit, Int)"))
181+ then true
182+ else $isInstanceOf($match0, "(Unit, String, Int, Unit)"))
183+ then true
184+ else $isInstanceOf($match0, "(Unit, String, Int, Int)"))
185+ then true
186+ else $isInstanceOf($match0, "(String, Unit, Unit, Unit)"))
187+ then true
188+ else $isInstanceOf($match0, "(String, Unit, Unit, Int)"))
189+ then true
190+ else $isInstanceOf($match0, "(String, Unit, Int, Unit)"))
191+ then true
192+ else $isInstanceOf($match0, "(String, Unit, Int, Int)"))
193+ then true
194+ else $isInstanceOf($match0, "(String, String, Unit, Unit)"))
195+ then true
196+ else $isInstanceOf($match0, "(String, String, Unit, Int)"))
197+ then true
198+ else $isInstanceOf($match0, "(String, String, Int, Unit)"))
199+ then true
200+ else $isInstanceOf($match0, "(String, String, Int, Int)")
201+ else false)
202+ then {
203+ let registrant_ = $match0._1
204+ let resolver_ = $match0._2
205+ let nameCreated_ = $match0._3
206+ let nameExpires_ = $match0._4
207+ $Tuple2(nil, $Tuple4(registrant_, resolver_, nameCreated_, nameExpires_))
208+ }
209+ else $Tuple2(nil, parentInfo)
210+ }
211+ })
212+
213+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 func getStringOrThrow (address,key) = valueOrErrorMessage(getString(address, key), ((("Can't read '" + key) + "' at address ") + toString(address)))
55
66
77 func getIntegerOrThrow (address,key) = valueOrErrorMessage(getInteger(address, key), ((("Can't read '" + key) + "' at address ") + toString(address)))
88
99
1010 func parseAddressOrThrow (maybeAddress) = valueOrErrorMessage(addressFromString(maybeAddress), (("Can't parse address from '" + maybeAddress) + "'"))
1111
1212
1313 func key_entity (name,pk,property) = ((((name + "_") + pk) + "_") + property)
1414
1515
1616 func key_Name_owner (node) = key_entity("Name", node, "owner")
1717
1818
1919 func key_Name_resolver (node) = key_entity("Name", node, "resolver")
2020
2121
2222 func key_Name_createdAt (node) = key_entity("Name", node, "createdAt")
2323
2424
2525 func _getOwner (node) = getString(this, key_Name_owner(node))
2626
2727
2828 func _setOwner (node,owner) = [StringEntry(key_Name_owner(node), owner)]
2929
3030
3131 func _getResolver (node) = getString(this, key_Name_resolver(node))
3232
3333
3434 func _setResolver (node,resolver) = [StringEntry(key_Name_resolver(node), resolver)]
3535
3636
3737 func _getCreatedAt (node) = getInteger(this, key_Name_createdAt(node))
3838
3939
4040 func _setCreatedAt (node,createdAt) = [IntegerEntry(key_Name_createdAt(node), createdAt)]
4141
4242
4343 func isAdmin (inv) = (inv.caller == this)
4444
4545
46-func isOwner (inv,node) = (toString(inv.caller) == valueOrErrorMessage(_getOwner(node), (("Owner for the `" + node) + "` was not found")))
46+func isOwner (inv,node) = (toString(inv.caller) == valueOrElse(_getOwner(node), ""))
47+
48+
49+func _splitLastLabel (name) = {
50+ let labels = split(name, ".")
51+ let lastIndex = (size(labels) - 1)
52+ let lastLabel = labels[lastIndex]
53+ let restLabels = makeString(removeByIndex(labels, lastIndex), ".")
54+ $Tuple2(lastLabel, restLabels)
55+ }
56+
57+
58+func _findResolver (name) = {
59+ let $t021972248 = _splitLastLabel(name)
60+ let lastLabel = $t021972248._1
61+ let restLabels = $t021972248._2
62+ match invoke(this, "resolver", [lastLabel], nil) {
63+ case resolverAddress: String =>
64+ $Tuple2(addressFromString(resolverAddress), restLabels)
65+ case _ =>
66+ $Tuple2(unit, name)
67+ }
68+ }
4769
4870
4971 func modifiers (validations) = unit
5072
5173
5274 func onlyAdmin (inv) = if (isAdmin(inv))
5375 then unit
5476 else throw("Permission denied")
5577
5678
5779 func onlyOwner (inv,node) = if (if (isAdmin(inv))
5880 then true
5981 else isOwner(inv, node))
6082 then unit
6183 else throw("Permission denied")
6284
6385
86+func validAddress (address) = if (isDefined(addressFromString(address)))
87+ then unit
88+ else throw("The address must be valid")
89+
90+
6491 @Callable(inv)
65-func setOwner (node,owner) = valueOrElse(modifiers([onlyOwner(inv, node)]), _setOwner(node, owner))
92+func setOwner (node,owner) = valueOrElse(modifiers([onlyOwner(inv, node), validAddress(owner)]), _setOwner(node, owner))
6693
6794
6895
6996 @Callable(inv)
7097 func owner (node) = $Tuple2(nil, _getOwner(node))
7198
7299
73100
74101 @Callable(inv)
75-func setResolver (node,resolver) = valueOrElse(modifiers([onlyOwner(inv, node)]), _setResolver(node, resolver))
102+func setResolver (node,resolver) = valueOrElse(modifiers([onlyOwner(inv, node), validAddress(resolver)]), _setResolver(node, resolver))
76103
77104
78105
79106 @Callable(inv)
80107 func resolver (node) = $Tuple2(nil, _getResolver(node))
81108
82109
83110
84111 @Callable(inv)
85112 func nameCreated (node) = $Tuple2(nil, _getCreatedAt(node))
86113
87114
88115
89116 @Callable(inv)
90117 func setRecord (node,owner,resolver) = valueOrElse(modifiers([onlyAdmin(inv)]), ((_setOwner(node, owner) ++ _setResolver(node, resolver)) ++ _setCreatedAt(node, lastBlock.timestamp)))
91118
92119
120+
121+@Callable(inv)
122+func whoIs (name) = valueOrElse(modifiers([if ((size(name) > 0))
123+ then unit
124+ else throw("Name cannot be empty")]), {
125+ let $t040804131 = _splitLastLabel(name)
126+ let lastLabel = $t040804131._1
127+ let restLabels = $t040804131._2
128+ let registrantAddress = _getOwner(lastLabel)
129+ let registrant = match registrantAddress {
130+ case owner: String =>
131+ addressFromString(owner)
132+ case _ =>
133+ unit
134+ }
135+ let resolver = _getResolver(lastLabel)
136+ let nameCreated = _getCreatedAt(lastLabel)
137+ let parentInfo = $Tuple4(registrantAddress, resolver, nameCreated, unit)
138+ let isRootName = if ((size(lastLabel) > 0))
139+ then (size(restLabels) == 0)
140+ else false
141+ let supportsInterface = match invoke(value(registrant), "supportsInterface", ["whoIs"], nil) {
142+ case supportsInterface: Boolean =>
143+ supportsInterface
144+ case _ =>
145+ false
146+ }
147+ if (if (if (isRootName)
148+ then true
149+ else !(isDefined(registrant)))
150+ then true
151+ else !(supportsInterface))
152+ then $Tuple2(nil, parentInfo)
153+ else match invoke(value(registrant), "whoIs", [value(restLabels)], nil) {
154+ case _ =>
155+ if (if (if (if ($isInstanceOf($match0._1, "String"))
156+ then true
157+ else $isInstanceOf($match0._1, "Unit"))
158+ then if (if ($isInstanceOf($match0._2, "String"))
159+ then true
160+ else $isInstanceOf($match0._2, "Unit"))
161+ then if (if ($isInstanceOf($match0._3, "Int"))
162+ then true
163+ else $isInstanceOf($match0._3, "Unit"))
164+ then if ($isInstanceOf($match0._4, "Int"))
165+ then true
166+ else $isInstanceOf($match0._4, "Unit")
167+ else false
168+ else false
169+ else false)
170+ then if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ($isInstanceOf($match0, "(Unit, Unit, Unit, Unit)"))
171+ then true
172+ else $isInstanceOf($match0, "(Unit, Unit, Unit, Int)"))
173+ then true
174+ else $isInstanceOf($match0, "(Unit, Unit, Int, Unit)"))
175+ then true
176+ else $isInstanceOf($match0, "(Unit, Unit, Int, Int)"))
177+ then true
178+ else $isInstanceOf($match0, "(Unit, String, Unit, Unit)"))
179+ then true
180+ else $isInstanceOf($match0, "(Unit, String, Unit, Int)"))
181+ then true
182+ else $isInstanceOf($match0, "(Unit, String, Int, Unit)"))
183+ then true
184+ else $isInstanceOf($match0, "(Unit, String, Int, Int)"))
185+ then true
186+ else $isInstanceOf($match0, "(String, Unit, Unit, Unit)"))
187+ then true
188+ else $isInstanceOf($match0, "(String, Unit, Unit, Int)"))
189+ then true
190+ else $isInstanceOf($match0, "(String, Unit, Int, Unit)"))
191+ then true
192+ else $isInstanceOf($match0, "(String, Unit, Int, Int)"))
193+ then true
194+ else $isInstanceOf($match0, "(String, String, Unit, Unit)"))
195+ then true
196+ else $isInstanceOf($match0, "(String, String, Unit, Int)"))
197+ then true
198+ else $isInstanceOf($match0, "(String, String, Int, Unit)"))
199+ then true
200+ else $isInstanceOf($match0, "(String, String, Int, Int)")
201+ else false)
202+ then {
203+ let registrant_ = $match0._1
204+ let resolver_ = $match0._2
205+ let nameCreated_ = $match0._3
206+ let nameExpires_ = $match0._4
207+ $Tuple2(nil, $Tuple4(registrant_, resolver_, nameCreated_, nameExpires_))
208+ }
209+ else $Tuple2(nil, parentInfo)
210+ }
211+ })
212+
213+

github/deemru/w8io/026f985 
44.58 ms