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