47 | | - | func sellNFT (price,payment_currency) = { |
---|
48 | | - | let txId = i.transactionId |
---|
49 | | - | let seller = i.caller.bytes |
---|
50 | | - | let $t019011986 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) |
---|
51 | | - | let token0 = $t019011986._1 |
---|
52 | | - | let amount0 = $t019011986._2 |
---|
53 | | - | if (!(isNft(token0))) |
---|
54 | | - | then throw("Token is not NFT") |
---|
55 | | - | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), price), StringEntry(((toString(i.caller) + separator) + kSell), (((toBase58String(token0) + separator) + toString(amount0)) + payment_currency))] |
---|
56 | | - | } |
---|
57 | | - | |
---|
58 | | - | |
---|
59 | | - | |
---|
60 | | - | @Callable(i) |
---|
61 | | - | func buyNFT (nftID,current_nft_owner) = { |
---|
62 | | - | let assetId = fromBase58String(nftID) |
---|
63 | | - | let amount = value(i.payments[0].amount) |
---|
64 | | - | let checkOwnerIsSame = match getString(this, (("nft_" + current_nft_owner) + "_owner")) { |
---|
65 | | - | case a: String => |
---|
66 | | - | a |
---|
67 | | - | case _ => |
---|
68 | | - | false |
---|
69 | | - | } |
---|
70 | | - | let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner)) |
---|
71 | | - | let seller_amount = ((amount / 1000) * 975) |
---|
72 | | - | let platform_fee = ((amount / 1000) * 25) |
---|
73 | | - | if ((current_nft_owner == toString(i.caller))) |
---|
74 | | - | then throw("current Owner of NFT not able to purchase") |
---|
75 | | - | else if ((i.payments[0].assetId == teams)) |
---|
76 | | - | then [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), seller_amount, teams), StringEntry((("nft_" + nftID) + "platform_fee"), toString(platform_fee)), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + current_nft_owner) + "_owner")), StringEntry((("nft_" + current_nft_owner) + "_owner"), toString(i.caller)), StringEntry(((nftID + separator) + "_owner"), toString(i.caller))] |
---|
77 | | - | else if ((i.payments[0].assetId == unit)) |
---|
78 | | - | then [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), seller_amount, unit), StringEntry((("nft_" + nftID) + "platform_fee"), toString(platform_fee)), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + current_nft_owner) + "_owner")), StringEntry((("nft_" + current_nft_owner) + "_owner"), toString(i.caller)), StringEntry(((nftID + separator) + "_owner"), toString(i.caller))] |
---|
79 | | - | else nil |
---|
80 | | - | } |
---|
81 | | - | |
---|
82 | | - | |
---|
83 | | - | |
---|
84 | | - | @Callable(i) |
---|
85 | | - | func cancelSell (nftId) = { |
---|
86 | | - | let txId = toBase58String(i.transactionId) |
---|
87 | | - | let seller = i.caller.bytes |
---|
88 | | - | [StringEntry(((txId + nftId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(seller), 1, fromBase58String(nftId))] |
---|
89 | | - | } |
---|
90 | | - | |
---|
91 | | - | |
---|
92 | | - | |
---|
93 | | - | @Callable(i) |
---|
94 | | - | func addAuction (start,end,startPrice,duration,payment_currency) = { |
---|
95 | | - | let txId = toBase58String(i.transactionId) |
---|
96 | | - | let nftId = value(i.payments[0].assetId) |
---|
97 | | - | let price = value(startPrice) |
---|
98 | | - | let endHeight = (lastBlock.height + duration) |
---|
99 | | - | let caller = i.caller.bytes |
---|
100 | | - | let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) { |
---|
101 | | - | case a: String => |
---|
102 | | - | true |
---|
103 | | - | case _ => |
---|
104 | | - | false |
---|
105 | | - | } |
---|
106 | | - | if ((checkNftAuctioned == true)) |
---|
107 | | - | then throw("Already in auction list") |
---|
108 | | - | else if ((duration > maxAuctionDuration)) |
---|
109 | | - | then throw(("Duration is too long. Must be less than or equal to 7 " + toString(maxAuctionDuration))) |
---|
110 | | - | else if ((i.payments[0].assetId == unit)) |
---|
111 | | - | then throw("NFT not attached") |
---|
112 | | - | else if ((i.payments[0].assetId == teams)) |
---|
113 | | - | then throw("NFT not attached") |
---|
114 | | - | 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 + "_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")] |
---|
115 | | - | } |
---|
116 | | - | |
---|
117 | | - | |
---|
118 | | - | |
---|
119 | | - | @Callable(i) |
---|
120 | | - | func placeBid (auctionId,nftId,nft_owner,bid_price) = { |
---|
121 | | - | let txId = toBase58String(i.transactionId) |
---|
122 | | - | let caller = i.caller.bytes |
---|
123 | | - | let assetId = fromBase58String(nftId) |
---|
124 | | - | let currentBidPrice = i.payments[0].amount |
---|
125 | | - | let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
126 | | - | let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder")) |
---|
127 | | - | let currentBidCount = getStringValue(this, (auctionId + "_bidder_count")) |
---|
128 | | - | let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
129 | | - | let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status")) |
---|
130 | | - | if ((checkNftAuctioned != "OPEN")) |
---|
131 | | - | then throw("Not open for auction") |
---|
132 | | - | else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice)) |
---|
133 | | - | then throw("Bid is less then starting/highest Bid") |
---|
134 | | - | else if (if ((getLastWinnerBidPrice == "0")) |
---|
135 | | - | then (i.payments[0].assetId == unit) |
---|
136 | | - | else false) |
---|
137 | | - | 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)] |
---|
138 | | - | else if (if ((getLastWinnerBidPrice != "0")) |
---|
139 | | - | then (i.payments[0].assetId == unit) |
---|
140 | | - | else false) |
---|
141 | | - | then [StringEntry((txId + "_previous_bid_amount_refund_to_address"), getLastWinnerAddress), StringEntry((txId + "_prevoius_bid_amount_refund"), getLastWinnerBidPrice), StringEntry((auctionId + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((auctionId + "_highest_bid"), toString(currentBidPrice)), StringEntry((auctionId + "_winner_of_nft"), toBase58String(i.caller.bytes)), 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), ScriptTransfer(Address(fromBase58String(getLastWinnerAddress)), parseIntValue(getLastWinnerBidPrice), unit)] |
---|
142 | | - | else if (if ((getLastWinnerBidPrice == "0")) |
---|
143 | | - | then (i.payments[0].assetId == teams) |
---|
144 | | - | else false) |
---|
145 | | - | 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)] |
---|
146 | | - | else if (if ((getLastWinnerBidPrice != "0")) |
---|
147 | | - | then (i.payments[0].assetId == teams) |
---|
148 | | - | else false) |
---|
149 | | - | then [StringEntry((txId + "_previous_bid_amount_refund_to_address"), getLastWinnerAddress), StringEntry((txId + "_prevoius_bid_amount_refund"), getLastWinnerBidPrice), StringEntry((auctionId + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((auctionId + "_highest_bid"), toString(currentBidPrice)), StringEntry((auctionId + "_winner_of_nft"), toBase58String(i.caller.bytes)), 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), ScriptTransfer(Address(fromBase58String(getLastWinnerAddress)), parseIntValue(getLastWinnerBidPrice), teams)] |
---|
150 | | - | else nil |
---|
151 | | - | } |
---|
152 | | - | |
---|
153 | | - | |
---|
154 | | - | |
---|
155 | | - | @Callable(i) |
---|
156 | | - | func acceptBidOffer (auctionId,nftId,bid_amount_from_user,current_currency) = { |
---|
157 | | - | let txId = toBase58String(i.transactionId) |
---|
158 | | - | let caller = i.caller.bytes |
---|
159 | | - | let assetId = fromBase58String(nftId) |
---|
160 | | - | let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
161 | | - | let getNftWinningamount = ((parseIntValue(getNftWinningPrice) / 1000) * 975) |
---|
162 | | - | let platform_fee = ((parseIntValue(getNftWinningPrice) / 1000) * 25) |
---|
163 | | - | let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
164 | | - | if ((current_currency == WAVES)) |
---|
165 | | - | then [ScriptTransfer(Address(caller), getNftWinningamount, unit), ScriptTransfer(Address(fromBase58String(getAuctionWinner)), 1, assetId), StringEntry("platform_fee", toString(platform_fee)), StringEntry((txId + "_amount_paid_to_owner"), getNftWinningPrice), 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")] |
---|
166 | | - | else if ((current_currency == teams)) |
---|
167 | | - | then [ScriptTransfer(Address(caller), getNftWinningamount, teams), ScriptTransfer(Address(fromBase58String(getAuctionWinner)), 1, assetId), StringEntry("platform_fee", toString(platform_fee)), StringEntry((txId + "_amount_paid_to_owner"), getNftWinningPrice), 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")] |
---|
168 | | - | else nil |
---|
169 | | - | } |
---|
170 | | - | |
---|
171 | | - | |
---|
172 | | - | |
---|
173 | | - | @Callable(i) |
---|
174 | | - | func cancelAuction (auctionId,current_currency) = { |
---|
175 | | - | let txId = toBase58String(i.transactionId) |
---|
176 | | - | let caller = i.caller.bytes |
---|
177 | | - | let auctionStatus = getStringValue(this, (auctionId + "_nft_status")) |
---|
178 | | - | let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
179 | | - | let nftOwner = getStringValue(this, (auctionId + "_nft_owner")) |
---|
180 | | - | let nftId = getStringValue(this, (auctionId + "_nft_on_auction")) |
---|
181 | | - | let biddingPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
182 | | - | if ((biddingWinner == "0")) |
---|
183 | | - | then [StringEntry(((txId + auctionId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))] |
---|
184 | | - | else if ((biddingWinner != "0")) |
---|
185 | | - | then throw("soory you can't cancel it because already auction placed by someone") |
---|
186 | | - | else nil |
---|
187 | | - | } |
---|
188 | | - | |
---|
189 | | - | |
---|
190 | | - | |
---|
191 | | - | @Callable(i) |
---|
192 | | - | func manualFundTransfer (recepientAddr,message) = { |
---|
| 21 | + | func sendRequest (recepientAddr,amount,Attachment) = { |
---|