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