Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/shimmer nfts #159

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading