Skip to content

Commit

Permalink
remove Owner entitlement
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Apr 29, 2024
1 parent 4a6f42d commit fa1f400
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions contracts/ExampleNFT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ access(all) contract ExampleNFT: NonFungibleToken {
}

/// withdraw removes an NFT from the collection and moves it to the caller
access(NonFungibleToken.Withdraw | NonFungibleToken.Owner) fun withdraw(withdrawID: UInt64): @{NonFungibleToken.NFT} {
access(NonFungibleToken.Withdraw) fun withdraw(withdrawID: UInt64): @{NonFungibleToken.NFT} {
let token <- self.ownedNFTs.remove(key: withdrawID)
?? panic("Could not withdraw an NFT with the provided ID from the collection")

Expand All @@ -176,7 +176,7 @@ access(all) contract ExampleNFT: NonFungibleToken {
// Do not add to your contract unless you have a specific
// reason to want to emit the NFTUpdated event somewhere
// in your contract
let authTokenRef = (&self.ownedNFTs[id] as auth(NonFungibleToken.Owner) &{NonFungibleToken.NFT}?)!
let authTokenRef = (&self.ownedNFTs[id] as auth(NonFungibleToken.Update) &{NonFungibleToken.NFT}?)!
//authTokenRef.updateTransferDate(date: getCurrentBlock().timestamp)
ExampleNFT.emitNFTUpdated(authTokenRef)
}
Expand Down
7 changes: 2 additions & 5 deletions contracts/NonFungibleToken.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ access(all) contract interface NonFungibleToken: ViewResolver {
/// An entitlement for allowing updates and update events for an NFT
access(all) entitlement Update

/// entitlement for owner that grants Withdraw and Update
access(all) entitlement Owner

/// Event that contracts should emit when the metadata of an NFT is updated
/// It can only be emitted by calling the `emitNFTUpdated` function
/// with an `Updatable` entitled reference to the NFT that was updated
Expand All @@ -63,7 +60,7 @@ access(all) contract interface NonFungibleToken: ViewResolver {
/// and query the updated metadata from the owners' collections.
///
access(all) event Updated(type: String, id: UInt64, uuid: UInt64, owner: Address?)
access(all) view fun emitNFTUpdated(_ nftRef: auth(Update | Owner) &{NonFungibleToken.NFT})
access(all) view fun emitNFTUpdated(_ nftRef: auth(Update) &{NonFungibleToken.NFT})
{
emit Updated(type: nftRef.getType().identifier, id: nftRef.id, uuid: nftRef.uuid, owner: nftRef.owner?.address)
}
Expand Down Expand Up @@ -139,7 +136,7 @@ access(all) contract interface NonFungibleToken: ViewResolver {
/// withdraw removes an NFT from the collection and moves it to the caller
/// It does not specify whether the ID is UUID or not
/// @param withdrawID: The id of the NFT to withdraw from the collection
access(Withdraw | Owner) fun withdraw(withdrawID: UInt64): @{NFT} {
access(Withdraw) fun withdraw(withdrawID: UInt64): @{NFT} {
post {
result.id == withdrawID: "The ID of the withdrawn token must be the same as the requested ID"
emit Withdrawn(type: result.getType().identifier, id: result.id, uuid: result.uuid, from: self.owner?.address, providerUUID: self.uuid)
Expand Down
Loading

0 comments on commit fa1f400

Please sign in to comment.