20 | | - | func g (c) = { |
---|
21 | | - | let h = { |
---|
22 | | - | let e = getString(this, c) |
---|
23 | | - | if ($isInstanceOf(e, "String")) |
---|
24 | | - | then { |
---|
25 | | - | let f = e |
---|
26 | | - | f |
---|
27 | | - | } |
---|
28 | | - | else a |
---|
29 | | - | } |
---|
30 | | - | h |
---|
31 | | - | } |
---|
32 | | - | |
---|
33 | | - | |
---|
34 | | - | func i (j) = (j + "_price") |
---|
35 | | - | |
---|
36 | | - | |
---|
37 | | - | func k (j) = b(i(j)) |
---|
38 | | - | |
---|
39 | | - | |
---|
40 | | - | func l (m,j) = (((j + "_") + m) + "_cnt") |
---|
41 | | - | |
---|
42 | | - | |
---|
43 | | - | func n (m,j) = b(l(m, j)) |
---|
44 | | - | |
---|
45 | | - | |
---|
46 | | - | func o (p,q) = ("item_" + toBase58String(sha256(toBytes((p + q))))) |
---|
47 | | - | |
---|
48 | | - | |
---|
49 | | - | func r (j) = (j + "_data") |
---|
50 | | - | |
---|
51 | | - | |
---|
52 | | - | func s (j) = (j + "_owner") |
---|
53 | | - | |
---|
54 | | - | |
---|
55 | | - | func t (j) = g(s(j)) |
---|
56 | | - | |
---|
57 | | - | |
---|
58 | | - | func u (v) = (v + "_balance") |
---|
59 | | - | |
---|
60 | | - | |
---|
61 | | - | func w (v) = b(u(v)) |
---|
62 | | - | |
---|
63 | | - | |
---|
64 | | - | let x = 3 |
---|
65 | | - | |
---|
66 | | - | let y = 2 |
---|
67 | | - | |
---|
68 | | - | let z = "voting" |
---|
69 | | - | |
---|
70 | | - | let A = "reveal" |
---|
71 | | - | |
---|
72 | | - | let B = "featured" |
---|
73 | | - | |
---|
74 | | - | let C = "delisted" |
---|
75 | | - | |
---|
76 | | - | func D (j,m) = (((j + "_") + m) + "_commit") |
---|
77 | | - | |
---|
78 | | - | |
---|
79 | | - | func E (j,m) = g(D(j, m)) |
---|
80 | | - | |
---|
81 | | - | |
---|
82 | | - | func F (j) = (j + "_comcnt") |
---|
83 | | - | |
---|
84 | | - | |
---|
85 | | - | func G (j) = b(F(j)) |
---|
86 | | - | |
---|
87 | | - | |
---|
88 | | - | func H (j,m) = (((j + "_") + m) + "_reveal") |
---|
89 | | - | |
---|
90 | | - | |
---|
91 | | - | func I (j,m) = g(H(j, m)) |
---|
92 | | - | |
---|
93 | | - | |
---|
94 | | - | func J (j) = (j + "_status") |
---|
95 | | - | |
---|
96 | | - | |
---|
97 | | - | func K (j) = g(J(j)) |
---|
98 | | - | |
---|
99 | | - | |
---|
100 | | - | func L (j,M) = ((j + "_res:") + M) |
---|
101 | | - | |
---|
102 | | - | |
---|
103 | | - | func N (j,M) = b(L(j, M)) |
---|
104 | | - | |
---|
105 | | - | |
---|
106 | | - | func O () = value(addressFromString("3MsbiyFyy8B3aN3kF8ntda474SPn4YMVkiq")) |
---|
107 | | - | |
---|
108 | | - | |
---|
109 | | - | let P = "blacklist" |
---|
110 | | - | |
---|
111 | | - | func Q (v) = (v + "_verifier_status") |
---|
112 | | - | |
---|
113 | | - | |
---|
114 | | - | func R (S,v) = { |
---|
115 | | - | let h = { |
---|
116 | | - | let e = getString(S, Q(v)) |
---|
117 | | - | if ($isInstanceOf(e, "String")) |
---|
118 | | - | then { |
---|
119 | | - | let f = e |
---|
120 | | - | f |
---|
121 | | - | } |
---|
122 | | - | else a |
---|
123 | | - | } |
---|
124 | | - | h |
---|
125 | | - | } |
---|
126 | | - | |
---|
127 | | - | |
---|
128 | | - | @Callable(T) |
---|
129 | | - | func addItem (q,U,V) = { |
---|
130 | | - | let W = toBase58String(T.caller.bytes) |
---|
131 | | - | let j = o(W, q) |
---|
132 | | - | let X = R(O(), W) |
---|
133 | | - | if ((0 >= U)) |
---|
134 | | - | then throw("Purchase amount cannot be less than item price") |
---|
135 | | - | else if ((t(j) != a)) |
---|
136 | | - | then throw("an item already exists") |
---|
137 | | - | else if ((X == P)) |
---|
138 | | - | then throw("supplier's account has been blacklisted") |
---|
139 | | - | else [StringEntry(s(j), W), IntegerEntry(i(j), U), StringEntry(r(j), V), StringEntry(Q(W), X)] |
---|
140 | | - | } |
---|
141 | | - | |
---|
142 | | - | |
---|
143 | | - | |
---|
144 | | - | @Callable(T) |
---|
145 | | - | func purchase (j) = { |
---|
146 | | - | let Y = T.payments[0] |
---|
147 | | - | if (isDefined(Y.assetId)) |
---|
148 | | - | then throw("WAVES ONLY HHEUAWHEUAS") |
---|
149 | | - | else { |
---|
150 | | - | let Z = toBase58String(T.caller.bytes) |
---|
151 | | - | let U = k(j) |
---|
152 | | - | let W = t(j) |
---|
153 | | - | if ((U > Y.amount)) |
---|
154 | | - | then throw("Purchase amount cannot be less than item price") |
---|
155 | | - | else if ((W == a)) |
---|
156 | | - | then throw("Supplier does not exist") |
---|
157 | | - | else [IntegerEntry(l(Z, j), (n(Z, j) + 1)), IntegerEntry(u(W), (w(W) + Y.amount))] |
---|
158 | | - | } |
---|
159 | | - | } |
---|
160 | | - | |
---|
161 | | - | |
---|
162 | | - | |
---|
163 | | - | @Callable(T) |
---|
164 | | - | func withdraw () = { |
---|
165 | | - | let W = toBase58String(T.caller.bytes) |
---|
166 | | - | let aa = w(W) |
---|
167 | | - | if ((0 >= aa)) |
---|
168 | | - | then throw("insuficient balance") |
---|
169 | | - | else [IntegerEntry(u(W), 0), ScriptTransfer(addressFromStringValue(W), aa, unit)] |
---|
170 | | - | } |
---|
171 | | - | |
---|
172 | | - | |
---|
173 | | - | |
---|
174 | | - | @Callable(T) |
---|
175 | | - | func voteCommit (j,ab) = { |
---|
176 | | - | let m = toBase58String(T.caller.bytes) |
---|
177 | | - | let ac = G(j) |
---|
178 | | - | let ad = K(j) |
---|
179 | | - | if ((ac >= x)) |
---|
180 | | - | then throw("Reached max num of voters") |
---|
181 | | - | else if ((E(j, m) != a)) |
---|
182 | | - | then throw("b1") |
---|
183 | | - | else if ((s(j) == a)) |
---|
184 | | - | then throw("b2") |
---|
185 | | - | else if (if ((ad != a)) |
---|
186 | | - | then (ad != z) |
---|
187 | | - | else false) |
---|
188 | | - | then throw("b3") |
---|
189 | | - | else [StringEntry(D(j, m), ab), IntegerEntry(F(j), (ac + 1)), StringEntry(J(j), if ((ac == x)) |
---|
190 | | - | then A |
---|
191 | | - | else z)] |
---|
192 | | - | } |
---|
193 | | - | |
---|
194 | | - | |
---|
195 | | - | |
---|
196 | | - | @Callable(T) |
---|
197 | | - | func voteReveal (j,M,ae) = { |
---|
198 | | - | let m = toBase58String(T.caller.bytes) |
---|
199 | | - | let ad = K(j) |
---|
200 | | - | let af = (N(j, M) + 1) |
---|
201 | | - | if ((toBase58String(sha256(toBytes((M + ae)))) != E(j, m))) |
---|
202 | | - | then throw("Reveal data is not valid") |
---|
203 | | - | else if ((x > G(j))) |
---|
204 | | - | then throw("max num of voters hasnt reached yet") |
---|
205 | | - | else if ((I(j, m) != a)) |
---|
206 | | - | then throw("user has already participated") |
---|
207 | | - | else if (if ((ad != z)) |
---|
208 | | - | then (ad != A) |
---|
209 | | - | else false) |
---|
210 | | - | then throw("wrong status") |
---|
211 | | - | else if (if ((M != B)) |
---|
212 | | - | then (M != C) |
---|
213 | | - | else false) |
---|
214 | | - | then throw("wrong vote") |
---|
215 | | - | else if (if ((ad == B)) |
---|
216 | | - | then true |
---|
217 | | - | else (ad == C)) |
---|
218 | | - | then throw("vote has finished") |
---|
219 | | - | else [StringEntry(H(j, m), M), IntegerEntry(L(j, M), af), StringEntry(J(j), if ((af >= y)) |
---|
220 | | - | then M |
---|
221 | | - | else A)] |
---|
222 | | - | } |
---|
223 | | - | |
---|
| 16 | + | @Verifier(d) |
---|
| 17 | + | func e () = sigVerify(d.bodyBytes, d.proofs[0], d.senderPublicKey) |
---|