Skip to content

Commit

Permalink
feat add support to iota evm testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperBatata committed Jul 22, 2024
1 parent 9a1f788 commit fd6d26b
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/id/walt/nftkit/Values.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ object Values {
const val MOONBEAM_MAINNET_CHAIN_ID: Long = 1284
const val ASTAR_MAINNET_CHAIN_ID: Long = 592
const val SHIMMEREVM_TESTNET_CHAIN_ID: Long = 1073
const val SHIMMEREVM_APPCHAIN_CHAIN_ID: Long = 1074
const val IOTA_TESTNET_CHAIN_ID: Long = 1075

const val ETHEREUM_MAINNET_SCAN_API_URL= "api.etherscan.io"
const val ETHEREUM_TESTNET_GOERLI_SCAN_API_URL = "api-goerli.etherscan.io"
const val ETHEREUM_TESTNET_SEPOLIA_SCAN_API_URL = "api-sepolia.etherscan.io"
const val POLYGON_MAINNET_SCAN_API_URL = "api.polygonscan.com"
const val POLYGON_TESTNET_AMOY_SCAN_API_URL = "api-testnet.polygonscan.com"
const val SHIMMEREVM_APPCHAIN_BLOCK_EXPLORER_URL = ""
const val IOTA_TESTNET_BLOCK_EXPLORER_URL = "https://explorer.evm.testnet.iotaledger.net"

const val ETHEREUM_MAINNET_BLOCK_EXPLORER_URL = "https://etherscan.io"
const val ETHEREUM_TESTNET_GOERLI_BLOCK_EXPLORER_URL = "https://goerli.etherscan.io/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ object Erc721TokenStandard : IErc721TokenStandard {
EVMChain.ASTAR -> Values.ASTAR_MAINNET_CHAIN_ID
EVMChain.MOONBEAM -> Values.MOONBEAM_MAINNET_CHAIN_ID
EVMChain.SHIMMEREVM -> Values.SHIMMEREVM_TESTNET_CHAIN_ID
EVMChain.SHIMMEREVM_APPCHAIN -> Values.SHIMMEREVM_APPCHAIN_CHAIN_ID
EVMChain.IOTA_TESTNET -> Values.IOTA_TESTNET_CHAIN_ID
}
val transactionManager: TransactionManager = RawTransactionManager(
web3j, credentials, chainId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ object SoulBoundTokenStandard : ISoulBoundTokenStandard {
private fun loadContract(chain: EVMChain, address: String, signedAccount: String? ="") : WaltidSoulBound {
val web3j = ProviderFactory.getProvider(chain)?.getWeb3j()

val privateKey: String = if((signedAccount == null || "" == (signedAccount)) && chain == EVMChain.SHIMMEREVM_APPCHAIN){
WaltIdServices.loadChainConfig().privateKeyAppchain
val privateKey: String = if((signedAccount == null || "" == (signedAccount)) && chain == EVMChain.IOTA_TESTNET){
WaltIdServices.loadChainConfig().privateKeyIotaTestnet
}else if(signedAccount == null || "" == (signedAccount) ) {
WaltIdServices.loadChainConfig().privateKey
}
Expand All @@ -49,7 +49,7 @@ object SoulBoundTokenStandard : ISoulBoundTokenStandard {
EVMChain.ASTAR -> Values.ASTAR_MAINNET_CHAIN_ID
EVMChain.MOONBEAM -> Values.MOONBEAM_MAINNET_CHAIN_ID
EVMChain.SHIMMEREVM -> Values.SHIMMEREVM_TESTNET_CHAIN_ID
EVMChain.SHIMMEREVM_APPCHAIN -> Values.SHIMMEREVM_APPCHAIN_CHAIN_ID
EVMChain.IOTA_TESTNET -> Values.IOTA_TESTNET_CHAIN_ID
}
val transactionManager: TransactionManager = RawTransactionManager(
web3j, credentials, chainId
Expand Down Expand Up @@ -106,7 +106,7 @@ object SoulBoundTokenStandard : ISoulBoundTokenStandard {
EVMChain.ASTAR -> Values.ASTAR_MAINNET_CHAIN_ID
EVMChain.MOONBEAM -> Values.MOONBEAM_MAINNET_CHAIN_ID
EVMChain.SHIMMEREVM -> Values.SHIMMEREVM_TESTNET_CHAIN_ID
EVMChain.SHIMMEREVM_APPCHAIN -> Values.SHIMMEREVM_APPCHAIN_CHAIN_ID
EVMChain.IOTA_TESTNET -> Values.IOTA_TESTNET_CHAIN_ID
}

val web3j = ProviderFactory.getProvider(chain)?.getWeb3j()
Expand Down
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("IOTA_TESTNET"){
post(
"contract/{contractAddress}/token/instances",
documented(NftController.getShimmerNFTinstancesDocs(), NftController::getShimmerNFTinstances)
)
}
path("ShimmerEVM"){
post(
"contract/{contractAddress}/token/instances",
Expand Down
7 changes: 4 additions & 3 deletions src/main/kotlin/id/walt/nftkit/services/NftService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ enum class Chain {
ALGORAND_TESTNET,
ALGORAND_BETANET,
SHIMMEREVM,
SHIMMEREVM_APPCHAIN
IOTA_TESTNET
}

enum class EVMChain {
Expand All @@ -107,7 +107,8 @@ enum class EVMChain {
ASTAR,
MOONBEAM,
SHIMMEREVM,
SHIMMEREVM_APPCHAIN
// SHIMMEREVM_APPCHAIN,
IOTA_TESTNET
}

enum class TokenStandard {
Expand Down Expand Up @@ -517,7 +518,7 @@ object NftService {
fun getShimmerNFTinstances(smartContractAddress: String) : shimmerNFT {

return runBlocking {
val url = "https://explorer.evm.testnet.shimmer.network/api/v2/tokens/${smartContractAddress}/instances"
val url = "https://explorer.evm.testnet.iotaledger.net/api/v2/tokens/${smartContractAddress}/instances"
val nfts = client.get(url)
{
contentType(ContentType.Application.Json)
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/id/walt/nftkit/services/WaltIdServices.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ data class Providers(
val opal: String,
val unique: String,
val shimmerevm: String,
val shimmerevmAppChain : String
val iotatestnet : String
)

data class ChainConfig(val providers: Providers, val privateKey: String , val privateKeyAppchain: String)
data class ChainConfig(val providers: Providers, val privateKey: String , val privateKeyIotaTestnet: String)

data class KeysConfig(val keys: Map<String, String>)

Expand Down Expand Up @@ -147,7 +147,7 @@ object WaltIdServices {
EVMChain.POLYGON -> Values.POLYGON_MAINNET_BLOCK_EXPLORER_URL
EVMChain.AMOY -> Values.POLYGON_TESTNET_AMOY_BLOCK_EXPLORER_URL
EVMChain.SHIMMEREVM -> Values.SHIMMEREVM_TESTNET_BLOCK_EXPLORER_URL
EVMChain.SHIMMEREVM_APPCHAIN -> Values.SHIMMEREVM_APPCHAIN_BLOCK_EXPLORER_URL
EVMChain.IOTA_TESTNET -> Values.IOTA_TESTNET_BLOCK_EXPLORER_URL
else -> {
throw Exception("${chain.toString()} is not supported")
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/id/walt/nftkit/utilis/Common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ object Common {
}

fun isEVMChain(chain: Chain): Boolean{
val EVMChains= listOf(Chain.ETHEREUM, Chain.POLYGON, Chain.GOERLI, Chain.SEPOLIA, Chain.AMOY, Chain.SHIMMEREVM , Chain.SHIMMEREVM_APPCHAIN)
val EVMChains= listOf(Chain.ETHEREUM, Chain.POLYGON, Chain.GOERLI, Chain.SEPOLIA, Chain.AMOY, Chain.SHIMMEREVM , Chain.IOTA_TESTNET)
return chain in EVMChains
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import id.walt.nftkit.services.WaltIdServices
import org.web3j.protocol.Web3j
import org.web3j.protocol.http.HttpService

class ShimmerAppChain : Web3jInstance {
class IotaTestnet : Web3jInstance {
override fun getWeb3j(): Web3j {
return Web3j.build(HttpService(WaltIdServices.loadChainConfig().providers.shimmerevmAppChain))
return Web3j.build(HttpService(WaltIdServices.loadChainConfig().providers.iotatestnet))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object ProviderFactory {
EVMChain.ASTAR -> AstarWeb3()
EVMChain.MOONBEAM -> MoonbeamWeb3()
EVMChain.SHIMMEREVM -> IotaWeb3()
EVMChain.SHIMMEREVM_APPCHAIN -> ShimmerAppChain()
EVMChain.IOTA_TESTNET -> IotaTestnet()
}
}

6 changes: 4 additions & 2 deletions src/main/resources/walt-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ providers:
moonbeam: "https://rpc.api.moonbeam.network"
unique: "https://rpc.unique.network"
opal: "https://rpc-opal.unique.network"
shimmerevmAppChain: "https://fpgaonkrwz.dune.spyce5.com/wasp/api/v1/chains/rms1pzhlaz2aalpsktkqacayyl2xr6s3rsa5h69lmc7mleq4wnaryejkgnprd6k/evm"
iotatestnet: "https://json-rpc.evm.testnet.iotaledger.net"
shimmerevm : "https://json-rpc.evm.testnet.shimmer.network"

#privateKey: "bd4cb3e507f342ee3a710370cef39dda48f17b0a158b0b8dd3f000fbd5b2c2d9"
privateKeyAppchain: "57901fd46ccf70f3f21e3f16815c9b18add89e0d7f2fcb3c847882ad8126408d"
privateKeyIotaTestnet: "3166cf13febd8b817cdd2a88dac1e76ddd3fc413f16c1c3dcb7b2c2eb0cd3b63"
#"57901fd46ccf70f3f21e3f16815c9b18add89e0d7f2fcb3c847882ad8126408d"
#privateKey: "a1fcab9b58015f452c9a89d4cde4807a80111ab27142730bfb96be936e576be1"
#privateKey: "bd4cb3e507f342ee3a710370cef39dda48f17b0a158b0b8dd3f000fbd5b2c2d9"
privateKey: "9224cd6478dc789815e4baaf3771709c69e55432ac8eb38dec4826a48840ddca"
Expand Down Expand Up @@ -66,6 +67,7 @@ apiKeys:




algorandConfig:
algorand_seed_Mnemonic: "famous hood lend donate orange globe spatial stamp opinion universe found gown river identify negative climb defy galaxy turkey height duty doctor hazard ability athlete"

Expand Down

0 comments on commit fd6d26b

Please sign in to comment.