query.gno
1.14 Kb ยท 46 lines
1package nftregistry3
2
3// Query functions for frontend or marketplaces
4
5// GetAllCollections - Returns all registered collections
6func GetAllCollections() []CollectionInfo {
7 result := make([]CollectionInfo, 0, totalCollections)
8
9 collections.Iterate("", "", func(key string, value interface{}) bool {
10 info := value.(*CollectionInfo)
11 result = append(result, *info)
12 return false
13 })
14
15 return result
16}
17
18// GetVerifiedCollections - Returns only verified collections
19func GetVerifiedCollections() []CollectionInfo {
20 result := make([]CollectionInfo, 0, verifiedCount)
21
22 collections.Iterate("", "", func(key string, value interface{}) bool {
23 info := value.(*CollectionInfo)
24 if info.Verified {
25 result = append(result, *info)
26 }
27 return false
28 })
29
30 return result
31}
32
33// GetCollectionsByCategory - Returns collections in a specific category
34func GetCollectionsByCategory(category string) []CollectionInfo {
35 result := make([]CollectionInfo, 0)
36
37 collections.Iterate("", "", func(key string, value interface{}) bool {
38 info := value.(*CollectionInfo)
39 if info.Category == category {
40 result = append(result, *info)
41 }
42 return false
43 })
44
45 return result
46}