From d5824a2ab123542e50d134b1f7c3fd7e15abd0a9 Mon Sep 17 00:00:00 2001 From: SuperBatata Date: Thu, 19 Oct 2023 13:34:05 +0100 Subject: [PATCH 1/3] get token instances for shimmer contract --- .../id/walt/nftkit/services/NftService.kt | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/main/kotlin/id/walt/nftkit/services/NftService.kt b/src/main/kotlin/id/walt/nftkit/services/NftService.kt index 955f1070..21cedaa2 100644 --- a/src/main/kotlin/id/walt/nftkit/services/NftService.kt +++ b/src/main/kotlin/id/walt/nftkit/services/NftService.kt @@ -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?=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?, + val public_tags: List?, + val watchlist_names: List? +) +@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, + val next_page_params: String?, +) /*@Serializable data class NFTsAlchemyResult( @@ -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() + + println("nfts: $nfts") + return@runBlocking nfts + } + + } + + + fun getAccountNFTsByAlchemy(chain: Chain, account: String): List { return runBlocking { val url = when (chain) { From feffccf3fd26db8399f4cf4e027d8d329fabfb97 Mon Sep 17 00:00:00 2001 From: SuperBatata Date: Thu, 19 Oct 2023 13:34:51 +0100 Subject: [PATCH 2/3] added shimmer endpoint --- src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt b/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt index 9093b895..f33730f8 100644 --- a/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt +++ b/src/main/kotlin/id/walt/nftkit/rest/NftKitApi.kt @@ -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", From 3162c7084d2f51acc2be7d2d869b6b51171c0175 Mon Sep 17 00:00:00 2001 From: SuperBatata Date: Thu, 19 Oct 2023 13:35:22 +0100 Subject: [PATCH 3/3] nft instances controller --- .../kotlin/id/walt/nftkit/rest/NftController.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/kotlin/id/walt/nftkit/rest/NftController.kt b/src/main/kotlin/id/walt/nftkit/rest/NftController.kt index dca0a0e8..b9014693 100644 --- a/src/main/kotlin/id/walt/nftkit/rest/NftController.kt +++ b/src/main/kotlin/id/walt/nftkit/rest/NftController.kt @@ -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") @@ -465,4 +466,16 @@ object NftController { }.json("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("contractAddress") { + }.json>("200") { } + }