Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added getInvetory retriever method fixes #30 #32

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
}