Skip to content

Commit

Permalink
change type resource interface
Browse files Browse the repository at this point in the history
  • Loading branch information
loic1 committed Mar 19, 2024
1 parent 5e4effc commit e795051
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions pds/contracts/IPackNFT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ access(all) contract interface IPackNFT{
/// Emitted when a packNFT has been opened
access(all) event Opened(id: UInt64)

// Enums cannot be declared anymore in interfaces in Cadence 1.0
// access(all) enum Status: UInt8 {
// access(all) case Sealed
// access(all) case Revealed
Expand All @@ -62,7 +63,7 @@ access(all) contract interface IPackNFT{
}

access(all) resource interface IOperator {
access(Operatable) fun mint(distId: UInt64, commitHash: String, issuer: Address): @{IPackNFT.INFT}
access(Operatable) fun mint(distId: UInt64, commitHash: String, issuer: Address): @{IPackNFT.NFT}
access(Operatable) fun reveal(id: UInt64, nfts: [{Collectible}], salt: String)
access(Operatable) fun open(id: UInt64, nfts: [{IPackNFT.Collectible}])
}
Expand All @@ -75,7 +76,7 @@ access(all) contract interface IPackNFT{
access(all) let issuer: Address
}

access(all) resource interface INFT: NonFungibleToken.NFT, IPackNFTToken {
access(all) resource interface NFT: NonFungibleToken.INFT, IPackNFTToken, IPackNFTOwnerOperator {
access(all) let id: UInt64
access(all) let issuer: Address
access(NonFungibleToken.Update | NonFungibleToken.Owner) fun reveal(openRequest: Bool)
Expand All @@ -89,7 +90,7 @@ access(all) contract interface IPackNFT{
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.INFT}? {
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 {
Expand Down
8 changes: 4 additions & 4 deletions pds/contracts/PackNFT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {

access(all) resource PackNFTOperator: IPackNFT.IOperator {

access(IPackNFT.Operatable) fun mint(distId: UInt64, commitHash: String, issuer: Address): @{IPackNFT.INFT} {
access(IPackNFT.Operatable) fun mint(distId: UInt64, commitHash: String, issuer: Address): @{IPackNFT.NFT} {
let nft <- create NFT(commitHash: commitHash, issuer: issuer)
PackNFT.totalSupply = PackNFT.totalSupply + 1
let p <-create Pack(commitHash: commitHash, issuer: issuer)
Expand Down Expand Up @@ -115,7 +115,7 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {
IPackNFT.IPackNFTToken,
IPackNFT.IPackNFTOwnerOperator,
NonFungibleToken.NFT,
IPackNFT.INFT
IPackNFT.NFT
{
access(all) let id: UInt64
access(all) let hash: [UInt8]
Expand Down Expand Up @@ -234,8 +234,8 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {
return &self.ownedNFTs[id]
}

view access(all) fun borrowPackNFT(id: UInt64): &{IPackNFT.INFT}? {
return self.borrowNFT(id) as! &{IPackNFT.INFT}?
view access(all) fun borrowPackNFT(id: UInt64): &{IPackNFT.NFT}? {
return self.borrowNFT(id) as! &{IPackNFT.NFT}?
}

/// createEmptyCollection creates an empty Collection of the same type
Expand Down
8 changes: 4 additions & 4 deletions pds/contracts/PackNFT_AllDay.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {

access(all) resource PackNFTOperator: IPackNFT.IOperator {

access(IPackNFT.Operatable) fun mint(distId: UInt64, commitHash: String, issuer: Address): @{IPackNFT.INFT}{
access(IPackNFT.Operatable) fun mint(distId: UInt64, commitHash: String, issuer: Address): @{IPackNFT.NFT}{
let nft <- create NFT(commitHash: commitHash, issuer: issuer)
PackNFT.totalSupply = PackNFT.totalSupply + 1
let p <-create Pack(commitHash: commitHash, issuer: issuer)
Expand Down Expand Up @@ -111,7 +111,7 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {
}
}

access(all) resource NFT: NonFungibleToken.INFT, IPackNFT.IPackNFTToken, IPackNFT.IPackNFTOwnerOperator, NonFungibleToken.NFT, IPackNFT.INFT {
access(all) resource NFT: NonFungibleToken.INFT, IPackNFT.IPackNFTToken, IPackNFT.IPackNFTOwnerOperator, NonFungibleToken.NFT, IPackNFT.NFT {
access(all) let id: UInt64
access(all) let commitHash: String
access(all) let issuer: Address
Expand Down Expand Up @@ -316,8 +316,8 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {
return &self.ownedNFTs[id]
}

view access(all) fun borrowPackNFT(id: UInt64): &{IPackNFT.INFT}? {
return self.borrowNFT(id) as! &{IPackNFT.INFT}?
view access(all) fun borrowPackNFT(id: UInt64): &{IPackNFT.NFT}? {
return self.borrowNFT(id) as! &{IPackNFT.NFT}?
}

/// createEmptyCollection creates an empty Collection of the same type
Expand Down

0 comments on commit e795051

Please sign in to comment.