1 | | - | {-# STDLIB_VERSION 7 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = "factory.ride" |
---|
7 | | - | |
---|
8 | | - | func c (d) = ((b + ": ") + d) |
---|
9 | | - | |
---|
10 | | - | |
---|
11 | | - | func e (d) = throw(c(d)) |
---|
12 | | - | |
---|
13 | | - | |
---|
14 | | - | let f = 5 |
---|
15 | | - | |
---|
16 | | - | let g = 3 |
---|
17 | | - | |
---|
18 | | - | let h = 32 |
---|
19 | | - | |
---|
20 | | - | func i (j) = makeString(["%s%s%s", "allowTxId", j], a) |
---|
21 | | - | |
---|
22 | | - | |
---|
23 | | - | func k (l,m) = makeString([l, m], a) |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | func n () = makeString(["%s", "adminAddressList"], a) |
---|
27 | | - | |
---|
28 | | - | |
---|
29 | | - | func o () = makeString(["%s", "txId"], a) |
---|
30 | | - | |
---|
31 | | - | |
---|
32 | | - | func p (l,q) = { |
---|
33 | | - | let r = k(l, q) |
---|
34 | | - | valueOrElse(getInteger(r), 0) |
---|
35 | | - | } |
---|
36 | | - | |
---|
37 | | - | |
---|
38 | | - | func s () = { |
---|
39 | | - | let t = getString(this, n()) |
---|
40 | | - | if ($isInstanceOf(t, "String")) |
---|
41 | | - | then { |
---|
42 | | - | let d = t |
---|
43 | | - | split(d, a) |
---|
44 | | - | } |
---|
45 | | - | else nil |
---|
46 | | - | } |
---|
47 | | - | |
---|
48 | | - | |
---|
49 | | - | func u (v) = containsElement(s(), v) |
---|
50 | | - | |
---|
51 | | - | |
---|
52 | | - | func w (x,m) = { |
---|
53 | | - | let y = x |
---|
54 | | - | let z = y._1 |
---|
55 | | - | let l = y._2 |
---|
56 | | - | $Tuple2((z :+ k(l, m)), l) |
---|
57 | | - | } |
---|
58 | | - | |
---|
59 | | - | |
---|
60 | | - | func A (B) = { |
---|
61 | | - | let C = n() |
---|
62 | | - | let D = { |
---|
63 | | - | let E = s() |
---|
64 | | - | let F = size(E) |
---|
65 | | - | let G = $Tuple2(nil, B) |
---|
66 | | - | func H (I,J) = if ((J >= F)) |
---|
67 | | - | then I |
---|
68 | | - | else w(I, E[J]) |
---|
69 | | - | |
---|
70 | | - | func K (I,J) = if ((J >= F)) |
---|
71 | | - | then I |
---|
72 | | - | else throw("List size exceeds 5") |
---|
73 | | - | |
---|
74 | | - | K(H(H(H(H(H(G, 0), 1), 2), 3), 4), 5) |
---|
75 | | - | } |
---|
76 | | - | let z = D._1 |
---|
77 | | - | let l = D._2 |
---|
78 | | - | z |
---|
79 | | - | } |
---|
80 | | - | |
---|
81 | | - | |
---|
82 | | - | func L (z,r) = (z + valueOrElse(getInteger(r), 0)) |
---|
83 | | - | |
---|
84 | | - | |
---|
85 | | - | func M (l) = { |
---|
86 | | - | let N = A(l) |
---|
87 | | - | let E = N |
---|
88 | | - | let F = size(E) |
---|
89 | | - | let G = 0 |
---|
90 | | - | func H (I,J) = if ((J >= F)) |
---|
91 | | - | then I |
---|
92 | | - | else L(I, E[J]) |
---|
93 | | - | |
---|
94 | | - | func K (I,J) = if ((J >= F)) |
---|
95 | | - | then I |
---|
96 | | - | else throw("List size exceeds 5") |
---|
97 | | - | |
---|
98 | | - | K(H(H(H(H(H(G, 0), 1), 2), 3), 4), 5) |
---|
99 | | - | } |
---|
100 | | - | |
---|
101 | | - | |
---|
102 | | - | func O (z,P) = (z :+ DeleteEntry(P)) |
---|
103 | | - | |
---|
104 | | - | |
---|
105 | | - | func Q (l) = { |
---|
106 | | - | let N = A(l) |
---|
107 | | - | let E = N |
---|
108 | | - | let F = size(E) |
---|
109 | | - | let G = nil |
---|
110 | | - | func H (I,J) = if ((J >= F)) |
---|
111 | | - | then I |
---|
112 | | - | else O(I, E[J]) |
---|
113 | | - | |
---|
114 | | - | func K (I,J) = if ((J >= F)) |
---|
115 | | - | then I |
---|
116 | | - | else throw("List size exceeds 5") |
---|
117 | | - | |
---|
118 | | - | K(H(H(H(H(H(G, 0), 1), 2), 3), 4), 5) |
---|
119 | | - | } |
---|
120 | | - | |
---|
121 | | - | |
---|
122 | | - | func R (S,B,T,U) = { |
---|
123 | | - | let r = k(B, S) |
---|
124 | | - | let V = p(B, S) |
---|
125 | | - | let W = if (!(u(S))) |
---|
126 | | - | then e((("Address: " + S) + " not in Admin list")) |
---|
127 | | - | else if ((V == 1)) |
---|
128 | | - | then e((r + " you already voted")) |
---|
129 | | - | else unit |
---|
130 | | - | if ((W == W)) |
---|
131 | | - | then { |
---|
132 | | - | let N = M(B) |
---|
133 | | - | if (((N + 1) >= T)) |
---|
134 | | - | then { |
---|
135 | | - | let X = Q(B) |
---|
136 | | - | (X ++ U) |
---|
137 | | - | } |
---|
138 | | - | else [IntegerEntry(r, 1)] |
---|
139 | | - | } |
---|
140 | | - | else throw("Strict value is not equal to itself.") |
---|
141 | | - | } |
---|
142 | | - | |
---|
143 | | - | |
---|
144 | | - | func Y () = "%s__calculator" |
---|
145 | | - | |
---|
146 | | - | |
---|
147 | | - | func Z () = "%s__proxyTreasury" |
---|
148 | | - | |
---|
149 | | - | |
---|
150 | | - | func aa () = "%s__child" |
---|
151 | | - | |
---|
152 | | - | |
---|
153 | | - | func ab () = "%s__blockProcessingReward" |
---|
154 | | - | |
---|
155 | | - | |
---|
156 | | - | func ac () = "%s__nextBlockToProcess" |
---|
157 | | - | |
---|
158 | | - | |
---|
159 | | - | func ad () = "%s__lpAssetId" |
---|
160 | | - | |
---|
161 | | - | |
---|
162 | | - | let ae = { |
---|
163 | | - | let t = getString(this, Y()) |
---|
164 | | - | if ($isInstanceOf(t, "String")) |
---|
165 | | - | then { |
---|
166 | | - | let d = t |
---|
167 | | - | addressFromString(d) |
---|
168 | | - | } |
---|
169 | | - | else if ($isInstanceOf(t, "Unit")) |
---|
170 | | - | then unit |
---|
171 | | - | else throw("Match error") |
---|
172 | | - | } |
---|
173 | | - | |
---|
174 | | - | let af = valueOrErrorMessage(ae, c("invalid calculator address")) |
---|
175 | | - | |
---|
176 | | - | let ag = { |
---|
177 | | - | let t = getString(this, Z()) |
---|
178 | | - | if ($isInstanceOf(t, "String")) |
---|
179 | | - | then { |
---|
180 | | - | let d = t |
---|
181 | | - | addressFromString(d) |
---|
182 | | - | } |
---|
183 | | - | else if ($isInstanceOf(t, "Unit")) |
---|
184 | | - | then unit |
---|
185 | | - | else throw("Match error") |
---|
186 | | - | } |
---|
187 | | - | |
---|
188 | | - | let ah = valueOrErrorMessage(ag, c("invalid proxy treasury address")) |
---|
189 | | - | |
---|
190 | | - | func ai () = "%s__config" |
---|
191 | | - | |
---|
192 | | - | |
---|
193 | | - | func aj () = "contract_children" |
---|
194 | | - | |
---|
195 | | - | |
---|
196 | | - | func ak () = "contract_voting_result" |
---|
197 | | - | |
---|
198 | | - | |
---|
199 | | - | func al (v,j) = ((("proposal_allow_broadcast_" + toString(v)) + "_") + toBase58String(j)) |
---|
200 | | - | |
---|
201 | | - | |
---|
202 | | - | func am (an,ao) = makeString(["investor", toString(an), toString(ao)], "_") |
---|
203 | | - | |
---|
204 | | - | |
---|
205 | | - | let ap = { |
---|
206 | | - | let t = getString(this, ai()) |
---|
207 | | - | if ($isInstanceOf(t, "String")) |
---|
208 | | - | then { |
---|
209 | | - | let d = t |
---|
210 | | - | addressFromString(d) |
---|
211 | | - | } |
---|
212 | | - | else if ($isInstanceOf(t, "Unit")) |
---|
213 | | - | then unit |
---|
214 | | - | else throw("Match error") |
---|
215 | | - | } |
---|
216 | | - | |
---|
217 | | - | let aq = valueOrErrorMessage(ap, c("invalid config address")) |
---|
218 | | - | |
---|
219 | | - | let ar = { |
---|
220 | | - | let t = ap |
---|
221 | | - | if ($isInstanceOf(t, "Address")) |
---|
222 | | - | then { |
---|
223 | | - | let x = t |
---|
224 | | - | let as = getString(x, ak()) |
---|
225 | | - | if ($isInstanceOf(as, "String")) |
---|
226 | | - | then { |
---|
227 | | - | let d = as |
---|
228 | | - | addressFromString(d) |
---|
229 | | - | } |
---|
230 | | - | else if ($isInstanceOf(as, "Unit")) |
---|
231 | | - | then unit |
---|
232 | | - | else throw("Match error") |
---|
233 | | - | } |
---|
234 | | - | else if ($isInstanceOf(t, "Unit")) |
---|
235 | | - | then unit |
---|
236 | | - | else throw("Match error") |
---|
237 | | - | } |
---|
238 | | - | |
---|
239 | | - | let at = valueOrErrorMessage(ar, c("invalid voting result address")) |
---|
240 | | - | |
---|
241 | | - | let au = { |
---|
242 | | - | let t = ap |
---|
243 | | - | if ($isInstanceOf(t, "Address")) |
---|
244 | | - | then { |
---|
245 | | - | let x = t |
---|
246 | | - | let as = getString(x, aj()) |
---|
247 | | - | if ($isInstanceOf(as, "String")) |
---|
248 | | - | then { |
---|
249 | | - | let d = as |
---|
250 | | - | addressFromString(d) |
---|
251 | | - | } |
---|
252 | | - | else if ($isInstanceOf(as, "Unit")) |
---|
253 | | - | then unit |
---|
254 | | - | else throw("Match error") |
---|
255 | | - | } |
---|
256 | | - | else if ($isInstanceOf(t, "Unit")) |
---|
257 | | - | then unit |
---|
258 | | - | else throw("Match error") |
---|
259 | | - | } |
---|
260 | | - | |
---|
261 | | - | let av = valueOrErrorMessage(au, c("invalid children address")) |
---|
262 | | - | |
---|
263 | | - | let aw = { |
---|
264 | | - | let t = getString(this, ad()) |
---|
265 | | - | if ($isInstanceOf(t, "String")) |
---|
266 | | - | then { |
---|
267 | | - | let d = t |
---|
268 | | - | fromBase58String(d) |
---|
269 | | - | } |
---|
270 | | - | else if ($isInstanceOf(t, "Unit")) |
---|
271 | | - | then unit |
---|
272 | | - | else throw("Match error") |
---|
273 | | - | } |
---|
274 | | - | |
---|
275 | | - | let ax = valueOrErrorMessage(aw, c("invalid lpAssetId")) |
---|
276 | | - | |
---|
277 | | - | func ay (az,v) = if ((az.caller == v)) |
---|
278 | | - | then true |
---|
279 | | - | else e("permission denied") |
---|
280 | | - | |
---|
281 | | - | |
---|
282 | | - | func aA (az) = ay(az, this) |
---|
283 | | - | |
---|
284 | | - | |
---|
285 | | - | func aB (az) = ay(az, af) |
---|
286 | | - | |
---|
287 | | - | |
---|
288 | | - | @Callable(az) |
---|
289 | | - | func stringEntry (P,aC) = if (aB(az)) |
---|
290 | | - | then $Tuple2([StringEntry(P, aC)], P) |
---|
291 | | - | else $Tuple2(nil, unit) |
---|
292 | | - | |
---|
293 | | - | |
---|
294 | | - | |
---|
295 | | - | @Callable(az) |
---|
296 | | - | func integerEntry (P,aC) = if (aB(az)) |
---|
297 | | - | then $Tuple2([IntegerEntry(P, aC)], P) |
---|
298 | | - | else $Tuple2(nil, unit) |
---|
299 | | - | |
---|
300 | | - | |
---|
301 | | - | |
---|
302 | | - | @Callable(az) |
---|
303 | | - | func booleanEntry (P,aC) = if (aB(az)) |
---|
304 | | - | then $Tuple2([BooleanEntry(P, aC)], P) |
---|
305 | | - | else $Tuple2(nil, unit) |
---|
306 | | - | |
---|
307 | | - | |
---|
308 | | - | |
---|
309 | | - | @Callable(az) |
---|
310 | | - | func binaryEntry (P,aC) = if (aB(az)) |
---|
311 | | - | then $Tuple2([BinaryEntry(P, aC)], P) |
---|
312 | | - | else $Tuple2(nil, unit) |
---|
313 | | - | |
---|
314 | | - | |
---|
315 | | - | |
---|
316 | | - | @Callable(az) |
---|
317 | | - | func deleteEntry (P) = if (aB(az)) |
---|
318 | | - | then $Tuple2([DeleteEntry(P)], P) |
---|
319 | | - | else $Tuple2(nil, unit) |
---|
320 | | - | |
---|
321 | | - | |
---|
322 | | - | |
---|
323 | | - | @Callable(az) |
---|
324 | | - | func reissue (aD) = if (aB(az)) |
---|
325 | | - | then $Tuple2([Reissue(ax, aD, true)], aD) |
---|
326 | | - | else $Tuple2(nil, unit) |
---|
327 | | - | |
---|
328 | | - | |
---|
329 | | - | |
---|
330 | | - | @Callable(az) |
---|
331 | | - | func burn (aD) = if (aB(az)) |
---|
332 | | - | then $Tuple2([Burn(ax, aD)], aD) |
---|
333 | | - | else $Tuple2(nil, unit) |
---|
334 | | - | |
---|
335 | | - | |
---|
336 | | - | |
---|
337 | | - | @Callable(az) |
---|
338 | | - | func transferAsset (aE,aD,aF) = if (aB(az)) |
---|
339 | | - | then $Tuple2([ScriptTransfer(Address(aE), aD, aF)], aD) |
---|
340 | | - | else $Tuple2(nil, unit) |
---|
341 | | - | |
---|
342 | | - | |
---|
343 | | - | |
---|
344 | | - | @Callable(az) |
---|
345 | | - | func transferWaves (aE,aD) = if (aB(az)) |
---|
346 | | - | then $Tuple2([ScriptTransfer(Address(aE), aD, unit)], aD) |
---|
347 | | - | else $Tuple2(nil, unit) |
---|
348 | | - | |
---|
349 | | - | |
---|
350 | | - | |
---|
351 | | - | @Callable(az) |
---|
352 | | - | func transferFromProxyTreasury (aG,aH) = if (aB(az)) |
---|
353 | | - | then $Tuple2(nil, invoke(ah, "transferWaves", [aG, aH], nil)) |
---|
354 | | - | else $Tuple2(nil, unit) |
---|
355 | | - | |
---|
356 | | - | |
---|
357 | | - | |
---|
358 | | - | @Callable(az) |
---|
359 | | - | func finalize (aI,aJ,aK) = $Tuple2(nil, reentrantInvoke(af, "finalize", [az.caller.bytes, aI, aJ, aK], az.payments)) |
---|
360 | | - | |
---|
361 | | - | |
---|
362 | | - | |
---|
363 | | - | @Callable(az) |
---|
364 | | - | func claimLP () = $Tuple2(nil, reentrantInvoke(af, "claimLP", [az.caller.bytes], az.payments)) |
---|
365 | | - | |
---|
366 | | - | |
---|
367 | | - | |
---|
368 | | - | @Callable(az) |
---|
369 | | - | func claimWaves (aL) = $Tuple2(nil, reentrantInvoke(af, "claimWaves", [az.caller.bytes, fromBase58String(aL)], az.payments)) |
---|
370 | | - | |
---|
371 | | - | |
---|
372 | | - | |
---|
373 | | - | @Callable(az) |
---|
374 | | - | func invest () = $Tuple2(nil, reentrantInvoke(af, "invest", [az.caller.bytes], az.payments)) |
---|
375 | | - | |
---|
376 | | - | |
---|
377 | | - | |
---|
378 | | - | @Callable(az) |
---|
379 | | - | func withdraw () = $Tuple2(nil, reentrantInvoke(af, "withdraw", [az.caller.bytes], az.payments)) |
---|
380 | | - | |
---|
381 | | - | |
---|
382 | | - | |
---|
383 | | - | @Callable(az) |
---|
384 | | - | func cancelWithdraw (aL) = $Tuple2(nil, reentrantInvoke(af, "cancelWithdraw", [az.caller.bytes, fromBase58String(aL)], az.payments)) |
---|
385 | | - | |
---|
386 | | - | |
---|
387 | | - | |
---|
388 | | - | @Callable(az) |
---|
389 | | - | func processBlocks () = $Tuple2(nil, reentrantInvoke(af, "processBlocks", [az.caller.bytes], az.payments)) |
---|
390 | | - | |
---|
391 | | - | |
---|
392 | | - | |
---|
393 | | - | @Callable(az) |
---|
394 | | - | func voteForTxId (j) = { |
---|
395 | | - | let S = toBase58String(az.caller.bytes) |
---|
396 | | - | let B = i(j) |
---|
397 | | - | let z = [StringEntry(o(), j)] |
---|
398 | | - | let aM = getString(this, o()) |
---|
399 | | - | let W = [if ((size(fromBase58String(j)) == h)) |
---|
400 | | - | then true |
---|
401 | | - | else e((j + " is not valid txId")), if (if ((aM == unit)) |
---|
402 | | - | then true |
---|
403 | | - | else (value(aM) != j)) |
---|
404 | | - | then true |
---|
405 | | - | else e((j + " is already allowed"))] |
---|
406 | | - | if ((W == W)) |
---|
407 | | - | then R(S, B, g, z) |
---|
408 | | - | else throw("Strict value is not equal to itself.") |
---|
409 | | - | } |
---|
410 | | - | |
---|
411 | | - | |
---|
412 | | - | @Verifier(aN) |
---|
413 | | - | func aO () = { |
---|
414 | | - | let aP = { |
---|
415 | | - | let t = ar |
---|
416 | | - | if ($isInstanceOf(t, "Address")) |
---|
417 | | - | then { |
---|
418 | | - | let aQ = t |
---|
419 | | - | valueOrElse(getBoolean(aQ, al(this, aN.id)), false) |
---|
420 | | - | } |
---|
421 | | - | else false |
---|
422 | | - | } |
---|
423 | | - | let aR = (aN.id == fromBase58String(valueOrElse(getString(this, o()), ""))) |
---|
424 | | - | let aS = if ((size(s()) >= g)) |
---|
425 | | - | then false |
---|
426 | | - | else sigVerify(aN.bodyBytes, aN.proofs[0], aN.senderPublicKey) |
---|
427 | | - | if (if (aP) |
---|
428 | | - | then true |
---|
429 | | - | else aR) |
---|
430 | | - | then true |
---|
431 | | - | else aS |
---|
432 | | - | } |
---|
433 | | - | |
---|
| 1 | + | # no script |
---|