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