-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,24 @@ pub contract NFTRetrieval { | |
return false | ||
} | ||
|
||
pub fun getInventory(address:Address) : {String: [UInt64]} { | ||
let inventory : {String:[UInt64]}={} | ||
let account=getAccount(address) | ||
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 path =catalogEntry.collectionData.publicPath | ||
let cap= account.getCapability<&{MetadataViews.ResolverCollection}>(path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't be guaranteed to exist just a heads up There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will not be guaranteed to not exist? I check if the cap is linked on the next line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The capability is linked |
||
if cap.check(){ | ||
inventory[nftType] = cap.borrow()!.getIDs() | ||
} | ||
} | ||
return inventory | ||
} | ||
|
||
init() {} | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 0 index here? Do we want to handle the case if one nft type has multiple collections like Mint Store?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the collections are stored in the same path, we just want the ids of them all. Paritioning these into subcollections will take up a lot of gas since you need to borrow each one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!