42 | | - | func r (s,t) = if ((s == true)) |
---|
43 | | - | then true |
---|
44 | | - | else contains(t, a) |
---|
45 | | - | |
---|
46 | | - | |
---|
47 | | - | @Callable(u) |
---|
48 | | - | func deposit () = if ((c > height)) |
---|
49 | | - | then throw("Waiting for genesis height") |
---|
50 | | - | else if ((this == u.caller)) |
---|
51 | | - | then throw("Self call is forbidden") |
---|
52 | | - | else if (if (if ((size(u.payments) != 1)) |
---|
53 | | - | then true |
---|
54 | | - | else (1 > u.payments[0].amount)) |
---|
55 | | - | then true |
---|
56 | | - | else (u.payments[0].amount > l)) |
---|
57 | | - | then throw("Attached payment issue") |
---|
58 | | - | else { |
---|
59 | | - | let v = { |
---|
60 | | - | let w = u.payments[0].assetId |
---|
61 | | - | if ($isInstanceOf(w, "ByteVector")) |
---|
62 | | - | then { |
---|
63 | | - | let x = w |
---|
64 | | - | toBase58String(valueOrErrorMessage(assetInfo(x), "Unknown asset").id) |
---|
65 | | - | } |
---|
66 | | - | else if ($isInstanceOf(w, "Unit")) |
---|
67 | | - | then { |
---|
68 | | - | let y = w |
---|
69 | | - | b |
---|
70 | | - | } |
---|
71 | | - | else throw("Wrong asset type") |
---|
72 | | - | } |
---|
73 | | - | let z = [f, toString(height), toString(u.caller), v, toString(u.payments[0].amount)] |
---|
74 | | - | if (({ |
---|
75 | | - | let A = z |
---|
76 | | - | let B = size(A) |
---|
77 | | - | let C = false |
---|
78 | | - | if ((B == 0)) |
---|
79 | | - | then C |
---|
80 | | - | else { |
---|
81 | | - | let D = r(C, A[0]) |
---|
82 | | - | if ((B == 1)) |
---|
83 | | - | then D |
---|
84 | | - | else { |
---|
85 | | - | let E = r(D, A[1]) |
---|
86 | | - | if ((B == 2)) |
---|
87 | | - | then E |
---|
88 | | - | else { |
---|
89 | | - | let F = r(E, A[2]) |
---|
90 | | - | if ((B == 3)) |
---|
91 | | - | then F |
---|
92 | | - | else { |
---|
93 | | - | let G = r(F, A[3]) |
---|
94 | | - | if ((B == 4)) |
---|
95 | | - | then G |
---|
96 | | - | else { |
---|
97 | | - | let H = r(G, A[4]) |
---|
98 | | - | if ((B == 5)) |
---|
99 | | - | then H |
---|
100 | | - | else { |
---|
101 | | - | let I = r(H, A[5]) |
---|
102 | | - | throw("List size exceed 5") |
---|
103 | | - | } |
---|
104 | | - | } |
---|
105 | | - | } |
---|
106 | | - | } |
---|
107 | | - | } |
---|
108 | | - | } |
---|
109 | | - | } == true)) |
---|
110 | | - | then throw("Separator found in fields") |
---|
111 | | - | else { |
---|
112 | | - | let J = makeString(z, a) |
---|
113 | | - | if ((size(toBytes(J)) > n)) |
---|
114 | | - | then throw("Too long contract") |
---|
115 | | - | else { |
---|
116 | | - | let K = p() |
---|
117 | | - | let L = Issue(d, J, 1, 0, false, unit, K) |
---|
118 | | - | let M = ScriptTransfer(u.caller, L.quantity, calculateAssetId(L)) |
---|
119 | | - | [IntegerEntry(i, K), L, M] |
---|
120 | | - | } |
---|
121 | | - | } |
---|
122 | | - | } |
---|
123 | | - | |
---|
124 | | - | |
---|
125 | | - | |
---|
126 | | - | @Callable(u) |
---|
127 | | - | func withdraw () = if ((this == u.caller)) |
---|
128 | | - | then throw("Self call is forbidden") |
---|
129 | | - | else if (if ((size(u.payments) != 1)) |
---|
130 | | - | then true |
---|
131 | | - | else (u.payments[0].amount != 1)) |
---|
132 | | - | then throw("Attached payment issue") |
---|
133 | | - | else { |
---|
134 | | - | let N = valueOrErrorMessage(assetInfo(valueOrErrorMessage(u.payments[0].assetId, "Wrong asset type")), "Unknown asset") |
---|
135 | | - | if ((N.issuer != this)) |
---|
136 | | - | then throw("Unknown issuer") |
---|
137 | | - | else { |
---|
138 | | - | let z = split(N.description, a) |
---|
139 | | - | if ((size(z) != 5)) |
---|
140 | | - | then throw("Wrong fields amount") |
---|
141 | | - | else if ((z[0] != f)) |
---|
142 | | - | then throw("Not a contract") |
---|
143 | | - | else { |
---|
144 | | - | let O = valueOrErrorMessage(parseInt(z[1]), "Not a height") |
---|
145 | | - | if ((isDefined(addressFromString(z[2])) != true)) |
---|
146 | | - | then throw("Not an address") |
---|
147 | | - | else { |
---|
148 | | - | let P = valueOrErrorMessage(parseInt(z[4]), "Not a quantity") |
---|
149 | | - | let Q = { |
---|
150 | | - | let w = assetInfo(fromBase58String(z[3])) |
---|
151 | | - | if ($isInstanceOf(w, "Asset")) |
---|
152 | | - | then { |
---|
153 | | - | let R = w |
---|
154 | | - | $Tuple2(R.id, assetBalance(this, R.id)) |
---|
155 | | - | } |
---|
156 | | - | else if ($isInstanceOf(w, "Unit")) |
---|
157 | | - | then { |
---|
158 | | - | let S = w |
---|
159 | | - | if ((z[3] == b)) |
---|
160 | | - | then $Tuple2(unit, wavesBalance(this).available) |
---|
161 | | - | else throw("Unknown asset") |
---|
162 | | - | } |
---|
163 | | - | else throw("Unknown asset") |
---|
164 | | - | } |
---|
165 | | - | if (if ((c > O)) |
---|
166 | | - | then true |
---|
167 | | - | else (O >= height)) |
---|
168 | | - | then throw("Not in height scope") |
---|
169 | | - | else if (if ((1 > P)) |
---|
170 | | - | then true |
---|
171 | | - | else (P > l)) |
---|
172 | | - | then throw("Quantity out-of-range") |
---|
173 | | - | else if ((P > Q._2)) |
---|
174 | | - | then throw("Insuffisant balance") |
---|
175 | | - | else { |
---|
176 | | - | let T = [g, toString(O), z[2], z[3], toString(P), toString(height), toBase58String(N.id), toString(u.caller)] |
---|
177 | | - | if (({ |
---|
178 | | - | let U = T |
---|
179 | | - | let V = size(U) |
---|
180 | | - | let W = false |
---|
181 | | - | if ((V == 0)) |
---|
182 | | - | then W |
---|
183 | | - | else { |
---|
184 | | - | let X = r(W, U[0]) |
---|
185 | | - | if ((V == 1)) |
---|
186 | | - | then X |
---|
187 | | - | else { |
---|
188 | | - | let Y = r(X, U[1]) |
---|
189 | | - | if ((V == 2)) |
---|
190 | | - | then Y |
---|
191 | | - | else { |
---|
192 | | - | let Z = r(Y, U[2]) |
---|
193 | | - | if ((V == 3)) |
---|
194 | | - | then Z |
---|
195 | | - | else { |
---|
196 | | - | let aa = r(Z, U[3]) |
---|
197 | | - | if ((V == 4)) |
---|
198 | | - | then aa |
---|
199 | | - | else { |
---|
200 | | - | let ab = r(aa, U[4]) |
---|
201 | | - | if ((V == 5)) |
---|
202 | | - | then ab |
---|
203 | | - | else { |
---|
204 | | - | let ac = r(ab, U[5]) |
---|
205 | | - | if ((V == 6)) |
---|
206 | | - | then ac |
---|
207 | | - | else { |
---|
208 | | - | let ad = r(ac, U[6]) |
---|
209 | | - | if ((V == 7)) |
---|
210 | | - | then ad |
---|
211 | | - | else { |
---|
212 | | - | let ae = r(ad, U[7]) |
---|
213 | | - | if ((V == 8)) |
---|
214 | | - | then ae |
---|
215 | | - | else { |
---|
216 | | - | let af = r(ae, U[8]) |
---|
217 | | - | throw("List size exceed 8") |
---|
218 | | - | } |
---|
219 | | - | } |
---|
220 | | - | } |
---|
221 | | - | } |
---|
222 | | - | } |
---|
223 | | - | } |
---|
224 | | - | } |
---|
225 | | - | } |
---|
226 | | - | } |
---|
227 | | - | } == true)) |
---|
228 | | - | then throw("Separator found in fields") |
---|
229 | | - | else { |
---|
230 | | - | let ag = makeString(T, a) |
---|
231 | | - | if ((size(toBytes(ag)) > n)) |
---|
232 | | - | then throw("Too long contract") |
---|
233 | | - | else { |
---|
234 | | - | let K = p() |
---|
235 | | - | let ah = Issue(e, ag, 1, 0, false, unit, K) |
---|
236 | | - | let ai = calculateAssetId(ah) |
---|
237 | | - | [IntegerEntry(i, K), Burn(N.id, 1), ah, ScriptTransfer(u.caller, ah.quantity, ai), ScriptTransfer(u.caller, P, Q._1)] |
---|
238 | | - | } |
---|
239 | | - | } |
---|
240 | | - | } |
---|
241 | | - | } |
---|
242 | | - | } |
---|
243 | | - | } |
---|
244 | | - | } |
---|
245 | | - | |
---|
246 | | - | |
---|
247 | | - | |
---|
248 | | - | @Callable(u) |
---|
249 | | - | func claim (aj) = if ((this == u.caller)) |
---|
250 | | - | then throw("Self call is forbidden") |
---|
251 | | - | else if ((1 > size(aj))) |
---|
252 | | - | then throw("Empty asset id") |
---|
253 | | - | else if ((size(u.payments) != 0)) |
---|
254 | | - | then throw("No need payment") |
---|
255 | | - | else { |
---|
256 | | - | let ak = valueOrErrorMessage(assetInfo(fromBase58String(aj)), "Unknown asset") |
---|
257 | | - | if ((ak.issuer != this)) |
---|
258 | | - | then throw("Unknown issuer") |
---|
259 | | - | else if ((assetBalance(this, ak.id) != 1)) |
---|
260 | | - | then throw("Unavailable") |
---|
261 | | - | else { |
---|
262 | | - | let al = valueOrErrorMessage(addressFromString(valueOrErrorMessage(split(ak.description, a)[2], "Address field missing")), "Not an address") |
---|
263 | | - | if ((u.caller != al)) |
---|
264 | | - | then throw("Not owner") |
---|
265 | | - | else [ScriptTransfer(u.caller, 1, ak.id)] |
---|
266 | | - | } |
---|
267 | | - | } |
---|
268 | | - | |
---|
269 | | - | |
---|
270 | | - | |
---|
271 | | - | @Callable(u) |
---|
272 | | - | func duplicate (aj) = if ((this == u.caller)) |
---|
273 | | - | then throw("Self call is forbidden") |
---|
274 | | - | else if ((1 > size(aj))) |
---|
275 | | - | then throw("Empty asset id") |
---|
276 | | - | else if ((size(u.payments) != 0)) |
---|
277 | | - | then throw("No need payment") |
---|
278 | | - | else { |
---|
279 | | - | let ak = valueOrErrorMessage(assetInfo(fromBase58String(aj)), "Unknown asset") |
---|
280 | | - | if ((ak.issuer != this)) |
---|
281 | | - | then throw("Unknown issuer") |
---|
282 | | - | else if ((assetBalance(u.caller, ak.id) != 1)) |
---|
283 | | - | then throw("Not owner") |
---|
284 | | - | else { |
---|
285 | | - | let am = split(ak.description, a) |
---|
286 | | - | if ((1 > size(am))) |
---|
287 | | - | then throw("No tag found") |
---|
288 | | - | else if (if ((am[0] != f)) |
---|
289 | | - | then (am[0] != g) |
---|
290 | | - | else false) |
---|
291 | | - | then throw("Not a contract or receipt") |
---|
292 | | - | else { |
---|
293 | | - | let an = (h + ak.name) |
---|
294 | | - | let ao = (h + ak.description) |
---|
295 | | - | if (if ((size(toBytes(ao)) > n)) |
---|
296 | | - | then true |
---|
297 | | - | else (size(toBytes(an)) > o)) |
---|
298 | | - | then throw("Too long, can't duplicate") |
---|
299 | | - | else { |
---|
300 | | - | let K = p() |
---|
301 | | - | let ap = Issue(an, ao, 1, 0, false, unit, K) |
---|
302 | | - | let aq = calculateAssetId(ap) |
---|
303 | | - | [IntegerEntry(i, K), ap, ScriptTransfer(u.caller, 1, ak.id)] |
---|
304 | | - | } |
---|
305 | | - | } |
---|
306 | | - | } |
---|
307 | | - | } |
---|
308 | | - | |
---|
309 | | - | |
---|
310 | | - | |
---|
311 | | - | @Callable(u) |
---|
312 | | - | func makeFree (ar) = if (if ((this != u.caller)) |
---|
313 | | - | then true |
---|
314 | | - | else (valueOrElse(getBoolean(this, j), false) == true)) |
---|
315 | | - | then throw("Access denied") |
---|
316 | | - | else [BooleanEntry(j, true), StringEntry(k, ar)] |
---|
317 | | - | |
---|
318 | | - | |
---|
319 | | - | @Verifier(as) |
---|
320 | | - | func at () = if ((valueOrElse(getBoolean(this, j), false) != false)) |
---|
321 | | - | then false |
---|
322 | | - | else { |
---|
323 | | - | let w = as |
---|
324 | | - | if ($isInstanceOf(w, "SetScriptTransaction")) |
---|
325 | | - | then { |
---|
326 | | - | let au = w |
---|
327 | | - | sigVerify(as.bodyBytes, as.proofs[0], as.senderPublicKey) |
---|
328 | | - | } |
---|
329 | | - | else false |
---|
330 | | - | } |
---|
| 14 | + | @Verifier(d) |
---|
| 15 | + | func e () = sigVerify(d.bodyBytes, d.proofs[0], d.senderPublicKey) |
---|