Skip to content

Commit

Permalink
Merge pull request #159 from walt-id/feat/shimmerNFTS
Browse files Browse the repository at this point in the history
Feat/shimmer nfts
  • Loading branch information
SuperBatata authored Oct 19, 2023
2 parents 24efc9e + 3162c70 commit 724804c
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/kotlin/id/walt/nftkit/rest/NftController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ data class ApproveRequest(
object NftController {
val TAG1 ="EVM based Blockchain"
val TAG2 ="General"
val TAG3 ="ShimmerEVM"
fun deploy(ctx: Context) {
val deployReq = ctx.bodyAsClass(DeployRequest::class.java)
val chain = ctx.pathParam("chain")
Expand Down Expand Up @@ -465,4 +466,16 @@ object NftController {
}.json<String>("200") { }


fun getShimmerNFTinstances(ctx: Context) {
val contractAddress = ctx.pathParam("contractAddress")
val result= NftService.getShimmerNFTinstances(contractAddress)
ctx.json(result)
}

fun getShimmerNFTinstancesDocs() = document().operation {
it.summary("Get Shimmer NFT instances")
.operationId("Get Shimmer NFT instances").addTagsItem(TAG3)
}.pathParam<String>("contractAddress") {
}.json<List<shimmerNFT>>("200") { }

}
6 changes: 6 additions & 0 deletions src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ object NftKitApi {
"chain/{chain}/contract/{contractAddress}/token/{tokenId}/getapproved",
documented(NftController.getApprovedDocs(), NftController::getApproved)
)
path("ShimmerEVM"){
post(
"contract/{contractAddress}/token/instances",
documented(NftController.getShimmerNFTinstancesDocs(), NftController::getShimmerNFTinstances)
)
}
path("tezos"){
post(
"chain/{chain}/contract/deploy",
Expand Down
72 changes: 72 additions & 0 deletions src/main/kotlin/id/walt/nftkit/services/NftService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,60 @@ data class Token(
val timeStamp: Long
)

@Serializable
data class Trait_shimmer(
val trait_type: String,
val value: String
)
@Serializable

data class Metadata(
val attributes: List<Trait_shimmer>?=null,
val description: String?=null,
val name: String?=null,
)
@Serializable
data class Owner(
val hash: String,
val implementation_name: String?,
val is_contract: Boolean,
val is_verified: Boolean?,
val name: String?,
val private_tags: List<String>?,
val public_tags: List<String>?,
val watchlist_names: List<String>?
)
@Serializable

data class Token_info(
val address: String,
val circulating_market_cap: String?,
val decimals: Int?,
val exchange_rate: String?,
val holders: String,
val icon_url: String?,
val name: String,
val symbol: String,
val total_supply: String?,
val type: String
)
@Serializable
data class Item(
val animation_url: String?,
val external_app_url: String?,
val id: String,
val image_url: String?,
val is_unique: Boolean,
val metadata: Metadata,
val owner: Owner,
val token: Token_info
)
@Serializable

data class shimmerNFT(
val items: List<Item>,
val next_page_params: String?,
)

/*@Serializable
data class NFTsAlchemyResult(
Expand Down Expand Up @@ -455,6 +509,24 @@ object NftService {
}
}


fun getShimmerNFTinstances(smartContractAddress: String) : shimmerNFT{

return runBlocking {
val url = "https://explorer.evm.testnet.shimmer.network/api/v2/tokens/${smartContractAddress}/instances"
val nfts = client.get(url)
{
contentType(ContentType.Application.Json)
}.body<shimmerNFT>()

println("nfts: $nfts")
return@runBlocking nfts
}

}



fun getAccountNFTsByAlchemy(chain: Chain, account: String): List<NFTsAlchemyResult.NftTokenByAlchemy> {
return runBlocking {
val url = when (chain) {
Expand Down

0 comments on commit 724804c

Please sign in to comment.