tx · BBNt8wqWCwKVh2NsTVKiVUcZzAWhpZRTWERJpfseC44c 3N7KPSUwpMgvDEVGw1DYBnKDiixSQUXhn2P: -0.10000000 Waves 2022.12.06 08:42 [2348075] smart account 3N7KPSUwpMgvDEVGw1DYBnKDiixSQUXhn2P > SELF 0.00000000 Waves
{ "type": 13, "id": "BBNt8wqWCwKVh2NsTVKiVUcZzAWhpZRTWERJpfseC44c", "fee": 10000000, "feeAssetId": null, "timestamp": 1670305396255, "version": 2, "chainId": 84, "sender": "3N7KPSUwpMgvDEVGw1DYBnKDiixSQUXhn2P", "senderPublicKey": "BTvXQMmkgSf57dbcqWxpEvbi3ZYcEeWFkkXDZC6FrneM", "proofs": [ "jzhdVFbPekHK7m8P7cFSMrsiqrZDXi4a18ssK7XLX6npDiKRdL1hmFzef6hueTLUhaSZ6vrFPPGgTFDNwTZ3p4s" ], "script": "base64:BgJACAISCwoJCAgICAgBCAgIEgMKAQESBAoCCAgSBgoECAgICBIGCgQICAgIEgUKAwgICBIDCgEIEgMKAQgSAwoBCCkACXNlcGFyYXRvcgIBXwAIa0F1Y3Rpb24CB2F1Y3Rpb24ABWtTZWxsAgRzZWxsAAhrVHJ1c3RlZAIHdHJ1c3RlZAAGa1ByaWNlAgVwcmljZQEKZ2V0U2xvdEtleQIGcHJlZml4BW5mdElkCQCsAgIJAKwCAgUGcHJlZml4BQlzZXBhcmF0b3IJANgEAQUFbmZ0SWQBC2dldFByaWNlS2V5AQVuZnRJZAkArAICCQCsAgIFBmtQcmljZQUJc2VwYXJhdG9yCQDYBAEFBW5mdElkAQpnZXRTZWxsS2V5AQVuZnRJZAkArAICCQCsAgIFBWtTZWxsBQlzZXBhcmF0b3IJANgEAQUFbmZ0SWQBDWdldEF1Y3Rpb25LZXkBBW5mdElkCQCsAgIJAKwCAgUIa0F1Y3Rpb24FCXNlcGFyYXRvcgkA2AQBBQVuZnRJZAENZ2V0VHJ1c3RlZEtleQEGaXNzdWVyCQCsAgIJAKwCAgUIa1RydX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OWndoaFlfaGlnaGVzdF9iaWQCATAFA25pbABYMmiY", "height": 2348075, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: J2Zgg1HDZU9vvoMKk8ZX3M5HpFy2eV7pcSZ9XxkLXCvz Next: sP8EEFbPQ4cTPbYKV36gbwSboHsXs29M2TgsxLrgk1o Diff:
Old | New | Differences | |
---|---|---|---|
248 | 248 | ||
249 | 249 | let kBuy = "buy" | |
250 | 250 | ||
251 | + | let kBid = "bid" | |
252 | + | ||
253 | + | let statusForNFT = $Tuple4("OPEN", "CLOSED", "REWARDED", "CANCELED") | |
254 | + | ||
255 | + | let dAppAddress = base58'3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq' | |
256 | + | ||
251 | 257 | @Callable(i) | |
252 | - | func | |
258 | + | func createNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = { | |
253 | 259 | let newToken = Issue(nft_name, nft_description, 1, 0, false) | |
254 | 260 | let issueId = calculateAssetId(newToken) | |
255 | 261 | let txId = i.transactionId | |
259 | 265 | ||
260 | 266 | ||
261 | 267 | @Callable(i) | |
262 | - | func issueNft (name,meta) = { | |
263 | - | let newToken = Issue(name, meta, 1, 0, false) | |
264 | - | let issueId = calculateAssetId(newToken) | |
265 | - | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller))] | |
266 | - | } | |
267 | - | ||
268 | - | ||
269 | - | ||
270 | - | @Callable(i) | |
271 | - | func buyNFT (nftID) = { | |
272 | - | let assetId = fromBase58String(nftID) | |
273 | - | let amount = value(i.payments[0].amount) | |
274 | - | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this NFT") | |
275 | - | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") | |
276 | - | if ((i.payments[0].assetId != unit)) | |
277 | - | then throw("Pay in waves") | |
278 | - | else if ((parseIntValue(price) > amount)) | |
279 | - | then throw("Invalid payment") | |
280 | - | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] | |
281 | - | } | |
282 | - | ||
283 | - | ||
284 | - | ||
285 | - | @Callable(i) | |
286 | 268 | func sellNFT (price) = { | |
287 | - | let $t073417426 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
288 | - | let token0 = $t073417426._1 | |
289 | - | let amount0 = $t073417426._2 | |
269 | + | let txId = i.transactionId | |
270 | + | let seller = i.caller.bytes | |
271 | + | let $t066056690 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
272 | + | let token0 = $t066056690._1 | |
273 | + | let amount0 = $t066056690._2 | |
290 | 274 | if (!(isNft(token0))) | |
291 | 275 | then throw("Token is not NFT") | |
292 | 276 | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
295 | 279 | ||
296 | 280 | ||
297 | 281 | @Callable(i) | |
298 | - | func addSell (price) = { | |
299 | - | let nftId = value(i.payments[0].assetId) | |
300 | - | valueOrElse(isCorrectNft(nftId), if (!(isCorrectSellPrice(price))) | |
301 | - | then throw("Price must be > 0") | |
302 | - | else [setSell(nftId, i.caller, price)]) | |
282 | + | func buyNFT (nftID,current_nft_owner) = { | |
283 | + | let assetId = fromBase58String(nftID) | |
284 | + | let amount = value(i.payments[0].amount) | |
285 | + | let checkOwnerIsSame = match getString(this, (("nft_" + current_nft_owner) + "_owner")) { | |
286 | + | case a: String => | |
287 | + | a | |
288 | + | case _ => | |
289 | + | false | |
290 | + | } | |
291 | + | let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner)) | |
292 | + | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") | |
293 | + | if ((i.payments[0].assetId != unit)) | |
294 | + | then throw("Pay in waves") | |
295 | + | else if ((checkOwnerIsSame == toString(i.caller))) | |
296 | + | then throw("Owner of NFT not able to purchase") | |
297 | + | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(owner)), amount, unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + current_nft_owner) + "_owner"))] | |
303 | 298 | } | |
304 | 299 | ||
305 | 300 | ||
306 | 301 | ||
307 | 302 | @Callable(i) | |
308 | - | func addAuction (startPrice,start,end) = { | |
303 | + | func addAuction (start,end,startPrice,duration) = { | |
304 | + | let txId = toBase58String(i.transactionId) | |
309 | 305 | let nftId = value(i.payments[0].assetId) | |
310 | - | valueOrElse(isCorrectNft(nftId), [setAuction(i.caller, nftId, startPrice, start, end), StringEntry(((toBase58String(nftId) + separator) + "nft_owner"), toString(i.caller))]) | |
306 | + | let price = value(startPrice) | |
307 | + | let caller = i.caller.bytes | |
308 | + | let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) { | |
309 | + | case a: String => | |
310 | + | true | |
311 | + | case _ => | |
312 | + | false | |
313 | + | } | |
314 | + | if ((i.payments[0].assetId == unit)) | |
315 | + | then throw("NFT not attached") | |
316 | + | else if ((checkNftAuctioned == true)) | |
317 | + | then throw("Already in auction list") | |
318 | + | else [StringEntry(((txId + "_nft_start_auction_date_") + toBase58String(caller)), start), StringEntry(((txId + "_nft_end_auction_date_") + toBase58String(caller)), end), StringEntry((txId + "_nft_start_price"), startPrice), StringEntry((txId + "duration_of_auction"), duration), StringEntry((txId + "_nft_owner"), toString(i.caller)), StringEntry((txId + "_nft_on_auction"), toBase58String(nftId)), StringEntry((txId + "_previous_bidder"), "none"), StringEntry((txId + "_highest_bid"), "0"), StringEntry((txId + "_winner_of_nft"), "0"), StringEntry((txId + "_bidder_count"), "0"), StringEntry((txId + "_nft_status"), "OPEN")] | |
311 | 319 | } | |
312 | 320 | ||
313 | 321 | ||
314 | 322 | ||
315 | 323 | @Callable(i) | |
316 | - | func buyFromSlot (nftId) = { | |
317 | - | let $t083468435 = $Tuple2(i.payments[0].assetId, value(i.payments[0].amount)) | |
318 | - | let paymentAsset = $t083468435._1 | |
319 | - | let paymentAmount = $t083468435._2 | |
324 | + | func placeBid (auctionId,nftId,nft_owner,bid_price) = { | |
325 | + | let txId = toBase58String(i.transactionId) | |
326 | + | let caller = i.caller.bytes | |
320 | 327 | let assetId = fromBase58String(nftId) | |
321 | - | let $t084798517 = getSlot(assetId) | |
322 | - | let type = $t084798517._1 | |
323 | - | let details = $t084798517._2 | |
324 | - | let baseRes = [ScriptTransfer(i.caller, 1, assetId), DeleteEntry(getSlotKey(type, assetId))] | |
325 | - | if ((type == kSell)) | |
326 | - | then { | |
327 | - | let $t086598706 = parseAsSell(details) | |
328 | - | let seller = $t086598706._1 | |
329 | - | let priceValue = $t086598706._2 | |
330 | - | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, priceValue), { | |
331 | - | let $t087918893 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, priceValue) | |
332 | - | let sellerAmount = $t087918893._1 | |
333 | - | let buyerAmount = $t087918893._2 | |
334 | - | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
335 | - | if ((buyerAmount > 0)) | |
336 | - | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
337 | - | else updatedRes | |
338 | - | }) | |
339 | - | } | |
340 | - | else { | |
341 | - | let $t091109179 = calcPriceAtCurrentMoment(assetId, height) | |
342 | - | let seller = $t091109179._1 | |
343 | - | let actualPrice = $t091109179._2 | |
344 | - | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, actualPrice), { | |
345 | - | let $t092659368 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, actualPrice) | |
346 | - | let sellerAmount = $t092659368._1 | |
347 | - | let buyerAmount = $t092659368._2 | |
348 | - | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
349 | - | if ((buyerAmount > 0)) | |
350 | - | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
351 | - | else updatedRes | |
352 | - | }) | |
353 | - | } | |
328 | + | let currentBidPrice = i.payments[0].amount | |
329 | + | let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
330 | + | let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder")) | |
331 | + | let currentBidCount = getStringValue(this, (auctionId + "_bidder_count")) | |
332 | + | let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft")) | |
333 | + | let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status")) | |
334 | + | if ((i.payments[0].assetId != unit)) | |
335 | + | then throw("Pay in waves") | |
336 | + | else if ((checkNftAuctioned != "OPEN")) | |
337 | + | then throw("Not open for auction") | |
338 | + | else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice)) | |
339 | + | then throw("Bid is less then starting/highest Bid") | |
340 | + | else if ((getLastWinnerBidPrice == "0")) | |
341 | + | then [StringEntry((auctionId + "_highest_bid"), toString(currentBidPrice)), StringEntry((auctionId + "_winner_of_nft"), toBase58String(i.caller.bytes)), StringEntry((auctionId + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((auctionId + "_nft_id"), toBase58String(assetId)), StringEntry((auctionId + "_nft_owner"), nft_owner), StringEntry((((txId + "_") + auctionId) + "_highest_bid"), toString(currentBidPrice)), StringEntry((((txId + "_") + auctionId) + "_winner"), toBase58String(i.caller.bytes)), StringEntry((((txId + "_") + auctionId) + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((((txId + "_") + auctionId) + "_nft_id"), toBase58String(assetId)), StringEntry((((txId + "_") + auctionId) + "_nft_owner"), nft_owner), StringEntry((txId + "_bid_for_nft_by"), toBase58String(caller)), StringEntry((txId + "_bid_price_place"), bid_price), StringEntry((txId + "_previous_bid_amount_refund_to_address"), getLastWinnerAddress), StringEntry((txId + "_prevoius_bid_amount_refund"), getLastWinnerBidPrice)] | |
342 | + | else [StringEntry((auctionId + "_highest_bid"), toString(currentBidPrice)), StringEntry((auctionId + "_winner_of_nft"), toBase58String(i.caller.bytes)), StringEntry((auctionId + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((auctionId + "_nft_id"), toBase58String(assetId)), StringEntry((auctionId + "_nft_owner"), nft_owner), StringEntry((((txId + "_") + auctionId) + "_highest_bid"), toString(currentBidPrice)), StringEntry((((txId + "_") + auctionId) + "_winner"), toBase58String(i.caller.bytes)), StringEntry((((txId + "_") + auctionId) + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((((txId + "_") + auctionId) + "_nft_id"), toBase58String(assetId)), StringEntry((((txId + "_") + auctionId) + "_nft_owner"), nft_owner), StringEntry((txId + "_bid_for_nft_by"), toBase58String(caller)), StringEntry((txId + "_bid_price_place"), bid_price), StringEntry((txId + "_previous_bid_amount_refund_to_address"), getLastWinnerAddress), StringEntry((txId + "_prevoius_bid_amount_refund"), getLastWinnerBidPrice), ScriptTransfer(Address(fromBase58String(getLastWinnerAddress)), parseIntValue(getLastWinnerBidPrice), unit)] | |
354 | 343 | } | |
355 | 344 | ||
356 | 345 | ||
357 | 346 | ||
358 | 347 | @Callable(i) | |
359 | - | func declineSlot (nftId) = { | |
348 | + | func acceptBidOffer (auctionId,nftId,bid_amount_from_user) = { | |
349 | + | let txId = toBase58String(i.transactionId) | |
350 | + | let caller = i.caller.bytes | |
360 | 351 | let assetId = fromBase58String(nftId) | |
361 | - | let $t096699707 = getSlot(assetId) | |
362 | - | let type = $t096699707._1 | |
363 | - | let details = $t096699707._2 | |
364 | - | let baseRes = [DeleteEntry(getSlotKey(type, assetId))] | |
365 | - | if ((type == kSell)) | |
366 | - | then { | |
367 | - | let $t097999846 = parseAsSell(details) | |
368 | - | let seller = $t097999846._1 | |
369 | - | let priceValue = $t097999846._2 | |
370 | - | if (!(isValidCaller(i.caller, seller))) | |
371 | - | then throw("Invalid caller") | |
372 | - | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
373 | - | } | |
374 | - | else { | |
375 | - | let $t0999110095 = parseAsAuction(details) | |
376 | - | let seller = $t0999110095._1 | |
377 | - | let startPriceValue = $t0999110095._2 | |
378 | - | let endPriceValue = $t0999110095._3 | |
379 | - | let startPeriodValue = $t0999110095._4 | |
380 | - | let endPeriodValue = $t0999110095._5 | |
381 | - | if (!(isValidCaller(i.caller, seller))) | |
382 | - | then throw("Invalid caller") | |
383 | - | else if (!(isAuctionEnded(height, endPeriodValue))) | |
384 | - | then throw("Wait for end of auction") | |
385 | - | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
386 | - | } | |
352 | + | let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
353 | + | let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft")) | |
354 | + | [ScriptTransfer(Address(caller), parseIntValue(getNftWinningPrice), unit), ScriptTransfer(Address(fromBase58String(getAuctionWinner)), 1, assetId), StringEntry((txId + "_nft_transfer_to"), getAuctionWinner), StringEntry((txId + "_nft_status"), "REWARDED"), StringEntry((auctionId + "_amount_paid_to_owner"), getNftWinningPrice), StringEntry((auctionId + "_nft_transfer_to"), getAuctionWinner), StringEntry((auctionId + "_nft_status"), "REWARDED")] | |
387 | 355 | } | |
388 | 356 | ||
389 | 357 | ||
390 | 358 | ||
391 | 359 | @Callable(i) | |
392 | - | func setTrustedIssuer (trustedAddr) = if (!(isAdmin(i.caller))) | |
393 | - | then throw("Only admin") | |
394 | - | else [BooleanEntry(getTrustedKey(addressFromStringValue(trustedAddr)), true)] | |
360 | + | func cancelAuction (auctionId) = { | |
361 | + | let txId = toBase58String(i.transactionId) | |
362 | + | let caller = i.caller.bytes | |
363 | + | let auctionStatus = getStringValue(this, (auctionId + "_nft_status")) | |
364 | + | let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft")) | |
365 | + | let nftOwner = getStringValue(this, (auctionId + "_nft_owner")) | |
366 | + | let nftId = getStringValue(this, (auctionId + "_nft_on_auction")) | |
367 | + | let biddingPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
368 | + | [StringEntry((auctionId + "_nft_status"), "CANCELED"), StringEntry((auctionId + "_previous_bid_amount_refund_to_address"), biddingWinner), StringEntry((auctionId + "_prevoius_bid_amount_refund"), biddingPrice), StringEntry((txId + "_nft_status"), "CANCELED"), StringEntry((txId + "_previous_bid_amount_refund_to_address"), biddingWinner), StringEntry((txId + "_prevoius_bid_amount_refund"), biddingPrice), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId)), ScriptTransfer(Address(fromBase58String(biddingWinner)), parseIntValue(biddingPrice), unit)] | |
369 | + | } | |
395 | 370 | ||
396 | 371 | ||
397 | 372 | ||
398 | 373 | @Callable(i) | |
399 | - | func getPriceAtCurrentMoment (nftId,moment) = { | |
400 | - | let assetId = fromBase58String(nftId) | |
401 | - | let $t01063610699 = calcPriceAtCurrentMoment(assetId, moment) | |
402 | - | let seller = $t01063610699._1 | |
403 | - | let price = $t01063610699._2 | |
404 | - | [IntegerEntry(getPriceKey(assetId), price)] | |
374 | + | func withdrawBid (bidTxId) = { | |
375 | + | let caller = i.caller.bytes | |
376 | + | let bidPrice = getStringValue(this, (bidTxId + "_highest_bid")) | |
377 | + | let asBidder = getStringValue(this, (bidTxId + "_winner")) | |
378 | + | let bidForNFT = getStringValue(this, (bidTxId + "_nft_id")) | |
379 | + | if ((toBase58String(caller) != asBidder)) | |
380 | + | then throw("No bid") | |
381 | + | else [StringEntry((bidTxId + "_nft_bid"), "WITHDRAW"), StringEntry((bidTxId + "_nft_id"), bidForNFT), StringEntry((bidTxId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), unit)] | |
405 | 382 | } | |
383 | + | ||
384 | + | ||
385 | + | ||
386 | + | @Callable(i) | |
387 | + | func testBid (data) = [StringEntry("E8kkFBYCy44JJaq6pAZ6KizsuResi5UKNhbD1WNZwhhY_highest_bid", "0")] | |
406 | 388 | ||
407 | 389 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "_" | |
5 | 5 | ||
6 | 6 | let kAuction = "auction" | |
7 | 7 | ||
8 | 8 | let kSell = "sell" | |
9 | 9 | ||
10 | 10 | let kTrusted = "trusted" | |
11 | 11 | ||
12 | 12 | let kPrice = "price" | |
13 | 13 | ||
14 | 14 | func getSlotKey (prefix,nftId) = ((prefix + separator) + toBase58String(nftId)) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getPriceKey (nftId) = ((kPrice + separator) + toBase58String(nftId)) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getSellKey (nftId) = ((kSell + separator) + toBase58String(nftId)) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func getAuctionKey (nftId) = ((kAuction + separator) + toBase58String(nftId)) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func getTrustedKey (issuer) = ((kTrusted + separator) + toString(issuer)) | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func addToList (accum,nextValue) = (accum ++ [nextValue]) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func joinString (params) = { | |
33 | 33 | let length = size(params) | |
34 | 34 | if ((length == 0)) | |
35 | 35 | then throw("Empty params") | |
36 | 36 | else if ((length == 1)) | |
37 | 37 | then makeString({ | |
38 | 38 | let $l = params | |
39 | 39 | let $s = size($l) | |
40 | 40 | let $acc0 = nil | |
41 | 41 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
42 | 42 | then $a | |
43 | 43 | else addToList($a, $l[$i]) | |
44 | 44 | ||
45 | 45 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
46 | 46 | then $a | |
47 | 47 | else throw("List size exceeds 1") | |
48 | 48 | ||
49 | 49 | $f0_2($f0_1($acc0, 0), 1) | |
50 | 50 | }, separator) | |
51 | 51 | else if ((length == 2)) | |
52 | 52 | then makeString({ | |
53 | 53 | let $l = params | |
54 | 54 | let $s = size($l) | |
55 | 55 | let $acc0 = nil | |
56 | 56 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
57 | 57 | then $a | |
58 | 58 | else addToList($a, $l[$i]) | |
59 | 59 | ||
60 | 60 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
61 | 61 | then $a | |
62 | 62 | else throw("List size exceeds 2") | |
63 | 63 | ||
64 | 64 | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
65 | 65 | }, separator) | |
66 | 66 | else if ((length == 3)) | |
67 | 67 | then makeString({ | |
68 | 68 | let $l = params | |
69 | 69 | let $s = size($l) | |
70 | 70 | let $acc0 = nil | |
71 | 71 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
72 | 72 | then $a | |
73 | 73 | else addToList($a, $l[$i]) | |
74 | 74 | ||
75 | 75 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
76 | 76 | then $a | |
77 | 77 | else throw("List size exceeds 3") | |
78 | 78 | ||
79 | 79 | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
80 | 80 | }, separator) | |
81 | 81 | else if ((length == 4)) | |
82 | 82 | then makeString({ | |
83 | 83 | let $l = params | |
84 | 84 | let $s = size($l) | |
85 | 85 | let $acc0 = nil | |
86 | 86 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
87 | 87 | then $a | |
88 | 88 | else addToList($a, $l[$i]) | |
89 | 89 | ||
90 | 90 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
91 | 91 | then $a | |
92 | 92 | else throw("List size exceeds 4") | |
93 | 93 | ||
94 | 94 | $f0_2($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4) | |
95 | 95 | }, separator) | |
96 | 96 | else if ((length == 5)) | |
97 | 97 | then makeString({ | |
98 | 98 | let $l = params | |
99 | 99 | let $s = size($l) | |
100 | 100 | let $acc0 = nil | |
101 | 101 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | 102 | then $a | |
103 | 103 | else addToList($a, $l[$i]) | |
104 | 104 | ||
105 | 105 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | 106 | then $a | |
107 | 107 | else throw("List size exceeds 5") | |
108 | 108 | ||
109 | 109 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
110 | 110 | }, separator) | |
111 | 111 | else throw("Max number of parameters exceeded") | |
112 | 112 | } | |
113 | 113 | ||
114 | 114 | ||
115 | 115 | func parseAsAuction (details) = { | |
116 | 116 | let res = split(details, separator) | |
117 | 117 | $Tuple5(addressFromStringValue(res[0]), parseIntValue(res[1]), parseIntValue(res[2]), parseIntValue(res[3]), parseIntValue(res[4])) | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | func parseAsSell (details) = { | |
122 | 122 | let res = split(details, separator) | |
123 | 123 | $Tuple2(addressFromStringValue(res[0]), parseIntValue(res[1])) | |
124 | 124 | } | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | func joinStruct (params) = match params { | |
128 | 128 | case auction: (Address, Int, String, String) => | |
129 | 129 | joinString([toString(auction._1), toString(auction._2), auction._3, auction._4]) | |
130 | 130 | case sell: (Address, Int) => | |
131 | 131 | joinString([toString(sell._1), toString(sell._2)]) | |
132 | 132 | case _ => | |
133 | 133 | throw("Wrong params tupple") | |
134 | 134 | } | |
135 | 135 | ||
136 | 136 | ||
137 | 137 | func setAuction (seller,nftId,startPrice,start,end) = StringEntry(getAuctionKey(nftId), joinStruct($Tuple4(seller, startPrice, start, end))) | |
138 | 138 | ||
139 | 139 | ||
140 | 140 | func setSell (nftId,celler,price) = StringEntry(getSellKey(nftId), joinStruct($Tuple2(celler, price))) | |
141 | 141 | ||
142 | 142 | ||
143 | 143 | func getAuction (nftId) = value(getString(this, getAuctionKey(nftId))) | |
144 | 144 | ||
145 | 145 | ||
146 | 146 | func getSell (nftId) = value(getString(this, getSellKey(nftId))) | |
147 | 147 | ||
148 | 148 | ||
149 | 149 | func calcPriceAtCurrentMoment (assetId,moment) = { | |
150 | 150 | let details = getAuction(assetId) | |
151 | 151 | let $t027552859 = parseAsAuction(details) | |
152 | 152 | let seller = $t027552859._1 | |
153 | 153 | let startPriceValue = $t027552859._2 | |
154 | 154 | let endPriceValue = $t027552859._3 | |
155 | 155 | let startPeriodValue = $t027552859._4 | |
156 | 156 | let endPeriodValue = $t027552859._5 | |
157 | 157 | if ((moment >= endPeriodValue)) | |
158 | 158 | then $Tuple2(seller, endPriceValue) | |
159 | 159 | else { | |
160 | 160 | let deltaPrice = (startPriceValue - endPriceValue) | |
161 | 161 | let period = (endPeriodValue - startPeriodValue) | |
162 | 162 | let spended = (moment - startPeriodValue) | |
163 | 163 | $Tuple2(seller, (startPriceValue - fraction(spended, deltaPrice, period))) | |
164 | 164 | } | |
165 | 165 | } | |
166 | 166 | ||
167 | 167 | ||
168 | 168 | func isNft (assetId) = match assetInfo(assetId) { | |
169 | 169 | case token: Asset => | |
170 | 170 | if (if ((token.decimals == 0)) | |
171 | 171 | then (token.quantity == 1) | |
172 | 172 | else false) | |
173 | 173 | then (token.reissuable == false) | |
174 | 174 | else false | |
175 | 175 | case _ => | |
176 | 176 | false | |
177 | 177 | } | |
178 | 178 | ||
179 | 179 | ||
180 | 180 | func isTrustedNft (assetId) = { | |
181 | 181 | let issuer = value(assetInfo(assetId)).issuer | |
182 | 182 | valueOrElse(getBoolean(this, getTrustedKey(issuer)), false) | |
183 | 183 | } | |
184 | 184 | ||
185 | 185 | ||
186 | 186 | func isSellExist (assetId) = isDefined(getString(this, getSellKey(assetId))) | |
187 | 187 | ||
188 | 188 | ||
189 | 189 | func isAuctionExist (assetId) = isDefined(getString(this, getAuctionKey(assetId))) | |
190 | 190 | ||
191 | 191 | ||
192 | 192 | func isCorrectSellPrice (price) = (price > 0) | |
193 | 193 | ||
194 | 194 | ||
195 | 195 | func isCorrectAuctionPrices (startPrice,endPrice) = (startPrice > endPrice) | |
196 | 196 | ||
197 | 197 | ||
198 | 198 | func isAdmin (caller) = (caller == this) | |
199 | 199 | ||
200 | 200 | ||
201 | 201 | func isValidCaller (caller,seller) = if ((caller == this)) | |
202 | 202 | then true | |
203 | 203 | else (caller == seller) | |
204 | 204 | ||
205 | 205 | ||
206 | 206 | func isAuctionEnded (now,end) = (now > end) | |
207 | 207 | ||
208 | 208 | ||
209 | 209 | func isEnoughFunds (payment,currentMomentPrice) = (payment >= currentMomentPrice) | |
210 | 210 | ||
211 | 211 | ||
212 | 212 | func isWawes (assetId) = (assetId == unit) | |
213 | 213 | ||
214 | 214 | ||
215 | 215 | func isCorrectNft (nftId) = if (!(isNft(nftId))) | |
216 | 216 | then throw("Token is not Nft") | |
217 | 217 | else if (isSellExist(nftId)) | |
218 | 218 | then throw("Sell already exists") | |
219 | 219 | else if (isAuctionExist(nftId)) | |
220 | 220 | then throw("Auction already exists") | |
221 | 221 | else unit | |
222 | 222 | ||
223 | 223 | ||
224 | 224 | func isCorrectPayments (paymentAsset,paymentAmount,price) = if (!(isWawes(paymentAsset))) | |
225 | 225 | then throw("Payment must be at WAVES") | |
226 | 226 | else if (!(isEnoughFunds(paymentAmount, price))) | |
227 | 227 | then throw("Not enough funds") | |
228 | 228 | else unit | |
229 | 229 | ||
230 | 230 | ||
231 | 231 | func calcFee () = 0 | |
232 | 232 | ||
233 | 233 | ||
234 | 234 | func calcTrustedFee () = 0 | |
235 | 235 | ||
236 | 236 | ||
237 | 237 | func resultFundsAmounts (isTrusted,paymentAmount,actualPrice) = if (isTrusted) | |
238 | 238 | then $Tuple2((actualPrice - calcTrustedFee()), (paymentAmount - actualPrice)) | |
239 | 239 | else $Tuple2((actualPrice - calcFee()), (paymentAmount - actualPrice)) | |
240 | 240 | ||
241 | 241 | ||
242 | 242 | func getSlot (nftId) = if (isSellExist(nftId)) | |
243 | 243 | then $Tuple2(kSell, getSell(nftId)) | |
244 | 244 | else if (isAuctionExist(nftId)) | |
245 | 245 | then $Tuple2(kAuction, getAuction(nftId)) | |
246 | 246 | else throw("Slot doesn`t exist") | |
247 | 247 | ||
248 | 248 | ||
249 | 249 | let kBuy = "buy" | |
250 | 250 | ||
251 | + | let kBid = "bid" | |
252 | + | ||
253 | + | let statusForNFT = $Tuple4("OPEN", "CLOSED", "REWARDED", "CANCELED") | |
254 | + | ||
255 | + | let dAppAddress = base58'3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq' | |
256 | + | ||
251 | 257 | @Callable(i) | |
252 | - | func | |
258 | + | func createNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = { | |
253 | 259 | let newToken = Issue(nft_name, nft_description, 1, 0, false) | |
254 | 260 | let issueId = calculateAssetId(newToken) | |
255 | 261 | let txId = i.transactionId | |
256 | 262 | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller)), StringEntry(((toBase58String(issueId) + separator) + "nft_type"), nft_type), StringEntry(((toBase58String(issueId) + separator) + "nft_tags"), nft_tags), StringEntry(((toBase58String(issueId) + separator) + "nft_dAppAddress"), nft_dAppAddress), IntegerEntry(((toBase58String(issueId) + separator) + "nft_selling_price"), nft_selling_price), StringEntry(((toBase58String(issueId) + separator) + "nft_onSell"), nft_onSell), StringEntry(((toBase58String(issueId) + separator) + "nft_data"), nft_data), StringEntry(((toBase58String(txId) + separator) + "issue_nft"), toBase58String(issueId))] | |
257 | 263 | } | |
258 | 264 | ||
259 | 265 | ||
260 | 266 | ||
261 | 267 | @Callable(i) | |
262 | - | func issueNft (name,meta) = { | |
263 | - | let newToken = Issue(name, meta, 1, 0, false) | |
264 | - | let issueId = calculateAssetId(newToken) | |
265 | - | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller))] | |
266 | - | } | |
267 | - | ||
268 | - | ||
269 | - | ||
270 | - | @Callable(i) | |
271 | - | func buyNFT (nftID) = { | |
272 | - | let assetId = fromBase58String(nftID) | |
273 | - | let amount = value(i.payments[0].amount) | |
274 | - | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this NFT") | |
275 | - | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") | |
276 | - | if ((i.payments[0].assetId != unit)) | |
277 | - | then throw("Pay in waves") | |
278 | - | else if ((parseIntValue(price) > amount)) | |
279 | - | then throw("Invalid payment") | |
280 | - | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(value(addressFromString(owner)), parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] | |
281 | - | } | |
282 | - | ||
283 | - | ||
284 | - | ||
285 | - | @Callable(i) | |
286 | 268 | func sellNFT (price) = { | |
287 | - | let $t073417426 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
288 | - | let token0 = $t073417426._1 | |
289 | - | let amount0 = $t073417426._2 | |
269 | + | let txId = i.transactionId | |
270 | + | let seller = i.caller.bytes | |
271 | + | let $t066056690 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
272 | + | let token0 = $t066056690._1 | |
273 | + | let amount0 = $t066056690._2 | |
290 | 274 | if (!(isNft(token0))) | |
291 | 275 | then throw("Token is not NFT") | |
292 | 276 | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
293 | 277 | } | |
294 | 278 | ||
295 | 279 | ||
296 | 280 | ||
297 | 281 | @Callable(i) | |
298 | - | func addSell (price) = { | |
299 | - | let nftId = value(i.payments[0].assetId) | |
300 | - | valueOrElse(isCorrectNft(nftId), if (!(isCorrectSellPrice(price))) | |
301 | - | then throw("Price must be > 0") | |
302 | - | else [setSell(nftId, i.caller, price)]) | |
282 | + | func buyNFT (nftID,current_nft_owner) = { | |
283 | + | let assetId = fromBase58String(nftID) | |
284 | + | let amount = value(i.payments[0].amount) | |
285 | + | let checkOwnerIsSame = match getString(this, (("nft_" + current_nft_owner) + "_owner")) { | |
286 | + | case a: String => | |
287 | + | a | |
288 | + | case _ => | |
289 | + | false | |
290 | + | } | |
291 | + | let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner)) | |
292 | + | let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner") | |
293 | + | if ((i.payments[0].assetId != unit)) | |
294 | + | then throw("Pay in waves") | |
295 | + | else if ((checkOwnerIsSame == toString(i.caller))) | |
296 | + | then throw("Owner of NFT not able to purchase") | |
297 | + | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(owner)), amount, unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + current_nft_owner) + "_owner"))] | |
303 | 298 | } | |
304 | 299 | ||
305 | 300 | ||
306 | 301 | ||
307 | 302 | @Callable(i) | |
308 | - | func addAuction (startPrice,start,end) = { | |
303 | + | func addAuction (start,end,startPrice,duration) = { | |
304 | + | let txId = toBase58String(i.transactionId) | |
309 | 305 | let nftId = value(i.payments[0].assetId) | |
310 | - | valueOrElse(isCorrectNft(nftId), [setAuction(i.caller, nftId, startPrice, start, end), StringEntry(((toBase58String(nftId) + separator) + "nft_owner"), toString(i.caller))]) | |
306 | + | let price = value(startPrice) | |
307 | + | let caller = i.caller.bytes | |
308 | + | let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) { | |
309 | + | case a: String => | |
310 | + | true | |
311 | + | case _ => | |
312 | + | false | |
313 | + | } | |
314 | + | if ((i.payments[0].assetId == unit)) | |
315 | + | then throw("NFT not attached") | |
316 | + | else if ((checkNftAuctioned == true)) | |
317 | + | then throw("Already in auction list") | |
318 | + | else [StringEntry(((txId + "_nft_start_auction_date_") + toBase58String(caller)), start), StringEntry(((txId + "_nft_end_auction_date_") + toBase58String(caller)), end), StringEntry((txId + "_nft_start_price"), startPrice), StringEntry((txId + "duration_of_auction"), duration), StringEntry((txId + "_nft_owner"), toString(i.caller)), StringEntry((txId + "_nft_on_auction"), toBase58String(nftId)), StringEntry((txId + "_previous_bidder"), "none"), StringEntry((txId + "_highest_bid"), "0"), StringEntry((txId + "_winner_of_nft"), "0"), StringEntry((txId + "_bidder_count"), "0"), StringEntry((txId + "_nft_status"), "OPEN")] | |
311 | 319 | } | |
312 | 320 | ||
313 | 321 | ||
314 | 322 | ||
315 | 323 | @Callable(i) | |
316 | - | func buyFromSlot (nftId) = { | |
317 | - | let $t083468435 = $Tuple2(i.payments[0].assetId, value(i.payments[0].amount)) | |
318 | - | let paymentAsset = $t083468435._1 | |
319 | - | let paymentAmount = $t083468435._2 | |
324 | + | func placeBid (auctionId,nftId,nft_owner,bid_price) = { | |
325 | + | let txId = toBase58String(i.transactionId) | |
326 | + | let caller = i.caller.bytes | |
320 | 327 | let assetId = fromBase58String(nftId) | |
321 | - | let $t084798517 = getSlot(assetId) | |
322 | - | let type = $t084798517._1 | |
323 | - | let details = $t084798517._2 | |
324 | - | let baseRes = [ScriptTransfer(i.caller, 1, assetId), DeleteEntry(getSlotKey(type, assetId))] | |
325 | - | if ((type == kSell)) | |
326 | - | then { | |
327 | - | let $t086598706 = parseAsSell(details) | |
328 | - | let seller = $t086598706._1 | |
329 | - | let priceValue = $t086598706._2 | |
330 | - | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, priceValue), { | |
331 | - | let $t087918893 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, priceValue) | |
332 | - | let sellerAmount = $t087918893._1 | |
333 | - | let buyerAmount = $t087918893._2 | |
334 | - | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
335 | - | if ((buyerAmount > 0)) | |
336 | - | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
337 | - | else updatedRes | |
338 | - | }) | |
339 | - | } | |
340 | - | else { | |
341 | - | let $t091109179 = calcPriceAtCurrentMoment(assetId, height) | |
342 | - | let seller = $t091109179._1 | |
343 | - | let actualPrice = $t091109179._2 | |
344 | - | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, actualPrice), { | |
345 | - | let $t092659368 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, actualPrice) | |
346 | - | let sellerAmount = $t092659368._1 | |
347 | - | let buyerAmount = $t092659368._2 | |
348 | - | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
349 | - | if ((buyerAmount > 0)) | |
350 | - | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
351 | - | else updatedRes | |
352 | - | }) | |
353 | - | } | |
328 | + | let currentBidPrice = i.payments[0].amount | |
329 | + | let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
330 | + | let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder")) | |
331 | + | let currentBidCount = getStringValue(this, (auctionId + "_bidder_count")) | |
332 | + | let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft")) | |
333 | + | let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status")) | |
334 | + | if ((i.payments[0].assetId != unit)) | |
335 | + | then throw("Pay in waves") | |
336 | + | else if ((checkNftAuctioned != "OPEN")) | |
337 | + | then throw("Not open for auction") | |
338 | + | else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice)) | |
339 | + | then throw("Bid is less then starting/highest Bid") | |
340 | + | else if ((getLastWinnerBidPrice == "0")) | |
341 | + | then [StringEntry((auctionId + "_highest_bid"), toString(currentBidPrice)), StringEntry((auctionId + "_winner_of_nft"), toBase58String(i.caller.bytes)), StringEntry((auctionId + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((auctionId + "_nft_id"), toBase58String(assetId)), StringEntry((auctionId + "_nft_owner"), nft_owner), StringEntry((((txId + "_") + auctionId) + "_highest_bid"), toString(currentBidPrice)), StringEntry((((txId + "_") + auctionId) + "_winner"), toBase58String(i.caller.bytes)), StringEntry((((txId + "_") + auctionId) + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((((txId + "_") + auctionId) + "_nft_id"), toBase58String(assetId)), StringEntry((((txId + "_") + auctionId) + "_nft_owner"), nft_owner), StringEntry((txId + "_bid_for_nft_by"), toBase58String(caller)), StringEntry((txId + "_bid_price_place"), bid_price), StringEntry((txId + "_previous_bid_amount_refund_to_address"), getLastWinnerAddress), StringEntry((txId + "_prevoius_bid_amount_refund"), getLastWinnerBidPrice)] | |
342 | + | else [StringEntry((auctionId + "_highest_bid"), toString(currentBidPrice)), StringEntry((auctionId + "_winner_of_nft"), toBase58String(i.caller.bytes)), StringEntry((auctionId + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((auctionId + "_nft_id"), toBase58String(assetId)), StringEntry((auctionId + "_nft_owner"), nft_owner), StringEntry((((txId + "_") + auctionId) + "_highest_bid"), toString(currentBidPrice)), StringEntry((((txId + "_") + auctionId) + "_winner"), toBase58String(i.caller.bytes)), StringEntry((((txId + "_") + auctionId) + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((((txId + "_") + auctionId) + "_nft_id"), toBase58String(assetId)), StringEntry((((txId + "_") + auctionId) + "_nft_owner"), nft_owner), StringEntry((txId + "_bid_for_nft_by"), toBase58String(caller)), StringEntry((txId + "_bid_price_place"), bid_price), StringEntry((txId + "_previous_bid_amount_refund_to_address"), getLastWinnerAddress), StringEntry((txId + "_prevoius_bid_amount_refund"), getLastWinnerBidPrice), ScriptTransfer(Address(fromBase58String(getLastWinnerAddress)), parseIntValue(getLastWinnerBidPrice), unit)] | |
354 | 343 | } | |
355 | 344 | ||
356 | 345 | ||
357 | 346 | ||
358 | 347 | @Callable(i) | |
359 | - | func declineSlot (nftId) = { | |
348 | + | func acceptBidOffer (auctionId,nftId,bid_amount_from_user) = { | |
349 | + | let txId = toBase58String(i.transactionId) | |
350 | + | let caller = i.caller.bytes | |
360 | 351 | let assetId = fromBase58String(nftId) | |
361 | - | let $t096699707 = getSlot(assetId) | |
362 | - | let type = $t096699707._1 | |
363 | - | let details = $t096699707._2 | |
364 | - | let baseRes = [DeleteEntry(getSlotKey(type, assetId))] | |
365 | - | if ((type == kSell)) | |
366 | - | then { | |
367 | - | let $t097999846 = parseAsSell(details) | |
368 | - | let seller = $t097999846._1 | |
369 | - | let priceValue = $t097999846._2 | |
370 | - | if (!(isValidCaller(i.caller, seller))) | |
371 | - | then throw("Invalid caller") | |
372 | - | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
373 | - | } | |
374 | - | else { | |
375 | - | let $t0999110095 = parseAsAuction(details) | |
376 | - | let seller = $t0999110095._1 | |
377 | - | let startPriceValue = $t0999110095._2 | |
378 | - | let endPriceValue = $t0999110095._3 | |
379 | - | let startPeriodValue = $t0999110095._4 | |
380 | - | let endPeriodValue = $t0999110095._5 | |
381 | - | if (!(isValidCaller(i.caller, seller))) | |
382 | - | then throw("Invalid caller") | |
383 | - | else if (!(isAuctionEnded(height, endPeriodValue))) | |
384 | - | then throw("Wait for end of auction") | |
385 | - | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
386 | - | } | |
352 | + | let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
353 | + | let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft")) | |
354 | + | [ScriptTransfer(Address(caller), parseIntValue(getNftWinningPrice), unit), ScriptTransfer(Address(fromBase58String(getAuctionWinner)), 1, assetId), StringEntry((txId + "_nft_transfer_to"), getAuctionWinner), StringEntry((txId + "_nft_status"), "REWARDED"), StringEntry((auctionId + "_amount_paid_to_owner"), getNftWinningPrice), StringEntry((auctionId + "_nft_transfer_to"), getAuctionWinner), StringEntry((auctionId + "_nft_status"), "REWARDED")] | |
387 | 355 | } | |
388 | 356 | ||
389 | 357 | ||
390 | 358 | ||
391 | 359 | @Callable(i) | |
392 | - | func setTrustedIssuer (trustedAddr) = if (!(isAdmin(i.caller))) | |
393 | - | then throw("Only admin") | |
394 | - | else [BooleanEntry(getTrustedKey(addressFromStringValue(trustedAddr)), true)] | |
360 | + | func cancelAuction (auctionId) = { | |
361 | + | let txId = toBase58String(i.transactionId) | |
362 | + | let caller = i.caller.bytes | |
363 | + | let auctionStatus = getStringValue(this, (auctionId + "_nft_status")) | |
364 | + | let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft")) | |
365 | + | let nftOwner = getStringValue(this, (auctionId + "_nft_owner")) | |
366 | + | let nftId = getStringValue(this, (auctionId + "_nft_on_auction")) | |
367 | + | let biddingPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
368 | + | [StringEntry((auctionId + "_nft_status"), "CANCELED"), StringEntry((auctionId + "_previous_bid_amount_refund_to_address"), biddingWinner), StringEntry((auctionId + "_prevoius_bid_amount_refund"), biddingPrice), StringEntry((txId + "_nft_status"), "CANCELED"), StringEntry((txId + "_previous_bid_amount_refund_to_address"), biddingWinner), StringEntry((txId + "_prevoius_bid_amount_refund"), biddingPrice), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId)), ScriptTransfer(Address(fromBase58String(biddingWinner)), parseIntValue(biddingPrice), unit)] | |
369 | + | } | |
395 | 370 | ||
396 | 371 | ||
397 | 372 | ||
398 | 373 | @Callable(i) | |
399 | - | func getPriceAtCurrentMoment (nftId,moment) = { | |
400 | - | let assetId = fromBase58String(nftId) | |
401 | - | let $t01063610699 = calcPriceAtCurrentMoment(assetId, moment) | |
402 | - | let seller = $t01063610699._1 | |
403 | - | let price = $t01063610699._2 | |
404 | - | [IntegerEntry(getPriceKey(assetId), price)] | |
374 | + | func withdrawBid (bidTxId) = { | |
375 | + | let caller = i.caller.bytes | |
376 | + | let bidPrice = getStringValue(this, (bidTxId + "_highest_bid")) | |
377 | + | let asBidder = getStringValue(this, (bidTxId + "_winner")) | |
378 | + | let bidForNFT = getStringValue(this, (bidTxId + "_nft_id")) | |
379 | + | if ((toBase58String(caller) != asBidder)) | |
380 | + | then throw("No bid") | |
381 | + | else [StringEntry((bidTxId + "_nft_bid"), "WITHDRAW"), StringEntry((bidTxId + "_nft_id"), bidForNFT), StringEntry((bidTxId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), unit)] | |
405 | 382 | } | |
383 | + | ||
384 | + | ||
385 | + | ||
386 | + | @Callable(i) | |
387 | + | func testBid (data) = [StringEntry("E8kkFBYCy44JJaq6pAZ6KizsuResi5UKNhbD1WNZwhhY_highest_bid", "0")] | |
406 | 388 | ||
407 | 389 |
github/deemru/w8io/026f985 81.22 ms ◑