github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/main/cadence/scripts/custom/get_nba_topshot_trailblazers.cdc (about)

     1  import TopShot from "TOPSHOT_ADDRESS" 
     2  import MetadataViews from "METADATA_VIEWS_ADDRESS"
     3  
     4  pub fun main(address: Address): [UInt64] {
     5  
     6      let account = getAccount(address)
     7  
     8      let collectionRef = account.getCapability(/public/MomentCollection)
     9                              .borrow<&{TopShot.MomentCollectionPublic}>()!
    10  
    11      let ids = collectionRef.getIDs()
    12  
    13      let nftIds: [UInt64] = []
    14  
    15      for id in ids {
    16          let nft = collectionRef.borrowMoment(id: id)!
    17          let view = nft.resolveView(Type<TopShot.TopShotMomentMetadataView>())!
    18          let metadata = view as! TopShot.TopShotMomentMetadataView
    19  
    20          if metadata.teamAtMoment == "Portland Trailblazers" {
    21               nftIds.append(id)
    22          }
    23      }
    24      
    25      return nftIds
    26  }
    27