Skip to content

Commit

Permalink
Update more scripts and fix local development
Browse files Browse the repository at this point in the history
  • Loading branch information
sequel21 committed Nov 9, 2024
1 parent 2f3d9e7 commit bd4eb4f
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 187 deletions.
11 changes: 7 additions & 4 deletions flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@
"testing": "0000000000000001",
"testnet": "631e88ae7f1d7c20"
}
},
"USDCFlow": {
"aliases": {
"mainnet": "f1ab99c82dee3526",
"testing": "0000000000000007",
"testnet": "64adf39cbc354fcb"
}
}
},
"networks": {
Expand Down Expand Up @@ -169,10 +176,6 @@
"deployments": {
"emulator": {
"emulator-account": [
"Burner",
"ViewResolver",
"MetadataViews",
"NonFungibleToken",
"NFTStorefront",
"NFTCatalog",
"NFTRetrieval",
Expand Down
12 changes: 6 additions & 6 deletions lib/go/iinft/internal/assets/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{{ define "catalog_get_collection_tokens" }}
import MetadataViews from {{.MetadataViews}}
import NFTCatalog from {{.NFTCatalog}}
import NFTRetrieval from {{.NFTRetrieval}}

pub struct NFT {
pub let id: UInt64
pub let name: String
pub let description: String
pub let thumbnail: String
pub let externalURL: String
access(all) struct NFT {
access(all) let id: UInt64
access(all) let name: String
access(all) let description: String
access(all) let thumbnail: String
access(all) let externalURL: String

init(
id: UInt64,
Expand All @@ -25,26 +24,53 @@ pub struct NFT {
}
}

pub fun main(ownerAddress: Address, collectionIdentifier: String): [NFT] {
access(all) fun main(ownerAddress: Address, collectionIdentifier: String): [NFT] {
let account = getAuthAccount(ownerAddress)

let value = NFTCatalog.getCatalogEntry(collectionIdentifier: collectionIdentifier)!
let keyHash = String.encodeHex(HashAlgorithm.SHA3_256.hash(collectionIdentifier.utf8))
let tempPathStr = "catalog".concat(keyHash)
let tempPublicPath = PublicPath(identifier: tempPathStr)!

account.link<&{MetadataViews.ResolverCollection}>(
tempPublicPath,
target: value.collectionData.storagePath
)

let collectionCap = account.getCapability<&AnyResource{MetadataViews.ResolverCollection}>(tempPublicPath)

if !collectionCap.check() {
return []
}

let views = NFTRetrieval.getNFTViewsFromCap(collectionIdentifier: collectionIdentifier, collectionCap: collectionCap)
fun hasMultipleCollectionsFn(nftTypeIdentifier : String): Bool {
let typeCollections = NFTCatalog.getCollectionsForType(nftTypeIdentifier: nftTypeIdentifier)!
var numberOfCollections = 0
for identifier in typeCollections.keys {
let existence = typeCollections[identifier]!
if existence {
numberOfCollections = numberOfCollections + 1
}
if numberOfCollections > 1 {
return true
}
}
return false
}

let views : [MetadataViews.NFTView] = []

// Check if we have multiple collections for the NFT type...
let hasMultipleCollections = self.hasMultipleCollections(nftTypeIdentifier : value.nftType.identifier)

if collectionCap.check() {
let collectionRef = collectionCap.borrow()!
for id in collectionRef.getIDs() {
let nftResolver = collectionRef.borrowViewResolver(id: id)
let nftViews = MetadataViews.getNFTView(id: id, viewResolver: nftResolver!)
if !hasMultipleCollections {
views.append(nftViews)
} else if nftViews.display!.name == value.collectionDisplay.name {
views.append(nftViews)
}

}
}

let items: [NFT] = []

Expand All @@ -70,4 +96,4 @@ pub fun main(ownerAddress: Address, collectionIdentifier: String): [NFT] {

return items
}
{{ end }}
{{ end }}
Loading

0 comments on commit bd4eb4f

Please sign in to comment.