Smart Contract

TheFabricantMetadataViewsV2

A.7752ea736384322f.TheFabricantMetadataViewsV2

Deployed

3h ago
Feb 28, 2026, 08:14:46 PM UTC

Dependents

0 imports
1import FungibleToken from 0xf233dcee88fe0abe
2import MetadataViews from 0x1d7e57aa55817448
3import CoCreatableV2 from 0x7752ea736384322f
4
5access(all) contract TheFabricantMetadataViewsV2 {
6
7// -----------------------------------------------------------------------
8// TheFabricantNFT Contract Views
9// -----------------------------------------------------------------------
10// These are the standard views for TF NFTs that they should implement
11
12// NOTE: TODO: There is a metadata view for original recipient
13// currently in discussion: https://github.com/onflow/flow-nft/issues/119
14access(all) struct TFNFTIdentifierV1 {
15   access(all) let uuid: UInt64
16   access(all) let id: UInt64
17   access(all) let name: String
18   access(all) let collection : String
19   access(all) let editions: MetadataViews.Editions
20   access(all) let address: Address
21   access(all) let originalRecipient: Address
22
23    
24    init(
25        uuid: UInt64,
26        id: UInt64,
27        name: String,
28        collection : String,
29        editions: MetadataViews.Editions,
30        address: Address,
31        originalRecipient: Address
32    ) {
33    self.uuid = uuid
34    self.id = id
35    self.name = name
36    self.collection = collection
37    self.editions = editions
38    self.address = address
39    self.originalRecipient = originalRecipient
40    }
41}
42
43access(all) struct TFNFTSimpleView {
44    access(all) let uuid: UInt64
45    access(all) let id: UInt64
46    access(all) let name: String
47    access(all) let description: String
48    access(all) let collection : String
49    access(all) let collectionId: String
50    access(all) let metadata: {String: AnyStruct}?
51    access(all) let media: MetadataViews.Medias
52    access(all) let images: {String: String}
53    access(all) let videos: {String: String}
54    access(all) let externalURL: MetadataViews.ExternalURL
55    access(all) let rarity: MetadataViews.Rarity?
56    access(all) let traits: MetadataViews.Traits?
57    access(all) let characteristics: {String: {CoCreatableV2.Characteristic}}?
58    access(all) let coCreatable: Bool
59    access(all) let coCreator: Address
60    access(all) let isRevealed: Bool?
61    access(all) let editions: MetadataViews.Editions
62    access(all) let originalRecipient: Address
63    access(all) let royalties: MetadataViews.Royalties
64    access(all) let royaltiesTFMarketplace: TheFabricantMetadataViewsV2.Royalties
65    access(all) let revealableTraits: {String: Bool}?
66    access(all) let address: Address
67
68     
69    init(
70        uuid: UInt64,
71        id: UInt64,
72        name: String,
73        description: String,
74        collection : String,
75        collectionId: String,
76        metadata: {String: AnyStruct}?,
77        media: MetadataViews.Medias,
78        images: {String: String},
79        videos: {String: String},
80        externalURL: MetadataViews.ExternalURL,
81        rarity: MetadataViews.Rarity?,
82        traits: MetadataViews.Traits?,
83        characteristics: {String: {CoCreatableV2.Characteristic}}?,
84        coCreatable: Bool,
85        coCreator: Address,
86        isRevealed: Bool?,
87        editions: MetadataViews.Editions,
88        originalRecipient: Address,
89        royalties: MetadataViews.Royalties,
90        royaltiesTFMarketplace: TheFabricantMetadataViewsV2.Royalties,
91        revealableTraits: {String: Bool}?,
92        address: Address,
93    ) {
94        self.uuid = uuid
95        self.id = id
96        self.name = name
97        self.description = description
98        self.collection = collection
99        self.collectionId = collectionId
100        self.metadata = metadata
101        self.media = media
102        self.images = images
103        self.videos = videos
104        self.externalURL = externalURL
105        self.rarity = rarity
106        self.traits = traits
107        self.characteristics = characteristics
108        self.coCreatable = coCreatable
109        self.coCreator = coCreator
110        self.isRevealed = isRevealed
111        self.editions = editions
112        self.originalRecipient = originalRecipient
113        self.royalties = royalties
114        self.royaltiesTFMarketplace = royaltiesTFMarketplace
115        self.revealableTraits = revealableTraits
116        self.address = address
117    }
118}
119
120
121// -----------------------------------------------------------------------
122// AccessPass Contract Views
123// -----------------------------------------------------------------------
124
125    access(all) struct AccessPassMetadataViewV2 {
126        access(all) let id: UInt64
127
128        access(all) let season: String
129
130        access(all) let campaignName: String
131
132        access(all) let promotionName: String
133
134        // The id of the NFT within the promotion
135        access(all) let edition: UInt64
136
137        access(all) let variant: String
138
139        access(all) let description: String
140
141        access(all) let file: String
142
143        access(all) let dateReceived: UFix64
144
145        // Points to a promotion
146        access(all) let promotionId: UInt64
147
148        access(all) let promotionHost: Address
149
150        access(all) let originalRecipient: Address
151
152        access(all) let accessUnits: UInt8
153
154        access(all) let initialAccessUnits: UInt8
155
156        access(all) let metadataId: UInt64?
157
158        access(all) let metadata: {String: String}?
159
160        access(all) let extraMetadata: {String: String}?
161
162        access(all) let royalties: [MetadataViews.Royalty]
163
164        access(all) let royaltiesTFMarketplace: [TheFabricantMetadataViewsV2.Royalty]
165
166        access(all) let owner: Address
167
168        init(
169            id: UInt64,
170            season: String,
171            campaignName: String,
172            promotionName: String,
173            edition: UInt64,
174            variant: String, 
175            description: String,
176            file: String,
177            dateReceived: UFix64, 
178            promotionId: UInt64,
179            promotionHost: Address,
180            originalRecipient: Address, 
181            accessUnits: UInt8,
182            initialAccessUnits: UInt8,
183            metadataId: UInt64?,
184            metadata: {String: String}?,
185            extraMetadata: {String: String}?,
186            royalties: [MetadataViews.Royalty],
187            royaltiesTFMarketplace: [TheFabricantMetadataViewsV2.Royalty],
188            owner: Address,
189        ) {
190            self.id = id
191            self.season = season
192            self.campaignName = campaignName
193            self.promotionName = promotionName
194            self.edition = edition
195            self.variant = variant
196            self.description = description
197            self.file = file
198            self.dateReceived = dateReceived
199            self.promotionId = promotionId
200            self.promotionHost = promotionHost
201            self.metadataId = metadataId
202            self.metadata = metadata
203            self.originalRecipient = originalRecipient
204            self.accessUnits = accessUnits
205            self.initialAccessUnits = initialAccessUnits
206            self.extraMetadata = extraMetadata
207            self.royalties = royalties
208            self.royaltiesTFMarketplace = royaltiesTFMarketplace
209            self.owner = owner
210        }
211    }
212
213    access(all) struct IdentifierV2 {
214        access(all) let id: UInt64
215        access(all) let season: String
216        access(all) let campaignName: String
217        access(all) let promotionName: String
218        access(all) let promotionId: UInt64
219        access(all) let edition: UInt64
220        access(all) let variant: String
221        access(all) let address: Address
222        access(all) let dateReceived: UFix64
223        access(all) let originalRecipient: Address
224        access(all) let accessUnits: UInt8
225        access(all) let initialAccessUnits: UInt8
226        access(all) let metadataId: UInt64?
227
228        init(
229            season: String,
230            campaignName: String,
231            promotionName: String,
232            promotionId: UInt64,
233            edition: UInt64,
234            variant: String,
235            id: UInt64, 
236            address: Address,
237            dateReceived: UFix64,
238            originalRecipient: Address,
239            accessUnits: UInt8,
240            initialAccessUnits: UInt8,
241            metadataId: UInt64?
242            
243            ) {
244            self.season = season
245            self.campaignName = campaignName
246            self.promotionName = promotionName
247            self.promotionId = promotionId
248            self.edition = edition
249            self.variant = variant
250            self.id = id
251            self.address = address
252            self.dateReceived = dateReceived
253            self.originalRecipient = originalRecipient
254            self.accessUnits = accessUnits
255            self.initialAccessUnits = initialAccessUnits
256            self.metadataId = metadataId
257        }
258    }
259
260    access(all) struct PromotionMetadataViewV2 {
261
262        access(all) var active: Bool
263        access(all) let id: UInt64
264        access(all) let season: String
265        access(all) let campaignName: String 
266        access(all) let promotionName: String?
267        access(all) var isAccessListUsed: Bool 
268        access(all) var onlyUseAccessList: Bool
269        access(all) var isOpenAccess: Bool
270        access(all) let typeRestrictions: [Type]?
271        access(all) var promotionAccessIds: [UInt64]?
272        access(all) var nftsUsedForClaim: {UInt64: TheFabricantMetadataViewsV2.IdentifierV2}
273        access(all) var addressesClaimed: {Address: [TheFabricantMetadataViewsV2.IdentifierV2]}
274        access(all) let dateCreated: UFix64
275        access(all) let description: String
276        access(all) let maxMintsPerAddress: Int?
277        access(all) let host: Address
278        access(all) let image: String?      
279        access(all) let accessPassMetadatas: {UInt64: {String: String}}?
280        access(all) let publicMinterPaths: [String]
281        access(all) let totalSupply: UInt64
282        access(all) let url: String?
283        access(all) let spentAccessUnits: {UInt64: [TheFabricantMetadataViewsV2.SpentAccessUnitView]}
284
285        // Options
286        access(all) let capacity: UInt64?
287        access(all) let startTime: UFix64?
288        access(all) let endTime: UFix64?
289
290        access(all) let isOpen: Bool
291
292        init (
293            active: Bool,
294            id: UInt64,
295            season: String,
296            campaignName: String,
297            promotionName: String?,
298            isAccessListUsed: Bool, 
299            onlyUseAccessList: Bool,
300            isOpenAccess: Bool,
301            typeRestrictions: [Type]?,
302            promotionAccessIds: [UInt64]?,
303            nftsUsedForClaim: {UInt64: TheFabricantMetadataViewsV2.IdentifierV2},
304            addressesClaimed: {Address: [TheFabricantMetadataViewsV2.IdentifierV2]},
305            dateCreated: UFix64,
306            description: String,
307            maxMintsPerAddress: Int?,
308            host: Address,
309            image: String?,
310            accessPassMetadatas: {UInt64: {String: String}}?,
311            publicMinterPaths: [String],
312            totalSupply: UInt64,
313            url: String?,
314            spentAccessUnits: {UInt64: [TheFabricantMetadataViewsV2.SpentAccessUnitView]},
315            capacity: UInt64?,
316            startTime: UFix64?,
317            endTime: UFix64?,
318            isOpen: Bool
319        ) {
320            self.active = active
321            self.id = id
322            self.season = season
323            self.campaignName = campaignName
324            self.promotionName = promotionName
325            self.isAccessListUsed = isAccessListUsed
326            self.onlyUseAccessList = onlyUseAccessList
327            self.isOpenAccess = isOpenAccess
328            self.typeRestrictions = typeRestrictions
329            self.promotionAccessIds = promotionAccessIds
330            self.nftsUsedForClaim = nftsUsedForClaim
331            self.addressesClaimed = addressesClaimed
332            self.dateCreated = dateCreated
333            self.description = description
334            self.maxMintsPerAddress = maxMintsPerAddress
335            self.host = host
336            self.image = image
337            self.accessPassMetadatas = accessPassMetadatas
338            self.publicMinterPaths = publicMinterPaths
339            self.totalSupply = totalSupply
340            self.url = url
341            self.spentAccessUnits = spentAccessUnits
342            self.capacity = capacity
343            self.startTime = startTime
344            self.endTime = endTime
345            self.isOpen = isOpen
346        }
347    }
348
349    access(all) struct PromotionAccessPassHoldersV2 {
350        access(all) let id: UInt64
351        access(all) let host: Address
352        access(all) let currentHolders: {UInt64: TheFabricantMetadataViewsV2.IdentifierV2}
353    
354        init(
355            id: UInt64, 
356            host: Address, 
357            currentHolders: {UInt64: TheFabricantMetadataViewsV2.IdentifierV2} 
358            ) {
359                self.id = id 
360                self.host = host 
361                self.currentHolders = currentHolders
362            }
363    }
364
365    access(all) struct PromotionAccessPassClaimsV2 {
366        access(all) let id: UInt64
367        access(all) let host: Address
368        access(all) let claims: {Address: [IdentifierV2]}
369        init(
370            id: UInt64, 
371            host: Address, 
372            claimed: {Address: [TheFabricantMetadataViewsV2.IdentifierV2]}
373            ) {
374            self.id = id 
375            self.host = host 
376            self.claims = claimed
377        }
378    }
379
380    access(all) struct PromotionAccessList {
381        access(all) let id: UInt64
382        access(all) let host: Address
383        access(all) let accessList: [Address]?
384        access(all) var isAccessListUsed: Bool 
385        access(all) var onlyUseAccessList: Bool
386        init(
387            id: UInt64, 
388            host: Address, 
389            accessList: [Address]?,
390            isAccessListUsed: Bool, 
391            onlyUseAccessList: Bool
392            ) {
393            self.id = id 
394            self.host = host 
395            self.accessList = accessList
396            self.isAccessListUsed = isAccessListUsed
397            self.onlyUseAccessList = onlyUseAccessList
398        }
399    }
400
401    access(all) struct SpentAccessUnitView {
402        access(all) let spender: Address 
403        access(all) let season: String
404        access(all) let campaignName: String
405        access(all) let promotionName: String
406        access(all) let promotionId: UInt64
407        access(all) let variant: String?
408        access(all) let accessPassId: UInt64
409        access(all) let accessPassSerial: UInt64
410        access(all) let accessTokenId: UInt64
411
412        init(
413            spender: Address, 
414            season: String,
415            campaignName: String,
416            promotionName: String,
417            promotionId: UInt64,
418            variant: String?,
419            accessPassId: UInt64,
420            accessPassSerial: UInt64,
421            accessTokenId: UInt64
422        ) {
423            self.spender = spender
424            self.season = season
425            self.promotionId = promotionId
426            self.promotionName = promotionName
427            self.campaignName = campaignName
428            self.variant = variant
429            self.accessPassId = accessPassId
430            self.accessPassSerial = accessPassSerial
431            self.accessTokenId = accessTokenId
432        }
433    }
434
435    access(all) struct PublicMinterView {
436        access(all) let id: UInt64
437        access(all) let season: String
438        access(all) let campaignName: String
439        access(all) let promotionName: String
440        access(all) let promotionId: UInt64
441        access(all) let variant: String
442        access(all) let nftFile: String
443        access(all) let nftMetadataId: UInt64?
444        access(all) let nftNumberOfAccessUnits: UInt8
445        access(all) var numberOfMints: UInt64
446
447        init(
448            id: UInt64, 
449            season: String,
450            campaignName: String,
451            promotionName: String,
452            promotionId: UInt64, 
453            nftFile: String, 
454            nftMetadataId: UInt64?, 
455            nftNumberOfAccessUnits: UInt8,  
456            variant: String,  
457            numberOfMints: UInt64, 
458        ) {
459            self.id = id
460            self.season = season
461            self.campaignName = campaignName
462            self.promotionName = promotionName
463            self.promotionId = promotionId
464            self.nftFile = nftFile
465            self.nftMetadataId = nftMetadataId
466            self.nftNumberOfAccessUnits = nftNumberOfAccessUnits
467            self.variant = variant
468            self.numberOfMints = numberOfMints
469        }
470    }
471
472    access(all) struct Royalty{
473
474		access(all) let receiver:Capability<&{FungibleToken.Receiver}> 
475        access(all) let initialCut: UFix64
476		access(all) let cut: UFix64
477        access(all) let description: String
478
479		/// @param wallet : The wallet to send royalty too
480		init(
481            receiver:Capability<&{FungibleToken.Receiver}>, 
482            initialCut: UFix64, 
483            cut: UFix64, 
484            description: String
485            ){
486			self.receiver = receiver
487            self.initialCut = initialCut
488			self.cut = cut
489            self.description = description
490		}
491	}
492
493    access(all) struct Royalties {
494
495        /// Array that tracks the individual royalties
496        access(self) let cutInfos: [Royalty]
497
498        access(all) init(_ cutInfos: [Royalty]) {
499            // Validate that sum of all cut multipliers should not be greater than 1.0
500            var totalCut = 0.0
501            for royalty in cutInfos {
502                totalCut = totalCut + royalty.cut
503            }
504            assert(totalCut <= 1.0, message: "Sum of cutInfos multipliers should not be greater than 1.0")
505            // Assign the cutInfos
506            self.cutInfos = cutInfos
507        }
508
509        /// Return the cutInfos list
510        access(all) fun getRoyalties(): [Royalty] {
511            return self.cutInfos
512        }
513    }
514
515     // -----------------------------------------------------------------------
516    // OLD IMPLEMENTATIONS
517    // -----------------------------------------------------------------------
518
519    access(all) struct AccessPassMetadataView {
520        access(all) let id: UInt64
521
522        // The id of the NFT within the promotion
523        access(all) let serial: UInt64
524
525        access(all) let campaignName: String
526
527        access(all) let variant: String
528
529        access(all) let description: String
530
531        access(all) let file: String
532
533        access(all) let dateReceived: UFix64
534
535        // Points to a promotion
536        access(all) let promotionId: UInt64
537
538        access(all) let promotionHost: Address
539
540        access(all) let metadataId: UInt64?
541
542        access(all) let metadata: {String: String}?
543
544        access(all) let originalRecipient: Address
545
546        access(all) let accessUnits: UInt8
547
548        access(all) let initialAccessUnits: UInt8
549
550        access(all) let extraMetadata: {String: String}?
551
552        access(all) let owner: Address
553
554        init(
555            id: UInt64,
556            serial: UInt64,
557            campaignName: String,
558            variant: String, 
559            description: String,
560            file: String,
561            dateReceived: UFix64, 
562            promotionId: UInt64,
563            promotionHost: Address,
564            metadataId: UInt64?,
565            metadata: {String: String}?,
566            originalRecipient: Address, 
567            accessUnits: UInt8,
568            initialAccessUnits: UInt8,
569            extraMetadata: {String: String}?,
570            owner: Address,
571        ) {
572            self.id = id
573            self.serial = serial
574            self.campaignName = campaignName
575            self.variant = variant
576            self.description = description
577            self.file = file
578            self.dateReceived = dateReceived
579            self.promotionId = promotionId
580            self.promotionHost = promotionHost
581            self.metadataId = metadataId
582            self.metadata = metadata
583            self.originalRecipient = originalRecipient
584            self.accessUnits = accessUnits
585            self.initialAccessUnits = initialAccessUnits
586            self.extraMetadata = extraMetadata
587            self.owner = owner
588        }
589    }
590
591    access(all) struct Identifier {
592        access(all) let season: String
593        access(all) let campaignName: String
594        access(all) let promotionName: String
595        access(all) let promotionId: UInt64
596        access(all) let variant: String
597        access(all) let id: UInt64
598        access(all) let serial: UInt64
599        access(all) let address: Address
600        access(all) let dateReceived: UFix64
601        access(all) let originalRecipient: Address
602        access(all) let accessUnits: UInt8
603        access(all) let initialAccessUnits: UInt8
604        access(all) let metadataId: UInt64?
605
606        init(
607            season: String,
608            campaignName: String,
609            promotionName: String,
610            promotionId: UInt64,
611            variant: String,
612            id: UInt64, 
613            serial: UInt64, 
614            address: Address,
615            dateReceived: UFix64,
616            originalRecipient: Address,
617            accessUnits: UInt8,
618            initialAccessUnits: UInt8,
619            metadataId: UInt64?
620            
621            ) {
622            self.season = season
623            self.campaignName = campaignName
624            self.promotionName = promotionName
625            self.promotionId = promotionId
626            self.variant = variant
627            self.id = id
628            self.serial = serial
629            self.address = address
630            self.dateReceived = dateReceived
631            self.originalRecipient = originalRecipient
632            self.accessUnits = accessUnits
633            self.initialAccessUnits = initialAccessUnits
634            self.metadataId = metadataId
635        }
636    }
637
638    access(all) struct PromotionMetadataView {
639
640        access(all) var active: Bool
641        access(all) let id: UInt64
642        access(all) let season: String
643        access(all) let campaignName: String 
644        access(all) let promotionName: String?
645        access(all) var isAccessListUsed: Bool 
646        access(all) var onlyUseAccessList: Bool
647        access(all) var isOpenAccess: Bool
648        access(all) let typeRestrictions: [Type]?
649        access(all) var promotionAccessIds: [UInt64]?
650        access(all) var nftsUsedForClaim: {UInt64: TheFabricantMetadataViewsV2.Identifier}
651        access(all) var addressesClaimed: {Address: [TheFabricantMetadataViewsV2.Identifier]}
652        access(all) let dateCreated: UFix64
653        access(all) let description: String
654        access(all) let maxMintsPerAddress: Int?
655        access(all) let host: Address
656        access(all) let image: String?      
657        access(all) let accessPassMetadatas: {UInt64: {String: String}}?
658        access(all) let publicMinterPaths: [String]
659        access(all) let totalSupply: UInt64
660        access(all) let url: String?
661        access(all) let spentAccessUnits: {UInt64: [TheFabricantMetadataViewsV2.SpentAccessUnitView]}
662
663        // Options
664        access(all) let capacity: UInt64?
665        access(all) let startTime: UFix64?
666        access(all) let endTime: UFix64?
667
668        access(all) let isOpen: Bool
669
670        init (
671            active: Bool,
672            id: UInt64,
673            season: String,
674            campaignName: String,
675            promotionName: String?,
676            isAccessListUsed: Bool, 
677            onlyUseAccessList: Bool,
678            isOpenAccess: Bool,
679            typeRestrictions: [Type]?,
680            promotionAccessIds: [UInt64]?,
681            nftsUsedForClaim: {UInt64: TheFabricantMetadataViewsV2.Identifier},
682            addressesClaimed: {Address: [TheFabricantMetadataViewsV2.Identifier]},
683            dateCreated: UFix64,
684            description: String,
685            maxMintsPerAddress: Int?,
686            host: Address,
687            image: String?,
688            accessPassMetadatas: {UInt64: {String: String}}?,
689            publicMinterPaths: [String],
690            totalSupply: UInt64,
691            url: String?,
692            spentAccessUnits: {UInt64: [TheFabricantMetadataViewsV2.SpentAccessUnitView]},
693            capacity: UInt64?,
694            startTime: UFix64?,
695            endTime: UFix64?,
696            isOpen: Bool
697        ) {
698            self.active = active
699            self.id = id
700            self.season = season
701            self.campaignName = campaignName
702            self.promotionName = promotionName
703            self.isAccessListUsed = isAccessListUsed
704            self.onlyUseAccessList = onlyUseAccessList
705            self.isOpenAccess = isOpenAccess
706            self.typeRestrictions = typeRestrictions
707            self.promotionAccessIds = promotionAccessIds
708            self.nftsUsedForClaim = nftsUsedForClaim
709            self.addressesClaimed = addressesClaimed
710            self.dateCreated = dateCreated
711            self.description = description
712            self.maxMintsPerAddress = maxMintsPerAddress
713            self.host = host
714            self.image = image
715            self.accessPassMetadatas = accessPassMetadatas
716            self.publicMinterPaths = publicMinterPaths
717            self.totalSupply = totalSupply
718            self.url = url
719            self.spentAccessUnits = spentAccessUnits
720            self.capacity = capacity
721            self.startTime = startTime
722            self.endTime = endTime
723            self.isOpen = isOpen
724        }
725    }
726
727    access(all) struct PromotionAccessPassHolders {
728        access(all) let id: UInt64
729        access(all) let host: Address
730        access(all) let currentHolders: {UInt64: TheFabricantMetadataViewsV2.Identifier}
731    
732        init(
733            id: UInt64, 
734            host: Address, 
735            currentHolders: {UInt64: TheFabricantMetadataViewsV2.Identifier} 
736            ) {
737                self.id = id 
738                self.host = host 
739                self.currentHolders = currentHolders
740            }
741    }
742
743    access(all) struct PromotionAccessPassClaims {
744        access(all) let id: UInt64
745        access(all) let host: Address
746        access(all) let claims: {Address: [Identifier]}
747        init(
748            id: UInt64, 
749            host: Address, 
750            claimed: {Address: [TheFabricantMetadataViewsV2.Identifier]}
751            ) {
752            self.id = id 
753            self.host = host 
754            self.claims = claimed
755        }
756    }
757}
758