-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from walt-id/feat/Algorand-support
Feat/algorand support
- Loading branch information
Showing
16 changed files
with
519 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
src/main/kotlin/id/walt/nftkit/rest/AlgorandNftController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package id.walt.nftkit.rest | ||
|
||
import cc.vileda.openapi.dsl.schema | ||
|
||
import id.walt.nftkit.services.* | ||
import id.walt.nftkit.tokenownersquery.TokenOwnersDataResponse | ||
import id.walt.nftkit.utilis.Common | ||
import io.javalin.http.Context | ||
import io.javalin.plugin.openapi.dsl.document | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
|
||
|
||
|
||
object AlgorandNftController{ | ||
|
||
private const val TAG = "Algorand Blockchain: Non-fungible tokens(NFTs)" | ||
fun accountCreation(ctx : Context){ | ||
val result = AlgorandNftService.createAccount() | ||
ctx.json(result) | ||
} | ||
|
||
fun accountCreationDocs() = document().operation { | ||
it.summary("Create Algorand Account").operationId("CreateAlgorandAccount").addTagsItem("Algorand Blockchain: Non-fungible tokens(NFTs)") | ||
}.json<AlgorandAccount>(200.toString()) { | ||
it.description("Algorand Account") | ||
} | ||
|
||
|
||
fun assetCreation(ctx : Context){ | ||
val result = AlgorandNftService.createAssetArc3(ctx.pathParam("assetName"), ctx.pathParam("assetUnitName"), ctx.pathParam("url")) | ||
ctx.json(result) | ||
} | ||
|
||
fun assetCreationDocs() = document().operation { | ||
it.summary("Create Algorand Asset").operationId("CreateAlgorandAsset").addTagsItem("Algorand Blockchain: Non-fungible tokens(NFTs)") | ||
}.json<AlgodResponse>(200.toString()) { | ||
it.description("Algorand Asset") | ||
} | ||
|
||
|
||
|
||
|
||
|
||
fun fetchToken(ctx: Context){ | ||
val chain =ctx.pathParam("chain") | ||
val asset = ctx.pathParam("assetId") | ||
val response = AlgorandNftService.getToken( | ||
asset.toLong(), | ||
Common.getAlgorandChain(chain.uppercase()) | ||
) | ||
ctx.json(response) | ||
} | ||
fun fetchTokenDocs()= document().operation { | ||
it.summary("Fetching Token") | ||
.operationId("fetchToken") | ||
.addTagsItem(TAG)} | ||
.pathParam<String>("chain") { | ||
it.schema<AlgorandChain>{}} | ||
.pathParam<String>("assetId"){} | ||
.json<AlgorandToken>("200"){ | ||
it.description("Fetched token") | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
fun fetchAssetMetadata(ctx: Context){ | ||
val chain =ctx.pathParam("chain") | ||
val asset = ctx.pathParam("assetId") | ||
val response = AlgorandNftService.getAssetMeatadata( | ||
asset.toLong(), | ||
Common.getAlgorandChain(chain.uppercase()) | ||
) | ||
ctx.json(response) | ||
} | ||
fun fetchAssetMetadataDocs()= document().operation { | ||
it.summary("Fetching token parametrs ") | ||
.operationId("fetchAlgornadAssets") | ||
.addTagsItem(TAG)} | ||
.pathParam<String>("chain") { | ||
it.schema<AlgorandChain>{}} | ||
.pathParam<String>("assetId"){} | ||
.json<Asset>("200"){ | ||
it.description("Fetched token parameteres") | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
fun fetchAccountAssets(ctx: Context){ | ||
val chain = ctx.pathParam("chain") | ||
val address = ctx.pathParam("address") | ||
val response = AlgorandNftService.getAccountAssets(address, Common.getAlgorandChain(chain.uppercase())) | ||
ctx.json(response) | ||
} | ||
fun fetchAccountAssetsDocs()= document().operation { | ||
it.summary("Fetching account tokens ") | ||
.operationId("fetchAccountAssets") | ||
.addTagsItem(TAG)} | ||
.pathParam<String>("chain") { | ||
it.schema<AlgorandChain>{}} | ||
.pathParam<String>("address"){} | ||
.json<AssetHoldingsResponse>("200"){ | ||
it.description("Fetched Tokens") | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
fun fetchNftMetadata(ctx: Context){ | ||
val chain =ctx.pathParam("chain") | ||
val asset = ctx.pathParam("assetId") | ||
val result = AlgorandNftService.getNftMetadata(asset.toLong(), Common.getAlgorandChain(chain.uppercase()) ) | ||
ctx.result(Json.encodeToString(result)) | ||
|
||
} | ||
fun fetchNftMetadataDocs()= document().operation { | ||
it.summary("Fetching NFT metadata ") | ||
.operationId("fetchAlgornadNfts") | ||
.addTagsItem(TAG)} | ||
.pathParam<String>("chain") { | ||
it.schema<AlgorandChain>{}} | ||
.pathParam<String>("assetId"){} | ||
.json<AlgoNftMetadata>("200"){ | ||
it.description("Fetched NFT metadata") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.