tx · 3LH4SLnQUAKworpJdUDTjG7iLUpeZFrdD5q1vpDw5q8p 3MrF6QFGLaSKfoNPMd8L3u7KYNm7cE43Ydw: -0.01000000 Waves 2022.10.17 13:35 [2276257] smart account 3MrF6QFGLaSKfoNPMd8L3u7KYNm7cE43Ydw > SELF 0.00000000 Waves
{ "type": 13, "id": "3LH4SLnQUAKworpJdUDTjG7iLUpeZFrdD5q1vpDw5q8p", "fee": 1000000, "feeAssetId": null, "timestamp": 1666002941411, "version": 2, "chainId": 84, "sender": "3MrF6QFGLaSKfoNPMd8L3u7KYNm7cE43Ydw", "senderPublicKey": "6NSakbUsm1WyESQ8yj3qpc1kQUfHWNd5C6CHVpbs4X7c", "proofs": [ "LuowNmub2jwvJae6j3fe6ZWQ3BEgtXbNyzsXAyFSV7Q7MoSAFNfb3DQy9xZatANwvyPjZS5yH8kSU9VnZTrro89" ], "script": "base64:AAIFAAAAAAAAABcIAhIDCgEIEgMKAQgSAwoBCBIECgIICAAAABEBAAAAEGdldFN0cmluZ09yVGhyb3cAAAACAAAAB2FkZHJlc3MAAAADa2V5CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQdAAAAAgUAAAAHYWRkcmVzcwUAAAADa2V5CQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAxDYW4ndCByZWFkICcFAAAAA2tleQIAAAANJyBhdCBhZGRyZXNzIAkABCUAAAABBQAAAAdhZGRyZXNzAQAAABNwYXJzZUFkZHJlc3NPclRocm93AAAAAQAAAAxtYXliZUFkZHJlc3MJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABCYAAAABBQAAAAxtYXliZUFkZHJlc3MJAAEsAAAAAgkAASwAAAACAgAAABpDYW4ndCBwYXJzZSBhZGRyZXNzIGZyb20gJwUAAAAMbWF5YmVBZGRyZXNzAgAAAAEnAQAAAA1rZXlfTmFtZV9hZGRyAAAAAQAAAARuYW1lCQABLAAAAAIJAAEsAAAAAgIAAAAFTmFtZV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AABG5hbWUAAAAAAAAAAAAFAAAABHVuaXQJAAACAAAAAQIAAAAUTmFtZSBjYW5ub3QgYmUgZW1wdHkFAAAAA25pbAkABRQAAAACBQAAAANuaWwJAQAAAAhfcmVzb2x2ZQAAAAIFAAAABG5hbWUCAAAABGFkZHIAAAADaW52AQAAAAdzZXRBZGRyAAAAAgAAAARuYW1lAAAAB2FkZHJlc3MJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAQAAAAltb2RpZmllcnMAAAABCQAETAAAAAIDCQAAZgAAAAIJAAExAAAAAQUAAAAEbmFtZQAAAAAAAAAAAAUAAAAEdW5pdAkAAAIAAAABAgAAABROYW1lIGNhbm5vdCBiZSBlbXB0eQkABEwAAAACCQEAAAAJb25seU93bmVyAAAAAgUAAAADaW52BQAAAARuYW1lCQAETAAAAAIDCQEAAAAJaXNEZWZpbmVkAAAAAQkABCYAAAABBQAAAAdhZGRyZXNzBQAAAAR1bml0CQAAAgAAAAECAAAAFUFkZHJlc3MgbXVzdCBiZSB2YWxpZAUAAAADbmlsCQEAAAAIX3NldEFkZHIAAAACBQAAAARuYW1lBQAAAAdhZGRyZXNzAAAAADfQO50=", "height": 2276257, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8QXX43E2LtMFmdGgcHnELprcLy97JateiAeNuTJ7hrVq Next: EnE51fMhdxW59yv3ircf8436S9rkarSPR77v7tELCKaq Diff:
Old | New | Differences | |
---|---|---|---|
7 | 7 | func parseAddressOrThrow (maybeAddress) = valueOrErrorMessage(addressFromString(maybeAddress), (("Can't parse address from '" + maybeAddress) + "'")) | |
8 | 8 | ||
9 | 9 | ||
10 | + | func key_Name_addr (name) = (("Name_" + name) + "_addr") | |
11 | + | ||
12 | + | ||
10 | 13 | let key_registry = "registry" | |
11 | 14 | ||
12 | 15 | let registry = parseAddressOrThrow(getStringOrThrow(this, key_registry)) | |
13 | 16 | ||
17 | + | func _getOwner (name) = match invoke(registry, "owner", [name], nil) { | |
18 | + | case owner: String => | |
19 | + | owner | |
20 | + | case _ => | |
21 | + | unit | |
22 | + | } | |
23 | + | ||
24 | + | ||
25 | + | func _getAddr (name) = valueOrElse(getString(this, key_Name_addr(name)), _getOwner(name)) | |
26 | + | ||
27 | + | ||
28 | + | func _setAddr (name,address) = [StringEntry(key_Name_addr(name), address)] | |
29 | + | ||
30 | + | ||
14 | 31 | func isAdmin (inv) = (inv.caller == this) | |
32 | + | ||
33 | + | ||
34 | + | func isOwner (inv,name) = (toString(inv.caller) == valueOrElse(_getOwner(name), "")) | |
35 | + | ||
36 | + | ||
37 | + | func isValidAddress (maybeAddress) = isDefined(addressFromString(maybeAddress)) | |
15 | 38 | ||
16 | 39 | ||
17 | 40 | func modifiers (validations) = unit | |
22 | 45 | else throw("Permission denied") | |
23 | 46 | ||
24 | 47 | ||
25 | - | func _addr (label) = match invoke(registry, "owner", [label], nil) { | |
26 | - | case owner: String => | |
27 | - | owner | |
28 | - | case _ => | |
29 | - | unit | |
30 | - | } | |
48 | + | func onlyOwner (inv,name) = if (if (isAdmin(inv)) | |
49 | + | then true | |
50 | + | else isOwner(inv, name)) | |
51 | + | then unit | |
52 | + | else throw("Permission denied") | |
31 | 53 | ||
32 | 54 | ||
33 | 55 | func _splitLastLabel (name) = { | |
36 | 58 | let lastLabel = labels[lastIndex] | |
37 | 59 | let restLabels = makeString(removeByIndex(labels, lastIndex), ".") | |
38 | 60 | $Tuple2(lastLabel, restLabels) | |
61 | + | } | |
62 | + | ||
63 | + | ||
64 | + | func _findResolver (name) = { | |
65 | + | let $t019341985 = _splitLastLabel(name) | |
66 | + | let lastLabel = $t019341985._1 | |
67 | + | let restLabels = $t019341985._2 | |
68 | + | if ((size(restLabels) == 0)) | |
69 | + | then $Tuple2(unit, name) | |
70 | + | else match invoke(registry, "resolver", [lastLabel], nil) { | |
71 | + | case resolverAddress: String => | |
72 | + | $Tuple2(addressFromString(resolverAddress), restLabels) | |
73 | + | case _ => | |
74 | + | $Tuple2(unit, name) | |
75 | + | } | |
76 | + | } | |
77 | + | ||
78 | + | ||
79 | + | func _resolve (name,callData) = { | |
80 | + | let $t023632411 = _findResolver(name) | |
81 | + | let resolver = $t023632411._1 | |
82 | + | let restLabels = $t023632411._2 | |
83 | + | let $t024172593 = match callData { | |
84 | + | case _ => | |
85 | + | if (("addr" == $match0)) | |
86 | + | then $Tuple3("addr", [value(restLabels)], _getAddr(name)) | |
87 | + | else $Tuple3(unit, unit, unit) | |
88 | + | } | |
89 | + | let callFunction = $t024172593._1 | |
90 | + | let callArgs = $t024172593._2 | |
91 | + | let returnsDefault = $t024172593._3 | |
92 | + | let supportsInterface = match invoke(value(resolver), "supportsInterface", [callData], nil) { | |
93 | + | case supportsInterface: Boolean => | |
94 | + | supportsInterface | |
95 | + | case _ => | |
96 | + | false | |
97 | + | } | |
98 | + | if (!(isDefined(resolver))) | |
99 | + | then returnsDefault | |
100 | + | else if (!(supportsInterface)) | |
101 | + | then unit | |
102 | + | else match invoke(value(resolver), value(callFunction), value(callArgs), nil) { | |
103 | + | case maybeAddr: String => | |
104 | + | if (isValidAddress(maybeAddr)) | |
105 | + | then maybeAddr | |
106 | + | else unit | |
107 | + | case _ => | |
108 | + | unit | |
109 | + | } | |
39 | 110 | } | |
40 | 111 | ||
41 | 112 | ||
50 | 121 | ||
51 | 122 | ||
52 | 123 | @Callable(inv) | |
53 | - | func addr (label) = $Tuple2(nil, _addr(_splitLastLabel(label)._1)) | |
124 | + | func addr (name) = valueOrElse(modifiers([if ((size(name) > 0)) | |
125 | + | then unit | |
126 | + | else throw("Name cannot be empty")]), $Tuple2(nil, _resolve(name, "addr"))) | |
127 | + | ||
128 | + | ||
129 | + | ||
130 | + | @Callable(inv) | |
131 | + | func setAddr (name,address) = valueOrElse(modifiers([if ((size(name) > 0)) | |
132 | + | then unit | |
133 | + | else throw("Name cannot be empty"), onlyOwner(inv, name), if (isDefined(addressFromString(address))) | |
134 | + | then unit | |
135 | + | else throw("Address must be valid")]), _setAddr(name, address)) | |
54 | 136 | ||
55 | 137 |
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 | + | func key_Name_addr (name) = (("Name_" + name) + "_addr") | |
11 | + | ||
12 | + | ||
10 | 13 | let key_registry = "registry" | |
11 | 14 | ||
12 | 15 | let registry = parseAddressOrThrow(getStringOrThrow(this, key_registry)) | |
13 | 16 | ||
17 | + | func _getOwner (name) = match invoke(registry, "owner", [name], nil) { | |
18 | + | case owner: String => | |
19 | + | owner | |
20 | + | case _ => | |
21 | + | unit | |
22 | + | } | |
23 | + | ||
24 | + | ||
25 | + | func _getAddr (name) = valueOrElse(getString(this, key_Name_addr(name)), _getOwner(name)) | |
26 | + | ||
27 | + | ||
28 | + | func _setAddr (name,address) = [StringEntry(key_Name_addr(name), address)] | |
29 | + | ||
30 | + | ||
14 | 31 | func isAdmin (inv) = (inv.caller == this) | |
32 | + | ||
33 | + | ||
34 | + | func isOwner (inv,name) = (toString(inv.caller) == valueOrElse(_getOwner(name), "")) | |
35 | + | ||
36 | + | ||
37 | + | func isValidAddress (maybeAddress) = isDefined(addressFromString(maybeAddress)) | |
15 | 38 | ||
16 | 39 | ||
17 | 40 | func modifiers (validations) = unit | |
18 | 41 | ||
19 | 42 | ||
20 | 43 | func onlyAdmin (inv) = if (isAdmin(inv)) | |
21 | 44 | then unit | |
22 | 45 | else throw("Permission denied") | |
23 | 46 | ||
24 | 47 | ||
25 | - | func _addr (label) = match invoke(registry, "owner", [label], nil) { | |
26 | - | case owner: String => | |
27 | - | owner | |
28 | - | case _ => | |
29 | - | unit | |
30 | - | } | |
48 | + | func onlyOwner (inv,name) = if (if (isAdmin(inv)) | |
49 | + | then true | |
50 | + | else isOwner(inv, name)) | |
51 | + | then unit | |
52 | + | else throw("Permission denied") | |
31 | 53 | ||
32 | 54 | ||
33 | 55 | func _splitLastLabel (name) = { | |
34 | 56 | let labels = split(name, ".") | |
35 | 57 | let lastIndex = (size(labels) - 1) | |
36 | 58 | let lastLabel = labels[lastIndex] | |
37 | 59 | let restLabels = makeString(removeByIndex(labels, lastIndex), ".") | |
38 | 60 | $Tuple2(lastLabel, restLabels) | |
61 | + | } | |
62 | + | ||
63 | + | ||
64 | + | func _findResolver (name) = { | |
65 | + | let $t019341985 = _splitLastLabel(name) | |
66 | + | let lastLabel = $t019341985._1 | |
67 | + | let restLabels = $t019341985._2 | |
68 | + | if ((size(restLabels) == 0)) | |
69 | + | then $Tuple2(unit, name) | |
70 | + | else match invoke(registry, "resolver", [lastLabel], nil) { | |
71 | + | case resolverAddress: String => | |
72 | + | $Tuple2(addressFromString(resolverAddress), restLabels) | |
73 | + | case _ => | |
74 | + | $Tuple2(unit, name) | |
75 | + | } | |
76 | + | } | |
77 | + | ||
78 | + | ||
79 | + | func _resolve (name,callData) = { | |
80 | + | let $t023632411 = _findResolver(name) | |
81 | + | let resolver = $t023632411._1 | |
82 | + | let restLabels = $t023632411._2 | |
83 | + | let $t024172593 = match callData { | |
84 | + | case _ => | |
85 | + | if (("addr" == $match0)) | |
86 | + | then $Tuple3("addr", [value(restLabels)], _getAddr(name)) | |
87 | + | else $Tuple3(unit, unit, unit) | |
88 | + | } | |
89 | + | let callFunction = $t024172593._1 | |
90 | + | let callArgs = $t024172593._2 | |
91 | + | let returnsDefault = $t024172593._3 | |
92 | + | let supportsInterface = match invoke(value(resolver), "supportsInterface", [callData], nil) { | |
93 | + | case supportsInterface: Boolean => | |
94 | + | supportsInterface | |
95 | + | case _ => | |
96 | + | false | |
97 | + | } | |
98 | + | if (!(isDefined(resolver))) | |
99 | + | then returnsDefault | |
100 | + | else if (!(supportsInterface)) | |
101 | + | then unit | |
102 | + | else match invoke(value(resolver), value(callFunction), value(callArgs), nil) { | |
103 | + | case maybeAddr: String => | |
104 | + | if (isValidAddress(maybeAddr)) | |
105 | + | then maybeAddr | |
106 | + | else unit | |
107 | + | case _ => | |
108 | + | unit | |
109 | + | } | |
39 | 110 | } | |
40 | 111 | ||
41 | 112 | ||
42 | 113 | @Callable(inv) | |
43 | 114 | func init (registryAddress) = valueOrElse(modifiers([onlyAdmin(inv)]), [StringEntry(key_registry, registryAddress)]) | |
44 | 115 | ||
45 | 116 | ||
46 | 117 | ||
47 | 118 | @Callable(inv) | |
48 | 119 | func supportsInterface (interfaceId) = $Tuple2(nil, (interfaceId == "addr")) | |
49 | 120 | ||
50 | 121 | ||
51 | 122 | ||
52 | 123 | @Callable(inv) | |
53 | - | func addr (label) = $Tuple2(nil, _addr(_splitLastLabel(label)._1)) | |
124 | + | func addr (name) = valueOrElse(modifiers([if ((size(name) > 0)) | |
125 | + | then unit | |
126 | + | else throw("Name cannot be empty")]), $Tuple2(nil, _resolve(name, "addr"))) | |
127 | + | ||
128 | + | ||
129 | + | ||
130 | + | @Callable(inv) | |
131 | + | func setAddr (name,address) = valueOrElse(modifiers([if ((size(name) > 0)) | |
132 | + | then unit | |
133 | + | else throw("Name cannot be empty"), onlyOwner(inv, name), if (isDefined(addressFromString(address))) | |
134 | + | then unit | |
135 | + | else throw("Address must be valid")]), _setAddr(name, address)) | |
54 | 136 | ||
55 | 137 |
github/deemru/w8io/169f3d6 28.09 ms ◑