/
songs-of-innocence.clar
333 lines (289 loc) · 21.7 KB
/
songs-of-innocence.clar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
;;####@##@###@###@##########@########@############@#@#@######*:--...............-..-+#@@###*:-::=*#@#@####@###@########@###@###@####@####@####@######@###@#@####@
;;#@@@@@@@###@#####@##@#######@##@@######@##@@##@@###@@#@@@###=--..................-.-+++++:-:=+*#@@####@#####@####@##@@##@@@##@@###@##@@#####@@###@##@@###@####@
;;@@##@##@###@@@##@##@##@#@#@#@#@#@@@#####@#@@####@@@@@#@#@###*:-..........-==*****######*=:=++##@##@@@##@#####@###@##@##@@@#@####@###@#######@#@#@@@####@####@#@
;;####@@#######@@##@#@########@####@####@####@#############@@##*:--..............-=+==+*#+::+*######################@##########@###@@####@########@###@#######@##
;;#@##@##@@@#@####@###@@@@##@####@#############@##@@#@###########*+=:-...........--:::+**##*##@##@#@#####@#@@####@#@@#@@@@###@@####@#@#@######@#@######@@#####@##
;;#@@#######@##@##@@#@#@##@@@####@###@#@#@##@##@@@#@@@@####@###*=*##*+=:--.........--::+**###@#@##@#@####@@########@@#@@#@@#####@@@###@##@#@@#@####@###@##@#@####
;;####@##@#####@##@#@#####@####@##@###@#########@######@@#####@*:--=*##*##*+=:====::=***##@@#####@@###@######@########@@@@###@###########@#######@#@#############
;;############@###@####@####@@@#@#@#@@@#@#@##@###@########@#@##*:-....:=*##############@@@@##@@##@#@###@##@######@#############@@@@##@@####@##@#@###@@##@########
;;@##@@######@#######@##@#@#@#@#########@##@@##@#####@@@#######+:-........-:=*###@####@#############@##@##@##############@#@###@##@#@####@########@##@########@##
;;##@#@#@@#@###@@@##########@#@##@@##@@##@##@##@##########@#@#=:--..............-=+*##@@####@@#####@@###@##@##@@#######@#####@@@#@#####@########@#@@#######@##@#@
;;@#@##@#######@#@@#@###@@####@###########@####@###@#@#####=-----................---:=++**####@##@##########@###@############@############@@@###@@###@##########@
;;##@####@##@@##@#@####@######@###@#@##@####@@#######+:--..----....................---::==++**###################@@#@@@####@######@######@@################@#####
;;@###@##@#@#######@#@####@###@@##@@#####@@###*=---.................................----::::::::::+====++++++====:=:=::::=+*##@@####@###@####@@##@@@#@@####@@@@##
;;#@##########@@#####@###@#########@##**=:---------.......................................-..----------:==+==::---.-------------::=*######@############@####@@###
;;#########@@@@@#######@@#@#####+:-.........................................................----:------:::::::::-------------.-..---:=+##@###@#@##@@#@@@####@###@
;;@####@@####@#@#######@@##*:--.....................................-.........................:----.--------------:-----.-........---:=+##@#@##@#@@@#@#@######@##
;;####@####@######@@####+-...................................................................-.-....-....----------:------------.----::=*######@#################
;;#@####@@@#@#@@######=-....................................................................-.................--------:::::::-------::=++##@@@@####@@#@@@######@#
;;#####@#@###@###@#@+--.........................................................................................-.----:::::==:::::::::==+*########@@#####@#@@####
;;@###@##@#@@@#@###:-....................................................................-..........................----::::===++++====++*###@####@@####@########
;;####@#@###@@@###=--...............................................................................................------::===+**##++++**###@@##@@####@@###@@@##
;;@###@@######@@#=--..................................................................-............................-------:::==+*####+++**#@####@######@##@@@####
;;#@##@##@###@##+:--................................................................:................................----:::==+*####@#*+*##@@@@@#@@#@@####@######
;;@#@###########=---.............--..................................................-............................-.----::==+*##@##@@@##**##@###@############@###
;;#@@#@#@@###@#*=----...........--:--............................................... : ............................---:::=+*##@@@@####@##*####@#@###########@#@#@
;;##@##@###@##@#=:----..........-:==:----............................................-.............................---::=+*###@@@#@@@@##***###@#@#@#####@@##@####
;;@###@####@####+::----.........-:+#*==:--..........................................-.............................---::=+*#@#@##@#@#@###***#####@@#######@@##@###
;;@##########@##+:::----.......--:+###+=:---......................................................................--::+**####@@@@@@#@@##****###@@##@###@#########
;;@###@@#######*=::--------------:=*###+::---..................................................................----:=+**########@#######*++*##@####@@@###########
;;@#@#@#@##@###+=::-------.------:=+*##::::----....-----...........................-.-.......................----:=++*##@##@@#@@@###@#@##****##@@#@##@@@######@#@
;;###@####@@###+=:-------------::=++*##=:::::--------:--.............................-..................-------::=+*##@@#@@@@##@@##@@@##@#****####@@##@@#####@@@#
;;#####@######*+=:-------.-----:=++***#==::::::::--------.............................................--.---::::=+*##@@##@########@#@#@#@#**+*###########@#@#####
;;@###@##@#@##*=:::-----------::=+**###*==:::-----------..............................................--.---:::==++*##@@@##@##@#@###@@@@@##****###@@#@#####@#@@##
;;@##@@##@####+==::----------::=+**###@#===:::------..........................-::=+#########@##***==:-.-.----:::==+**##@########@@@@@#@@@##****####@@@#@###@###@#
;;####@######*+==:::-------:::==+*######*=::::------................... -=*##########@#@###########@#@###+=:-:::=++*###@####@##@@#####@####*++**###@@##@#@@#@####
;;@#@##@#####*+=::::-:---:::::=+**#######*=:::-----..............:=*#########@@@##@####@###@#####@#@@@@##@#*=::=++**##@@###@###@@#########*+++***####@#@#@##@####
;;#######@#@#+==:::::::---:::=+**##@#@@#@#+::-----.--...-::+###############@@###@##@@#@########@@###@#@@@##@@#*++*###@@@##@###########@##**++++****###@@##@#@@@@@
;;###@###@@#*==::::-::-:::::=++*##@@#######==:---.-...:+####@#####@@##@#@##@@@#@@@@@#@###@##@@#@###@#####@##@@@#######@@######@###@#@#@###**+++=+++**####@@@@@###
;;########@*+==:::::::::====++*####@#######*=:::---..-++###@#@####@####@####@###########@###########@#@##@##@@#@######@##@#####@#######@##*++++=====+*##@##@@##@@
;;#@@##@#@#+==:::::::=====+++**##@#@@#######+=:::----:*##@@###@@#@#####**#####@############@#@@#@##@####@##@##@###@###@##@##@@@###@#@@@###**+==:::-::=+*##@#@#@##
;;#@###@@#*==::-::::===+++++***##@#@#####@##*=:::-----:==*##@########**+++***##################@######@#@@@#####@#@#####@#@@####@@@#@#####*+==---.---::+*#######@
;;@#######+=::---::=====++=++**##@######@###+=::::-------.::-----..-.--..-=++**+++++*##################@###@#@######@##@############@####*+=:--...---:==*##@@####
;;####@@#*+=::-----:::::::=+++**#@##########+:::-:----------.............-=+*+****+**########*#######################@@#@######@#######@#*+::-------::=+*##@@#@#@
;;@##@@##+==::::-:::-:::::==+***#@@###@#@###+:------------:--..........--:++*+++***+****#####*###############@########@@@###@##@@#@#@@@###+=::------::=+**######@
;;@###@#*+===:::::::::::===+++*#########@@#*:-----------.-:::---------::=+++++++++************#**#########@#@######@###@#@############@###*+==::----:=+++**###@##
;;######*++==:::::::::====+++*##@##########=:-----.-----.-------------::-=+=++++++++++*+*****+***#***#####@##@########@##@#####@@##########**+==:::::==++*##@####
;;@#@###*++====:::::::====++*##@##@@@@@###*::--------.-..:=:-------------:::==+++********++:-..-=++=:=*####@#@##@##@@@###@#@#@@@@###@@@#@@###*++==::::=++**###@@#
;;@#@###*++===::::======+++**##@###@#@@##*=::---------....:=::--.....-----::::=++*******+:-.-:#+:-..::=#**##@#####@#@@@##@#####@##@#@##@@@@@##***+====++**###@@##
;;##@###*+++==::::=:===+++**##@#@##@##@##+=::---------......:##*+++++=:-------:::===::::-.--:==+-:+=-::*##@#@#@@######@#@@#@####@#########@#####**++===+****###@@
;;@@####**+======:====++***####@@@@##@#*+==::----------...--...:+*+:---:-------:::::::::---...:#::-.-++#####@@@@#@@##@#@###@#@@#@##@@#####@@#@#@##**++=++**###@@@
;;##@###**++=========++***####@@@@@@#+:-===::------------::-:----:=:-......--::::=====:=::::===-.-=++=##@@@@#############@###@#@@@##@######@@@@#@##***+++***##@@#
;;@#@###**+++======+++***###@#####+:---:=:::-----------.::---..----::::--:::::==::====:::::::=-..::=#@@#####***+++++++++*######@@@@#@######@@@@##@##**++***######
;;@#####**+++=====+++**###@@####+::-:=:+=::-------------:+**+=:--::::-:=+++==::::::::---::::::=*+*#@@##@##**++====::::==+*#***###*****++****#####@@##**++**###@@#
;;######**+++=+++++++**#############**+=::-----------------.--.:+=:-:::---::::::::::::--:::====+++*####*++=:::::::-----:++***++=+***++=:::===++*##@@#***+**####@@
;;@##@##**++++++++++**#####@#+=:==+*#=+==:-------------------...-===:---:::-::::::::::::::===++++*++++==::----......-=:-.-:=++=::::=++*++=::===++**##@#*+***##@@@
;;@@@####*+++++++++**####@@#+===:::=*+##*+::-------------------.-..:**+=:-:::::::===::::==++++++**+=::-:-----....--......-:==++=:--::=++++++====+++*##@@######@@#
;;##@#@#****++++*++**####@#*+==:::::=*##@@##*+=::-------------------:*+=++=:=========++++***####*+::::-----...-:-.......--:==++=:::::::=++**+++===++*##@#######@#
;;@###@##**+++++****##@@###*++===:::==*@@#@#########+====:::::::::==+*+=::=+++=++++++**###@@#@@#+=::::----.-::..--.....---:=======:::::==+***++====+**####@@@#@##
;;##@@@###*++++++***#@#@@#*+++===:::::=*##@##@#@###@#####@##*+=:=***####**++***####@@###@#@@##@#*+==:::::=:.....-.....---::========:=:===+**##*++=+++**###@######
;;####@##***++++****##@#@#**++====:::::=+####@@##@@#@@#@@@##@#*+***##@@########@##@@@##@#@#@@@##+====:==::------....---:::::::==::::::==+++*####*++++**##@@@@####
;;@##@@##****+*****##@#@###*++====::::::==*+==*##@@@##@@@@####****#@@#@@##@#@@@@#@@##@#*+==:::::::-:------------------:::::::::=::::-:::=+*#######****#####@@#@##
;;@##@@###****++***##@##@#**++===::::::::==**+=+++***#########***##@###@##@#@#####+:::=:=+=::----....-------.....---:::::--------:::::::::==*###@@#######@####@##
;;@##@####****+***##@@@##@#**++====::::::==+*#**#++*####++#******##@##*****###*=:==++++**++=:=:..........--.-------------::---::::::::=======+*###@@####@@##@####
;;###@@###********###@###@#**+++====::::::==+*##**#####+=*+########*###***==:-:=*+***#*++++++=-... ..........---------------:-:::::::===++++++**##@@##@####@##@##
;;#@##@@###********##@###@@#***++==::::::::=+*###+=+*++*#**#########+:::::::+*+**+**+++++#*=:::--............---------------::::::::===++++*****###@#@@##@#@#@##@
;;##@#@@###**********####@###***++=::::::-::=+*###*++*######*++===::::::::::+++*+***++*+*#*+=+++=:---.....-----::::::::=:::::::=======+++****#####@@###@#@#@##@##
;;##@#@###********+****##@@####*++==:::::::::=+##@####++====:==::::::::::::::******######++++**+------------:::==+===============+++++****###@@#@##@@####@##@####
;;@###@####*****+++*****###@####**++==::::::::==+**+=======:=:::::::::==:::=::=****#*##*#+**##+:===::::-::::=====+=+===========+++++****#####@@#@@@@#@###@@#####@
;;@###@@###**************###@####**++=========================::::::============+#+*#*###+*#*===+===============++=+==========++++****#########@@#@#############@
;;##@######***************######@##*++++==================+===::::::======++=++===+*+#*+#*++=++=++++++++++++++++++=======++++++++*+****##########@#####@@########
;;@##########******#@#########@#####**++++++++===========+==+=====::::=:===+=+=++=+++++++++++++++++++++++++==============++++++*********#####@##@#@@#@@#@##@#####
;;@##@#@######****##@##@@###@#@#@#####****++++++++=+========++=====:::================+======++++++++++++++++++++++==++++++++++**********#####@##@@##@#@###@@####
;;####@@#####*#*####@@#@######@#@#######*********+++++++++++++++==============================++==++++=++++++========++++++++++++******######@@#@###@@###@#@@@##@
;;####@######@#####@##@#######@@#@#############*******+++++++++++++++++++++=============================++++++=+=======+++++++***+***###@@####@#####@############
;;##@@#@@######@#####@#@##@@##*######@@##@@###########*************+*+*+++*+++++++==+==+++++++++++++++++++++==============+=++*****####@#@@##@###@@##@######@####
;;##@@##@#@@#@@#@####@####@@##@@@##@@#@#@#@@###@@#@##@@#########**************************#*########******++======:::=====+++***#####@#####@#####@#########@@@@##
;;##@##@######@@###@#@#@######@###@##@#######@###@######@@@##############################@@@#######@@###**++++++======+++***#############@########@##@###########
;;@###@##@###@####@##@###@@#@###@@#@####@#@@@####@@@####@@@##@#@####@@#@###@#######@@###@#@@#@##@#@@@########*********#####@@##@##@#@####@########@#@##@#@##@@@#@
;;@#@###@#######@@##@###@@###@@@@#@####@#######@#@#@@@######@#@#@#@#@@@@#@########@#@@##@#@##@@@###@#####@@##@@@@@@##@###@@#@@##@###@#@##@@#@#@@@######@#@####@@#
;;@#############@####@#@#@@###@@#@@########@#@#######@##@@@@@@@##@##@#########@#######@##@#@#@#@###@##@######@##@##@@@##@######@##@####@#####@##@#@###@##@####@##
(impl-trait 'SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait.nft-trait)
(define-non-fungible-token songs-of-innocence uint)
;; Constants
(define-constant DEPLOYER tx-sender)
(define-constant COMM u99000)
(define-constant COMM-ADDR-ONE 'SPV0WDJQHWJVR2XD59H5NGX9AMNNTP4Q92XV77JD)
(define-constant COMM-ADDR-TWO 'SPV0WDJQHWJVR2XD59H5NGX9AMNNTP4Q92XV77JD)
(define-constant ERR-NO-MORE-NFTS u100)
(define-constant ERR-NOT-ENOUGH-PASSES u101)
(define-constant ERR-PUBLIC-SALE-DISABLED u102)
(define-constant ERR-CONTRACT-INITIALIZED u103)
(define-constant ERR-NOT-AUTHORIZED u104)
(define-constant ERR-INVALID-USER u105)
(define-constant ERR-LISTING u106)
(define-constant ERR-WRONG-COMMISSION u107)
(define-constant ERR-NOT-FOUND u108)
(define-constant ERR-PAUSED u109)
(define-constant ERR-MINT-LIMIT u110)
(define-constant ERR-METADATA-FROZEN u111)
(define-constant ERR-AIRDROP-CALLED u112)
(define-constant ERR-NO-MORE-MINTS u113)
;; Internal variables
(define-data-var mint-limit uint u69420000000)
(define-data-var last-id uint u1)
(define-data-var total-price uint u0)
(define-data-var artist-address principal 'SPV0WDJQHWJVR2XD59H5NGX9AMNNTP4Q92XV77JD)
(define-data-var ipfs-root (string-ascii 80) "ipfs:/QmUvDzhR2kwLxkRSffLPtXkyaN86hngcKWNs1cPTZniJBn/")
(define-data-var mint-paused bool false)
(define-data-var premint-enabled bool false)
(define-data-var sale-enabled bool true)
(define-data-var metadata-frozen bool false)
(define-data-var airdrop-called bool false)
(define-data-var mint-cap uint u69420000000)
(define-map mints-per-user principal uint)
(define-map mint-passes principal uint)
(define-public (claim-for (addr principal))
(mint-many (list addr)))
(define-public (claim-five-for (addrs (list 5 principal)))
(mint-many addrs))
(define-public (claim-ten-for (addrs (list 10 principal)))
(mint-many addrs))
(define-public (claim-twenty-five-for (addrs (list 25 principal)))
(mint-many addrs))
;; Mintpass Minting
(define-private (mint (orders (list 25 principal)))
(let
(
(passes (get-passes tx-sender))
)
(if (var-get premint-enabled)
(begin
(asserts! (>= passes (len orders)) (err ERR-NOT-ENOUGH-PASSES))
(map-set mint-passes tx-sender (- passes (len orders)))
(mint-many orders)
)
(begin
(asserts! (var-get sale-enabled) (err ERR-PUBLIC-SALE-DISABLED))
(mint-many orders)))))
(define-private (mint-many (orders (list 25 principal)))
(let
(
(last-nft-id (var-get last-id))
(enabled true)
(art-addr (var-get artist-address))
(id-reached (fold mint-many-iter orders last-nft-id))
(price (* (var-get total-price) (- id-reached last-nft-id)))
(total-commission (/ (* price COMM u2) u10000))
(total-artist (- price total-commission))
)
(var-set last-id id-reached)
(ok last-nft-id)))
(define-private (mint-many-iter (user principal) (next-id uint))
(if (<= next-id (var-get mint-limit))
(begin
(unwrap! (nft-mint? songs-of-innocence next-id user) next-id)
(+ next-id u1)
)
next-id))
(define-public (set-artist-address (address principal))
(begin
(asserts! (or (is-eq tx-sender (var-get artist-address)) (is-eq tx-sender DEPLOYER)) (err ERR-INVALID-USER))
(ok (var-set artist-address address))))
(define-public (set-price (price uint))
(begin
(asserts! (or (is-eq tx-sender (var-get artist-address)) (is-eq tx-sender DEPLOYER)) (err ERR-INVALID-USER))
(ok (var-set total-price price))))
(define-public (toggle-pause)
(begin
(asserts! (or (is-eq tx-sender (var-get artist-address)) (is-eq tx-sender DEPLOYER)) (err ERR-INVALID-USER))
(ok (var-set mint-paused (not (var-get mint-paused))))))
(define-public (set-mint-limit (limit uint))
(begin
(asserts! (or (is-eq tx-sender (var-get artist-address)) (is-eq tx-sender DEPLOYER)) (err ERR-INVALID-USER))
(asserts! (< limit (var-get mint-limit)) (err ERR-MINT-LIMIT))
(ok (var-set mint-limit limit))))
(define-private (is-owner (token-id uint) (user principal))
(is-eq user (unwrap! (nft-get-owner? songs-of-innocence token-id) false)))
(define-public (set-base-uri (new-base-uri (string-ascii 80)))
(begin
(asserts! (or (is-eq tx-sender (var-get artist-address)) (is-eq tx-sender DEPLOYER)) (err ERR-NOT-AUTHORIZED))
(asserts! (not (var-get metadata-frozen)) (err ERR-METADATA-FROZEN))
(var-set ipfs-root new-base-uri)
(ok true)))
(define-public (freeze-metadata)
(begin
(asserts! (or (is-eq tx-sender (var-get artist-address)) (is-eq tx-sender DEPLOYER)) (err ERR-NOT-AUTHORIZED))
(var-set metadata-frozen true)
(ok true)))
;; Non-custodial SIP-009 transfer function
(define-public (transfer (id uint) (sender principal) (recipient principal))
(begin
(asserts! (is-eq tx-sender sender) (err ERR-NOT-AUTHORIZED))
(asserts! (is-none (map-get? market id)) (err ERR-LISTING))
(trnsfr id sender recipient)))
;; read-only functions
(define-read-only (get-owner (token-id uint))
(ok (nft-get-owner? songs-of-innocence token-id)))
(define-read-only (get-last-token-id)
(ok (- (var-get last-id) u1)))
(define-read-only (get-token-uri (token-id uint))
(ok (some (concat (concat (var-get ipfs-root) "songs-of-innocence") ".json"))))
(define-read-only (get-paused)
(ok (var-get mint-paused)))
(define-read-only (get-price)
(ok (var-get total-price)))
(define-read-only (get-mints (caller principal))
(default-to u0 (map-get? mints-per-user caller)))
(define-read-only (get-mint-limit)
(ok (var-get mint-limit)))
;; Non-custodial marketplace extras
(define-trait commission-trait
((pay (uint uint) (response bool uint))))
(define-map token-count principal uint)
(define-map market uint {price: uint, commission: principal})
(define-read-only (get-balance (account principal))
(default-to u0
(map-get? token-count account)))
(define-private (trnsfr (id uint) (sender principal) (recipient principal))
(let
(
(next-id (var-get last-id))
)
(var-set last-id (+ u1 next-id))
(try! (nft-mint? songs-of-innocence next-id recipient))
(print "I had this beautiful idea, but (we) got carried away with ourselves. Artists are prone to that kind of thing. A drop of megalomania, a touch of generosity, a dash of self-promotion and deep fear that these songs, that we poured our life into over the last few years, mightn't be heard. There's a lot of noise out there. I guess we got a little noisy ourselves to get through it")
(ok true)))
(define-private (is-sender-owner (id uint))
(let ((owner (unwrap! (nft-get-owner? songs-of-innocence id) false)))
(or (is-eq tx-sender owner) (is-eq contract-caller owner))))
(define-read-only (get-listing-in-ustx (id uint))
(map-get? market id))
(define-public (list-in-ustx (id uint) (price uint) (comm-trait <commission-trait>))
(let ((listing {price: price, commission: (contract-of comm-trait)}))
(asserts! (is-sender-owner id) (err ERR-NOT-AUTHORIZED))
(map-set market id listing)
(print (merge listing {a: "list-in-ustx", id: id}))
(ok true)))
(define-public (unlist-in-ustx (id uint))
(begin
(asserts! (is-sender-owner id) (err ERR-NOT-AUTHORIZED))
(map-delete market id)
(print {a: "unlist-in-ustx", id: id})
(ok true)))
(define-public (buy-in-ustx (id uint) (comm-trait <commission-trait>))
(let ((owner (unwrap! (nft-get-owner? songs-of-innocence id) (err ERR-NOT-FOUND)))
(listing (unwrap! (map-get? market id) (err ERR-LISTING)))
(price (get price listing)))
(asserts! (is-eq (contract-of comm-trait) (get commission listing)) (err ERR-WRONG-COMMISSION))
(try! (stx-transfer? price tx-sender owner))
(try! (contract-call? comm-trait pay id price))
(try! (trnsfr id owner tx-sender))
(map-delete market id)
(print {a: "buy-in-ustx", id: id})
(ok true)))
;; Extra functionality required for mintpass
(define-public (toggle-sale-state)
(let
(
;; (premint (not (var-get premint-enabled)))
(sale (not (var-get sale-enabled)))
)
(asserts! (or (is-eq tx-sender (var-get artist-address)) (is-eq tx-sender DEPLOYER)) (err ERR-NOT-AUTHORIZED))
(var-set premint-enabled false)
(var-set sale-enabled sale)
(print { sale: sale })
(ok true)))
(define-public (enable-premint)
(begin
(asserts! (or (is-eq tx-sender (var-get artist-address)) (is-eq tx-sender DEPLOYER)) (err ERR-NOT-AUTHORIZED))
(ok (var-set premint-enabled true))))
(define-public (disable-premint)
(begin
(asserts! (or (is-eq tx-sender (var-get artist-address)) (is-eq tx-sender DEPLOYER)) (err ERR-NOT-AUTHORIZED))
(ok (var-set premint-enabled false))))
(define-read-only (get-passes (caller principal))
(default-to u0 (map-get? mint-passes caller)))
(define-read-only (get-premint-enabled)
(ok (var-get premint-enabled)))
(define-read-only (get-sale-enabled)
(ok (var-get sale-enabled)))
(define-public (burn (token-id uint))
(let
(
(next-id (var-get last-id))
)
(var-set last-id (+ u1 next-id))
(try! (nft-mint? songs-of-innocence next-id tx-sender))
(print "You said burn, so I burned you another copy of the album.")
(ok true)))