Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cadence/contracts/NFTRetrieval.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ pub contract NFTRetrieval {

init() {}

}
}
26 changes: 26 additions & 0 deletions cadence/scripts/get_nft_collections_in_account.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import MetadataViews from "./MetadataViews.cdc"
import NFTCatalog from "./NFTCatalog.cdc"


pub fun main(ownerAddress: Address) : {String:[UInt64]} {

let account = getAuthAccount(ownerAddress)

let inventory : {String:[UInt64]}={}
let collections : {String:PublicPath} ={}
let types = NFTCatalog.getCatalogTypeData()
for nftType in types.keys {

let typeData=types[nftType]!
let collectionKey=typeData.keys[0]
let catalogEntry = NFTCatalog.getCatalogEntry(collectionIdentifier:collectionKey)!
let tempPathStr = "catalog".concat(collectionKey)
let tempPublicPath = PublicPath(identifier: tempPathStr)!
account.link<&{MetadataViews.ResolverCollection}>(tempPublicPath, target: catalogEntry.collectionData.storagePath)
let cap= account.getCapability<&{MetadataViews.ResolverCollection}>(tempPublicPath)
if cap.check(){
inventory[nftType] = cap.borrow()!.getIDs()
}
}
return inventory
}