1 | | - | {-# STDLIB_VERSION 6 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = "treasury.ride" |
---|
7 | | - | |
---|
8 | | - | let c = 5 |
---|
9 | | - | |
---|
10 | | - | let d = 3 |
---|
11 | | - | |
---|
12 | | - | let e = 32 |
---|
13 | | - | |
---|
14 | | - | func f (g) = ((b + ": ") + g) |
---|
15 | | - | |
---|
16 | | - | |
---|
17 | | - | func h (g) = throw(f(g)) |
---|
18 | | - | |
---|
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 () = "%s__config" |
---|
33 | | - | |
---|
34 | | - | |
---|
35 | | - | func q () = "contract_voting_result" |
---|
36 | | - | |
---|
37 | | - | |
---|
38 | | - | func r (s,j) = ((("proposal_allow_broadcast_" + toString(s)) + "_") + toBase58String(j)) |
---|
39 | | - | |
---|
40 | | - | |
---|
41 | | - | let t = { |
---|
42 | | - | let u = getString(this, p()) |
---|
43 | | - | if ($isInstanceOf(u, "String")) |
---|
44 | | - | then { |
---|
45 | | - | let g = u |
---|
46 | | - | addressFromString(g) |
---|
47 | | - | } |
---|
48 | | - | else if ($isInstanceOf(u, "Unit")) |
---|
49 | | - | then unit |
---|
50 | | - | else throw("Match error") |
---|
51 | | - | } |
---|
52 | | - | |
---|
53 | | - | let v = valueOrErrorMessage(t, f("invalid config address")) |
---|
54 | | - | |
---|
55 | | - | let w = { |
---|
56 | | - | let u = t |
---|
57 | | - | if ($isInstanceOf(u, "Address")) |
---|
58 | | - | then { |
---|
59 | | - | let x = u |
---|
60 | | - | let y = getString(x, q()) |
---|
61 | | - | if ($isInstanceOf(y, "String")) |
---|
62 | | - | then { |
---|
63 | | - | let g = y |
---|
64 | | - | addressFromString(g) |
---|
65 | | - | } |
---|
66 | | - | else if ($isInstanceOf(y, "Unit")) |
---|
67 | | - | then unit |
---|
68 | | - | else throw("Match error") |
---|
69 | | - | } |
---|
70 | | - | else if ($isInstanceOf(u, "Unit")) |
---|
71 | | - | then unit |
---|
72 | | - | else throw("Match error") |
---|
73 | | - | } |
---|
74 | | - | |
---|
75 | | - | let z = valueOrErrorMessage(w, f("invalid voting result address")) |
---|
76 | | - | |
---|
77 | | - | func A (l,B) = { |
---|
78 | | - | let C = k(l, B) |
---|
79 | | - | valueOrElse(getInteger(C), 0) |
---|
80 | | - | } |
---|
81 | | - | |
---|
82 | | - | |
---|
83 | | - | func D () = { |
---|
84 | | - | let u = getString(this, n()) |
---|
85 | | - | if ($isInstanceOf(u, "String")) |
---|
86 | | - | then { |
---|
87 | | - | let g = u |
---|
88 | | - | split(g, a) |
---|
89 | | - | } |
---|
90 | | - | else nil |
---|
91 | | - | } |
---|
92 | | - | |
---|
93 | | - | |
---|
94 | | - | func E (s) = containsElement(D(), s) |
---|
95 | | - | |
---|
96 | | - | |
---|
97 | | - | func F (x,m) = { |
---|
98 | | - | let G = x |
---|
99 | | - | let H = G._1 |
---|
100 | | - | let l = G._2 |
---|
101 | | - | $Tuple2((H :+ k(l, m)), l) |
---|
102 | | - | } |
---|
103 | | - | |
---|
104 | | - | |
---|
105 | | - | func I (J) = { |
---|
106 | | - | let K = n() |
---|
107 | | - | let L = { |
---|
108 | | - | let M = D() |
---|
109 | | - | let N = size(M) |
---|
110 | | - | let O = $Tuple2(nil, J) |
---|
111 | | - | func P (Q,R) = if ((R >= N)) |
---|
112 | | - | then Q |
---|
113 | | - | else F(Q, M[R]) |
---|
114 | | - | |
---|
115 | | - | func S (Q,R) = if ((R >= N)) |
---|
116 | | - | then Q |
---|
117 | | - | else throw("List size exceeds 5") |
---|
118 | | - | |
---|
119 | | - | S(P(P(P(P(P(O, 0), 1), 2), 3), 4), 5) |
---|
120 | | - | } |
---|
121 | | - | let H = L._1 |
---|
122 | | - | let l = L._2 |
---|
123 | | - | H |
---|
124 | | - | } |
---|
125 | | - | |
---|
126 | | - | |
---|
127 | | - | func T (H,C) = (H + valueOrElse(getInteger(C), 0)) |
---|
128 | | - | |
---|
129 | | - | |
---|
130 | | - | func U (l) = { |
---|
131 | | - | let V = I(l) |
---|
132 | | - | let M = V |
---|
133 | | - | let N = size(M) |
---|
134 | | - | let O = 0 |
---|
135 | | - | func P (Q,R) = if ((R >= N)) |
---|
136 | | - | then Q |
---|
137 | | - | else T(Q, M[R]) |
---|
138 | | - | |
---|
139 | | - | func S (Q,R) = if ((R >= N)) |
---|
140 | | - | then Q |
---|
141 | | - | else throw("List size exceeds 5") |
---|
142 | | - | |
---|
143 | | - | S(P(P(P(P(P(O, 0), 1), 2), 3), 4), 5) |
---|
144 | | - | } |
---|
145 | | - | |
---|
146 | | - | |
---|
147 | | - | func W (H,X) = (H :+ DeleteEntry(X)) |
---|
148 | | - | |
---|
149 | | - | |
---|
150 | | - | func Y (l) = { |
---|
151 | | - | let V = I(l) |
---|
152 | | - | let M = V |
---|
153 | | - | let N = size(M) |
---|
154 | | - | let O = nil |
---|
155 | | - | func P (Q,R) = if ((R >= N)) |
---|
156 | | - | then Q |
---|
157 | | - | else W(Q, M[R]) |
---|
158 | | - | |
---|
159 | | - | func S (Q,R) = if ((R >= N)) |
---|
160 | | - | then Q |
---|
161 | | - | else throw("List size exceeds 5") |
---|
162 | | - | |
---|
163 | | - | S(P(P(P(P(P(O, 0), 1), 2), 3), 4), 5) |
---|
164 | | - | } |
---|
165 | | - | |
---|
166 | | - | |
---|
167 | | - | func Z (aa,J,ab,ac) = { |
---|
168 | | - | let C = k(J, aa) |
---|
169 | | - | let ad = A(J, aa) |
---|
170 | | - | let ae = if (!(E(aa))) |
---|
171 | | - | then h((("Address: " + aa) + " not in Admin list")) |
---|
172 | | - | else if ((ad == 1)) |
---|
173 | | - | then h((C + " you already voted")) |
---|
174 | | - | else unit |
---|
175 | | - | if ((ae == ae)) |
---|
176 | | - | then { |
---|
177 | | - | let V = U(J) |
---|
178 | | - | if (((V + 1) >= ab)) |
---|
179 | | - | then { |
---|
180 | | - | let af = Y(J) |
---|
181 | | - | (af ++ ac) |
---|
182 | | - | } |
---|
183 | | - | else [IntegerEntry(C, 1)] |
---|
184 | | - | } |
---|
185 | | - | else throw("Strict value is not equal to itself.") |
---|
186 | | - | } |
---|
187 | | - | |
---|
188 | | - | |
---|
189 | | - | @Callable(ag) |
---|
190 | | - | func voteForTxId (j) = { |
---|
191 | | - | let aa = toBase58String(ag.caller.bytes) |
---|
192 | | - | let J = i(j) |
---|
193 | | - | let H = [StringEntry(o(), j)] |
---|
194 | | - | let ah = getString(this, o()) |
---|
195 | | - | let ae = [if ((size(fromBase58String(j)) == e)) |
---|
196 | | - | then true |
---|
197 | | - | else h((j + " is not valid txId")), if (if ((ah == unit)) |
---|
198 | | - | then true |
---|
199 | | - | else (value(ah) != j)) |
---|
200 | | - | then true |
---|
201 | | - | else h((j + " is already allowed"))] |
---|
202 | | - | if ((ae == ae)) |
---|
203 | | - | then Z(aa, J, d, H) |
---|
204 | | - | else throw("Strict value is not equal to itself.") |
---|
205 | | - | } |
---|
206 | | - | |
---|
207 | | - | |
---|
208 | | - | @Verifier(ai) |
---|
209 | | - | func aj () = { |
---|
210 | | - | let ak = getString(o()) |
---|
211 | | - | let al = D() |
---|
212 | | - | let am = valueOrElse(getBoolean(z, r(this, ai.id)), false) |
---|
213 | | - | let an = if ((ak != unit)) |
---|
214 | | - | then (ai.id == fromBase58String(value(ak))) |
---|
215 | | - | else false |
---|
216 | | - | let ao = sigVerify(ai.bodyBytes, ai.proofs[0], ai.senderPublicKey) |
---|
217 | | - | if (if ((t != unit)) |
---|
218 | | - | then (size(al) == c) |
---|
219 | | - | else false) |
---|
220 | | - | then if (if ((w != unit)) |
---|
221 | | - | then am |
---|
222 | | - | else false) |
---|
223 | | - | then true |
---|
224 | | - | else an |
---|
225 | | - | else ao |
---|
226 | | - | } |
---|
227 | | - | |
---|
| 1 | + | # no script |
---|