tx · HDyUfaRxWPV3FKrdF6et8zv8SLf3T75DAJ9jedtmEdk5

3MvCgypmBZFTRqL5HuRwCgS7maC7Fkv7pZY:  -0.01000000 Waves

2022.10.17 10:46 [2276085] smart account 3MvCgypmBZFTRqL5HuRwCgS7maC7Fkv7pZY > SELF 0.00000000 Waves

{ "type": 13, "id": "HDyUfaRxWPV3FKrdF6et8zv8SLf3T75DAJ9jedtmEdk5", "fee": 1000000, "feeAssetId": null, "timestamp": 1665992854248, "version": 2, "chainId": 84, "sender": "3MvCgypmBZFTRqL5HuRwCgS7maC7Fkv7pZY", "senderPublicKey": "BqGSAiYghM27RZ2Axx3bmTudq9koHT4575AeK31Wx2Pp", "proofs": [ "5XN8VymjZsYHCf2z1ck77JZKj8YoQjfyfMZkWmpEsF98xN4Ngh4rzHyJdfjjZV2cCDuNo6ZdK1HoPriQ39pK3NUn" ], "script": "base64:AAIFAAAAAAAAACkIAhIECgIICBIDCgEIEgMKAQgSBAoCCAgSAwoBCBIFCgMICAgSAwoBCAAAABYBAAAAEGdldFN0cmluZ09yVGhyb3cAAAACAAAAB2FkZHJlc3MAAAADa2V5CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQdAAAAAgUAAAAHYWRkcmVzcwUAAAADa2V5CQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAxDYW4ndCByZWFkICcFAAAAA2tleQIAAAANJyBhdCBhZGRyZXNzIAkABCUAAAABBQAAAAdhZGRyZXNzAQAAABFnZXRJbnRlZ2VyT3JUaHJvdwAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABBoAAAACBQAAAAdhZGRyZXNzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAADENhbid0IHJlYWQgJwUAAAADa2V5AgAAAA0nIGF0IGFkZHJlc3MgCQAEJQAAAAEFAAAAB2FkZHJlc3MBAAAAE3BhcnNlQWRkcmVzc09yV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hfc3VwcG9ydGVkSW50ZXJmYWNlQXNJbnQAAAADCQEAAAAFdmFsdWUAAAABBQAAAApyZWdpc3RyYW50AgAAAAtuYW1lRXhwaXJlcwUAAAAKcmVzdExhYmVscwQAAAAKaXNSb290TmFtZQMJAABmAAAAAgkAATEAAAABBQAAAAlsYXN0TGFiZWwAAAAAAAAAAAAJAAAAAAAAAgkAATEAAAABBQAAAApyZXN0TGFiZWxzAAAAAAAAAAAABwMDBQAAAAppc1Jvb3ROYW1lBgkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQUAAAAKcmVnaXN0cmFudAkABRQAAAACBQAAAANuaWwJAAUWAAAABAUAAAARcmVnaXN0cmFudEFkZHJlc3MFAAAADnBhcmVudFJlc29sdmVyBQAAAA1wYXJlbnRDcmVhdGVkBQAAAAR1bml0CQAFFAAAAAIFAAAAA25pbAkABRYAAAAEBAAAAAckbWF0Y2gwBQAAAAVvd25lcgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAVvd25lcgUAAAAHJG1hdGNoMAUAAAAFb3duZXIFAAAAEXJlZ2lzdHJhbnRBZGRyZXNzBAAAAAckbWF0Y2gwBQAAAAhyZXNvbHZlcgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAhyZXNvbHZlcgUAAAAHJG1hdGNoMAUAAAAIcmVzb2x2ZXIFAAAADnBhcmVudFJlc29sdmVyBAAAAAckbWF0Y2gwBQAAAAtuYW1lQ3JlYXRlZAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAtuYW1lQ3JlYXRlZAUAAAAHJG1hdGNoMAUAAAALbmFtZUNyZWF0ZWQFAAAADXBhcmVudENyZWF0ZWQFAAAAC25hbWVFeHBpcmVzAAAAAGA2LbM=", "height": 2276085, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DUyev2FfWN56XqEQErT2evC3nhwhE5SD6HpcpBTADopn Next: 8CfJRrbiFPx4hyb9GUP2pQy9asF8vnZ8SPUwgPVP3gD9 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 isValidAddress (maybeAddress) = isDefined(addressFromString(maybeAddress))
50+
51+
52+func _splitLastLabel (name) = {
53+ let labels = split(name, ".")
54+ let lastIndex = (size(labels) - 1)
55+ let lastLabel = labels[lastIndex]
56+ let restLabels = makeString(removeByIndex(labels, lastIndex), ".")
57+ $Tuple2(lastLabel, restLabels)
58+ }
59+
60+
61+func _supportedInterfaceAsString (registrant,interfaceId,restLabels) = match invoke(registrant, "supportsInterface", [interfaceId], nil) {
62+ case supportsInterface: Boolean =>
63+ if (!(supportsInterface))
64+ then unit
65+ else match invoke(value(registrant), interfaceId, [restLabels], nil) {
66+ case mayBeString: String =>
67+ mayBeString
68+ case _ =>
69+ unit
70+ }
71+ case _ =>
72+ unit
73+}
74+
75+
76+func _supportedInterfaceAsInt (registrant,interfaceId,restLabels) = match invoke(registrant, "supportsInterface", [interfaceId], nil) {
77+ case supportsInterface: Boolean =>
78+ if (!(supportsInterface))
79+ then unit
80+ else match invoke(value(registrant), interfaceId, [restLabels], nil) {
81+ case mayBeInt: Int =>
82+ mayBeInt
83+ case _ =>
84+ unit
85+ }
86+ case _ =>
87+ unit
88+}
4789
4890
4991 func modifiers (validations) = unit
62104
63105
64106 @Callable(inv)
65-func setOwner (node,owner) = valueOrElse(modifiers([onlyOwner(inv, node)]), _setOwner(node, owner))
107+func setOwner (node,owner) = valueOrElse(modifiers([onlyOwner(inv, node), if (isValidAddress(owner))
108+ then unit
109+ else throw("Owner must be a valid address")]), _setOwner(node, owner))
66110
67111
68112
72116
73117
74118 @Callable(inv)
75-func setResolver (node,resolver) = valueOrElse(modifiers([onlyOwner(inv, node)]), _setResolver(node, resolver))
119+func resolver (node) = $Tuple2(nil, _getResolver(node))
76120
77121
78122
79123 @Callable(inv)
80-func resolver (node) = $Tuple2(nil, _getResolver(node))
124+func setResolver (node,resolver) = valueOrElse(modifiers([onlyOwner(inv, node), if (isValidAddress(resolver))
125+ then unit
126+ else throw("Resolver must be a valid contract address")]), _setResolver(node, resolver))
81127
82128
83129
90136 func setRecord (node,owner,resolver) = valueOrElse(modifiers([onlyAdmin(inv)]), ((_setOwner(node, owner) ++ _setResolver(node, resolver)) ++ _setCreatedAt(node, lastBlock.timestamp)))
91137
92138
139+
140+@Callable(inv)
141+func whoIs (name) = valueOrElse(modifiers([if ((size(name) > 0))
142+ then unit
143+ else throw("Name cannot be empty")]), {
144+ let $t047164767 = _splitLastLabel(name)
145+ let lastLabel = $t047164767._1
146+ let restLabels = $t047164767._2
147+ let registrantAddress = _getOwner(lastLabel)
148+ let registrant = match registrantAddress {
149+ case owner: String =>
150+ addressFromString(owner)
151+ case _ =>
152+ unit
153+ }
154+ let parentResolver = _getResolver(lastLabel)
155+ let parentCreated = _getCreatedAt(lastLabel)
156+ let owner = _supportedInterfaceAsString(value(registrant), "owner", restLabels)
157+ let resolver = _supportedInterfaceAsString(value(registrant), "resolver", restLabels)
158+ let nameCreated = _supportedInterfaceAsInt(value(registrant), "nameCreated", restLabels)
159+ let nameExpires = _supportedInterfaceAsInt(value(registrant), "nameExpires", restLabels)
160+ let isRootName = if ((size(lastLabel) > 0))
161+ then (size(restLabels) == 0)
162+ else false
163+ if (if (isRootName)
164+ then true
165+ else !(isDefined(registrant)))
166+ then $Tuple2(nil, $Tuple4(registrantAddress, parentResolver, parentCreated, unit))
167+ else $Tuple2(nil, $Tuple4( match owner {
168+ case owner: String =>
169+ owner
170+ case _ =>
171+ registrantAddress
172+ }, match resolver {
173+ case resolver: String =>
174+ resolver
175+ case _ =>
176+ parentResolver
177+ }, match nameCreated {
178+ case nameCreated: Int =>
179+ nameCreated
180+ case _ =>
181+ parentCreated
182+ }, nameExpires))
183+ })
184+
185+
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 isValidAddress (maybeAddress) = isDefined(addressFromString(maybeAddress))
50+
51+
52+func _splitLastLabel (name) = {
53+ let labels = split(name, ".")
54+ let lastIndex = (size(labels) - 1)
55+ let lastLabel = labels[lastIndex]
56+ let restLabels = makeString(removeByIndex(labels, lastIndex), ".")
57+ $Tuple2(lastLabel, restLabels)
58+ }
59+
60+
61+func _supportedInterfaceAsString (registrant,interfaceId,restLabels) = match invoke(registrant, "supportsInterface", [interfaceId], nil) {
62+ case supportsInterface: Boolean =>
63+ if (!(supportsInterface))
64+ then unit
65+ else match invoke(value(registrant), interfaceId, [restLabels], nil) {
66+ case mayBeString: String =>
67+ mayBeString
68+ case _ =>
69+ unit
70+ }
71+ case _ =>
72+ unit
73+}
74+
75+
76+func _supportedInterfaceAsInt (registrant,interfaceId,restLabels) = match invoke(registrant, "supportsInterface", [interfaceId], nil) {
77+ case supportsInterface: Boolean =>
78+ if (!(supportsInterface))
79+ then unit
80+ else match invoke(value(registrant), interfaceId, [restLabels], nil) {
81+ case mayBeInt: Int =>
82+ mayBeInt
83+ case _ =>
84+ unit
85+ }
86+ case _ =>
87+ unit
88+}
4789
4890
4991 func modifiers (validations) = unit
5092
5193
5294 func onlyAdmin (inv) = if (isAdmin(inv))
5395 then unit
5496 else throw("Permission denied")
5597
5698
5799 func onlyOwner (inv,node) = if (if (isAdmin(inv))
58100 then true
59101 else isOwner(inv, node))
60102 then unit
61103 else throw("Permission denied")
62104
63105
64106 @Callable(inv)
65-func setOwner (node,owner) = valueOrElse(modifiers([onlyOwner(inv, node)]), _setOwner(node, owner))
107+func setOwner (node,owner) = valueOrElse(modifiers([onlyOwner(inv, node), if (isValidAddress(owner))
108+ then unit
109+ else throw("Owner must be a valid address")]), _setOwner(node, owner))
66110
67111
68112
69113 @Callable(inv)
70114 func owner (node) = $Tuple2(nil, _getOwner(node))
71115
72116
73117
74118 @Callable(inv)
75-func setResolver (node,resolver) = valueOrElse(modifiers([onlyOwner(inv, node)]), _setResolver(node, resolver))
119+func resolver (node) = $Tuple2(nil, _getResolver(node))
76120
77121
78122
79123 @Callable(inv)
80-func resolver (node) = $Tuple2(nil, _getResolver(node))
124+func setResolver (node,resolver) = valueOrElse(modifiers([onlyOwner(inv, node), if (isValidAddress(resolver))
125+ then unit
126+ else throw("Resolver must be a valid contract address")]), _setResolver(node, resolver))
81127
82128
83129
84130 @Callable(inv)
85131 func nameCreated (node) = $Tuple2(nil, _getCreatedAt(node))
86132
87133
88134
89135 @Callable(inv)
90136 func setRecord (node,owner,resolver) = valueOrElse(modifiers([onlyAdmin(inv)]), ((_setOwner(node, owner) ++ _setResolver(node, resolver)) ++ _setCreatedAt(node, lastBlock.timestamp)))
91137
92138
139+
140+@Callable(inv)
141+func whoIs (name) = valueOrElse(modifiers([if ((size(name) > 0))
142+ then unit
143+ else throw("Name cannot be empty")]), {
144+ let $t047164767 = _splitLastLabel(name)
145+ let lastLabel = $t047164767._1
146+ let restLabels = $t047164767._2
147+ let registrantAddress = _getOwner(lastLabel)
148+ let registrant = match registrantAddress {
149+ case owner: String =>
150+ addressFromString(owner)
151+ case _ =>
152+ unit
153+ }
154+ let parentResolver = _getResolver(lastLabel)
155+ let parentCreated = _getCreatedAt(lastLabel)
156+ let owner = _supportedInterfaceAsString(value(registrant), "owner", restLabels)
157+ let resolver = _supportedInterfaceAsString(value(registrant), "resolver", restLabels)
158+ let nameCreated = _supportedInterfaceAsInt(value(registrant), "nameCreated", restLabels)
159+ let nameExpires = _supportedInterfaceAsInt(value(registrant), "nameExpires", restLabels)
160+ let isRootName = if ((size(lastLabel) > 0))
161+ then (size(restLabels) == 0)
162+ else false
163+ if (if (isRootName)
164+ then true
165+ else !(isDefined(registrant)))
166+ then $Tuple2(nil, $Tuple4(registrantAddress, parentResolver, parentCreated, unit))
167+ else $Tuple2(nil, $Tuple4( match owner {
168+ case owner: String =>
169+ owner
170+ case _ =>
171+ registrantAddress
172+ }, match resolver {
173+ case resolver: String =>
174+ resolver
175+ case _ =>
176+ parentResolver
177+ }, match nameCreated {
178+ case nameCreated: Int =>
179+ nameCreated
180+ case _ =>
181+ parentCreated
182+ }, nameExpires))
183+ })
184+
185+

github/deemru/w8io/169f3d6 
36.00 ms