6 | | - | let b = "auction" |
---|
7 | | - | |
---|
8 | | - | let c = "sell" |
---|
9 | | - | |
---|
10 | | - | let d = "trusted" |
---|
11 | | - | |
---|
12 | | - | let e = "price" |
---|
13 | | - | |
---|
14 | | - | func f (g,h) = ((g + a) + toBase58String(h)) |
---|
15 | | - | |
---|
16 | | - | |
---|
17 | | - | func i (h) = ((e + a) + toBase58String(h)) |
---|
18 | | - | |
---|
19 | | - | |
---|
20 | | - | func j (h) = ((c + a) + toBase58String(h)) |
---|
21 | | - | |
---|
22 | | - | |
---|
23 | | - | func k (h) = ((b + a) + toBase58String(h)) |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | func l (m) = ((d + a) + toString(m)) |
---|
27 | | - | |
---|
28 | | - | |
---|
29 | | - | func n (o,p) = (o ++ [p]) |
---|
30 | | - | |
---|
31 | | - | |
---|
32 | | - | func q (r) = { |
---|
33 | | - | let s = size(r) |
---|
34 | | - | if ((s == 0)) |
---|
35 | | - | then throw("Empty params") |
---|
36 | | - | else if ((s == 1)) |
---|
37 | | - | then makeString({ |
---|
38 | | - | let t = r |
---|
39 | | - | let u = size(t) |
---|
40 | | - | let v = nil |
---|
41 | | - | func w (x,y) = if ((y >= u)) |
---|
42 | | - | then x |
---|
43 | | - | else n(x, t[y]) |
---|
44 | | - | |
---|
45 | | - | func z (x,y) = if ((y >= u)) |
---|
46 | | - | then x |
---|
47 | | - | else throw("List size exceeds 1") |
---|
48 | | - | |
---|
49 | | - | z(w(v, 0), 1) |
---|
50 | | - | }, a) |
---|
51 | | - | else if ((s == 2)) |
---|
52 | | - | then makeString({ |
---|
53 | | - | let t = r |
---|
54 | | - | let u = size(t) |
---|
55 | | - | let v = nil |
---|
56 | | - | func w (x,y) = if ((y >= u)) |
---|
57 | | - | then x |
---|
58 | | - | else n(x, t[y]) |
---|
59 | | - | |
---|
60 | | - | func z (x,y) = if ((y >= u)) |
---|
61 | | - | then x |
---|
62 | | - | else throw("List size exceeds 2") |
---|
63 | | - | |
---|
64 | | - | z(w(w(v, 0), 1), 2) |
---|
65 | | - | }, a) |
---|
66 | | - | else if ((s == 3)) |
---|
67 | | - | then makeString({ |
---|
68 | | - | let t = r |
---|
69 | | - | let u = size(t) |
---|
70 | | - | let v = nil |
---|
71 | | - | func w (x,y) = if ((y >= u)) |
---|
72 | | - | then x |
---|
73 | | - | else n(x, t[y]) |
---|
74 | | - | |
---|
75 | | - | func z (x,y) = if ((y >= u)) |
---|
76 | | - | then x |
---|
77 | | - | else throw("List size exceeds 3") |
---|
78 | | - | |
---|
79 | | - | z(w(w(w(v, 0), 1), 2), 3) |
---|
80 | | - | }, a) |
---|
81 | | - | else if ((s == 4)) |
---|
82 | | - | then makeString({ |
---|
83 | | - | let t = r |
---|
84 | | - | let u = size(t) |
---|
85 | | - | let v = nil |
---|
86 | | - | func w (x,y) = if ((y >= u)) |
---|
87 | | - | then x |
---|
88 | | - | else n(x, t[y]) |
---|
89 | | - | |
---|
90 | | - | func z (x,y) = if ((y >= u)) |
---|
91 | | - | then x |
---|
92 | | - | else throw("List size exceeds 4") |
---|
93 | | - | |
---|
94 | | - | z(w(w(w(w(v, 0), 1), 2), 3), 4) |
---|
95 | | - | }, a) |
---|
96 | | - | else if ((s == 5)) |
---|
97 | | - | then makeString({ |
---|
98 | | - | let t = r |
---|
99 | | - | let u = size(t) |
---|
100 | | - | let v = nil |
---|
101 | | - | func w (x,y) = if ((y >= u)) |
---|
102 | | - | then x |
---|
103 | | - | else n(x, t[y]) |
---|
104 | | - | |
---|
105 | | - | func z (x,y) = if ((y >= u)) |
---|
106 | | - | then x |
---|
107 | | - | else throw("List size exceeds 5") |
---|
108 | | - | |
---|
109 | | - | z(w(w(w(w(w(v, 0), 1), 2), 3), 4), 5) |
---|
110 | | - | }, a) |
---|
111 | | - | else throw("Max number of parameters exceeded") |
---|
112 | | - | } |
---|
113 | | - | |
---|
114 | | - | |
---|
115 | | - | func A (B) = { |
---|
116 | | - | let C = split(B, a) |
---|
117 | | - | $Tuple5(addressFromStringValue(C[0]), parseIntValue(C[1]), parseIntValue(C[2]), parseIntValue(C[3]), parseIntValue(C[4])) |
---|
118 | | - | } |
---|
119 | | - | |
---|
120 | | - | |
---|
121 | | - | func D (B) = { |
---|
122 | | - | let C = split(B, a) |
---|
123 | | - | $Tuple2(addressFromStringValue(C[0]), parseIntValue(C[1])) |
---|
124 | | - | } |
---|
125 | | - | |
---|
126 | | - | |
---|
127 | | - | func E (r) = { |
---|
128 | | - | let F = r |
---|
129 | | - | if ($isInstanceOf(F, "(Address, Int, String, String)")) |
---|
130 | | - | then { |
---|
131 | | - | let G = F |
---|
132 | | - | q([toString(G._1), toString(G._2), G._3, G._4]) |
---|
133 | | - | } |
---|
134 | | - | else if ($isInstanceOf(F, "(Address, Int)")) |
---|
135 | | - | then { |
---|
136 | | - | let H = F |
---|
137 | | - | q([toString(H._1), toString(H._2)]) |
---|
138 | | - | } |
---|
139 | | - | else throw("Wrong params tupple") |
---|
140 | | - | } |
---|
141 | | - | |
---|
142 | | - | |
---|
143 | | - | func I (J,h,K,L,M) = StringEntry(k(h), E($Tuple4(J, K, L, M))) |
---|
144 | | - | |
---|
145 | | - | |
---|
146 | | - | func N (h,O,P) = StringEntry(j(h), E($Tuple2(O, P))) |
---|
147 | | - | |
---|
148 | | - | |
---|
149 | | - | func Q (h) = value(getString(this, k(h))) |
---|
150 | | - | |
---|
151 | | - | |
---|
152 | | - | func R (h) = value(getString(this, j(h))) |
---|
153 | | - | |
---|
154 | | - | |
---|
155 | | - | func S (T,U) = { |
---|
156 | | - | let B = Q(T) |
---|
157 | | - | let V = A(B) |
---|
158 | | - | let J = V._1 |
---|
159 | | - | let W = V._2 |
---|
160 | | - | let X = V._3 |
---|
161 | | - | let Y = V._4 |
---|
162 | | - | let Z = V._5 |
---|
163 | | - | if ((U >= Z)) |
---|
164 | | - | then $Tuple2(J, X) |
---|
165 | | - | else { |
---|
166 | | - | let aa = (W - X) |
---|
167 | | - | let ab = (Z - Y) |
---|
168 | | - | let ac = (U - Y) |
---|
169 | | - | $Tuple2(J, (W - fraction(ac, aa, ab))) |
---|
170 | | - | } |
---|
171 | | - | } |
---|
172 | | - | |
---|
173 | | - | |
---|
174 | | - | func ad (T) = { |
---|
175 | | - | let F = assetInfo(T) |
---|
176 | | - | if ($isInstanceOf(F, "Asset")) |
---|
177 | | - | then { |
---|
178 | | - | let ae = F |
---|
179 | | - | if (if ((ae.decimals == 0)) |
---|
180 | | - | then (ae.quantity == 1) |
---|
181 | | - | else false) |
---|
182 | | - | then (ae.reissuable == false) |
---|
183 | | - | else false |
---|
184 | | - | } |
---|
185 | | - | else false |
---|
186 | | - | } |
---|
187 | | - | |
---|
188 | | - | |
---|
189 | | - | func af (T) = { |
---|
190 | | - | let m = value(assetInfo(T)).issuer |
---|
191 | | - | valueOrElse(getBoolean(this, l(m)), false) |
---|
192 | | - | } |
---|
193 | | - | |
---|
194 | | - | |
---|
195 | | - | func ag (T) = isDefined(getString(this, j(T))) |
---|
196 | | - | |
---|
197 | | - | |
---|
198 | | - | func ah (T) = isDefined(getString(this, k(T))) |
---|
199 | | - | |
---|
200 | | - | |
---|
201 | | - | func ai (P) = (P > 0) |
---|
202 | | - | |
---|
203 | | - | |
---|
204 | | - | func aj (K,ak) = (K > ak) |
---|
205 | | - | |
---|
206 | | - | |
---|
207 | | - | func al (am) = (am == this) |
---|
208 | | - | |
---|
209 | | - | |
---|
210 | | - | func an (am,J) = if ((am == this)) |
---|
211 | | - | then true |
---|
212 | | - | else (am == J) |
---|
213 | | - | |
---|
214 | | - | |
---|
215 | | - | func ao (ap,M) = (ap > M) |
---|
216 | | - | |
---|
217 | | - | |
---|
218 | | - | func aq (ar,as) = (ar >= as) |
---|
219 | | - | |
---|
220 | | - | |
---|
221 | | - | func at (T) = (T == unit) |
---|
222 | | - | |
---|
223 | | - | |
---|
224 | | - | func au (h) = if (!(ad(h))) |
---|
225 | | - | then throw("Token is not Nft") |
---|
226 | | - | else if (ag(h)) |
---|
227 | | - | then throw("Sell already exists") |
---|
228 | | - | else if (ah(h)) |
---|
229 | | - | then throw("Auction already exists") |
---|
230 | | - | else unit |
---|
231 | | - | |
---|
232 | | - | |
---|
233 | | - | func av (aw,ax,P) = if (!(at(aw))) |
---|
234 | | - | then throw("Payment must be at WAVES") |
---|
235 | | - | else if (!(aq(ax, P))) |
---|
236 | | - | then throw("Not enough funds") |
---|
237 | | - | else unit |
---|
238 | | - | |
---|
239 | | - | |
---|
240 | | - | func ay () = 0 |
---|
241 | | - | |
---|
242 | | - | |
---|
243 | | - | func az () = 0 |
---|
244 | | - | |
---|
245 | | - | |
---|
246 | | - | func aA (aB,ax,aC) = if (aB) |
---|
247 | | - | then $Tuple2((aC - az()), (ax - aC)) |
---|
248 | | - | else $Tuple2((aC - ay()), (ax - aC)) |
---|
249 | | - | |
---|
250 | | - | |
---|
251 | | - | func aD (h) = if (ag(h)) |
---|
252 | | - | then $Tuple2(c, R(h)) |
---|
253 | | - | else if (ah(h)) |
---|
254 | | - | then $Tuple2(b, Q(h)) |
---|
255 | | - | else throw("Slot doesn`t exist") |
---|
256 | | - | |
---|
257 | | - | |
---|
258 | | - | let aE = "buy" |
---|
259 | | - | |
---|
260 | | - | let aF = "bid" |
---|
261 | | - | |
---|
262 | | - | let aG = $Tuple4("OPEN", "CLOSED", "REWARDED", "CANCELED") |
---|
263 | | - | |
---|
264 | | - | let aH = base58'3N85YW6NZ9pLYvSdt1ASMQTGxvncnU1vUNx' |
---|
265 | | - | |
---|
266 | | - | @Callable(aI) |
---|
267 | | - | func createNft (aJ,aK,aL,aM,aN,aO,aP,aQ,aR) = { |
---|
268 | | - | let aS = Issue(aJ, aP, 1, 0, false) |
---|
269 | | - | let aT = calculateAssetId(aS) |
---|
270 | | - | let aU = aI.transactionId |
---|
271 | | - | [aS, ScriptTransfer(aI.caller, 1, aT), StringEntry(((toBase58String(aT) + a) + "Owner"), toString(aI.caller)), StringEntry(((toBase58String(aT) + a) + "nft_type"), aM), StringEntry(((toBase58String(aT) + a) + "nft_tags"), aN), StringEntry(((toBase58String(aT) + a) + "nft_dAppAddress"), aL), IntegerEntry(((toBase58String(aT) + a) + "nft_selling_price"), aO), StringEntry(((toBase58String(aT) + a) + "nft_onSell"), aQ), StringEntry(((toBase58String(aT) + a) + "nft_data"), aR), StringEntry(((toBase58String(aU) + a) + "issue_nft"), toBase58String(aT))] |
---|
| 6 | + | @Callable(b) |
---|
| 7 | + | func call () = { |
---|
| 8 | + | let c = Issue("Asset", "", 1, 0, true, unit, 0) |
---|
| 9 | + | let d = calculateAssetId(c) |
---|
| 10 | + | [BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), c, Reissue(d, 1, false), Burn(d, 1), ScriptTransfer(b.caller, 1, d)] |
---|
313 | | - | |
---|
314 | | - | @Callable(aI) |
---|
315 | | - | func addAuction (L,M,K,be) = { |
---|
316 | | - | let aU = toBase58String(aI.transactionId) |
---|
317 | | - | let h = value(aI.payments[0].assetId) |
---|
318 | | - | let P = value(K) |
---|
319 | | - | let am = aI.caller.bytes |
---|
320 | | - | let bf = { |
---|
321 | | - | let F = getString(this, (((toBase58String(h) + a) + "nft_status_") + toBase58String(am))) |
---|
322 | | - | if ($isInstanceOf(F, "String")) |
---|
323 | | - | then { |
---|
324 | | - | let bc = F |
---|
325 | | - | true |
---|
326 | | - | } |
---|
327 | | - | else false |
---|
328 | | - | } |
---|
329 | | - | if ((aI.payments[0].assetId == unit)) |
---|
330 | | - | then throw("NFT not attached") |
---|
331 | | - | else if ((bf == true)) |
---|
332 | | - | then throw("Already in auction list") |
---|
333 | | - | else [StringEntry(((aU + "_nft_start_auction_date_") + toBase58String(am)), L), StringEntry(((aU + "_nft_end_auction_date_") + toBase58String(am)), M), StringEntry((aU + "_nft_start_price"), K), StringEntry((aU + "duration_of_auction"), be), StringEntry((aU + "_nft_owner"), toString(aI.caller)), StringEntry((aU + "_nft_on_auction"), toBase58String(h)), StringEntry((aU + "_previous_bidder"), "none"), StringEntry((aU + "_highest_bid"), "0"), StringEntry((aU + "_winner_of_nft"), "0"), StringEntry((aU + "_bidder_count"), "0"), StringEntry((aU + "_nft_status"), "OPEN")] |
---|
334 | | - | } |
---|
335 | | - | |
---|
336 | | - | |
---|
337 | | - | |
---|
338 | | - | @Callable(aI) |
---|
339 | | - | func placeBid (bg,h,aK,bh) = { |
---|
340 | | - | let aU = toBase58String(aI.transactionId) |
---|
341 | | - | let am = aI.caller.bytes |
---|
342 | | - | let T = fromBase58String(h) |
---|
343 | | - | let bi = aI.payments[0].amount |
---|
344 | | - | let bj = getStringValue(this, (bg + "_highest_bid")) |
---|
345 | | - | let bk = getString(this, (bg + "_previous_bidder")) |
---|
346 | | - | let bl = getStringValue(this, (bg + "_bidder_count")) |
---|
347 | | - | let bm = getStringValue(this, (bg + "_winner_of_nft")) |
---|
348 | | - | let bf = getStringValue(this, (bg + "_nft_status")) |
---|
349 | | - | if ((aI.payments[0].assetId != unit)) |
---|
350 | | - | then throw("Pay in waves") |
---|
351 | | - | else if ((bf != "OPEN")) |
---|
352 | | - | then throw("Not open for auction") |
---|
353 | | - | else if ((parseIntValue(bj) >= bi)) |
---|
354 | | - | then throw("Bid is less then starting/highest Bid") |
---|
355 | | - | else if ((bj == "0")) |
---|
356 | | - | then [StringEntry((bg + "_highest_bid"), toString(bi)), StringEntry((bg + "_winner_of_nft"), toBase58String(aI.caller.bytes)), StringEntry((bg + "_bidder_count"), toString((parseIntValue(bl) + 1))), StringEntry((bg + "_nft_id"), toBase58String(T)), StringEntry((bg + "_nft_owner"), aK), StringEntry((((aU + "_") + bg) + "_highest_bid"), toString(bi)), StringEntry((((aU + "_") + bg) + "_winner"), toBase58String(aI.caller.bytes)), StringEntry((((aU + "_") + bg) + "_bidder_count"), toString((parseIntValue(bl) + 1))), StringEntry((((aU + "_") + bg) + "_nft_id"), toBase58String(T)), StringEntry((((aU + "_") + bg) + "_nft_owner"), aK), StringEntry((aU + "_bid_for_nft_by"), toBase58String(am)), StringEntry((aU + "_bid_price_place"), bh), StringEntry((aU + "_previous_bid_amount_refund_to_address"), bm), StringEntry((aU + "_prevoius_bid_amount_refund"), bj)] |
---|
357 | | - | else [StringEntry((bg + "_highest_bid"), toString(bi)), StringEntry((bg + "_winner_of_nft"), toBase58String(aI.caller.bytes)), StringEntry((bg + "_bidder_count"), toString((parseIntValue(bl) + 1))), StringEntry((bg + "_nft_id"), toBase58String(T)), StringEntry((bg + "_nft_owner"), aK), StringEntry((((aU + "_") + bg) + "_highest_bid"), toString(bi)), StringEntry((((aU + "_") + bg) + "_winner"), toBase58String(aI.caller.bytes)), StringEntry((((aU + "_") + bg) + "_bidder_count"), toString((parseIntValue(bl) + 1))), StringEntry((((aU + "_") + bg) + "_nft_id"), toBase58String(T)), StringEntry((((aU + "_") + bg) + "_nft_owner"), aK), StringEntry((aU + "_bid_for_nft_by"), toBase58String(am)), StringEntry((aU + "_bid_price_place"), bh), StringEntry((aU + "_previous_bid_amount_refund_to_address"), bm), StringEntry((aU + "_prevoius_bid_amount_refund"), bj), ScriptTransfer(Address(fromBase58String(bm)), parseIntValue(bj), unit)] |
---|
358 | | - | } |
---|
359 | | - | |
---|
360 | | - | |
---|
361 | | - | |
---|
362 | | - | @Callable(aI) |
---|
363 | | - | func acceptBidOffer (bg,h,bn) = { |
---|
364 | | - | let aU = toBase58String(aI.transactionId) |
---|
365 | | - | let am = aI.caller.bytes |
---|
366 | | - | let T = fromBase58String(h) |
---|
367 | | - | let bo = getStringValue(this, (bg + "_highest_bid")) |
---|
368 | | - | let bp = getStringValue(this, (bg + "_winner_of_nft")) |
---|
369 | | - | [ScriptTransfer(Address(am), parseIntValue(bo), unit), ScriptTransfer(Address(fromBase58String(bp)), 1, T), StringEntry((aU + "_amount_paid_to_owner"), bo), StringEntry((aU + "_nft_transfer_to"), bp), StringEntry((aU + "_nft_status"), "REWARDED"), StringEntry((bg + "_amount_paid_to_owner"), bo), StringEntry((bg + "_nft_transfer_to"), bp), StringEntry((bg + "_nft_status"), "REWARDED")] |
---|
370 | | - | } |
---|
371 | | - | |
---|
372 | | - | |
---|
373 | | - | |
---|
374 | | - | @Callable(aI) |
---|
375 | | - | func cancelAuction (bg) = { |
---|
376 | | - | let aU = toBase58String(aI.transactionId) |
---|
377 | | - | let am = aI.caller.bytes |
---|
378 | | - | let bq = getStringValue(this, (bg + "_nft_status")) |
---|
379 | | - | let br = getStringValue(this, (bg + "_winner_of_nft")) |
---|
380 | | - | let bs = getStringValue(this, (bg + "_nft_owner")) |
---|
381 | | - | let h = getStringValue(this, (bg + "_nft_on_auction")) |
---|
382 | | - | let bt = getStringValue(this, (bg + "_highest_bid")) |
---|
383 | | - | [StringEntry((bg + "_nft_status"), "CANCELED"), StringEntry((bg + "_previous_bid_amount_refund_to_address"), br), StringEntry((bg + "_prevoius_bid_amount_refund"), bt), StringEntry((aU + "_nft_status"), "CANCELED"), StringEntry((aU + "_previous_bid_amount_refund_to_address"), br), StringEntry((aU + "_prevoius_bid_amount_refund"), bt), ScriptTransfer(Address(fromBase58String(bs)), 1, fromBase58String(h)), ScriptTransfer(Address(fromBase58String(br)), parseIntValue(bt), unit)] |
---|
384 | | - | } |
---|
385 | | - | |
---|
386 | | - | |
---|
387 | | - | |
---|
388 | | - | @Callable(aI) |
---|
389 | | - | func withdrawBid (bu) = { |
---|
390 | | - | let am = aI.caller.bytes |
---|
391 | | - | let bv = getStringValue(this, (bu + "_highest_bid")) |
---|
392 | | - | let bw = getStringValue(this, (bu + "_winner")) |
---|
393 | | - | let bx = getStringValue(this, (bu + "_nft_id")) |
---|
394 | | - | if ((toBase58String(am) != bw)) |
---|
395 | | - | then throw("No bid") |
---|
396 | | - | else [StringEntry((bu + "_nft_bid"), "WITHDRAW"), StringEntry((bu + "_nft_id"), bx), StringEntry((bu + "_bidding_price_refund_amount"), bv), ScriptTransfer(aI.caller, parseIntValue(bv), unit)] |
---|
397 | | - | } |
---|
398 | | - | |
---|
399 | | - | |
---|
400 | | - | |
---|
401 | | - | @Callable(aI) |
---|
402 | | - | func testBid (by) = [StringEntry("E8kkFBYCy44JJaq6pAZ6KizsuResi5UKNhbD1WNZwhhY_highest_bid", "0")] |
---|
403 | | - | |
---|
| 48 | + | @Verifier(o) |
---|
| 49 | + | func p () = sigVerify(o.bodyBytes, o.proofs[0], o.senderPublicKey) |
---|