Collection Data
How do I store, send, or withdraw from this collection?
pub contract Avataaars: NonFungibleToken, ViewResolver {
// ...
pub resource NFT: NonFungibleToken.INFT, MetadataViews.ResolverCollection {
pub fun resolveView(_ view: Type): AnyStruct? {
switch view {
// ...
case Type<MetadataViews.NFTCollectionData>():
return Avataaars.resolveView(view)
// ...
}
return nil
}
}
pub fun resolveView(_ view: Type): AnyStruct? {
switch view {
case Type<MetadataViews.NFTCollectionData>():
return MetadataViews.NFTCollectionData(
storagePath: Avataaars.CollectionStoragePath,
publicPath: Avataaars.CollectionPublicPath,
providerPath: Avataaars.CollectionProviderPath,
publicCollection: Type<&Avataaars.Collection{Avataaars.AvataaarsCollectionPublic}>(),
publicLinkedType: Type<&Avataaars.Collection{Avataaars.AvataaarsCollectionPublic,NonFungibleToken.CollectionPublic,NonFungibleToken.Receiver,MetadataViews.ResolverCollection}>(),
providerLinkedType: Type<&Avataaars.Collection{Avataaars.AvataaarsCollectionPublic,NonFungibleToken.CollectionPublic,NonFungibleToken.Provider,MetadataViews.ResolverCollection}>(),
createEmptyCollectionFunction: (fun (): @NonFungibleToken.Collection {
return <-Avataaars.createEmptyCollection()
})
)
// ...
}
return nil
}
}Last updated