diff --git a/cadence/contract.cdc b/cadence/contract.cdc index c7b372e..1a11c46 100644 --- a/cadence/contract.cdc +++ b/cadence/contract.cdc @@ -1,14 +1,16 @@ -//Here is where the rest of your NFT resource code will go... +// Here is where the rest of your NFT resource code will go... // Below is the metadata functions to include in your NFT resource... // Checkout the NFT Metadata example to see it all put together -pub fun getViews(): [Type] { +access(all) +fun getViews(): [Type] { return [ Type() ] } -pub fun resolveView(_ view: Type): AnyStruct? { +access(all) +fun resolveView(_ view: Type): AnyStruct? { switch view { case Type(): return MetadataViews.Display( @@ -21,12 +23,13 @@ pub fun resolveView(_ view: Type): AnyStruct? { return nil } -// below is where you will have your metadata in your NFT initialzied +// Below is where you will have your metadata in your NFT initialized ..... -//the following code is in your collections resource +// The following code is in your collections resource -pub fun borrowViewResolver(id: UInt64): &AnyResource{MetadataViews.Resolver} { +access(all) +fun borrowViewResolver(id: UInt64): &AnyResource{MetadataViews.Resolver} { let nft = &self.ownedNFTs[id] as auth &NonFungibleToken.NFT let exampleNFT = nft as! &NewExampleNFT.NFT return exampleNFT as &AnyResource{MetadataViews.Resolver} diff --git a/cadence/transaction.cdc b/cadence/transaction.cdc index c1a6c29..094d892 100644 --- a/cadence/transaction.cdc +++ b/cadence/transaction.cdc @@ -1,21 +1,20 @@ import MetadataViews from 0x01 -pub fun main(): AnyStruct { +access(all) +fun main(): AnyStruct { let address: Address = 0x02 let id: UInt64 = 0 let account = getAccount(address) let collection = account - .getCapability(/public/exampleNFTCollection) - .borrow<&{MetadataViews.ResolverCollection}>() + .capabilities + .borrow<&{MetadataViews.ResolverCollection}>(/public/exampleNFTCollection) ?? panic("Could not borrow a reference to the collection") let nft = collection.borrowViewResolver(id: id) - // Get the basic display information for this NFT - let display = nft.resolveView(Type()) return display diff --git a/index.js b/index.js index a2df7d1..74f4839 100644 --- a/index.js +++ b/index.js @@ -23,6 +23,6 @@ export const metadataViews = { transactionCode: transactionPath, transactionExplanation: transactionExplanationPath, filters: { - difficulty: "beginner" - } + difficulty: "beginner", + }, };