Skip to content

Commit

Permalink
Merge pull request #142 from walt-id/fix/algorand_chains
Browse files Browse the repository at this point in the history
updated algorand chains names
  • Loading branch information
ahmedsmiai authored Sep 1, 2023
2 parents ff97b50 + ecc434a commit 86e14e3
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/main/kotlin/id/walt/nftkit/services/AlgorandNftService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ data class NFTStorageResponse(
val value: NFTStorageValue
)
enum class AlgorandChain{
MAINNET, TESTNET, BETANET
ALGORAND_MAINNET, ALGORAND_TESTNET, ALGORAND_BETANET
}

@Serializable
Expand Down Expand Up @@ -251,9 +251,9 @@ object AlgorandNftService {
}

val client_algod = when(chain) {
AlgorandChain.MAINNET -> AlgodClient("https://mainnet-algorand.api.purestake.io/ps2", ALGOD_PORT, ALGOD_API_TOKEN, ALGOD_API_TOKEN_KEY)
AlgorandChain.TESTNET -> AlgodClient("https://testnet-algorand.api.purestake.io/ps2", ALGOD_PORT, ALGOD_API_TOKEN, ALGOD_API_TOKEN_KEY)
AlgorandChain.BETANET -> AlgodClient("https://betanet-algorand.api.purestake.io/ps2", ALGOD_PORT, ALGOD_API_TOKEN, ALGOD_API_TOKEN_KEY)
AlgorandChain.ALGORAND_MAINNET -> AlgodClient("https://mainnet-algorand.api.purestake.io/ps2", ALGOD_PORT, ALGOD_API_TOKEN, ALGOD_API_TOKEN_KEY)
AlgorandChain.ALGORAND_TESTNET -> AlgodClient("https://testnet-algorand.api.purestake.io/ps2", ALGOD_PORT, ALGOD_API_TOKEN, ALGOD_API_TOKEN_KEY)
AlgorandChain.ALGORAND_BETANET -> AlgodClient("https://betanet-algorand.api.purestake.io/ps2", ALGOD_PORT, ALGOD_API_TOKEN, ALGOD_API_TOKEN_KEY)
}
val SRC_ACCOUNT = loadAlgorand().algorandConfig.algorand_seed_Mnemonic
val src = Account(SRC_ACCOUNT)
Expand Down Expand Up @@ -282,9 +282,9 @@ object AlgorandNftService {
val encodedTxBytes = Encoder.encodeToMsgPack(signedTx)
val txResponse = client_algod.RawTransaction().rawtxn(encodedTxBytes).execute(txHeaders, txValues).body()
return when(chain) {
AlgorandChain.MAINNET -> AlgodResponse(txResponse.txId, "$ALGORAND_MAINNET_EXPLORER"+"tx/${txResponse.txId}")
AlgorandChain.TESTNET -> AlgodResponse(txResponse.txId, "$ALGORAND_TESTNET_EXPLORER"+"tx/${txResponse.txId}")
AlgorandChain.BETANET -> AlgodResponse(txResponse.txId, "$ALGORAND_BETANET_EXPLORER"+"tx/${txResponse.txId}")
AlgorandChain.ALGORAND_MAINNET -> AlgodResponse(txResponse.txId, "$ALGORAND_MAINNET_EXPLORER"+"tx/${txResponse.txId}")
AlgorandChain.ALGORAND_TESTNET -> AlgodResponse(txResponse.txId, "$ALGORAND_TESTNET_EXPLORER"+"tx/${txResponse.txId}")
AlgorandChain.ALGORAND_BETANET -> AlgodResponse(txResponse.txId, "$ALGORAND_BETANET_EXPLORER"+"tx/${txResponse.txId}")
}
} catch (e: Exception) {
e.printStackTrace()
Expand All @@ -296,9 +296,9 @@ object AlgorandNftService {
fun getToken(assetId: String, chain: AlgorandChain): AlgorandToken {
return runBlocking {
val API_ADDR = when (chain) {
AlgorandChain.MAINNET -> "https://mainnet-api.algonode.cloud"
AlgorandChain.TESTNET -> "https://testnet-api.algonode.cloud"
AlgorandChain.BETANET -> "https://betanet-api.algonode.cloud"
AlgorandChain.ALGORAND_MAINNET -> "https://mainnet-api.algonode.cloud"
AlgorandChain.ALGORAND_TESTNET -> "https://testnet-api.algonode.cloud"
AlgorandChain.ALGORAND_BETANET -> "https://betanet-api.algonode.cloud"
}
val tokenParams = client.get(API_ADDR + "/v2/assets/" + assetId){
contentType(ContentType.Application.Json)
Expand All @@ -324,9 +324,9 @@ object AlgorandNftService {
fun getAssetMeatadata(assetId: String, chain: AlgorandChain): Asset {
return runBlocking {
val API_ADDR = when (chain) {
AlgorandChain.MAINNET -> "https://mainnet-api.algonode.cloud"
AlgorandChain.TESTNET -> "https://testnet-api.algonode.cloud"
AlgorandChain.BETANET -> "https://betanet-api.algonode.cloud"
AlgorandChain.ALGORAND_MAINNET -> "https://mainnet-api.algonode.cloud"
AlgorandChain.ALGORAND_TESTNET -> "https://testnet-api.algonode.cloud"
AlgorandChain.ALGORAND_BETANET -> "https://betanet-api.algonode.cloud"
}
val asset = client.get(API_ADDR + "/v2/assets/" + assetId){
contentType(ContentType.Application.Json)
Expand All @@ -353,9 +353,9 @@ object AlgorandNftService {

fun getAccountAssets(address: String, chain: AlgorandChain): List<AlgorandToken> {
val API_ADDR = when (chain) {
AlgorandChain.MAINNET -> "https://mainnet-idx.algonode.cloud"
AlgorandChain.TESTNET -> "https://testnet-idx.algonode.cloud"
AlgorandChain.BETANET -> "https://betanet-idx.algonode.cloud"
AlgorandChain.ALGORAND_MAINNET -> "https://mainnet-idx.algonode.cloud"
AlgorandChain.ALGORAND_TESTNET -> "https://testnet-idx.algonode.cloud"
AlgorandChain.ALGORAND_BETANET -> "https://betanet-idx.algonode.cloud"
}

return runBlocking {
Expand All @@ -379,9 +379,9 @@ object AlgorandNftService {
fun verifyOwnership(address: String, assetId:String, chain: AlgorandChain): AccountAssetResponse{
return runBlocking {
val API_ADDR = when (chain) {
AlgorandChain.MAINNET -> "https://mainnet-api.algonode.cloud"
AlgorandChain.TESTNET -> "https://testnet-api.algonode.cloud"
AlgorandChain.BETANET -> "https://betanet-api.algonode.cloud"
AlgorandChain.ALGORAND_MAINNET -> "https://mainnet-api.algonode.cloud"
AlgorandChain.ALGORAND_TESTNET -> "https://testnet-api.algonode.cloud"
AlgorandChain.ALGORAND_BETANET -> "https://betanet-api.algonode.cloud"
}
val response =
client.get(API_ADDR+"/v2/accounts/"+address+"/assets/"+assetId){
Expand Down

0 comments on commit 86e14e3

Please sign in to comment.