Skip to content

Commit

Permalink
clean up conformances (following emulator state migration fix), add b…
Browse files Browse the repository at this point in the history
…urnCallback & comments
  • Loading branch information
loic1 committed Mar 25, 2024
1 parent cc91459 commit befe7b2
Show file tree
Hide file tree
Showing 10 changed files with 410 additions and 224 deletions.
43 changes: 29 additions & 14 deletions pds/contracts/IPackNFT.cdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Crypto
import NonFungibleToken from "NonFungibleToken"

/// Contract interface for PackNFT contracts.
///
access(all) contract interface IPackNFT{

/// Entitlement to perform operations on the PackNFT
Expand All @@ -10,39 +12,49 @@ access(all) contract interface IPackNFT{
/// StoragePath for Collection Resource
///
access(all) let CollectionStoragePath: StoragePath

/// PublicPath expected for deposit
///
access(all) let CollectionPublicPath: PublicPath

/// PublicPath for receiving PackNFT
///
access(all) let CollectionIPackNFTPublicPath: PublicPath

/// StoragePath for the PackNFT Operator Resource (issuer owns this)
///
access(all) let OperatorStoragePath: StoragePath

/// Request for Reveal
///
access(all) event RevealRequest(id: UInt64, openRequest: Bool)

/// Request for Open
///
/// This is emitted when owner of a PackNFT request for the entitled NFT to be
/// deposited to its account
access(all) event OpenRequest(id: UInt64)

/// Burned
///
/// Emitted when a PackNFT has been burned
access(all) event Burned(id: UInt64 )

/// Opened
///
/// Emitted when a packNFT has been opened
access(all) event Opened(id: UInt64)

// TODO: Clean up after enum handling/removal is clarified.
// Enums cannot be declared anymore in interfaces in Cadence 1.0
// access(all) enum Status: UInt8 {
// access(all) case Sealed
// access(all) case Revealed
// access(all) case Opened
// }
/// Struct interface for Collectible
///
access(all) struct interface Collectible {
access(all) let address: Address
access(all) let contractName: String
Expand All @@ -51,6 +63,8 @@ access(all) contract interface IPackNFT{
init(address: Address, contractName: String, id: UInt64)
}

/// Resource interface for PackNFT
///
access(all) resource interface IPack {
access(all) let issuer: Address
// access(all) var status: Status
Expand All @@ -62,6 +76,8 @@ access(all) contract interface IPackNFT{
init(commitHash: String, issuer: Address)
}

/// Resource interface for IOperator
///
access(all) resource interface IOperator {
access(Operatable) fun mint(distId: UInt64, commitHash: String, issuer: Address): @{IPackNFT.NFT}
access(Operatable) fun reveal(id: UInt64, nfts: [{Collectible}], salt: String)
Expand All @@ -71,11 +87,15 @@ access(all) contract interface IPackNFT{
// Included for backwards compatibility
access(all) resource interface PackNFTOperator: IOperator {}

/// Resource interface for IPackNFTToken
///
access(all) resource interface IPackNFTToken {
access(all) let id: UInt64
access(all) let issuer: Address
}

/// Resource interface for NFT
///
access(all) resource interface NFT: NonFungibleToken.INFT, IPackNFTToken, IPackNFTOwnerOperator {
access(all) let id: UInt64
access(all) let issuer: Address
Expand All @@ -85,22 +105,17 @@ access(all) contract interface IPackNFT{

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

access(all) resource interface IPackNFTCollectionPublic {
access(all) fun deposit(token: @{NonFungibleToken.NFT})
view access(all) fun getIDs(): [UInt64]
view access(all) fun borrowNFT(_ id: UInt64): &{NonFungibleToken.NFT}?
view access(all) fun borrowPackNFT(id: UInt64): &{IPackNFT.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 PackNFT reference: The ID of the returned reference is incorrect"
}
}
}

/// Emit a RevealRequest event to signal a Sealed Pack NFT should be revealed
///
access(contract) fun revealRequest(id: UInt64, openRequest: Bool)

/// Emit an OpenRequest event to signal a Revealed Pack NFT should be opened
///
access(contract) fun openRequest(id: UInt64)

/// Reveal a Sealed Pack NFT
///
access(all) fun publicReveal(id: UInt64, nfts: [{IPackNFT.Collectible}], salt: String)
}
Loading

0 comments on commit befe7b2

Please sign in to comment.