Skip to content

Commit

Permalink
change nftupdated to access all
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Apr 2, 2024
1 parent 7ed142c commit f02f665
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions docs/cadence_migration_guide/nft-guide.mdx
Expand Up @@ -459,7 +459,7 @@ so they can query collections to get the updated metadata to show in their user

```cadence
access(all) event Updated(type: String, id: UInt64, uuid: UInt64, owner: Address?)
access(contract) view fun emitNFTUpdated(_ nftRef: auth(Update | Owner) &{NonFungibleToken.NFT})
access(all) view fun emitNFTUpdated(_ nftRef: auth(Update | Owner) &{NonFungibleToken.NFT})
{
emit Updated(type: nftRef.getType().identifier, id: nftRef.id, uuid: nftRef.uuid, owner: nftRef.owner?.address)
}
Expand All @@ -468,10 +468,9 @@ so they can query collections to get the updated metadata to show in their user
As you can see, it requires an authorized reference to an NFT, so only the owner of
and NFT can call this to emit an event. Additionally, as is noted in the example below,
you have to use your own contract's name to call the function because the code
that emits the event is a default implementation of an `access(contract)` function.
that emits the event is a default implementation that can only be accessed from an implementation.

This restriction is to make it so only the code in your contract can call the function
to emit the events about your NFT. DO NOT Re-implement the `emitNFTUpdated` function
DO NOT Re-implement the `emitNFTUpdated` function
in your contract or you will lose access to the ability to emit the standard event.

This function could be called from within a `Collection`
Expand Down
Expand Up @@ -459,7 +459,7 @@ so they can query collections to get the updated metadata to show in their user

```cadence
access(all) event Updated(type: String, id: UInt64, uuid: UInt64, owner: Address?)
access(contract) view fun emitNFTUpdated(_ nftRef: auth(Update | Owner) &{NonFungibleToken.NFT})
access(all) view fun emitNFTUpdated(_ nftRef: auth(Update | Owner) &{NonFungibleToken.NFT})
{
emit Updated(type: nftRef.getType().identifier, id: nftRef.id, uuid: nftRef.uuid, owner: nftRef.owner?.address)
}
Expand All @@ -468,10 +468,9 @@ so they can query collections to get the updated metadata to show in their user
As you can see, it requires an authorized reference to an NFT, so only the owner of
and NFT can call this to emit an event. Additionally, as is noted in the example below,
you have to use your own contract's name to call the function because the code
that emits the event is a default implementation of an `access(contract)` function.
that emits the event is a default implementation that can only be accessed from an implementation.

This restriction is to make it so only the code in your contract can call the function
to emit the events about your NFT. DO NOT Re-implement the `emitNFTUpdated` function
DO NOT Re-implement the `emitNFTUpdated` function
in your contract or you will lose access to the ability to emit the standard event.

This function could be called from within a `Collection`
Expand Down

0 comments on commit f02f665

Please sign in to comment.