diff --git a/docs/MetdataViews/MetadataViews.md b/docs/MetdataViews/MetadataViews.md new file mode 100644 index 0000000..0fd7629 --- /dev/null +++ b/docs/MetdataViews/MetadataViews.md @@ -0,0 +1,646 @@ +# Contract `MetadataViews` + +```cadence +pub contract MetadataViews { +} +``` + +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. +## Interfaces + +### `Resolver` + +```cadence +pub resource interface Resolver { +} +``` +Provides access to a set of metadata views. A struct or +resource (e.g. an NFT) can implement this interface to provide access to +the views that it supports. + +[More...](MetadataViews_Resolver.md) + +--- + +### `ResolverCollection` + +```cadence +pub resource interface ResolverCollection { +} +``` +A group of view resolvers indexed by ID. + +[More...](MetadataViews_ResolverCollection.md) + +--- + +### `File` + +```cadence +pub struct interface File { +} +``` +Generic interface that represents a file stored on or off chain. Files +can be used to references images, videos and other media. + +[More...](MetadataViews_File.md) + +--- +## Structs & Resources + +### `NFTView` + +```cadence +pub struct NFTView { + + pub let id: UInt64 + + pub let uuid: UInt64 + + pub let display: Display? + + pub let externalURL: ExternalURL? + + pub let collectionData: NFTCollectionData? + + pub let collectionDisplay: NFTCollectionDisplay? + + pub let royalties: Royalties? + + pub let traits: Traits? +} +``` +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. + +[More...](MetadataViews_NFTView.md) + +--- + +### `Display` + +```cadence +pub struct Display { + + pub let name: String + + pub let description: String + + pub let thumbnail: AnyStruct{File} +} +``` +Display is a basic view that includes the name, description and +thumbnail for an object. Most objects should implement this view. + +[More...](MetadataViews_Display.md) + +--- + +### `HTTPFile` + +```cadence +pub struct HTTPFile { + + pub let url: String +} +``` +View to expose a file that is accessible at an HTTP (or HTTPS) URL. + +[More...](MetadataViews_HTTPFile.md) + +--- + +### `IPFSFile` + +```cadence +pub struct IPFSFile { + + pub let cid: String + + pub let path: String? +} +``` +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. + +[More...](MetadataViews_IPFSFile.md) + +--- + +### `URI` + +```cadence +pub struct URI { + + pub let baseURI: String? + + access(self) let value: String +} +``` +View 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.). + +[More...](MetadataViews_URI.md) + +--- + +### `Edition` + +```cadence +pub struct Edition { + + pub let name: String? + + pub let number: UInt64 + + pub let max: UInt64? +} +``` +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 + +[More...](MetadataViews_Edition.md) + +--- + +### `Editions` + +```cadence +pub struct Editions { + + pub let infoList: [Edition] +} +``` +Wrapper view for multiple Edition views + +[More...](MetadataViews_Editions.md) + +--- + +### `Serial` + +```cadence +pub struct Serial { + + pub let number: UInt64 +} +``` +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 + +[More...](MetadataViews_Serial.md) + +--- + +### `Royalty` + +```cadence +pub struct Royalty { + + pub let receiver: Capability<&AnyResource{FungibleToken.Receiver}> + + pub let cut: UFix64 + + pub let description: String +} +``` +View that defines the composable royalty standard that gives marketplaces a +unified interface to support NFT royalties. + +[More...](MetadataViews_Royalty.md) + +--- + +### `Royalties` + +```cadence +pub struct Royalties { + + priv let cutInfos: [Royalty] +} +``` +Wrapper view for multiple Royalty views. +Marketplaces can query this `Royalties` struct from NFTs +and are expected to pay royalties based on these specifications. + +[More...](MetadataViews_Royalties.md) + +--- + +### `Media` + +```cadence +pub struct Media { + + pub let file: AnyStruct{File} + + pub let mediaType: String +} +``` +View to represent, a file with an correspoiding mediaType. + +[More...](MetadataViews_Media.md) + +--- + +### `Medias` + +```cadence +pub struct Medias { + + pub let items: [Media] +} +``` +Wrapper view for multiple media views + +[More...](MetadataViews_Medias.md) + +--- + +### `License` + +```cadence +pub struct License { + + pub let spdxIdentifier: String +} +``` +View to represent a license according to https://spdx.org/licenses/ +This view can be used if the content of an NFT is licensed. + +[More...](MetadataViews_License.md) + +--- + +### `ExternalURL` + +```cadence +pub struct ExternalURL { + + pub let url: String +} +``` +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. + +[More...](MetadataViews_ExternalURL.md) + +--- + +### `NFTCollectionData` + +```cadence +pub struct NFTCollectionData { + + pub let storagePath: StoragePath + + pub let publicPath: PublicPath + + pub let providerPath: PrivatePath + + pub let publicCollection: Type + + pub let publicLinkedType: Type + + pub let providerLinkedType: Type + + pub let createEmptyCollection: ((): @NonFungibleToken.Collection) +} +``` +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. + +[More...](MetadataViews_NFTCollectionData.md) + +--- + +### `NFTCollectionDisplay` + +```cadence +pub struct NFTCollectionDisplay { + + pub let name: String + + pub let description: String + + pub let externalURL: ExternalURL + + pub let squareImage: Media + + pub let bannerImage: Media + + pub let socials: {String: ExternalURL} +} +``` +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. + +[More...](MetadataViews_NFTCollectionDisplay.md) + +--- + +### `Rarity` + +```cadence +pub struct Rarity { + + pub let score: UFix64? + + pub let max: UFix64? + + pub let description: String? +} +``` +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 + +[More...](MetadataViews_Rarity.md) + +--- + +### `Trait` + +```cadence +pub struct Trait { + + pub let name: String + + pub let value: AnyStruct + + pub let displayType: String? + + pub let rarity: Rarity? +} +``` +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 + +[More...](MetadataViews_Trait.md) + +--- + +### `Traits` + +```cadence +pub struct Traits { + + pub let traits: [Trait] +} +``` +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. + +[More...](MetadataViews_Traits.md) + +--- + +### `EVMBridgedMetadata` + +```cadence +pub struct EVMBridgedMetadata { + + pub let name: String + + pub let symbol: String + + pub let uri: {File} +} +``` +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. + +[More...](MetadataViews_EVMBridgedMetadata.md) + +--- +## Functions + +### `getNFTView()` + +```cadence +fun getNFTView(id: UInt64, viewResolver: &{Resolver}): NFTView +``` +Helper to get an NFT view + +Parameters: + - id : _The NFT id_ + - viewResolver : _A reference to the resolver resource_ + +Returns: A NFTView struct + +--- + +### `getDisplay()` + +```cadence +fun getDisplay(_: &{Resolver}): Display? +``` +Helper to get Display in a typesafe way + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: An optional Display struct + +--- + +### `getEditions()` + +```cadence +fun getEditions(_: &{Resolver}): Editions? +``` +Helper to get Editions in a typesafe way + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: An optional Editions struct + +--- + +### `getSerial()` + +```cadence +fun getSerial(_: &{Resolver}): Serial? +``` +Helper to get Serial in a typesafe way + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: An optional Serial struct + +--- + +### `getRoyalties()` + +```cadence +fun getRoyalties(_: &{Resolver}): Royalties? +``` +Helper to get Royalties in a typesafe way + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: A optional Royalties struct + +--- + +### `getRoyaltyReceiverPublicPath()` + +```cadence +fun getRoyaltyReceiverPublicPath(): PublicPath +``` +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. + +Returns: The PublicPath for the generic FT receiver + +--- + +### `getMedias()` + +```cadence +fun getMedias(_: &{Resolver}): Medias? +``` +Helper to get Medias in a typesafe way + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: A optional Medias struct + +--- + +### `getLicense()` + +```cadence +fun getLicense(_: &{Resolver}): License? +``` +Helper to get License in a typesafe way + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: A optional License struct + +--- + +### `getExternalURL()` + +```cadence +fun getExternalURL(_: &{Resolver}): ExternalURL? +``` +Helper to get ExternalURL in a typesafe way + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: A optional ExternalURL struct + +--- + +### `getNFTCollectionData()` + +```cadence +fun getNFTCollectionData(_: &{Resolver}): NFTCollectionData? +``` +Helper to get NFTCollectionData in a way that will return an typed Optional + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: A optional NFTCollectionData struct + +--- + +### `getNFTCollectionDisplay()` + +```cadence +fun getNFTCollectionDisplay(_: &{Resolver}): NFTCollectionDisplay? +``` +Helper to get NFTCollectionDisplay in a way that will return a typed +Optional + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: A optional NFTCollection struct + +--- + +### `getRarity()` + +```cadence +fun getRarity(_: &{Resolver}): Rarity? +``` +Helper to get Rarity view in a typesafe way + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: A optional Rarity struct + +--- + +### `getTraits()` + +```cadence +fun getTraits(_: &{Resolver}): Traits? +``` +Helper to get Traits view in a typesafe way + +Parameters: + - viewResolver : _A reference to the resolver resource_ + +Returns: A optional Traits struct + +--- + +### `dictToTraits()` + +```cadence +fun dictToTraits(dict: {String: AnyStruct}, excludedNames: [String]?): Traits +``` +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. + +keys that are not wanted to become `Traits` + +Parameters: + - dict : _The dictionary to be converted to Traits_ + - excludedNames : _An optional String array specifying the `dict`_ + +Returns: The generated Traits view + +--- diff --git a/docs/MetdataViews/MetadataViews_EVMBridgedMetadata.md b/docs/MetdataViews/MetadataViews_EVMBridgedMetadata.md new file mode 100644 index 0000000..693c116 --- /dev/null +++ b/docs/MetdataViews/MetadataViews_EVMBridgedMetadata.md @@ -0,0 +1,28 @@ +# Struct `EVMBridgedMetadata` + +```cadence +pub struct EVMBridgedMetadata { + + pub let name: String + + pub let symbol: String + + pub let uri: {File} +} +``` + +This view may be used by Cadence-native projects to define 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. + +### Initializer + +```cadence +init(name: String, symbol: String, uri: {File}) +``` + +--- diff --git a/docs/MetdataViews/MetadataViews_URI.md b/docs/MetdataViews/MetadataViews_URI.md new file mode 100644 index 0000000..d4a4476 --- /dev/null +++ b/docs/MetdataViews/MetadataViews_URI.md @@ -0,0 +1,40 @@ +# Struct `URI` + +```cadence +pub struct URI { + + pub let baseURI: String? + + access(self) let value: String +} +``` + +View 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.) + +Implemented Interfaces: + - `File` + + +### Initializer + +```cadence +init(baseURI: String?, value: String?) +``` + + +## Functions + +### `uri()` + +```cadence +view fun uri(): String +``` +This function returns the uri for this file. If the `baseURI` is set, +this will be a concatenation of the `baseURI` and the `value`. If the +`baseURI` is not set, this will return the `value`. + +Returns: The string containing the file uri + +--- diff --git a/lib/go/templates/internal/assets/assets.go b/lib/go/templates/internal/assets/assets.go index 5200acc..0d0b91b 100644 --- a/lib/go/templates/internal/assets/assets.go +++ b/lib/go/templates/internal/assets/assets.go @@ -15,7 +15,7 @@ // transactions/scripts/get_collection_length_from_storage.cdc (722B) // transactions/scripts/get_contract_storage_path.cdc (520B) // transactions/scripts/get_contract_views.cdc (242B) -// transactions/scripts/get_nft_metadata.cdc (6.121kB) +// transactions/scripts/get_nft_metadata.cdc (6.19kB) // transactions/scripts/get_nft_view.cdc (4.367kB) // transactions/scripts/get_views.cdc (890B) // transactions/scripts/iterate_ids.cdc (794B) @@ -394,7 +394,7 @@ func transactionsScriptsGet_contract_viewsCdc() (*asset, error) { return a, nil } -var _transactionsScriptsGet_nft_metadataCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x58\x41\x6f\xdb\x38\x13\xbd\xfb\x57\x4c\x72\xf8\x60\x01\xfd\x94\x3d\x2c\xf6\x60\x54\x0d\xda\x26\x59\x04\x48\x8d\x22\x71\x7b\x29\x7a\xa0\xa5\x91\x43\x84\xa6\xbc\x24\xd5\xd4\x08\xf2\xdf\x17\x24\x25\x91\x94\x48\x2b\xdb\x43\x2d\x0d\xdf\x70\x28\x72\xde\x0c\x5f\x2e\x2e\x2e\x60\xf3\x48\x25\xc8\x52\xd0\x83\x82\x1d\x2a\x09\x84\x31\x50\x8f\x08\xbf\x28\x3e\xff\x7f\x4b\x24\x56\xb0\x47\x45\x2a\xa2\x08\x10\x29\x9b\x92\x12\x85\x15\x3c\x53\xf5\x68\x70\xf2\x80\x25\xad\x29\x56\xb0\xbe\xd9\x2c\xf4\x94\x84\x57\x20\x50\xb5\x82\x4b\xa0\x0a\x88\x04\x02\x92\xf2\x1d\x43\x90\x4a\xb4\xa5\x5a\x2c\xe8\xfe\xd0\x08\x05\xe7\xd7\xbf\xc9\xfe\xc0\x70\x7d\xb3\x39\x1f\x6c\x5f\xba\x68\xdf\x29\x3e\xcb\xf3\xc5\x82\x94\x25\x4a\xb9\x24\x8c\x65\x9d\xbf\x8e\x04\x2f\x0b\x00\x00\x7f\x90\xa1\x02\x4e\xf6\xb8\x82\x07\x25\x28\xdf\x45\x01\x15\xda\x8f\xa5\x0d\x3f\x89\x53\x8f\xed\x7e\xcb\x09\x65\x27\x51\xcd\x33\x47\xb1\x82\x8f\x55\x25\x50\xca\xf8\x44\xc7\xc3\xe9\x15\x89\xe6\x48\x98\xa2\x28\x57\xf0\x23\xf8\xf6\xfc\xde\x8c\x1c\x7f\x46\xdd\xf0\xb7\x42\xc1\x09\xfb\x76\x7f\x77\x72\x7a\x89\x82\x12\xb6\x6e\xf7\x5b\xbd\xd2\x6f\xb7\x5c\xfd\xf5\x67\x14\x58\x36\x8c\x61\xa9\x37\xe6\x6b\xbb\x65\xb4\xfc\x4a\xd4\xe3\x0a\xdc\xf3\x8c\xd3\x83\x6a\x04\xd9\xa1\xf5\xf2\x5e\xde\x14\xeb\xe4\x17\x8c\xc1\x77\x94\x3f\x61\xb5\x99\xdb\x57\xe7\xb6\x9e\x4b\x0a\x07\xbd\x7a\x63\x7a\x38\x8f\xeb\x37\x9e\x83\xb7\x53\xff\xb4\x44\xe0\xed\x9e\xec\xde\xba\xaa\x4f\x84\x73\x14\xff\xc5\xe3\x41\xf3\x94\xc9\x15\xbc\x58\x78\xef\xf6\x1a\xcf\xa5\x8a\xda\x2f\x0e\xf3\xef\xda\x9a\xe3\x69\x2d\x08\x55\x72\xec\xb1\x31\xd6\xa8\xc3\x1e\x2b\x4a\x26\x0e\x5f\x8c\xf5\x32\xea\xc1\x68\x89\x5c\xe2\xd8\xe5\xce\x9a\xe3\x3e\x5b\x41\xab\x1d\x56\xb3\x27\x2e\x8f\xfb\x6d\x73\x9a\xdb\xaa\x79\x42\xfe\xed\xfe\x76\x00\x19\x14\xe5\x54\x2d\xcd\x93\xfe\xe7\x97\x9b\x77\x83\x35\x52\x63\xdc\xe0\xa4\xb0\xb8\xa1\xb0\x9a\x38\x3b\xaf\x95\x9f\xed\x6e\x60\xbe\x74\x38\x6c\xa4\x5e\xb8\xc1\x58\x91\x70\xa3\x73\x95\x21\x86\x4c\x95\x83\xf4\xac\xd3\x55\xcd\x13\x3f\x86\x5d\x47\xcf\xe4\x24\xc5\x63\xb0\x08\xaf\xa3\xdf\x39\x25\x73\x0c\x16\x61\x70\x74\xb6\x14\x6d\xbd\x73\x3c\xc9\x55\x2f\xcf\x4e\x10\xd4\xa1\x3a\x56\x46\x49\xe9\x50\x3d\x13\xe3\x44\x74\xb8\x08\xfb\xbc\x1c\x0b\x28\xe7\x2d\x74\xcc\x33\x6d\xcc\xba\xfe\x6e\x93\x93\xd5\xb9\x66\x1a\x14\x86\x70\xe1\x80\x47\x36\x28\x7c\xea\x85\xb0\x81\x76\x50\x38\x0a\x86\x10\x43\x3f\x28\x2c\x0d\x47\xde\xc7\x83\x89\x6e\x89\x18\x8e\x0d\x24\x84\xc2\x11\x32\x84\x78\xdc\x83\xc2\x67\x62\x08\xf3\x59\x08\x45\x40\xca\x10\x18\x23\x24\x14\x51\x9e\xa6\x1c\x3d\x4a\x06\x9e\xe3\xce\x9d\x8c\x19\x89\x77\xda\xc1\xb1\x37\xe2\xea\x06\x53\x93\xac\x6d\x02\x84\x86\x14\xf8\x2a\x48\x8a\xa8\x3d\xe5\x7a\x1d\x9c\x55\xd4\x9e\xdc\x53\x57\x0b\xc2\x3d\x75\xf6\x94\xab\x57\x1f\x02\x57\xcf\x9e\x8c\x6a\x6b\x46\x18\xd1\xda\x46\x59\x68\x4b\x84\xce\x40\xaf\xb1\xbb\x1c\x37\xa5\x41\xd3\xc3\x35\xf1\x61\xd0\xd6\x09\x28\xba\x82\x11\x0e\x76\xe5\x01\x8a\xbe\x50\x84\xc3\x5e\x55\x80\xc2\xaf\x11\xa3\xec\x37\xf5\x41\xe7\xbd\x79\x18\x2d\xae\x2b\x12\x7a\x79\xdd\xa3\x01\xbc\x2e\x5e\x43\x85\x50\xb7\x1c\xf6\x84\xf2\x25\xb1\x5d\xd4\xb5\x53\xa0\x55\xdf\xda\xb2\x95\x27\x21\x74\xaf\x27\x65\xd9\xb4\x5c\x41\xa1\x35\xd0\x47\xfb\xd2\xcf\x90\x2d\x06\x98\x97\x48\x5a\x0e\x15\xe0\xf4\x4b\x2e\x50\x36\xec\x17\x7e\x6e\xb8\x12\xa4\x54\xba\x44\x2e\xb5\xad\x15\x25\xda\x96\xc5\x29\x7b\x67\x64\x95\x7d\xd5\xff\xbf\x0f\x2b\xea\xfa\x66\xf3\x39\x08\xf1\x61\x99\x65\x40\xe4\x19\xcc\xe0\x2e\x87\xdd\xba\xbc\x84\x03\xe1\xb4\x5c\x9e\x6b\xe8\xbd\x5d\x94\x80\xaa\x41\x09\xbc\x51\xd0\x2d\x13\x26\x53\x98\x95\x9d\x67\x66\xa2\xc8\x07\x43\xd1\x6f\x52\x5e\x92\x03\xd9\x52\x46\x75\x9d\xcb\xb7\x8d\x10\xcd\xf3\xfb\xff\x79\x3b\xe1\xe6\xfd\xe0\x6e\x4a\x10\xf6\x60\xa2\x48\x7e\x98\x16\xa9\xcc\x5b\xff\xe7\xa6\x65\x95\x59\xb3\x8d\x01\x04\x04\xd6\x28\x90\x97\x08\xaa\x31\xe2\xd3\xcd\x78\xee\x1d\x13\xaf\x55\xc0\x86\x6e\x91\xeb\x9b\xcd\x92\x56\x59\x64\xab\xe6\x42\x11\x6e\xf2\x65\xd0\xbc\x3b\xfa\x0b\x39\xdc\x5e\xf5\x41\x2f\x2e\xe0\x6f\xa3\x19\x11\xb6\x44\xd2\x12\x2a\x2a\x0f\x8c\x1c\x81\xf2\xba\x11\x7b\x62\x36\xb0\x6e\x04\x28\xad\xb6\xb5\x4e\xee\x97\xda\x03\x8b\xd1\x09\xef\x50\x5d\xd9\xa1\x25\xaf\x55\x76\x36\x89\x63\x3b\x4d\x2c\x42\xbf\x3c\x3f\x4c\x87\xd6\x73\xc7\x42\xdd\xf7\x6d\xcb\x0f\x36\x12\x99\x31\x3f\xaf\x26\x8e\x3d\xbd\xb3\x4e\x7f\x62\x98\x84\xc1\xf7\x7a\x67\xe9\x20\xa9\xf5\x4f\x92\x79\xbc\x1a\x5e\xab\xee\x82\x94\x9a\xa2\x1b\x96\xa3\xf0\x7e\x0f\x4e\xb9\x3e\x18\xcc\x38\x64\x78\x99\xb7\x97\x07\x7b\xc5\x38\xcb\xbb\xca\x12\x7c\xe5\x66\xb8\x62\xe8\x39\xf5\xdb\x32\x5a\x79\x92\x57\x44\x28\xe0\xc5\xca\x3b\x9d\x07\x4f\xa8\x73\x63\x7a\x0c\xb9\xb4\xfe\xf9\x13\x1e\xa5\x77\xc9\x9a\x04\xf8\xf1\x84\xc7\x9f\x61\xf3\x0c\x67\x30\x80\xb3\xbc\x15\xac\xab\xc4\xc3\x62\x87\x4e\x32\xd9\x2a\x7b\xfd\x1c\x6f\xd5\xd0\x5c\x26\x78\x7b\x13\x35\xf8\x01\xed\xba\xcd\x04\xde\xdd\x48\x2d\x7e\x70\xe8\x3a\x4e\x8f\x8e\x9e\xfe\xf7\x2f\x9f\x42\x94\xbf\x46\xfb\xc7\x2c\x4d\xa8\xb1\xf2\xeb\xe8\x6b\x6e\xa7\x09\xfd\xd7\x43\x3c\x63\x54\x0c\xf6\xb8\xc1\x94\xb7\x82\x2e\xb3\x89\x3a\x34\x3f\x11\x6d\xd8\x3d\xe4\xb4\x42\xae\x68\x4d\x7d\x90\xa7\x13\xbd\x4a\x10\x32\x3f\x4b\x48\x45\xef\x45\x9f\x75\x4a\x33\x8e\x89\x92\x73\xf3\x38\x27\x22\x27\xf4\xf6\xba\xc2\xac\xac\x9c\x3a\xcb\xb7\x09\xcd\x54\x54\x67\x8c\x6e\xe3\x29\x3d\x9a\x9a\xd2\x61\x66\xa6\xb4\xa2\x69\xca\xb6\x30\xb5\x12\x32\x76\xea\x16\x4d\xb7\x84\xba\x9d\x7a\x27\x0f\x3d\x21\x7c\x23\x45\xc2\x0d\xe7\x35\x65\x38\xce\xe6\x84\x34\x9e\x4e\xb4\x75\xc3\x33\x13\x0d\x95\x71\x62\x8a\xa8\xe7\xb0\x23\xe4\xba\x8d\xde\x51\xa9\x7e\xfc\xf1\x73\x2a\xa1\x55\x5c\x34\x77\xbf\x53\x99\xdc\x3f\x24\x84\xf1\xa8\x1e\x8d\x4e\xb8\x97\xc9\x63\x94\xb5\xc7\x64\xf3\x18\xd9\x0a\x6a\x37\xc9\x2a\xe9\xc5\xeb\xe2\xdf\x00\x00\x00\xff\xff\xbc\x4b\x33\xeb\xe9\x17\x00\x00" +var _transactionsScriptsGet_nft_metadataCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\x58\xcd\x6e\xdb\x38\x10\xbe\xfb\x29\x26\x39\x2c\x6c\xa0\xab\xec\x61\xb1\x07\xa3\x6a\xd0\x36\xc9\x22\x40\x6a\x14\x89\xdb\x4b\xd1\x03\x2d\x8d\x1d\x22\x34\xe5\x25\xa9\xa6\x46\x91\x77\x5f\x90\x94\xc4\x1f\x91\x56\x16\xdb\x43\x2d\x0d\xbf\xf9\x11\x39\xdf\x0c\x27\x17\x17\x17\xb0\x7e\xa4\x12\x64\x25\xe8\x41\xc1\x0e\x95\x04\xc2\x18\xa8\x47\x84\x1f\x14\x9f\x7f\xdf\x10\x89\x35\xec\x51\x91\x9a\x28\x02\x44\xca\xa6\xa2\x44\x61\x0d\xcf\x54\x3d\x1a\x9c\x3c\x60\x45\xb7\x14\x6b\x58\xdd\xac\x67\xda\x24\xe1\x35\x08\x54\xad\xe0\x12\xa8\x02\x22\x81\x80\xa4\x7c\xc7\x10\xa4\x12\x6d\xa5\x66\x33\xba\x3f\x34\x42\xc1\xf9\xf5\x4f\xb2\x3f\x30\x5c\xdd\xac\xcf\x07\xd9\xa7\xce\xdb\x57\x8a\xcf\xf2\x7c\x36\x23\x55\x85\x52\xce\x09\x63\x8b\x4e\x5f\x7b\x82\x5f\x33\x00\x00\x7f\x91\xa1\x02\x4e\xf6\xb8\x84\x07\x25\x28\xdf\x25\x01\x35\xda\x8f\xa5\x0d\x3f\x89\x53\x8f\xed\x7e\xc3\x09\x65\x27\x51\xcd\x33\x47\xb1\x84\xf7\x75\x2d\x50\xca\xb4\xa1\xe3\xe1\x74\x44\xa2\x39\x12\xa6\x28\xca\x25\x7c\x0b\xbe\xbd\xb8\x37\x2b\xc7\xef\x49\x35\xfc\xa9\x50\x70\xc2\xbe\xdc\xdf\x9d\x34\x2f\x51\x50\xc2\x56\xed\x7e\xa3\x23\xfd\x72\xcb\xd5\x5f\x7f\x26\x81\x55\xc3\x18\x56\x7a\x63\x3e\xb7\x1b\x46\xab\xcf\x44\x3d\x2e\xc1\x3d\x4f\x28\x3d\xa8\x46\x90\x1d\x5a\x2d\xef\xe5\x55\xbe\x4e\x7e\x41\x0c\xbe\xa3\xfc\x09\xeb\xf5\xd4\xbe\x3a\xb5\xd5\x54\x52\x38\xe8\xd5\x2b\xd3\xc3\x69\x5c\xbf\xf2\x1c\xbc\x9d\xfa\xa7\x25\x02\x6f\xf7\x64\xf7\xda\xa8\x3e\x10\xce\x51\xfc\x17\x8d\x07\xcd\x53\x26\x97\xf0\xcb\xc2\x7b\xb5\x97\x74\x2e\xd5\xd4\x7e\x71\x98\x7f\xd7\x56\x9c\x4e\x6b\x41\xa8\x92\xb1\xc6\xda\x48\x93\x0a\x7b\xac\x29\x19\x29\x7c\x32\xd2\xcb\xa4\x06\xa3\x15\x72\x89\xb1\xca\x9d\x15\xa7\x75\x36\x82\xd6\x3b\xac\x27\x4f\x5c\x1e\xf7\x9b\xe6\x34\xb7\x55\xf3\x84\xfc\xcb\xfd\xed\x00\x32\x28\xca\xa9\x9a\x9b\x27\xfd\xcf\x2f\x37\x6f\x06\x69\xa2\xc6\xb8\xc5\x51\x61\x71\x4b\x61\x35\x71\x72\xbe\x55\x7e\xb6\xbb\x85\xe9\xd2\xe1\xb0\x89\x7a\xe1\x16\x53\x45\xc2\xad\x4e\x55\x86\x14\x32\x57\x0e\xf2\x56\xc7\x51\x4d\x13\x3f\x85\x5d\x25\xcf\xe4\x24\xc5\x53\xb0\x04\xaf\x93\xdf\x39\x26\x73\x0a\x96\x60\x70\xd2\x5a\x8e\xb6\xde\x39\x9e\xe4\xaa\x97\x67\x27\x08\xea\x50\x1d\x2b\x93\xa4\x74\xa8\x9e\x89\x69\x22\x3a\x5c\x82\x7d\x5e\x8e\x05\x94\xf3\x02\x8d\x79\xa6\x85\x8b\xae\xbf\xdb\xe4\x64\xdb\x42\x33\x0d\x4a\x43\xb8\x70\xc1\x23\x1b\x94\x3e\xf5\x42\xd8\x40\x3b\x28\x1d\x05\x43\x88\xa1\x1f\x94\x96\x86\x91\xf6\xf1\x60\xbc\x5b\x22\x86\x6b\x03\x09\xa1\x74\x84\x0c\x21\x1e\xf7\xa0\xf4\x99\x18\xc2\x7c\x16\x42\x19\x90\x32\x04\xa6\x08\x09\x65\x92\xa7\x39\x45\x8f\x92\x81\x66\xdc\xb9\xb3\x3e\x13\xfe\x4e\x2b\x38\xf6\x26\x54\xdd\x62\xce\xc8\xca\x26\x40\x28\xc8\x81\xaf\x82\xa4\x48\xca\x73\xaa\xd7\xc1\x59\x25\xe5\xd9\x3d\x75\xb5\x20\xdc\x53\x27\xcf\xa9\x7a\xf5\x21\x50\xf5\xe4\x59\xaf\xb6\x66\x84\x1e\xad\x2c\xca\x42\x5b\x22\x74\x06\x7a\x8d\xdd\xe5\xb8\x29\x0d\x9a\x1e\xae\x89\x0f\x8b\xb6\x4e\x40\xd9\x15\x8c\x70\xb1\x2b\x0f\x50\xf6\x85\x22\x5c\xf6\xaa\x02\x94\x7e\x8d\x88\xb2\xdf\xd4\x07\x9d\xf7\xe6\x21\x0a\xae\x2b\x12\x3a\xbc\xee\xd1\x00\x5e\x66\x2f\xe1\x84\xb0\x6d\x39\xec\x09\xe5\x73\x62\xbb\xa8\x6b\xa7\x40\xeb\xbe\xb5\x2d\x96\xde\x08\xa1\x7b\x3d\xa9\xaa\xa6\xe5\x0a\x4a\x3d\x03\xbd\xb7\x2f\xbd\x85\xc5\x6c\x80\x79\x89\xa4\xc7\xa1\x12\xdc\xfc\x52\x08\x94\x0d\xfb\x81\x1f\x1b\xae\x04\xa9\x94\x2e\x91\x73\x2d\x6b\x45\x85\xb6\x65\x71\xca\xde\x98\xb1\xca\xbe\xea\xff\xdf\x86\x15\x75\x75\xb3\xfe\x18\xb8\x78\x37\x5f\x2c\x80\xc8\x33\x98\xc0\x5d\x0e\xbb\x75\x79\x09\x07\xc2\x69\x35\x3f\xd7\xd0\x7b\x1b\x94\x80\xba\x41\x09\xbc\x51\xd0\x85\x09\x23\x13\x26\xb2\xf3\x85\x31\x94\xf8\x60\x28\xfb\x4d\x2a\x2a\x72\x20\x1b\xca\xa8\xae\x73\xc5\xa6\x11\xa2\x79\x7e\xfb\x9b\xb7\x13\xce\xee\x3b\x77\x53\x82\xb0\x07\x13\x45\x8a\xc3\xb8\x48\x2d\xbc\xf8\x3f\x36\x2d\xab\x4d\xcc\xd6\x07\x10\x10\xb8\x45\x81\xbc\x42\x50\x8d\x19\x3e\x9d\xc5\x73\xef\x98\xf8\x56\x05\x6c\xe8\x82\x5c\xdd\xac\xe7\xb4\x5e\x24\xb6\x6a\xca\x15\xe1\x26\x5f\x86\x99\x77\x47\x7f\x20\x87\xdb\xab\xde\xe9\xc5\x05\xfc\x6d\x66\x46\x84\x0d\x91\xb4\x82\x9a\xca\x03\x23\x47\xa0\x7c\xdb\x88\x3d\x31\x1b\xb8\x6d\x04\x28\x3d\x6d\xeb\x39\xb9\x0f\xb5\x07\x96\xd1\x09\xef\x50\x5d\xd9\xa5\x39\xdf\xaa\xc5\xd9\xc8\x8f\xed\x34\x29\x0f\x7d\x78\xbe\x9b\x0e\xad\x6d\xa7\x5c\xdd\xf7\x6d\xcb\x77\x16\x0d\x99\x29\x3d\xaf\x26\xc6\x9a\xde\x59\xe7\x3f\x31\x4c\xc2\xe0\x7b\xbd\xb3\x74\x90\x5c\xfc\xa3\x64\x8e\xa3\xe1\x5b\xd5\x5d\x90\x72\x26\xba\x65\x19\xb9\xf7\x7b\x70\x4e\xf5\xc1\x60\x62\x97\xe1\x65\xde\x5e\x1e\xec\x15\xe3\xac\xe8\x2a\x4b\xf0\x95\xeb\xe1\x8a\xa1\x6d\xea\xb7\x79\xb2\xf2\x64\xaf\x88\x50\xc2\x2f\x3b\xde\xe9\x3c\x78\x42\x9d\x1b\xe3\x63\x28\xa4\xd5\x2f\x9e\xf0\x28\xbd\x4b\xd6\xc8\xc1\xb7\x27\x3c\x7e\x0f\x9b\x67\x68\xc1\x00\xce\x8a\x56\xb0\xae\x12\x0f\xc1\x0e\x9d\x64\xb4\x55\xf6\xfa\x19\x6f\xd5\xd0\x5c\x46\x78\x7b\x13\x35\xf8\x01\xed\xba\xcd\x08\xde\xdd\x48\x2d\x7e\x50\xe8\x3a\x4e\x8f\x4e\x9e\xfe\xd7\x4f\x1f\x42\x54\x1c\xe3\xff\x36\x62\xff\x22\xa6\x59\x19\x8f\x8f\x5d\x0d\x30\x57\xdc\xcc\x10\xd9\x43\x3c\x61\x72\xa2\xec\x71\x83\xa8\x68\x05\x9d\x2f\x46\x23\xa6\xf9\x49\x0c\x98\xdd\x43\x41\x6b\xe4\x8a\x6e\xa9\x0f\xf2\x86\x4d\xaf\x9c\x84\xe5\x63\x91\x99\x37\xbd\x17\x9d\x30\xb9\xc1\x33\x66\x5b\xc1\xcd\xe3\xd4\x24\x3a\xaa\x11\x5e\x6b\x99\x9c\x4d\xc7\xca\xf2\x75\xd3\x6a\xce\xab\x13\x26\xb7\xf1\xd4\x50\x9b\x33\xe9\x30\x13\x26\xed\xe4\x35\xa6\x6c\x98\x5a\x99\x59\x78\xac\x96\x4c\xb7\xcc\x88\x3c\xd6\xce\x1e\x7a\x66\x7a\x4e\x54\x1a\xb7\x5c\x6c\x29\xc3\x38\x9b\x33\xf3\xf5\xd8\xd0\xc6\x2d\x4f\x18\x1a\xca\xeb\x48\x94\x18\xc1\xc3\xb6\x52\xe8\x5e\x7c\x47\xa5\xfa\xf6\xc7\xf7\xf1\x1c\xae\xd2\x93\x77\xf7\x3b\x9e\xb5\xfb\x87\xcc\x74\x1d\xd5\xa3\xe8\x84\xfb\x59\x3b\x46\x59\x79\x6a\xf6\x8e\x91\xad\xa0\x76\x93\xec\x38\x3e\x7b\x99\xfd\x1b\x00\x00\xff\xff\x32\x4b\x59\xcf\x2e\x18\x00\x00" func transactionsScriptsGet_nft_metadataCdcBytes() ([]byte, error) { return bindataRead( @@ -410,7 +410,7 @@ func transactionsScriptsGet_nft_metadataCdc() (*asset, error) { } info := bindataFileInfo{name: "transactions/scripts/get_nft_metadata.cdc", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x4b, 0x4c, 0x7a, 0xc7, 0xeb, 0x27, 0x9c, 0x41, 0xdc, 0xa0, 0x16, 0x3a, 0x1c, 0xd2, 0x73, 0x16, 0x80, 0x1e, 0xd7, 0x37, 0xea, 0xc0, 0x71, 0x7c, 0xc6, 0xb4, 0xe3, 0xc9, 0x92, 0x4b, 0xe2, 0x18}} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2f, 0x98, 0x35, 0x5f, 0x85, 0x11, 0xe, 0x86, 0x10, 0xe9, 0x0, 0xbb, 0x6, 0xe2, 0x89, 0x9d, 0x55, 0x57, 0x50, 0x6f, 0x71, 0x14, 0x7f, 0x71, 0xb0, 0xb6, 0x2b, 0x69, 0x7e, 0x10, 0x8e, 0xdd}} return a, nil } diff --git a/tests/scripts/get_nft_metadata.cdc b/tests/scripts/get_nft_metadata.cdc new file mode 100644 index 0000000..cfee7d3 --- /dev/null +++ b/tests/scripts/get_nft_metadata.cdc @@ -0,0 +1,203 @@ +/// This script checks all views from MetadataViews for +/// a given NFT. Used for testing only. + +import "ExampleNFT" +import "MetadataViews" + +pub struct NFT { + pub let name: String + pub let description: String + pub let thumbnail: String + pub let owner: Address + pub let type: String + pub let royalties: [MetadataViews.Royalty] + pub let externalURL: String + pub let serialNumber: UInt64 + pub let collectionPublicPath: PublicPath + pub let collectionStoragePath: StoragePath + pub let collectionProviderPath: PrivatePath + pub let collectionPublic: String + pub let collectionPublicLinkedType: String + pub let collectionProviderLinkedType: String + pub let collectionName: String + pub let collectionDescription: String + pub let collectionExternalURL: String + pub let collectionSquareImage: String + pub let collectionBannerImage: String + pub let collectionSocials: {String: String} + pub let edition: MetadataViews.Edition + pub let traits: MetadataViews.Traits + pub let medias: MetadataViews.Medias? + pub let license: MetadataViews.License? + pub let bridgedName: String + pub let symbol: String + pub let tokenURI: String + + init( + name: String, + description: String, + thumbnail: String, + owner: Address, + nftType: String, + royalties: [MetadataViews.Royalty], + externalURL: String, + serialNumber: UInt64, + collectionPublicPath: PublicPath, + collectionStoragePath: StoragePath, + collectionProviderPath: PrivatePath, + collectionPublic: String, + collectionPublicLinkedType: String, + collectionProviderLinkedType: String, + collectionName: String, + collectionDescription: String, + collectionExternalURL: String, + collectionSquareImage: String, + collectionBannerImage: String, + collectionSocials: {String: String}, + edition: MetadataViews.Edition, + traits: MetadataViews.Traits, + medias: MetadataViews.Medias?, + license: MetadataViews.License?, + bridgedName: String, + symbol: String, + tokenURI: String + ) { + self.name = name + self.description = description + self.thumbnail = thumbnail + self.owner = owner + self.type = nftType + self.royalties = royalties + self.externalURL = externalURL + self.serialNumber = serialNumber + self.collectionPublicPath = collectionPublicPath + self.collectionStoragePath = collectionStoragePath + self.collectionProviderPath = collectionProviderPath + self.collectionPublic = collectionPublic + self.collectionPublicLinkedType = collectionPublicLinkedType + self.collectionProviderLinkedType = collectionProviderLinkedType + self.collectionName = collectionName + self.collectionDescription = collectionDescription + self.collectionExternalURL = collectionExternalURL + self.collectionSquareImage = collectionSquareImage + self.collectionBannerImage = collectionBannerImage + self.collectionSocials = collectionSocials + self.edition = edition + self.traits = traits + self.medias = medias + self.license = license + self.bridgedName = bridgedName + self.symbol = symbol + self.tokenURI = tokenURI + } +} + +pub fun main(address: Address, id: UInt64): Bool { + let account = getAccount(address) + + let collection = account + .getCapability(ExampleNFT.CollectionPublicPath) + .borrow<&{ExampleNFT.ExampleNFTCollectionPublic}>() + ?? panic("Could not borrow a reference to the collection") + + let nft = collection.borrowExampleNFT(id: id)! + + // Get the basic display information for this NFT + let display = MetadataViews.getDisplay(nft)! + + // Get the royalty information for the given NFT + let royaltyView = MetadataViews.getRoyalties(nft)! + + let externalURL = MetadataViews.getExternalURL(nft)! + + let collectionDisplay = MetadataViews.getNFTCollectionDisplay(nft)! + let nftCollectionView = MetadataViews.getNFTCollectionData(nft)! + + let nftEditionView = MetadataViews.getEditions(nft)! + let serialNumberView = MetadataViews.getSerial(nft)! + + let owner: Address = nft.owner!.address! + let nftType = nft.getType() + + let collectionSocials: {String: String} = {} + for key in collectionDisplay.socials.keys { + collectionSocials[key] = collectionDisplay.socials[key]!.url + } + + let traits = MetadataViews.getTraits(nft)! + + let medias = MetadataViews.getMedias(nft) + let license = MetadataViews.getLicense(nft) + + let bridgedMetadata = MetadataViews.getEVMBridgedMetadata(nft)! + + let nftMetadata = NFT( + name: display.name, + description: display.description, + thumbnail: display.thumbnail.uri(), + owner: owner, + nftType: nftType.identifier, + royalties: royaltyView.getRoyalties(), + externalURL: externalURL.url, + serialNumber: serialNumberView.number, + collectionPublicPath: nftCollectionView.publicPath, + collectionStoragePath: nftCollectionView.storagePath, + collectionProviderPath: nftCollectionView.providerPath, + collectionPublic: nftCollectionView.publicCollection.identifier, + collectionPublicLinkedType: nftCollectionView.publicLinkedType.identifier, + collectionProviderLinkedType: nftCollectionView.providerLinkedType.identifier, + collectionName: collectionDisplay.name, + collectionDescription: collectionDisplay.description, + collectionExternalURL: collectionDisplay.externalURL.url, + collectionSquareImage: collectionDisplay.squareImage.file.uri(), + collectionBannerImage: collectionDisplay.bannerImage.file.uri(), + collectionSocials: collectionSocials, + edition: nftEditionView.infoList[0], + traits: traits, + medias: medias, + license: license, + bridgedName: bridgedMetadata.name, + symbol: bridgedMetadata.symbol, + tokenURI: bridgedMetadata.uri.uri() + ) + + assert("NFT Name" == nftMetadata.name) + assert("NFT Description" == nftMetadata.description) + assert("NFT Thumbnail" == nftMetadata.thumbnail) + assert(Address(0x0000000000000007) == nftMetadata.owner) + assert("A.0000000000000007.ExampleNFT.NFT" == nftMetadata.type) + assert("Creator Royalty" == nftMetadata.royalties[0].description) + assert(Address(0x0000000000000007) == nftMetadata.royalties[0].receiver.address) + assert(0.05 == nftMetadata.royalties[0].cut) + assert("https://example-nft.onflow.org/0" == nftMetadata.externalURL) + assert((0 as UInt64) == nftMetadata.serialNumber) + assert(/public/exampleNFTCollection == nftMetadata.collectionPublicPath) + assert(/storage/exampleNFTCollection == nftMetadata.collectionStoragePath) + assert(/private/exampleNFTCollection == nftMetadata.collectionProviderPath) + assert("&A.0000000000000007.ExampleNFT.Collection{A.0000000000000007.ExampleNFT.ExampleNFTCollectionPublic}" == nftMetadata.collectionPublic) + assert("&A.0000000000000007.ExampleNFT.Collection{A.0000000000000007.ExampleNFT.ExampleNFTCollectionPublic,A.0000000000000001.NonFungibleToken.CollectionPublic,A.0000000000000001.NonFungibleToken.Receiver,A.0000000000000007.MetadataViews.ResolverCollection}" == nftMetadata.collectionPublicLinkedType) + assert("&A.0000000000000007.ExampleNFT.Collection{A.0000000000000007.ExampleNFT.ExampleNFTCollectionPublic,A.0000000000000001.NonFungibleToken.CollectionPublic,A.0000000000000001.NonFungibleToken.Provider,A.0000000000000007.MetadataViews.ResolverCollection}" == nftMetadata.collectionProviderLinkedType) + assert("The Example Collection" == nftMetadata.collectionName) + assert("This collection is used as an example to help you develop your next Flow NFT." == nftMetadata.collectionDescription) + assert("https://example-nft.onflow.org" == nftMetadata.collectionExternalURL) + assert("https://assets.website-files.com/5f6294c0c7a8cdd643b1c820/5f6294c0c7a8cda55cb1c936_Flow_Wordmark.svg" == nftMetadata.collectionSquareImage) + assert("https://assets.website-files.com/5f6294c0c7a8cdd643b1c820/5f6294c0c7a8cda55cb1c936_Flow_Wordmark.svg" == nftMetadata.collectionBannerImage) + assert({"twitter": "https://twitter.com/flow_blockchain"} == nftMetadata.collectionSocials) + assert("Example NFT Edition" == nftMetadata.edition.name) + assert((0 as UInt64) == nftMetadata.edition.number) + assert(nil == nftMetadata.edition.max) + assert("Common" == nftMetadata.traits.traits[3]!.rarity!.description) + assert(10.0 == nftMetadata.traits.traits[3]!.rarity!.score) + assert(100.0 == nftMetadata.traits.traits[3]!.rarity!.max) + assert(nil == nftMetadata.medias) + assert(nil == nftMetadata.license) + assert("ExampleNFT" == nftMetadata.bridgedName) + assert("XMPL" == nftMetadata.symbol, message: "Symbol is ".concat(nftMetadata.symbol)) + assert("https://example-nft.onflow.org/token-metadata/".concat(id.toString()).concat(".json") == nftMetadata.tokenURI) + + let coll <- nftCollectionView.createEmptyCollection() + assert(0 == coll.getIDs().length) + destroy <- coll + + return true +} diff --git a/transactions/scripts/get_nft_metadata.cdc b/transactions/scripts/get_nft_metadata.cdc index 304297e..ecc79db 100644 --- a/transactions/scripts/get_nft_metadata.cdc +++ b/transactions/scripts/get_nft_metadata.cdc @@ -128,6 +128,8 @@ access(all) fun main(address: Address, id: UInt64): NFT { let bridgedMetadata = MetadataViews.getEVMBridgedMetadata(nft)! + let bridgedMetadata = MetadataViews.getEVMBridgedMetadata(nft)! + return NFT( name: display.name, description: display.description,