Skip to content

Commit

Permalink
Re-add public interfaces now due to usage in tests; remove un-needed …
Browse files Browse the repository at this point in the history
…nftUpdated event call, as it was already being called
  • Loading branch information
fkenji committed Aug 8, 2024
1 parent 7800460 commit 81680be
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 23 deletions.
19 changes: 18 additions & 1 deletion contracts/MarketTopShotOldVersion.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,24 @@ access(all) contract Market {
// The interface that a user can publish their sale as
// to allow others to access their sale
/// Deprecated: This is no longer used for defining access control anymore.
access(all) resource interface SalePublic {}
access(all) resource interface SalePublic {
access(all) var cutPercentage: UFix64
access(all) fun purchase(tokenID: UInt64, buyTokens: @DapperUtilityCoin.Vault): @TopShot.NFT {
post {
result.id == tokenID: "The ID of the withdrawn token must be the same as the requested ID"
}
}
access(all) fun getPrice(tokenID: UInt64): UFix64?
access(all) fun getIDs(): [UInt64]
access(all) fun borrowMoment(id: UInt64): &TopShot.NFT? {
// If the result isn't nil, the id of the returned reference
// should be the same as the argument to the function
post {
(result == nil) || (result?.id == id):
"Cannot borrow Moment reference: The ID of the returned reference is incorrect"
}
}
}

// SaleCollection
//
Expand Down
14 changes: 11 additions & 3 deletions contracts/TopShot.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,17 @@ access(all) contract TopShot: NonFungibleToken {
// to allow others to deposit Moments into their Collection. It also allows for reading
// the IDs of Moments in the Collection.
/// Deprecated: This is no longer used for defining access control anymore.
access(all) resource interface MomentCollectionPublic : NonFungibleToken.CollectionPublic {}
access(all) resource interface MomentCollectionPublic : NonFungibleToken.CollectionPublic {
access(all) fun batchDeposit(tokens: @{NonFungibleToken.Collection})
access(all) fun borrowMoment(id: UInt64): &TopShot.NFT? {
// If the result isn't nil, the id of the returned reference
// should be the same as the argument to the function
post {
(result == nil) || (result?.id == id):
"Cannot borrow Moment reference: The ID of the returned reference is incorrect"
}
}
}

// Collection is a resource that every user who owns NFTs
// will store in their account to manage their NFTS
Expand Down Expand Up @@ -1175,7 +1185,6 @@ access(all) contract TopShot: NonFungibleToken {
?? panic("Cannot lock: Moment does not exist in the collection")

TopShot.emitNFTUpdated(&token as auth(NonFungibleToken.Update) &{NonFungibleToken.NFT})
NonFungibleToken.emitNFTUpdated(&token as auth(NonFungibleToken.Update) &{NonFungibleToken.NFT})

// pass the token to the locking contract
// store it again after it comes back
Expand All @@ -1201,7 +1210,6 @@ access(all) contract TopShot: NonFungibleToken {
?? panic("Cannot lock: Moment does not exist in the collection")

TopShot.emitNFTUpdated(&token as auth(NonFungibleToken.Update) &{NonFungibleToken.NFT})
NonFungibleToken.emitNFTUpdated(&token as auth(NonFungibleToken.Update) &{NonFungibleToken.NFT})

// Pass the token to the TopShotLocking contract then get it back
// Store it back to the ownedNFTs dictionary
Expand Down
Loading

0 comments on commit 81680be

Please sign in to comment.