46 | | - | |
---|
47 | | - | |
---|
48 | | - | |
---|
49 | | - | @Callable(o) |
---|
50 | | - | func sellNFT (B,C) = { |
---|
51 | | - | let A = o.transactionId |
---|
52 | | - | let D = o.caller.bytes |
---|
53 | | - | let E = $Tuple2(value(o.payments[0].assetId), value(o.payments[0].amount)) |
---|
54 | | - | let F = E._1 |
---|
55 | | - | let G = E._2 |
---|
56 | | - | if (!(k(F))) |
---|
57 | | - | then throw("Token is not NFT") |
---|
58 | | - | else [StringEntry(((c + a) + toBase58String(value(o.payments[0].assetId))), (B + C)), StringEntry(((toString(o.caller) + a) + d), (((toBase58String(F) + a) + toString(G)) + C))] |
---|
59 | | - | } |
---|
60 | | - | |
---|
61 | | - | |
---|
62 | | - | |
---|
63 | | - | @Callable(o) |
---|
64 | | - | func buyNFT (H,I) = { |
---|
65 | | - | let l = fromBase58String(H) |
---|
66 | | - | let J = value(o.payments[0].amount) |
---|
67 | | - | let K = { |
---|
68 | | - | let m = getString(this, (("nft_" + I) + "_owner")) |
---|
69 | | - | if ($isInstanceOf(m, "String")) |
---|
70 | | - | then { |
---|
71 | | - | let L = m |
---|
72 | | - | L |
---|
73 | | - | } |
---|
74 | | - | else false |
---|
75 | | - | } |
---|
76 | | - | let B = getStringValue(((((c + a) + H) + "_") + I)) |
---|
77 | | - | if ((I == toString(o.caller))) |
---|
78 | | - | then throw("current Owner of NFT not able to purchase") |
---|
79 | | - | else if ((o.payments[0].assetId == f)) |
---|
80 | | - | then [ScriptTransfer(o.caller, 1, l), ScriptTransfer(Address(fromBase58String(I)), J, f), StringEntry(((toString(o.caller) + a) + b), ((H + a) + toString(J))), DeleteEntry((("nft_" + I) + "_owner")), StringEntry((("nft_" + I) + "_owner"), toString(o.caller)), StringEntry(((H + a) + "_owner"), toString(o.caller))] |
---|
81 | | - | else if ((o.payments[0].assetId == unit)) |
---|
82 | | - | then [ScriptTransfer(o.caller, 1, l), ScriptTransfer(Address(fromBase58String(I)), J, unit), StringEntry(((toString(o.caller) + a) + b), ((H + a) + toString(J))), DeleteEntry((("nft_" + I) + "_owner")), StringEntry((("nft_" + I) + "_owner"), toString(o.caller)), StringEntry(((H + a) + "_owner"), toString(o.caller))] |
---|
83 | | - | else nil |
---|
84 | | - | } |
---|
85 | | - | |
---|
86 | | - | |
---|
87 | | - | |
---|
88 | | - | @Callable(o) |
---|
89 | | - | func cancelSell (M) = { |
---|
90 | | - | let A = toBase58String(o.transactionId) |
---|
91 | | - | let D = o.caller.bytes |
---|
92 | | - | [StringEntry(((A + M) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(D), 1, fromBase58String(M))] |
---|
93 | | - | } |
---|
94 | | - | |
---|
95 | | - | |
---|
96 | | - | |
---|
97 | | - | @Callable(o) |
---|
98 | | - | func addAuction (N,O,P,Q,C) = { |
---|
99 | | - | let A = toBase58String(o.transactionId) |
---|
100 | | - | let M = value(o.payments[0].assetId) |
---|
101 | | - | let B = value(P) |
---|
102 | | - | let R = (lastBlock.height + Q) |
---|
103 | | - | let S = o.caller.bytes |
---|
104 | | - | let T = { |
---|
105 | | - | let m = getString(this, (((toBase58String(M) + a) + "nft_status_") + toBase58String(S))) |
---|
106 | | - | if ($isInstanceOf(m, "String")) |
---|
107 | | - | then { |
---|
108 | | - | let L = m |
---|
109 | | - | true |
---|
110 | | - | } |
---|
111 | | - | else false |
---|
112 | | - | } |
---|
113 | | - | if ((T == true)) |
---|
114 | | - | then throw("Already in auction list") |
---|
115 | | - | else if ((Q > e)) |
---|
116 | | - | then throw(("Duration is too long. Must be less than or equal to 7 " + toString(e))) |
---|
117 | | - | else if ((o.payments[0].assetId == unit)) |
---|
118 | | - | then throw("NFT not attached") |
---|
119 | | - | else if ((o.payments[0].assetId == f)) |
---|
120 | | - | then throw("NFT not attached") |
---|
121 | | - | else [StringEntry(((A + "nft_start_auction_date") + toBase58String(S)), N), StringEntry(((A + "nft_end_auction_date") + toBase58String(S)), O), StringEntry((A + "_nft_start_price"), (P + C)), StringEntry((A + "_nft_owner"), toString(o.caller)), StringEntry((A + "_nft_on_auction"), toBase58String(M)), StringEntry((A + "_previous_bidder"), "none"), StringEntry((A + "_highest_bid"), "0"), StringEntry((A + "_winner_of_nft"), "0"), StringEntry((A + "_bidder_count"), "0"), StringEntry((A + "_nft_status"), "OPEN")] |
---|
122 | | - | } |
---|
123 | | - | |
---|
124 | | - | |
---|
125 | | - | |
---|
126 | | - | @Callable(o) |
---|
127 | | - | func placeBid (U,M,q,P,V) = { |
---|
128 | | - | let A = toBase58String(o.transactionId) |
---|
129 | | - | let S = o.caller.bytes |
---|
130 | | - | let l = fromBase58String(M) |
---|
131 | | - | let W = o.payments[0].amount |
---|
132 | | - | let X = getStringValue(this, (U + "_highest_bid")) |
---|
133 | | - | let Y = getString(this, (U + "_previous_bidder")) |
---|
134 | | - | let Z = getStringValue(this, (U + "_bidder_count")) |
---|
135 | | - | let aa = getStringValue(this, (U + "_winner_of_nft")) |
---|
136 | | - | let T = getStringValue(this, (U + "_nft_status")) |
---|
137 | | - | if ((T != "OPEN")) |
---|
138 | | - | then throw("Not open for auction") |
---|
139 | | - | else if ((parseIntValue(X) >= W)) |
---|
140 | | - | then throw("Bid is less then starting/highest Bid") |
---|
141 | | - | else if ((X == "0")) |
---|
142 | | - | then [StringEntry((U + "_highest_bid"), toString(W)), StringEntry((U + "_winner_of_nft"), toBase58String(o.caller.bytes)), StringEntry((U + "_bidder_count"), toString((parseIntValue(Z) + 1))), StringEntry((U + "_nft_id"), toBase58String(l)), StringEntry((U + "_nft_owner"), q), StringEntry((((A + "_") + U) + "_highest_bid"), toString(W)), StringEntry((((A + "_") + U) + "_winner"), toBase58String(o.caller.bytes)), StringEntry((((A + "_") + U) + "_bidder_count"), toString((parseIntValue(Z) + 1))), StringEntry((((A + "_") + U) + "_nft_id"), toBase58String(l)), StringEntry((((A + "_") + U) + "_nft_owner"), q), StringEntry((A + "_bid_for_nft_by"), toBase58String(S)), StringEntry((A + "_bid_price_place"), V), StringEntry((A + "_previous_bid_amount_refund_to_address"), aa), StringEntry((A + "_prevoius_bid_amount_refund"), X)] |
---|
143 | | - | else if ((o.payments[0].assetId == unit)) |
---|
144 | | - | then [StringEntry((U + "_highest_bid"), toString(W)), StringEntry((U + "_winner_of_nft"), toBase58String(o.caller.bytes)), StringEntry((U + "_bidder_count"), toString((parseIntValue(Z) + 1))), StringEntry((U + "_nft_id"), toBase58String(l)), StringEntry((U + "_nft_owner"), q), StringEntry((((A + "_") + U) + "_highest_bid"), toString(W)), StringEntry((((A + "_") + U) + "_winner"), toBase58String(o.caller.bytes)), StringEntry((((A + "_") + U) + "_bidder_count"), toString((parseIntValue(Z) + 1))), StringEntry((((A + "_") + U) + "_nft_id"), toBase58String(l)), StringEntry((((A + "_") + U) + "_nft_owner"), q), StringEntry((A + "_bid_for_nft_by"), toBase58String(S)), StringEntry((A + "_bid_price_place"), V), StringEntry((A + "_previous_bid_amount_refund_to_address"), aa), StringEntry((A + "_prevoius_bid_amount_refund"), X), ScriptTransfer(Address(fromBase58String(aa)), parseIntValue(X), unit)] |
---|
145 | | - | else if ((o.payments[0].assetId == f)) |
---|
146 | | - | then [StringEntry((U + "_highest_bid"), toString(W)), StringEntry((U + "_winner_of_nft"), toBase58String(o.caller.bytes)), StringEntry((U + "_bidder_count"), toString((parseIntValue(Z) + 1))), StringEntry((U + "_nft_id"), toBase58String(l)), StringEntry((U + "_nft_owner"), q), StringEntry((((A + "_") + U) + "_highest_bid"), toString(W)), StringEntry((((A + "_") + U) + "_winner"), toBase58String(o.caller.bytes)), StringEntry((((A + "_") + U) + "_bidder_count"), toString((parseIntValue(Z) + 1))), StringEntry((((A + "_") + U) + "_nft_id"), toBase58String(l)), StringEntry((((A + "_") + U) + "_nft_owner"), q), StringEntry((A + "_bid_for_nft_by"), toBase58String(S)), StringEntry((A + "_bid_price_place"), V), StringEntry((A + "_previous_bid_amount_refund_to_address"), aa), StringEntry((A + "_prevoius_bid_amount_refund"), X), ScriptTransfer(Address(fromBase58String(aa)), parseIntValue(X), f)] |
---|
147 | | - | else nil |
---|
148 | | - | } |
---|
149 | | - | |
---|
150 | | - | |
---|
151 | | - | |
---|
152 | | - | @Callable(o) |
---|
153 | | - | func acceptBidOffer (U,M,ab) = { |
---|
154 | | - | let A = toBase58String(o.transactionId) |
---|
155 | | - | let S = o.caller.bytes |
---|
156 | | - | let l = fromBase58String(M) |
---|
157 | | - | let ac = getStringValue(this, (U + "_highest_bid")) |
---|
158 | | - | let ad = getStringValue(this, (U + "_winner_of_nft")) |
---|
159 | | - | [ScriptTransfer(Address(S), parseIntValue(ac), f), ScriptTransfer(Address(fromBase58String(ad)), 1, l), StringEntry((A + "_amount_paid_to_owner"), ac), StringEntry((A + "_nft_transfer_to"), ad), StringEntry((A + "_nft_status"), "REWARDED"), StringEntry((U + "_amount_paid_to_owner"), ac), StringEntry((U + "_nft_transfer_to"), ad), StringEntry((U + "_nft_status"), "REWARDED")] |
---|
160 | | - | } |
---|
161 | | - | |
---|
162 | | - | |
---|
163 | | - | |
---|
164 | | - | @Callable(o) |
---|
165 | | - | func cancelAuction (U) = { |
---|
166 | | - | let A = toBase58String(o.transactionId) |
---|
167 | | - | let S = o.caller.bytes |
---|
168 | | - | let ae = getStringValue(this, (U + "_nft_status")) |
---|
169 | | - | let af = getStringValue(this, (U + "_winner_of_nft")) |
---|
170 | | - | let ag = getStringValue(this, (U + "_nft_owner")) |
---|
171 | | - | let M = getStringValue(this, (U + "_nft_on_auction")) |
---|
172 | | - | let ah = getStringValue(this, (U + "_highest_bid")) |
---|
173 | | - | if ((af == "0")) |
---|
174 | | - | then [StringEntry(((A + U) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(ag)), 1, fromBase58String(M))] |
---|
175 | | - | else if ((o.payments[0].assetId == unit)) |
---|
176 | | - | then [StringEntry((U + "_nft_status"), "CANCELED"), StringEntry((U + "_previous_bid_amount_refund_to_address"), af), StringEntry((U + "_prevoius_bid_amount_refund"), ah), StringEntry((A + "_nft_status"), "CANCELED"), StringEntry((A + "_previous_bid_amount_refund_to_address"), af), StringEntry((A + "_prevoius_bid_amount_refund"), ah), ScriptTransfer(Address(fromBase58String(ag)), 1, fromBase58String(M)), ScriptTransfer(Address(fromBase58String(af)), parseIntValue(ah), unit)] |
---|
177 | | - | else if ((o.payments[0].assetId == f)) |
---|
178 | | - | then [StringEntry((U + "_nft_status"), "CANCELED"), StringEntry((U + "_previous_bid_amount_refund_to_address"), af), StringEntry((U + "_prevoius_bid_amount_refund"), ah), StringEntry((A + "_nft_status"), "CANCELED"), StringEntry((A + "_previous_bid_amount_refund_to_address"), af), StringEntry((A + "_prevoius_bid_amount_refund"), ah), ScriptTransfer(Address(fromBase58String(ag)), 1, fromBase58String(M)), ScriptTransfer(Address(fromBase58String(af)), parseIntValue(ah), f)] |
---|
179 | | - | else nil |
---|
180 | | - | } |
---|
181 | | - | |
---|
182 | | - | |
---|
183 | | - | |
---|
184 | | - | @Callable(o) |
---|
185 | | - | func withdrawBid (ai) = { |
---|
186 | | - | let S = o.caller.bytes |
---|
187 | | - | let aj = getStringValue(this, (ai + "_highest_bid")) |
---|
188 | | - | let ak = getStringValue(this, (ai + "_winner")) |
---|
189 | | - | let al = getStringValue(this, (ai + "_nft_id")) |
---|
190 | | - | if ((toBase58String(S) != ak)) |
---|
191 | | - | then throw("No bid") |
---|
192 | | - | else [StringEntry((ai + "_nft_bid"), "WITHDRAW"), StringEntry((ai + "_nft_id"), al), StringEntry((ai + "_bidding_price_refund_amount"), aj), ScriptTransfer(o.caller, parseIntValue(aj), unit)] |
---|
193 | | - | } |
---|
194 | | - | |
---|
195 | | - | |
---|
196 | | - | |
---|
197 | | - | @Callable(o) |
---|
198 | | - | func manualFundTransfer (am,an) = { |
---|
199 | | - | let S = o.caller.bytes |
---|
200 | | - | let ao = fromBase58String(am) |
---|
201 | | - | let J = o.payments[0].amount |
---|
202 | | - | if ((o.payments[0].assetId == unit)) |
---|
203 | | - | then [IntegerEntry((toBase58String(S) + "_transfer"), J), StringEntry((toBase58String(S) + "_transfer_to"), am), ScriptTransfer(Address(ao), J, unit)] |
---|
204 | | - | else if ((o.payments[0].assetId == f)) |
---|
205 | | - | then [IntegerEntry((toBase58String(S) + "_transfer"), J), StringEntry((toBase58String(S) + "_transfer_to"), am), ScriptTransfer(Address(ao), J, f)] |
---|
206 | | - | else nil |
---|
207 | | - | } |
---|
208 | | - | |
---|
209 | | - | |
---|
210 | | - | |
---|
211 | | - | @Callable(o) |
---|
212 | | - | func testBid (ap) = [StringEntry("E8kkFBYCy44JJaq6pAZ6KizsuResi5UKNhbD1WNZwhhY_highest_bid", "0")] |
---|