-
Notifications
You must be signed in to change notification settings - Fork 13
/
MetadataViews.cdc
779 lines (679 loc) · 27.7 KB
/
MetadataViews.cdc
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
import "FungibleToken"
import "NonFungibleToken"
import "ViewResolver"
/// This contract implements the metadata standard proposed
/// in FLIP-0636.
///
/// Ref: https://github.com/onflow/flips/blob/main/application/20210916-nft-metadata.md
///
/// Structs and resources can implement one or more
/// metadata types, called views. Each view type represents
/// a different kind of metadata, such as a creator biography
/// or a JPEG image file.
///
access(all) contract MetadataViews {
/// Display is a basic view that includes the name, description and
/// thumbnail for an object. Most objects should implement this view.
///
access(all) struct Display {
/// The name of the object.
///
/// This field will be displayed in lists and therefore should
/// be short an concise.
///
access(all) let name: String
/// A written description of the object.
///
/// This field will be displayed in a detailed view of the object,
/// so can be more verbose (e.g. a paragraph instead of a single line).
///
access(all) let description: String
/// A small thumbnail representation of the object.
///
/// This field should be a web-friendly file (i.e JPEG, PNG)
/// that can be displayed in lists, link previews, etc.
///
access(all) let thumbnail: {File}
view init(
name: String,
description: String,
thumbnail: {File}
) {
self.name = name
self.description = description
self.thumbnail = thumbnail
}
}
/// Helper to get Display in a typesafe way
///
/// @param viewResolver: A reference to the resolver resource
/// @return An optional Display struct
///
access(all) fun getDisplay(_ viewResolver: &{ViewResolver.Resolver}) : Display? {
if let view = viewResolver.resolveView(Type<Display>()) {
if let v = view as? Display {
return v
}
}
return nil
}
/// Generic interface that represents a file stored on or off chain. Files
/// can be used to references images, videos and other media.
///
access(all) struct interface File {
access(all) view fun uri(): String
}
/// View to expose a file that is accessible at an HTTP (or HTTPS) URL.
///
access(all) struct HTTPFile: File {
access(all) let url: String
view init(url: String) {
self.url = url
}
access(all) view fun uri(): String {
return self.url
}
}
/// View to expose a file stored on IPFS.
/// IPFS images are referenced by their content identifier (CID)
/// rather than a direct URI. A client application can use this CID
/// to find and load the image via an IPFS gateway.
///
access(all) struct IPFSFile: File {
/// CID is the content identifier for this IPFS file.
///
/// Ref: https://docs.ipfs.io/concepts/content-addressing/
///
access(all) let cid: String
/// Path is an optional path to the file resource in an IPFS directory.
///
/// This field is only needed if the file is inside a directory.
///
/// Ref: https://docs.ipfs.io/concepts/file-systems/
///
access(all) let path: String?
view init(cid: String, path: String?) {
self.cid = cid
self.path = path
}
/// This function returns the IPFS native URL for this file.
/// Ref: https://docs.ipfs.io/how-to/address-ipfs-on-web/#native-urls
///
/// @return The string containing the file uri
///
access(all) view fun uri(): String {
if let path = self.path {
return "ipfs://".concat(self.cid).concat("/").concat(path)
}
return "ipfs://".concat(self.cid)
}
}
/// A struct to represent a generic URI. May be used to represent the URI of
/// the NFT where the type of URI is not able to be determined (i.e. HTTP,
/// IPFS, etc.)
///
access(all) struct URI: File {
/// The base URI prefix, if any. Not needed for all URIs, but helpful
/// for some use cases For example, updating a whole NFT collection's
/// image host easily
///
access(all) let baseURI: String?
/// The URI string value
/// NOTE: this is set on init as a concatenation of the baseURI and the
/// value if baseURI != nil
///
access(self) let value: String
access(all) view fun uri(): String {
return self.value
}
init(baseURI: String?, value: String) {
self.baseURI = baseURI
self.value = baseURI != nil ? baseURI!.concat(value) : value
}
}
access(all) struct Media {
/// File for the media
///
access(all) let file: {File}
/// media-type comes on the form of type/subtype as described here
/// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
///
access(all) let mediaType: String
view init(file: {File}, mediaType: String) {
self.file=file
self.mediaType=mediaType
}
}
/// Wrapper view for multiple media views
///
access(all) struct Medias {
/// An arbitrary-sized list for any number of Media items
access(all) let items: [Media]
view init(_ items: [Media]) {
self.items = items
}
}
/// Helper to get Medias in a typesafe way
///
/// @param viewResolver: A reference to the resolver resource
/// @return A optional Medias struct
///
access(all) fun getMedias(_ viewResolver: &{ViewResolver.Resolver}) : Medias? {
if let view = viewResolver.resolveView(Type<Medias>()) {
if let v = view as? Medias {
return v
}
}
return nil
}
/// View to represent a license according to https://spdx.org/licenses/
/// This view can be used if the content of an NFT is licensed.
///
access(all) struct License {
access(all) let spdxIdentifier: String
view init(_ identifier: String) {
self.spdxIdentifier = identifier
}
}
/// Helper to get License in a typesafe way
///
/// @param viewResolver: A reference to the resolver resource
/// @return An optional License struct
///
access(all) fun getLicense(_ viewResolver: &{ViewResolver.Resolver}) : License? {
if let view = viewResolver.resolveView(Type<License>()) {
if let v = view as? License {
return v
}
}
return nil
}
/// View to expose a URL to this item on an external site.
/// This can be used by applications like .find and Blocto to direct users
/// to the original link for an NFT or a project page that describes the NFT collection.
/// eg https://www.my-nft-project.com/overview-of-nft-collection
///
access(all) struct ExternalURL {
access(all) let url: String
view init(_ url: String) {
self.url=url
}
}
/// Helper to get ExternalURL in a typesafe way
///
/// @param viewResolver: A reference to the resolver resource
/// @return An optional ExternalURL struct
///
access(all) fun getExternalURL(_ viewResolver: &{ViewResolver.Resolver}) : ExternalURL? {
if let view = viewResolver.resolveView(Type<ExternalURL>()) {
if let v = view as? ExternalURL {
return v
}
}
return nil
}
/// View that defines the composable royalty standard that gives marketplaces a
/// unified interface to support NFT royalties.
///
access(all) struct Royalty {
/// Generic FungibleToken Receiver for the beneficiary of the royalty
/// Can get the concrete type of the receiver with receiver.getType()
/// Recommendation - Users should create a new link for a FlowToken
/// receiver for this using `getRoyaltyReceiverPublicPath()`, and not
/// use the default FlowToken receiver. This will allow users to update
/// the capability in the future to use a more generic capability
access(all) let receiver: Capability<&{FungibleToken.Receiver}>
/// Multiplier used to calculate the amount of sale value transferred to
/// royalty receiver. Note - It should be between 0.0 and 1.0
/// Ex - If the sale value is x and multiplier is 0.56 then the royalty
/// value would be 0.56 * x.
/// Generally percentage get represented in terms of basis points
/// in solidity based smart contracts while cadence offers `UFix64`
/// that already supports the basis points use case because its
/// operations are entirely deterministic integer operations and support
/// up to 8 points of precision.
access(all) let cut: UFix64
/// Optional description: This can be the cause of paying the royalty,
/// the relationship between the `wallet` and the NFT, or anything else
/// that the owner might want to specify.
access(all) let description: String
view init(receiver: Capability<&{FungibleToken.Receiver}>, cut: UFix64, description: String) {
pre {
cut >= 0.0 && cut <= 1.0 : "Cut value should be in valid range i.e [0,1]"
}
self.receiver = receiver
self.cut = cut
self.description = description
}
}
/// Wrapper view for multiple Royalty views.
/// Marketplaces can query this `Royalties` struct from NFTs
/// and are expected to pay royalties based on these specifications.
///
access(all) struct Royalties {
/// Array that tracks the individual royalties
access(self) let cutInfos: [Royalty]
access(all) view init(_ cutInfos: [Royalty]) {
// Validate that sum of all cut multipliers should not be greater than 1.0
var totalCut = 0.0
for royalty in cutInfos {
totalCut = totalCut + royalty.cut
}
assert(totalCut <= 1.0, message: "Sum of cutInfos multipliers should not be greater than 1.0")
// Assign the cutInfos
self.cutInfos = cutInfos
}
/// Return the cutInfos list
///
/// @return An array containing all the royalties structs
///
access(all) view fun getRoyalties(): [Royalty] {
return self.cutInfos
}
}
/// Helper to get Royalties in a typesafe way
///
/// @param viewResolver: A reference to the resolver resource
/// @return A optional Royalties struct
///
access(all) fun getRoyalties(_ viewResolver: &{ViewResolver.Resolver}) : Royalties? {
if let view = viewResolver.resolveView(Type<Royalties>()) {
if let v = view as? Royalties {
return v
}
}
return nil
}
/// Get the path that should be used for receiving royalties
/// This is a path that will eventually be used for a generic switchboard receiver,
/// hence the name but will only be used for royalties for now.
///
/// @return The PublicPath for the generic FT receiver
///
access(all) view fun getRoyaltyReceiverPublicPath(): PublicPath {
return /public/GenericFTReceiver
}
/// View to represent a single field of metadata on an NFT.
/// This is used to get traits of individual key/value pairs along with some
/// contextualized data about the trait
///
access(all) struct Trait {
// The name of the trait. Like Background, Eyes, Hair, etc.
access(all) let name: String
// The underlying value of the trait, the rest of the fields of a trait provide context to the value.
access(all) let value: AnyStruct
// displayType is used to show some context about what this name and value represent
// for instance, you could set value to a unix timestamp, and specify displayType as "Date" to tell
// platforms to consume this trait as a date and not a number
access(all) let displayType: String?
// Rarity can also be used directly on an attribute.
//
// This is optional because not all attributes need to contribute to the NFT's rarity.
access(all) let rarity: Rarity?
view init(name: String, value: AnyStruct, displayType: String?, rarity: Rarity?) {
self.name = name
self.value = value
self.displayType = displayType
self.rarity = rarity
}
}
/// Wrapper view to return all the traits on an NFT.
/// This is used to return traits as individual key/value pairs along with
/// some contextualized data about each trait.
access(all) struct Traits {
access(all) let traits: [Trait]
view init(_ traits: [Trait]) {
self.traits = traits
}
/// Adds a single Trait to the Traits view
///
/// @param Trait: The trait struct to be added
///
access(all) fun addTrait(_ t: Trait) {
self.traits.append(t)
}
}
/// Helper to get Traits view in a typesafe way
///
/// @param viewResolver: A reference to the resolver resource
/// @return A optional Traits struct
///
access(all) fun getTraits(_ viewResolver: &{ViewResolver.Resolver}) : Traits? {
if let view = viewResolver.resolveView(Type<Traits>()) {
if let v = view as? Traits {
return v
}
}
return nil
}
/// Helper function to easily convert a dictionary to traits. For NFT
/// collections that do not need either of the optional values of a Trait,
/// this method should suffice to give them an array of valid traits.
///
/// @param dict: The dictionary to be converted to Traits
/// @param excludedNames: An optional String array specifying the `dict`
/// keys that are not wanted to become `Traits`
/// @return The generated Traits view
///
access(all) fun dictToTraits(dict: {String: AnyStruct}, excludedNames: [String]?): Traits {
// Collection owners might not want all the fields in their metadata included.
// They might want to handle some specially, or they might just not want them included at all.
if excludedNames != nil {
for k in excludedNames! {
dict.remove(key: k)
}
}
let traits: [Trait] = []
for k in dict.keys {
let trait = Trait(name: k, value: dict[k]!, displayType: nil, rarity: nil)
traits.append(trait)
}
return Traits(traits)
}
/// Optional view for collections that issue multiple objects
/// with the same or similar metadata, for example an X of 100 set. This
/// information is useful for wallets and marketplaces.
/// An NFT might be part of multiple editions, which is why the edition
/// information is returned as an arbitrary sized array
///
access(all) struct Edition {
/// The name of the edition
/// For example, this could be Set, Play, Series,
/// or any other way a project could classify its editions
access(all) let name: String?
/// The edition number of the object.
/// For an "24 of 100 (#24/100)" item, the number is 24.
access(all) let number: UInt64
/// The max edition number of this type of objects.
/// This field should only be provided for limited-editioned objects.
/// For an "24 of 100 (#24/100)" item, max is 100.
/// For an item with unlimited edition, max should be set to nil.
///
access(all) let max: UInt64?
view init(name: String?, number: UInt64, max: UInt64?) {
if max != nil {
assert(number <= max!, message: "The number cannot be greater than the max number!")
}
self.name = name
self.number = number
self.max = max
}
}
/// Wrapper view for multiple Edition views
///
access(all) struct Editions {
/// An arbitrary-sized list for any number of editions
/// that the NFT might be a part of
access(all) let infoList: [Edition]
view init(_ infoList: [Edition]) {
self.infoList = infoList
}
}
/// Helper to get Editions in a typesafe way
///
/// @param viewResolver: A reference to the resolver resource
/// @return An optional Editions struct
///
access(all) fun getEditions(_ viewResolver: &{ViewResolver.Resolver}) : Editions? {
if let view = viewResolver.resolveView(Type<Editions>()) {
if let v = view as? Editions {
return v
}
}
return nil
}
/// View representing a project-defined serial number for a specific NFT
/// Projects have different definitions for what a serial number should be
/// Some may use the NFTs regular ID and some may use a different
/// classification system. The serial number is expected to be unique among
/// other NFTs within that project
///
access(all) struct Serial {
access(all) let number: UInt64
view init(_ number: UInt64) {
self.number = number
}
}
/// Helper to get Serial in a typesafe way
///
/// @param viewResolver: A reference to the resolver resource
/// @return An optional Serial struct
///
access(all) fun getSerial(_ viewResolver: &{ViewResolver.Resolver}) : Serial? {
if let view = viewResolver.resolveView(Type<Serial>()) {
if let v = view as? Serial {
return v
}
}
return nil
}
/// View to expose rarity information for a single rarity
/// Note that a rarity needs to have either score or description but it can
/// have both
///
access(all) struct Rarity {
/// The score of the rarity as a number
access(all) let score: UFix64?
/// The maximum value of score
access(all) let max: UFix64?
/// The description of the rarity as a string.
///
/// This could be Legendary, Epic, Rare, Uncommon, Common or any other string value
access(all) let description: String?
view init(score: UFix64?, max: UFix64?, description: String?) {
if score == nil && description == nil {
panic("A Rarity needs to set score, description or both")
}
self.score = score
self.max = max
self.description = description
}
}
/// Helper to get Rarity view in a typesafe way
///
/// @param viewResolver: A reference to the resolver resource
/// @return A optional Rarity struct
///
access(all) fun getRarity(_ viewResolver: &{ViewResolver.Resolver}) : Rarity? {
if let view = viewResolver.resolveView(Type<Rarity>()) {
if let v = view as? Rarity {
return v
}
}
return nil
}
/// NFTView wraps all Core views along `id` and `uuid` fields, and is used
/// to give a complete picture of an NFT. Most NFTs should implement this
/// view.
///
access(all) struct NFTView {
access(all) let id: UInt64
access(all) let uuid: UInt64
access(all) let display: MetadataViews.Display?
access(all) let externalURL: MetadataViews.ExternalURL?
access(all) let collectionData: NFTCollectionData?
access(all) let collectionDisplay: NFTCollectionDisplay?
access(all) let royalties: Royalties?
access(all) let traits: Traits?
view init(
id : UInt64,
uuid : UInt64,
display : MetadataViews.Display?,
externalURL : MetadataViews.ExternalURL?,
collectionData : NFTCollectionData?,
collectionDisplay : NFTCollectionDisplay?,
royalties : Royalties?,
traits: Traits?
) {
self.id = id
self.uuid = uuid
self.display = display
self.externalURL = externalURL
self.collectionData = collectionData
self.collectionDisplay = collectionDisplay
self.royalties = royalties
self.traits = traits
}
}
/// Helper to get an NFT view
///
/// @param id: The NFT id
/// @param viewResolver: A reference to the resolver resource
/// @return A NFTView struct
///
access(all) fun getNFTView(id: UInt64, viewResolver: &{ViewResolver.Resolver}) : NFTView {
let nftView = viewResolver.resolveView(Type<NFTView>())
if nftView != nil {
return nftView! as! NFTView
}
return NFTView(
id : id,
uuid: viewResolver.uuid,
display: MetadataViews.getDisplay(viewResolver),
externalURL : MetadataViews.getExternalURL(viewResolver),
collectionData : self.getNFTCollectionData(viewResolver),
collectionDisplay : self.getNFTCollectionDisplay(viewResolver),
royalties : self.getRoyalties(viewResolver),
traits : self.getTraits(viewResolver)
)
}
/// View to expose the information needed store and retrieve an NFT.
/// This can be used by applications to setup a NFT collection with proper
/// storage and public capabilities.
///
access(all) struct NFTCollectionData {
/// Path in storage where this NFT is recommended to be stored.
access(all) let storagePath: StoragePath
/// Public path which must be linked to expose public capabilities of this NFT
/// including standard NFT interfaces and metadataviews interfaces
access(all) let publicPath: PublicPath
/// The concrete type of the collection that is exposed to the public
/// now that entitlements exist, it no longer needs to be restricted to a specific interface
access(all) let publicCollection: Type
/// Type that should be linked at the aforementioned public path
access(all) let publicLinkedType: Type
/// Function that allows creation of an empty NFT collection that is intended to store
/// this NFT.
access(all) let createEmptyCollection: fun(): @{NonFungibleToken.Collection}
view init(
storagePath: StoragePath,
publicPath: PublicPath,
publicCollection: Type,
publicLinkedType: Type,
createEmptyCollectionFunction: fun(): @{NonFungibleToken.Collection}
) {
pre {
publicLinkedType.isSubtype(of: Type<&{NonFungibleToken.Collection}>()): "Public type must be a subtype of NonFungibleToken.Collection interface."
}
self.storagePath=storagePath
self.publicPath=publicPath
self.publicCollection=publicCollection
self.publicLinkedType=publicLinkedType
self.createEmptyCollection=createEmptyCollectionFunction
}
}
/// Helper to get NFTCollectionData in a way that will return an typed Optional
///
/// @param viewResolver: A reference to the resolver resource
/// @return A optional NFTCollectionData struct
///
access(all) fun getNFTCollectionData(_ viewResolver: &{ViewResolver.Resolver}) : NFTCollectionData? {
if let view = viewResolver.resolveView(Type<NFTCollectionData>()) {
if let v = view as? NFTCollectionData {
return v
}
}
return nil
}
/// View to expose the information needed to showcase this NFT's
/// collection. This can be used by applications to give an overview and
/// graphics of the NFT collection this NFT belongs to.
///
access(all) struct NFTCollectionDisplay {
// Name that should be used when displaying this NFT collection.
access(all) let name: String
// Description that should be used to give an overview of this collection.
access(all) let description: String
// External link to a URL to view more information about this collection.
access(all) let externalURL: MetadataViews.ExternalURL
// Square-sized image to represent this collection.
access(all) let squareImage: MetadataViews.Media
// Banner-sized image for this collection, recommended to have a size near 1400x350.
access(all) let bannerImage: MetadataViews.Media
// Social links to reach this collection's social homepages.
// Possible keys may be "instagram", "twitter", "discord", etc.
access(all) let socials: {String: MetadataViews.ExternalURL}
view init(
name: String,
description: String,
externalURL: MetadataViews.ExternalURL,
squareImage: MetadataViews.Media,
bannerImage: MetadataViews.Media,
socials: {String: MetadataViews.ExternalURL}
) {
self.name = name
self.description = description
self.externalURL = externalURL
self.squareImage = squareImage
self.bannerImage = bannerImage
self.socials = socials
}
}
/// Helper to get NFTCollectionDisplay in a way that will return a typed
/// Optional
///
/// @param viewResolver: A reference to the resolver resource
/// @return A optional NFTCollection struct
///
access(all) fun getNFTCollectionDisplay(_ viewResolver: &{ViewResolver.Resolver}) : NFTCollectionDisplay? {
if let view = viewResolver.resolveView(Type<NFTCollectionDisplay>()) {
if let v = view as? NFTCollectionDisplay {
return v
}
}
return nil
}
/// This view may be used by Cadence-native projects to define their
/// contract- and token-level metadata according to EVM-compatible formats.
/// Several ERC standards (e.g. ERC20, ERC721, etc.) expose name and symbol
/// values to define assets as well as contract- & token-level metadata view
/// `tokenURI(uint256)` and `contractURI()` methods. This view enables
/// Cadence projects to define in their own contracts how they would like
/// their metadata to be defined when bridged to EVM.
///
access(all) struct EVMBridgedMetadata {
/// The name of the asset
///
access(all) let name: String
/// The symbol of the asset
///
access(all) let symbol: String
/// The URI of the asset - this can either be contract-level or
/// token-level URI depending on where the metadata is resolved. It
/// is recommended to reference EVM metadata standards for how to best
/// prepare your view's formatted value.
///
/// For example, while you may choose to take advantage of onchain
/// metadata, as is the case for most Cadence NFTs, you may also choose
/// to represent your asset's metadata in IPFS and assign this value as
/// an IPFSFile struct pointing to that IPFS file. Alternatively, you
/// may serialize your NFT's metadata and assign it as a JSON string
/// data URL representating the NFT's onchain metadata at the time this
/// view is resolved.
///
access(all) let uri: {File}
init(name: String, symbol: String, uri: {File}) {
self.name = name
self.symbol = symbol
self.uri = uri
}
}
access(all) fun getEVMBridgedMetadata(_ viewResolver: &{ViewResolver.Resolver}) : EVMBridgedMetadata? {
if let view = viewResolver.resolveView(Type<EVMBridgedMetadata>()) {
if let v = view as? EVMBridgedMetadata {
return v
}
}
return nil
}
}