Skip to content

Commit

Permalink
Remove dangling debugging code
Browse files Browse the repository at this point in the history
  • Loading branch information
waltkb committed Sep 11, 2023
1 parent b4404b3 commit b6e7d32
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ object PolkadotUniqueNftController {
val network: UniqueNetwork = Common.getUniqueChain(chain.uppercase())
val result = PolkadotNftService.fetchUniqueNFTsMetadata(network, account)

println("Result: $result")

ctx.result(Json.encodeToString(result))
}

Expand Down

This file was deleted.

14 changes: 3 additions & 11 deletions src/main/kotlin/id/walt/nftkit/services/PolkadotNftService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,29 +153,26 @@ object PolkadotNftService {
}

fun fetchUniqueNFTs(network: UniqueNetwork, account: String): TokenOwnersDataResponse = runBlocking {
println("--- FETCH UNIQUE NFTs")
val uniqueGraphqlClient =
GraphQLWebClient(url = getUniqueNetworkIndexerUrl(network), serializer = PolkadotGraphQLClientKotlinxSerializer())
GraphQLWebClient(url = getUniqueNetworkIndexerUrl(network), serializer = GraphQLClientKotlinxSerializer())
val tokenOwnersQuery = TokenOwnersQuery()
tokenOwnersQuery.query = tokenOwnersQuery.query.replace("address", account)
uniqueGraphqlClient.execute(tokenOwnersQuery).data!!.token_owners
}

fun fetchUniqueNFTMetadata(network: UniqueNetwork, collectionId: String, tokenId: String): TokenDataResponse? = runBlocking {
println("--- FETCH UNIQUE NFT METADATA")
val uniqueGraphqlClient =
GraphQLWebClient(url = getUniqueNetworkIndexerUrl(network), serializer = PolkadotGraphQLClientKotlinxSerializer())
GraphQLWebClient(url = getUniqueNetworkIndexerUrl(network), serializer = GraphQLClientKotlinxSerializer())
val tokensQuery = TokensQuery()
tokensQuery.query = tokensQuery.query.replace("tokenId", tokenId)
tokensQuery.query = tokensQuery.query.replace("collectionId", collectionId)
uniqueGraphqlClient.execute(tokensQuery).also { println("DATA FROM QUERY IS: ${it.data}") }.data?.tokens
uniqueGraphqlClient.execute(tokensQuery).data?.tokens
}

fun fetchUniqueNFTsMetadata(network: UniqueNetwork, account: String): List<UniqueNftMetadata> = runBlocking {
val tokens = mutableListOf<UniqueNftMetadata>()

fetchUniqueNFTs(network, account).data?.forEach {
println("Current NFT: ${it.token_id} of ${it.collection_id} on $network of $account")
val fetchResult = fetchUniqueNFTMetadata(network, it.collection_id.toString(), it.token_id.toString())
val parseResult = parseNftMetadataUniqueResponse(fetchResult!!)
tokens.add(parseResult)
Expand All @@ -187,13 +184,8 @@ object PolkadotNftService {
fun parseNftMetadataUniqueResponse(tokens: TokenDataResponse): UniqueNftMetadata {
val metadata = (tokens.data ?: throw IllegalArgumentException("Tokens have no data?"))[0]

println("Tokens: ${Json.encodeToString(tokens)}")
println("Metadata: ${Json.encodeToString(metadata)}")


val attributes = metadata.attributes?.values?.map { attributeElement ->
val attribute = attributeElement.jsonObject
println("ATTRIBUTE: $attribute")

val name = attribute["name"]!!.jsonObject["_"]!!.jsonPrimitive.content

Expand Down

0 comments on commit b6e7d32

Please sign in to comment.