1 | | - | {-# STDLIB_VERSION 6 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = "manager_vault.ride" |
---|
7 | | - | |
---|
8 | | - | let c = 10 |
---|
9 | | - | |
---|
10 | | - | let d = 2 |
---|
11 | | - | |
---|
12 | | - | let e = 26 |
---|
13 | | - | |
---|
14 | | - | let f = 32 |
---|
15 | | - | |
---|
16 | | - | func g (h) = throw(((b + ": ") + h)) |
---|
17 | | - | |
---|
18 | | - | |
---|
19 | | - | func i () = makeString(["%s", "managerPublicKey"], a) |
---|
20 | | - | |
---|
21 | | - | |
---|
22 | | - | func j () = makeString(["%s", "pendingManagerPublicKey"], a) |
---|
23 | | - | |
---|
24 | | - | |
---|
25 | | - | func k () = makeString(["%s", "currentManagerPublicKey"], a) |
---|
26 | | - | |
---|
27 | | - | |
---|
28 | | - | func l (m) = makeString(["%s%s%s", "setManager", m], a) |
---|
29 | | - | |
---|
30 | | - | |
---|
31 | | - | func n () = makeString(["%s%s", "deactivateManager"], a) |
---|
32 | | - | |
---|
33 | | - | |
---|
34 | | - | func o () = makeString(["%s%s", "activateManager"], a) |
---|
35 | | - | |
---|
36 | | - | |
---|
37 | | - | func p (q) = makeString(["%s%s%s", "addAdmin", q], a) |
---|
38 | | - | |
---|
39 | | - | |
---|
40 | | - | func r (s) = makeString(["%s%s%s", "removeAdmin", s], a) |
---|
41 | | - | |
---|
42 | | - | |
---|
43 | | - | func t (u) = makeString(["%s%s%s", "allowTxId", u], a) |
---|
44 | | - | |
---|
45 | | - | |
---|
46 | | - | func v (w,x) = makeString([w, x], a) |
---|
47 | | - | |
---|
48 | | - | |
---|
49 | | - | func y () = makeString(["%s", "adminAddressList"], a) |
---|
50 | | - | |
---|
51 | | - | |
---|
52 | | - | func z () = makeString(["%s", "TXID"], a) |
---|
53 | | - | |
---|
54 | | - | |
---|
55 | | - | func A (w,B) = { |
---|
56 | | - | let C = v(w, B) |
---|
57 | | - | valueOrElse(getInteger(C), 0) |
---|
58 | | - | } |
---|
59 | | - | |
---|
60 | | - | |
---|
61 | | - | func D () = { |
---|
62 | | - | let E = getString(j()) |
---|
63 | | - | if ($isInstanceOf(E, "String")) |
---|
64 | | - | then { |
---|
65 | | - | let h = E |
---|
66 | | - | fromBase58String(h) |
---|
67 | | - | } |
---|
68 | | - | else if ($isInstanceOf(E, "Unit")) |
---|
69 | | - | then unit |
---|
70 | | - | else throw("Match error") |
---|
71 | | - | } |
---|
72 | | - | |
---|
73 | | - | |
---|
74 | | - | func F () = split(valueOrElse(getString(this, y()), ""), a) |
---|
75 | | - | |
---|
76 | | - | |
---|
77 | | - | func G (H) = containsElement(F(), H) |
---|
78 | | - | |
---|
79 | | - | |
---|
80 | | - | func I (J,x) = { |
---|
81 | | - | let K = J |
---|
82 | | - | let L = K._1 |
---|
83 | | - | let w = K._2 |
---|
84 | | - | $Tuple2((L :+ v(w, x)), w) |
---|
85 | | - | } |
---|
86 | | - | |
---|
87 | | - | |
---|
88 | | - | func M (N) = { |
---|
89 | | - | let O = y() |
---|
90 | | - | let P = F() |
---|
91 | | - | let Q = size(P) |
---|
92 | | - | let R = $Tuple2(nil, N) |
---|
93 | | - | func S (T,U) = if ((U >= Q)) |
---|
94 | | - | then T |
---|
95 | | - | else I(T, P[U]) |
---|
96 | | - | |
---|
97 | | - | func V (T,U) = if ((U >= Q)) |
---|
98 | | - | then T |
---|
99 | | - | else throw("List size exceeds 20") |
---|
100 | | - | |
---|
101 | | - | V(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(R, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
102 | | - | } |
---|
103 | | - | |
---|
104 | | - | |
---|
105 | | - | func W (L,C) = (L + valueOrElse(getInteger(C), 0)) |
---|
106 | | - | |
---|
107 | | - | |
---|
108 | | - | func X (w) = { |
---|
109 | | - | let Y = M(w)._1 |
---|
110 | | - | let P = Y |
---|
111 | | - | let Q = size(P) |
---|
112 | | - | let R = 0 |
---|
113 | | - | func S (T,U) = if ((U >= Q)) |
---|
114 | | - | then T |
---|
115 | | - | else W(T, P[U]) |
---|
116 | | - | |
---|
117 | | - | func V (T,U) = if ((U >= Q)) |
---|
118 | | - | then T |
---|
119 | | - | else throw("List size exceeds 20") |
---|
120 | | - | |
---|
121 | | - | V(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(R, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
122 | | - | } |
---|
123 | | - | |
---|
124 | | - | |
---|
125 | | - | func Z (L,aa) = (L :+ DeleteEntry(aa)) |
---|
126 | | - | |
---|
127 | | - | |
---|
128 | | - | func ab (w) = { |
---|
129 | | - | let Y = M(w)._1 |
---|
130 | | - | let P = Y |
---|
131 | | - | let Q = size(P) |
---|
132 | | - | let R = nil |
---|
133 | | - | func S (T,U) = if ((U >= Q)) |
---|
134 | | - | then T |
---|
135 | | - | else Z(T, P[U]) |
---|
136 | | - | |
---|
137 | | - | func V (T,U) = if ((U >= Q)) |
---|
138 | | - | then T |
---|
139 | | - | else throw("List size exceeds 20") |
---|
140 | | - | |
---|
141 | | - | V(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(S(R, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
142 | | - | } |
---|
143 | | - | |
---|
144 | | - | |
---|
145 | | - | func ac (ad,N,ae,af) = { |
---|
146 | | - | let C = v(N, ad) |
---|
147 | | - | let ag = A(N, ad) |
---|
148 | | - | let ah = if (!(G(ad))) |
---|
149 | | - | then g((("Address: " + ad) + " not in Admin list")) |
---|
150 | | - | else if ((ag == 1)) |
---|
151 | | - | then g((C + " you already voted")) |
---|
152 | | - | else unit |
---|
153 | | - | if ((ah == ah)) |
---|
154 | | - | then { |
---|
155 | | - | let Y = X(N) |
---|
156 | | - | if (((Y + 1) >= ae)) |
---|
157 | | - | then { |
---|
158 | | - | let ai = ab(N) |
---|
159 | | - | (ai ++ af) |
---|
160 | | - | } |
---|
161 | | - | else [IntegerEntry(C, 1)] |
---|
162 | | - | } |
---|
163 | | - | else throw("Strict value is not equal to itself.") |
---|
164 | | - | } |
---|
165 | | - | |
---|
166 | | - | |
---|
167 | | - | @Callable(aj) |
---|
168 | | - | func confirmManager () = { |
---|
169 | | - | let ak = D() |
---|
170 | | - | let al = if (isDefined(ak)) |
---|
171 | | - | then true |
---|
172 | | - | else g("no pending manager") |
---|
173 | | - | if ((al == al)) |
---|
174 | | - | then { |
---|
175 | | - | let am = if ((aj.callerPublicKey == value(ak))) |
---|
176 | | - | then true |
---|
177 | | - | else g("you are not pending manager") |
---|
178 | | - | if ((am == am)) |
---|
179 | | - | then [StringEntry(k(), toBase58String(value(ak))), StringEntry(i(), toBase58String(value(ak))), DeleteEntry(j())] |
---|
180 | | - | else throw("Strict value is not equal to itself.") |
---|
181 | | - | } |
---|
182 | | - | else throw("Strict value is not equal to itself.") |
---|
183 | | - | } |
---|
184 | | - | |
---|
185 | | - | |
---|
186 | | - | |
---|
187 | | - | @Callable(aj) |
---|
188 | | - | func voteForNewManager (an) = { |
---|
189 | | - | let ad = toBase58String(aj.caller.bytes) |
---|
190 | | - | let N = l(an) |
---|
191 | | - | let ao = 2 |
---|
192 | | - | let L = [StringEntry(j(), an)] |
---|
193 | | - | ac(ad, N, ao, L) |
---|
194 | | - | } |
---|
195 | | - | |
---|
196 | | - | |
---|
197 | | - | |
---|
198 | | - | @Callable(aj) |
---|
199 | | - | func deactivateManager () = { |
---|
200 | | - | let ad = toBase58String(aj.caller.bytes) |
---|
201 | | - | let N = n() |
---|
202 | | - | let ao = 1 |
---|
203 | | - | let L = [StringEntry(i(), "disabled")] |
---|
204 | | - | ac(ad, N, ao, L) |
---|
205 | | - | } |
---|
206 | | - | |
---|
207 | | - | |
---|
208 | | - | |
---|
209 | | - | @Callable(aj) |
---|
210 | | - | func activateManager () = { |
---|
211 | | - | let ad = toBase58String(aj.caller.bytes) |
---|
212 | | - | let N = o() |
---|
213 | | - | let ao = 2 |
---|
214 | | - | let ap = getStringValue(k()) |
---|
215 | | - | let L = [StringEntry(i(), ap)] |
---|
216 | | - | ac(ad, N, ao, L) |
---|
217 | | - | } |
---|
218 | | - | |
---|
219 | | - | |
---|
220 | | - | |
---|
221 | | - | @Callable(aj) |
---|
222 | | - | func addNewAdmin (aq) = { |
---|
223 | | - | let ad = toBase58String(aj.caller.bytes) |
---|
224 | | - | let N = p(aq) |
---|
225 | | - | let ao = 2 |
---|
226 | | - | let ar = F() |
---|
227 | | - | let ah = if ((size(ar) >= c)) |
---|
228 | | - | then g((("MAX_ADMIN_LIST_SIZE (" + toString(c)) + ") is exceeded")) |
---|
229 | | - | else if ((size(fromBase58String(aq)) != e)) |
---|
230 | | - | then g((aq + " is not valid Address")) |
---|
231 | | - | else unit |
---|
232 | | - | if ((ah == ah)) |
---|
233 | | - | then { |
---|
234 | | - | let E = indexOf(ar, aq) |
---|
235 | | - | if ($isInstanceOf(E, "Int")) |
---|
236 | | - | then { |
---|
237 | | - | let J = E |
---|
238 | | - | g((aq + " already in Admin List")) |
---|
239 | | - | } |
---|
240 | | - | else { |
---|
241 | | - | let as = (ar :+ aq) |
---|
242 | | - | let L = [StringEntry(y(), makeString(as, a))] |
---|
243 | | - | ac(ad, N, ao, L) |
---|
244 | | - | } |
---|
245 | | - | } |
---|
246 | | - | else throw("Strict value is not equal to itself.") |
---|
247 | | - | } |
---|
248 | | - | |
---|
249 | | - | |
---|
250 | | - | |
---|
251 | | - | @Callable(aj) |
---|
252 | | - | func removeAdmin (s) = { |
---|
253 | | - | let ad = toBase58String(aj.caller.bytes) |
---|
254 | | - | let N = r(s) |
---|
255 | | - | let ao = 2 |
---|
256 | | - | let ar = F() |
---|
257 | | - | let E = indexOf(ar, s) |
---|
258 | | - | if ($isInstanceOf(E, "Int")) |
---|
259 | | - | then { |
---|
260 | | - | let at = E |
---|
261 | | - | let as = removeByIndex(ar, at) |
---|
262 | | - | let L = [StringEntry(y(), makeString(as, a))] |
---|
263 | | - | ac(ad, N, ao, L) |
---|
264 | | - | } |
---|
265 | | - | else g((s + " not found in Admin List")) |
---|
266 | | - | } |
---|
267 | | - | |
---|
268 | | - | |
---|
269 | | - | |
---|
270 | | - | @Callable(aj) |
---|
271 | | - | func voteForTxId (u) = { |
---|
272 | | - | let ad = toBase58String(aj.caller.bytes) |
---|
273 | | - | let N = t(u) |
---|
274 | | - | let ao = 2 |
---|
275 | | - | let L = [StringEntry(z(), u)] |
---|
276 | | - | let ah = if ((size(fromBase58String(u)) != f)) |
---|
277 | | - | then g((u + " not valid txId")) |
---|
278 | | - | else unit |
---|
279 | | - | if ((ah == ah)) |
---|
280 | | - | then ac(ad, N, ao, L) |
---|
281 | | - | else throw("Strict value is not equal to itself.") |
---|
282 | | - | } |
---|
283 | | - | |
---|
284 | | - | |
---|
285 | | - | @Verifier(au) |
---|
286 | | - | func av () = { |
---|
287 | | - | let aw = fromBase58String(getStringValue(z())) |
---|
288 | | - | let E = au |
---|
289 | | - | if ($isInstanceOf(E, "SetScriptTransaction")) |
---|
290 | | - | then { |
---|
291 | | - | let ax = E |
---|
292 | | - | sigVerify(au.bodyBytes, au.proofs[0], au.senderPublicKey) |
---|
293 | | - | } |
---|
294 | | - | else if ($isInstanceOf(E, "DataTransaction")) |
---|
295 | | - | then { |
---|
296 | | - | let ax = E |
---|
297 | | - | sigVerify(au.bodyBytes, au.proofs[0], au.senderPublicKey) |
---|
298 | | - | } |
---|
299 | | - | else { |
---|
300 | | - | let ar = F() |
---|
301 | | - | if ((size(ar) >= d)) |
---|
302 | | - | then (au.id == aw) |
---|
303 | | - | else sigVerify(au.bodyBytes, au.proofs[0], au.senderPublicKey) |
---|
304 | | - | } |
---|
305 | | - | } |
---|
306 | | - | |
---|
| 1 | + | # no script |
---|