Skip to content

Commit

Permalink
reveal and open from collection
Browse files Browse the repository at this point in the history
  • Loading branch information
loic1 committed Jun 12, 2024
1 parent e87e024 commit 4bf9ff8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
12 changes: 9 additions & 3 deletions pds/contracts/IPackNFT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,19 @@ access(all) contract interface IPackNFT{
access(all) resource interface NFT: NonFungibleToken.NFT, IPackNFTToken, IPackNFTOwnerOperator {
access(all) let id: UInt64
access(all) let issuer: Address
access(NonFungibleToken.Update) fun reveal(openRequest: Bool)
access(NonFungibleToken.Update) fun open()
access(contract) fun reveal(openRequest: Bool)
access(contract) fun open()
}

/// Resource interface for PackNFT Collection
///
access(all) resource interface IPackNFTCollectionPublic {
access(NonFungibleToken.Update) fun reveal(id: UInt64, openRequest: Bool)
access(NonFungibleToken.Update) fun open(id: UInt64)
}

// Included for backwards compatibility
access(all) resource interface IPackNFTOwnerOperator{}
access(all) resource interface IPackNFTCollectionPublic {}

/// Emit a RevealRequest event to signal a Sealed Pack NFT should be revealed
///
Expand Down
18 changes: 16 additions & 2 deletions pds/contracts/PackNFT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {

/// Reveal a Sealed Pack resource.
///
access(NonFungibleToken.Update) fun reveal(openRequest: Bool) {
access(contract) fun reveal(openRequest: Bool) {
PackNFT.revealRequest(id: self.id, openRequest: openRequest)
}

/// Open a Revealed Pack resource.
///
access(NonFungibleToken.Update) fun open() {
access(contract) fun open() {
PackNFT.openRequest(id: self.id)
}

Expand Down Expand Up @@ -241,6 +241,20 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {
destroy oldToken
}

/// Reveal a Sealed Pack resource.
///
access(NonFungibleToken.Update) fun reveal(id: UInt64, openRequest: Bool) {
let packRef = self.borrowNFT(id) as! &NFT
packRef.reveal(openRequest: openRequest)
}

/// Open a Revealed Pack resource.
///
access(NonFungibleToken.Update) fun open(id: UInt64) {
let packRef = self.borrowNFT(id) as! &NFT
packRef.open()
}

/// Return an array of the IDs that are in the collection.
///
access(all) view fun getIDs(): [UInt64] {
Expand Down
Loading

0 comments on commit 4bf9ff8

Please sign in to comment.