Skip to content

Commit

Permalink
fix two contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
bjartek committed Sep 5, 2024
1 parent 3bc7bd4 commit 5766c05
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
20 changes: 16 additions & 4 deletions contracts/CharityNFT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,28 @@ access(all) contract CharityNFT: NonFungibleToken {

access(all) view fun getContractViews(resourceType: Type?): [Type] {
return [
Type<MetadataViews.NFTCollectionData>()
Type<MetadataViews.NFTCollectionData>(),
Type<MetadataViews.NFTCollectionDisplay>()
]
}

access(all) fun resolveContractView(resourceType: Type?, viewType: Type): AnyStruct? {
switch viewType {

case Type<MetadataViews.NFTCollectionDisplay>() :
return MetadataViews.NFTCollectionDisplay(
name: "Neo Charity 2021",
description: "This collection is to show participation in the Neo Collectibles x Flowverse Charity Auction in 2021.",
externalURL: MetadataViews.ExternalURL("http://find.xyz/neoCharity"),
squareImage: MetadataViews.Media(file: MetadataViews.HTTPFile(url: "https://pbs.twimg.com/profile_images/1467546091780550658/R1uc6dcq_400x400.jpg") , mediaType: "image"),
bannerImage: MetadataViews.Media(file: MetadataViews.HTTPFile(url: "https://pbs.twimg.com/profile_banners/1448245049666510848/1652452073/1500x500") , mediaType: "image"),
socials: {
"Twitter" : MetadataViews.ExternalURL("https://twitter.com/findonflow") ,
"Discord" : MetadataViews.ExternalURL("https://discord.gg/95P274mayM")
}
)

case Type<MetadataViews.NFTCollectionData>():
let collectionRef = self.account.storage.borrow<&CharityNFT.Collection>(
from: CharityNFT.CollectionStoragePath
) ?? panic("Could not borrow a reference to the stored collection")
let collectionData = MetadataViews.NFTCollectionData(
storagePath: CharityNFT.CollectionStoragePath,
publicPath: CharityNFT.CollectionPublicPath,
Expand Down
33 changes: 15 additions & 18 deletions contracts/FindPack.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -542,21 +542,6 @@ access(all) contract FindPack: NonFungibleToken{
case Type<MetadataViews.NFTCollectionDisplay>():

return self.getMetadata().collectionDisplay
/* to be determined
//let externalURL = MetadataViews.ExternalURL("https://find.xyz/mp/findPack")
let externalURL = MetadataViews.ExternalURL("https://find.xyz/")
let squareImage = MetadataViews.Media(file: MetadataViews.HTTPFile(url: "https://pbs.twimg.com/profile_images/1467546091780550658/R1uc6dcq_400x400.jpg"), mediaType: "image")
let bannerImage = MetadataViews.Media(file: MetadataViews.HTTPFile(url: "https://pbs.twimg.com/profile_banners/1448245049666510848/1652452073/1500x500"), mediaType: "image")
return MetadataViews.NFTCollectionDisplay(name: "find Pack",
description: "Find pack",
externalURL: externalURL,
squareImage: squareImage,
bannerImage: bannerImage,
socials: {
"discord": MetadataViews.ExternalURL("https://discord.gg/ejdVgzWmYN"),
"twitter" : MetadataViews.ExternalURL("https://twitter.com/findonflow")
})
*/
}
return nil
}
Expand All @@ -573,12 +558,24 @@ access(all) contract FindPack: NonFungibleToken{
]
}


access(all) fun resolveContractView(resourceType: Type?, viewType: Type): AnyStruct? {
switch viewType {
case Type<MetadataViews.NFTCollectionDisplay>():
return MetadataViews.NFTCollectionDisplay(
name: "Find Pack",
description: "A generic find pack that can contain lots of stuff",
externalURL: MetadataViews.ExternalURL("http://find.xyz"),
squareImage: MetadataViews.Media(file: MetadataViews.HTTPFile(url: "https://pbs.twimg.com/profile_images/1467546091780550658/R1uc6dcq_400x400.jpg") , mediaType: "image"),
bannerImage: MetadataViews.Media(file: MetadataViews.HTTPFile(url: "https://pbs.twimg.com/profile_banners/1448245049666510848/1652452073/1500x500") , mediaType: "image"),
socials: {
"Twitter" : MetadataViews.ExternalURL("https://twitter.com/findonflow") ,
"Discord" : MetadataViews.ExternalURL("https://discord.gg/95P274mayM")
}
)


case Type<MetadataViews.NFTCollectionData>():
let collectionRef = self.account.storage.borrow<&FindPack.Collection>(
from: FindPack.CollectionStoragePath
) ?? panic("Could not borrow a reference to the stored collection")
let collectionData = MetadataViews.NFTCollectionData(
storagePath: FindPack.CollectionStoragePath,
publicPath: FindPack.CollectionPublicPath,
Expand Down

0 comments on commit 5766c05

Please sign in to comment.