Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
loic1 committed May 30, 2024
1 parent 471f8e4 commit f2a05f2
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 51 deletions.
4 changes: 2 additions & 2 deletions pds/contracts/PackNFT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {
switch viewType {
case Type<MetadataViews.NFTCollectionData>():
let collectionData = MetadataViews.NFTCollectionData(
storagePath: /storage/cadenceExampleNFTCollection,
publicPath: /public/cadenceExampleNFTCollection,
storagePath: /storage/exampleNFTCollection,
publicPath: /public/exampleNFTCollection,
publicCollection: Type<&Collection>(),
publicLinkedType: Type<&Collection>(),
createEmptyCollectionFunction: (fun(): @{NonFungibleToken.Collection} {
Expand Down
4 changes: 2 additions & 2 deletions pds/contracts/PackNFT_AllDay.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {
switch viewType {
case Type<MetadataViews.NFTCollectionData>():
let collectionData = MetadataViews.NFTCollectionData(
storagePath: /storage/cadenceExampleNFTCollection,
publicPath: /public/cadenceExampleNFTCollection,
storagePath: /storage/exampleNFTCollection,
publicPath: /public/exampleNFTCollection,
publicCollection: Type<&Collection>(),
publicLinkedType: Type<&Collection>(),
createEmptyCollectionFunction: (fun(): @{NonFungibleToken.Collection} {
Expand Down
4 changes: 2 additions & 2 deletions pds/contracts/PackNFT_TopShot.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ access(all) contract PackNFT: NonFungibleToken, IPackNFT {
switch viewType {
case Type<MetadataViews.NFTCollectionData>():
let collectionData = MetadataViews.NFTCollectionData(
storagePath: /storage/cadenceExampleNFTCollection,
publicPath: /public/cadenceExampleNFTCollection,
storagePath: /storage/exampleNFTCollection,
publicPath: /public/exampleNFTCollection,
publicCollection: Type<&Collection>(),
publicLinkedType: Type<&Collection>(),
createEmptyCollectionFunction: (fun(): @{NonFungibleToken.Collection} {
Expand Down
6 changes: 3 additions & 3 deletions pds/contracts/imports/ExampleNFT.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ access(all) contract ExampleNFT: NonFungibleToken {

init () {
self.ownedNFTs <- {}
let identifier = "cadenceExampleNFTCollection"
let identifier = "exampleNFTCollection"
self.storagePath = StoragePath(identifier: identifier)!
self.publicPath = PublicPath(identifier: identifier)!
}
Expand Down Expand Up @@ -232,8 +232,8 @@ access(all) contract ExampleNFT: NonFungibleToken {
switch viewType {
case Type<MetadataViews.NFTCollectionData>():
let collectionData = MetadataViews.NFTCollectionData(
storagePath: /storage/cadenceExampleNFTCollection,
publicPath: /public/cadenceExampleNFTCollection,
storagePath: /storage/exampleNFTCollection,
publicPath: /public/exampleNFTCollection,
publicCollection: Type<&ExampleNFT.Collection>(),
publicLinkedType: Type<&ExampleNFT.Collection>(),
createEmptyCollectionFunction: (fun(): @{NonFungibleToken.Collection} {
Expand Down
27 changes: 17 additions & 10 deletions pds/contracts/imports/NonFungibleToken.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Collection to complete the transfer.
*/

import ViewResolver from "ViewResolver"
import "ViewResolver"

/// The main NFT contract. Other NFT contracts will
/// import and implement the interfaces defined in this contract
Expand All @@ -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(contract) 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 All @@ -85,9 +82,6 @@ access(all) contract interface NonFungibleToken: ViewResolver {
///
access(all) event Deposited(type: String, id: UInt64, uuid: UInt64, to: Address?, collectionUUID: UInt64)

/// Included for backwards-compatibility
access(all) resource interface INFT: NFT {}

/// Interface that the NFTs must conform to
///
access(all) resource interface NFT: ViewResolver.Resolver {
Expand All @@ -105,6 +99,7 @@ access(all) contract interface NonFungibleToken: ViewResolver {
access(all) fun createEmptyCollection(): @{Collection} {
post {
result.getLength() == 0: "The created collection must be empty!"
result.isSupportedNFTType(type: self.getType()): "The created collection must support this NFT type"
}
}

Expand Down Expand Up @@ -141,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 Expand Up @@ -174,6 +169,7 @@ access(all) contract interface NonFungibleToken: ViewResolver {
access(all) fun deposit(token: @{NFT})
access(all) view fun getLength(): Int
access(all) view fun getIDs(): [UInt64]
access(all) fun forEachID(_ f: fun (UInt64): Bool): Void
access(all) view fun borrowNFT(_ id: UInt64): &{NFT}?
}

Expand All @@ -182,6 +178,8 @@ access(all) contract interface NonFungibleToken: ViewResolver {
///
access(all) resource interface Collection: Provider, Receiver, CollectionPublic, ViewResolver.ResolverCollection {

access(all) var ownedNFTs: @{UInt64: {NonFungibleToken.NFT}}

/// deposit takes a NFT as an argument and stores it in the collection
/// @param token: The NFT to deposit into the collection
access(all) fun deposit(token: @{NonFungibleToken.NFT}) {
Expand All @@ -196,7 +194,16 @@ access(all) contract interface NonFungibleToken: ViewResolver {

/// Gets the amount of NFTs stored in the collection
/// @return An integer indicating the size of the collection
access(all) view fun getLength(): Int
access(all) view fun getLength(): Int {
return self.ownedNFTs.length
}

/// Allows a given function to iterate through the list
/// of owned NFT IDs in a collection without first
/// having to load the entire list into memory
access(all) fun forEachID(_ f: fun (UInt64): Bool): Void {
self.ownedNFTs.forEachKey(f)
}

/// Borrows a reference to an NFT stored in the collection
/// If the NFT with the specified ID is not in the collection,
Expand Down
4 changes: 2 additions & 2 deletions pds/flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
"source": "./contracts/PDS.cdc",
"aliases": {
"mainnet": "b6f2481eba4df97b",
"testnet": "18ddf0823a55a0ee"
"testnet": "ef4cd3d07a7b43ce"
}
},
"IPackNFT": {
"source": "./contracts/IPackNFT.cdc",
"aliases": {
"mainnet": "18ddf0823a55a0ee",
"testnet": "a2526e2d9cc7f0d2"
"testnet": "d8f6346999b983f5"
}
},
"PackNFT": {
Expand Down
Loading

0 comments on commit f2a05f2

Please sign in to comment.