Skip to content

Commit

Permalink
use receiver and collection in public linked type
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Feb 1, 2024
1 parent 912407f commit ebdb001
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion contracts/ExampleNFT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ access(all) contract ExampleNFT: NonFungibleToken {
self.account.storage.save(<-collection, to: defaultStoragePath)

// create a public capability for the collection
let collectionCap = self.account.capabilities.storage.issue<&ExampleNFT.Collection>(defaultStoragePath)
let collectionCap = self.account.capabilities.storage.issue<&{NonFungibleToken.Receiver, NonFungibleToken.Collection}>(defaultStoragePath)
self.account.capabilities.publish(collectionCap, at: defaultPublicPath)

// Create a Minter resource and save it to storage
Expand Down
3 changes: 3 additions & 0 deletions contracts/MetadataViews.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ access(all) contract MetadataViews {
publicLinkedType: Type,
createEmptyCollectionFunction: fun(): @{NonFungibleToken.Collection}
) {
pre {
publicLinkedType.isSubtype(of: Type<&{NonFungibleToken.Receiver}>()): "Public type must include NonFungibleToken.Receiver interface."
}
self.storagePath=storagePath
self.publicPath=publicPath
self.publicCollection=publicCollection
Expand Down
12 changes: 6 additions & 6 deletions lib/go/contracts/internal/assets/assets.go

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lib/go/templates/internal/assets/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion transactions/setup_account.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ transaction {

// create a public capability for the collection
signer.capabilities.unpublish(collectionData.publicPath)
let collectionCap = signer.capabilities.storage.issue<&ExampleNFT.Collection>(collectionData.storagePath)
let collectionCap = signer.capabilities.storage.issue<&{NonFungibleToken.Receiver, NonFungibleToken.Collection}>(collectionData.storagePath)
signer.capabilities.publish(collectionCap, at: collectionData.publicPath)
}
}
2 changes: 1 addition & 1 deletion transactions/setup_account_from_nft_reference.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ transaction(address: Address, publicPath: PublicPath, id: UInt64) {
signer.storage.save(<-emptyCollection, to: collectionData.storagePath)

// create a public capability for the collection
let collectionCap = signer.capabilities.storage.issue<&{NonFungibleToken.Collection}>(
let collectionCap = signer.capabilities.storage.issue<&{NonFungibleToken.Receiver, NonFungibleToken.Collection}>(
collectionData.storagePath
)
signer.capabilities.publish(collectionCap, at: publicPath)
Expand Down

0 comments on commit ebdb001

Please sign in to comment.