1 | | - | {-# STDLIB_VERSION 5 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "registry" |
---|
5 | | - | |
---|
6 | | - | let b = valueOrErrorMessage(addressFromString(value(getString(this, a))), "Registry is not valid address") |
---|
7 | | - | |
---|
8 | | - | func c (d,e) = { |
---|
9 | | - | let f = invoke(value(addressFromString(d)), "supportsInterface", ["getOwner"], nil) |
---|
10 | | - | if ($isInstanceOf(f, "Boolean")) |
---|
11 | | - | then { |
---|
12 | | - | let g = f |
---|
13 | | - | g |
---|
14 | | - | } |
---|
15 | | - | else false |
---|
16 | | - | } |
---|
17 | | - | |
---|
18 | | - | |
---|
19 | | - | let h = isDefined(getString(this, a)) |
---|
20 | | - | |
---|
21 | | - | func i (j) = (j.caller == this) |
---|
22 | | - | |
---|
23 | | - | |
---|
24 | | - | func k (l) = isDefined(addressFromString(l)) |
---|
25 | | - | |
---|
26 | | - | |
---|
27 | | - | func m (n) = unit |
---|
28 | | - | |
---|
29 | | - | |
---|
30 | | - | func o (j) = if (i(j)) |
---|
31 | | - | then unit |
---|
32 | | - | else throw("Permission denied") |
---|
33 | | - | |
---|
34 | | - | |
---|
35 | | - | func p () = if (h) |
---|
36 | | - | then unit |
---|
37 | | - | else throw("Contract is not initialized") |
---|
38 | | - | |
---|
39 | | - | |
---|
40 | | - | func q (r) = { |
---|
41 | | - | let f = invoke(b, "getOwner", [r], nil) |
---|
42 | | - | if ($isInstanceOf(f, "String")) |
---|
43 | | - | then { |
---|
44 | | - | let s = f |
---|
45 | | - | s |
---|
46 | | - | } |
---|
47 | | - | else unit |
---|
48 | | - | } |
---|
49 | | - | |
---|
50 | | - | |
---|
51 | | - | @Callable(j) |
---|
52 | | - | func init (d) = valueOrElse(m([o(j), if (k(d)) |
---|
53 | | - | then unit |
---|
54 | | - | else throw("Registry must be a valid address"), if (c(d, "getOwner")) |
---|
55 | | - | then unit |
---|
56 | | - | else throw("Registry must support `getOwner` interface"), if (!(h)) |
---|
57 | | - | then unit |
---|
58 | | - | else throw("Contract has already been initialized")]), [StringEntry(a, d)]) |
---|
59 | | - | |
---|
60 | | - | |
---|
61 | | - | |
---|
62 | | - | @Callable(j) |
---|
63 | | - | func supportsInterface (e) = $Tuple2(nil, (e == "getAddr")) |
---|
64 | | - | |
---|
65 | | - | |
---|
66 | | - | |
---|
67 | | - | @Callable(j) |
---|
68 | | - | func getAddr (r) = valueOrElse(m([p()]), $Tuple2(nil, q(r))) |
---|
69 | | - | |
---|
70 | | - | |
---|
| 1 | + | # no script |
---|