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 | | - | @Callable(O) |
---|
107 | | - | func addItem (q,P,Q) = { |
---|
108 | | - | let R = toBase58String(O.caller.bytes) |
---|
109 | | - | let j = o(R, q) |
---|
110 | | - | if ((0 >= P)) |
---|
111 | | - | then throw("Purchase amount cannot be less than item price") |
---|
112 | | - | else if ((t(j) != a)) |
---|
113 | | - | then throw("an item already exists") |
---|
114 | | - | else [StringEntry(s(j), R), IntegerEntry(i(j), P), StringEntry(r(j), Q)] |
---|
115 | | - | } |
---|
116 | | - | |
---|
117 | | - | |
---|
118 | | - | |
---|
119 | | - | @Callable(O) |
---|
120 | | - | func purchase (j) = { |
---|
121 | | - | let S = O.payments[0] |
---|
122 | | - | if (isDefined(S.assetId)) |
---|
123 | | - | then throw("WAVES ONLY HHEUAWHEUAS") |
---|
124 | | - | else { |
---|
125 | | - | let T = toBase58String(O.caller.bytes) |
---|
126 | | - | let P = k(j) |
---|
127 | | - | let R = t(j) |
---|
128 | | - | if ((P > S.amount)) |
---|
129 | | - | then throw("Purchase amount cannot be less than item price") |
---|
130 | | - | else if ((R == a)) |
---|
131 | | - | then throw("Supplier does not exist") |
---|
132 | | - | else [IntegerEntry(l(T, j), (n(T, j) + 1)), IntegerEntry(u(R), (w(R) + S.amount))] |
---|
133 | | - | } |
---|
134 | | - | } |
---|
135 | | - | |
---|
136 | | - | |
---|
137 | | - | |
---|
138 | | - | @Callable(O) |
---|
139 | | - | func withdraw () = { |
---|
140 | | - | let R = toBase58String(O.caller.bytes) |
---|
141 | | - | let U = w(R) |
---|
142 | | - | if ((0 >= U)) |
---|
143 | | - | then throw("insuficient balance") |
---|
144 | | - | else [IntegerEntry(u(R), 0), ScriptTransfer(addressFromStringValue(R), U, unit)] |
---|
145 | | - | } |
---|
146 | | - | |
---|
147 | | - | |
---|
148 | | - | |
---|
149 | | - | @Callable(O) |
---|
150 | | - | func voteCommit (j,V) = { |
---|
151 | | - | let m = toBase58String(O.caller.bytes) |
---|
152 | | - | let W = G(j) |
---|
153 | | - | let X = K(j) |
---|
154 | | - | if ((W >= x)) |
---|
155 | | - | then throw("Reached max num of voters") |
---|
156 | | - | else if ((E(j, m) != a)) |
---|
157 | | - | then throw("b1") |
---|
158 | | - | else if ((s(j) == a)) |
---|
159 | | - | then throw("b2") |
---|
160 | | - | else if (if ((X != a)) |
---|
161 | | - | then (X != z) |
---|
162 | | - | else false) |
---|
163 | | - | then throw("b3") |
---|
164 | | - | else [StringEntry(D(j, m), V), IntegerEntry(F(j), (W + 1)), StringEntry(J(j), if ((W == x)) |
---|
165 | | - | then A |
---|
166 | | - | else z)] |
---|
167 | | - | } |
---|
168 | | - | |
---|
169 | | - | |
---|
170 | | - | |
---|
171 | | - | @Callable(O) |
---|
172 | | - | func voteReveal (j,M,Y) = { |
---|
173 | | - | let m = toBase58String(O.caller.bytes) |
---|
174 | | - | let X = K(j) |
---|
175 | | - | let Z = (N(j, M) + 1) |
---|
176 | | - | if ((toBase58String(sha256(toBytes((M + Y)))) != E(j, m))) |
---|
177 | | - | then throw("Reveal data is not valid") |
---|
178 | | - | else if ((x > G(j))) |
---|
179 | | - | then throw("max num of voters hasnt reached yet") |
---|
180 | | - | else if ((I(j, m) != a)) |
---|
181 | | - | then throw("user has already participated") |
---|
182 | | - | else if (if ((X != z)) |
---|
183 | | - | then (X != A) |
---|
184 | | - | else false) |
---|
185 | | - | then throw("wrong status") |
---|
186 | | - | else if (if ((M != B)) |
---|
187 | | - | then (M != C) |
---|
188 | | - | else false) |
---|
189 | | - | then throw("wrong vote") |
---|
190 | | - | else if (if ((X == B)) |
---|
191 | | - | then true |
---|
192 | | - | else (X == C)) |
---|
193 | | - | then throw("vote has finished") |
---|
194 | | - | else [StringEntry(H(j, m), M), IntegerEntry(L(j, M), Z), StringEntry(J(j), if ((Z >= y)) |
---|
195 | | - | then M |
---|
196 | | - | else A)] |
---|
197 | | - | } |
---|
198 | | - | |
---|
| 10 | + | @Verifier(b) |
---|
| 11 | + | func c () = sigVerify(b.bodyBytes, b.proofs[0], b.senderPublicKey) |
---|