Skip to content

Commit

Permalink
fix issues causing nft borrowing and data resolution to not work
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkline committed Sep 9, 2024
1 parent c872f67 commit 84f5bad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/nft/BaseCollection.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ access(all) contract interface BaseCollection: ViewResolver {
token.getType() == self.nftType: "unexpected nft type being deposited"
}

destroy self.ownedNFTs.insert(key: token.uuid, <-token)
destroy self.ownedNFTs.insert(key: token.id, <-token)
}

access(all) view fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}? {
Expand Down
4 changes: 2 additions & 2 deletions contracts/nft/BaseNFT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ access(all) contract interface BaseNFT: ViewResolver {

access(all) fun resolveView(_ view: Type): AnyStruct? {
if view == Type<MetadataViews.Serial>() {
return self.id
return MetadataViews.Serial(self.id)
}

let rt = self.getType()
Expand Down Expand Up @@ -75,7 +75,7 @@ access(all) contract interface BaseNFT: ViewResolver {
}
)
case Type<MetadataViews.NFTCollectionDisplay>():
return md.collectionInfo.collectionDisplay
return md.collectionInfo.getDisplay()
}

if let entry = md.borrowMetadata(id: self.metadataID) {
Expand Down
12 changes: 12 additions & 0 deletions contracts/nft/UniversalCollection.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ access(all) contract UniversalCollection {
return <- create Collection(nftType: self.nftType)
}

access(all) fun deposit(token: @{NonFungibleToken.NFT}) {
pre {
token.getType() == self.nftType: "unexpected nft type being deposited"
}

destroy self.ownedNFTs.insert(key: token.id, <-token)
}

access(all) view fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}? {
return &self.ownedNFTs[id]
}

init (nftType: Type) {
self.ownedNFTs <- {}
self.nftType = nftType
Expand Down

0 comments on commit 84f5bad

Please sign in to comment.