Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issues causing nft borrowing and data resolution to not work #33

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -e

flow-c1 test --cover --covercode="contracts" --coverprofile="coverage.lcov" tests/*_tests.cdc
flow test --cover --covercode="contracts" --coverprofile="coverage.lcov" tests/*_tests.cdc
Loading