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