From 08d60e173070b8e10abfd044e15969defdfa4a26 Mon Sep 17 00:00:00 2001 From: ahmed smiai Date: Wed, 6 Sep 2023 22:43:41 +0100 Subject: [PATCH] support verification and fetching for shimmerEvm --- src/main/kotlin/id/walt/nftkit/services/NftService.kt | 5 ++++- .../kotlin/id/walt/nftkit/services/VerificationService.kt | 5 ++--- src/main/kotlin/id/walt/nftkit/services/WaltIdServices.kt | 2 +- src/main/kotlin/id/walt/nftkit/utilis/Common.kt | 4 +++- src/main/resources/walt-default.yaml | 4 +++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/id/walt/nftkit/services/NftService.kt b/src/main/kotlin/id/walt/nftkit/services/NftService.kt index 4dbf857a..beb3f43a 100644 --- a/src/main/kotlin/id/walt/nftkit/services/NftService.kt +++ b/src/main/kotlin/id/walt/nftkit/services/NftService.kt @@ -95,7 +95,8 @@ enum class Chain { OPAL, ALGORAND_MAINNET, ALGORAND_TESTNET, - ALGORAND_BETANET + ALGORAND_BETANET, + SHIMMEREVM } enum class EVMChain { @@ -405,6 +406,7 @@ object NftService { fun getAccountNFTs(chain: Chain, account: String): NFTsInfos { return when{ Common.isEVMChain(chain) -> { + val result = getAccountNFTsByAlchemy(chain, account) return (NFTsInfos(evmNfts = result)) } @@ -462,6 +464,7 @@ object NftService { Chain.SEPOLIA -> Values.ETHEREUM_TESTNET_SEPOLIA_ALCHEMY_URL Chain.POLYGON -> Values.POLYGON_MAINNET_ALCHEMY_URL Chain.MUMBAI -> Values.POLYGON_TESTNET_MUMBAI_ALCHEMY_URL + Chain.SHIMMEREVM -> Values.SHIMMEREVM_TESTNET_BLOCK_EXPLORER_URL Chain.TEZOS -> throw Exception("Tezos is not supported") Chain.GHOSTNET -> throw Exception("Ghostnet is not supported") Chain.TESTNET -> throw Exception("Near testnet is not supported") diff --git a/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt b/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt index a4433582..be47c714 100644 --- a/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt +++ b/src/main/kotlin/id/walt/nftkit/services/VerificationService.kt @@ -43,9 +43,7 @@ object VerificationService { return when{ Common.isEVMChain(chain) -> NFTsEvmOwnershipVerification(EVMChain.valueOf(chain.toString()), contractAddress, account, BigInteger(tokenId)) Common.isTezosChain(chain) -> NFTsTezosOwnershipVerification(chain, contractAddress, account, tokenId) - Common.isNearChain(chain) -> NFTsNearOwnershipVerification(NearChain.valueOf(chain.toString()), contractAddress, account, tokenId) - Common.isPolkadotParachain(chain) -> NFTsPolkadotOwnershipVerification(PolkadotParachain.valueOf(chain.toString()), contractAddress, account, tokenId) Common.isUniqueParachain(chain) -> NFTsUniqueOwnershipVerification(UniqueNetwork.valueOf(chain.toString()), contractAddress, account, tokenId) Common.isAlgorand(chain) -> NFTsAlgorandOwnershipVerification(AlgorandChain.valueOf(chain.toString()), account, tokenId ) @@ -112,7 +110,6 @@ object VerificationService { println(it.value?.content) println(traitValue) if (it.trait_type == traitType && it.value?.content.equals(traitValue)) { - return true } } @@ -148,6 +145,8 @@ object VerificationService { } return false } + + else -> {throw Exception("Chain is not supported")} } diff --git a/src/main/kotlin/id/walt/nftkit/services/WaltIdServices.kt b/src/main/kotlin/id/walt/nftkit/services/WaltIdServices.kt index 09f2b361..d89a4ca4 100644 --- a/src/main/kotlin/id/walt/nftkit/services/WaltIdServices.kt +++ b/src/main/kotlin/id/walt/nftkit/services/WaltIdServices.kt @@ -14,7 +14,7 @@ data class ChainConfig(val providers: Providers, val privateKey: String) data class KeysConfig(val keys: Map) -data class ApiKeys(val ethereumBlockExplorer: String, val polygonBlockExplorer: String, val alchemy: String, val nftstorage: String, val subscan: String) +data class ApiKeys(val ethereumBlockExplorer: String, val polygonBlockExplorer: String, val shimmerBlockExplorer:String, val alchemy: String, val nftstorage: String, val subscan: String) data class BlockExplorerScanApiKeyConfig(val apiKeys: ApiKeys) data class TezosConfig(val tezosBackendServer: String) data class NearConfig(val nearBackendServer: String) diff --git a/src/main/kotlin/id/walt/nftkit/utilis/Common.kt b/src/main/kotlin/id/walt/nftkit/utilis/Common.kt index 6a849871..0fb42a84 100644 --- a/src/main/kotlin/id/walt/nftkit/utilis/Common.kt +++ b/src/main/kotlin/id/walt/nftkit/utilis/Common.kt @@ -108,12 +108,13 @@ object Common { EVMChain.SEPOLIA -> WaltIdServices.loadApiKeys().apiKeys.ethereumBlockExplorer EVMChain.POLYGON -> WaltIdServices.loadApiKeys().apiKeys.polygonBlockExplorer EVMChain.MUMBAI -> WaltIdServices.loadApiKeys().apiKeys.polygonBlockExplorer + EVMChain.SHIMMEREVM -> WaltIdServices.loadApiKeys().apiKeys.shimmerBlockExplorer else -> {throw Exception("$chain is not supported")} } } fun isEVMChain(chain: Chain): Boolean{ - val EVMChains= listOf(Chain.ETHEREUM, Chain.POLYGON, Chain.GOERLI, Chain.SEPOLIA, Chain.MUMBAI) + val EVMChains= listOf(Chain.ETHEREUM, Chain.POLYGON, Chain.GOERLI, Chain.SEPOLIA, Chain.MUMBAI, Chain.SHIMMEREVM) return chain in EVMChains } @@ -134,5 +135,6 @@ object Common { chain in listOf(Chain.UNIQUE, Chain.OPAL) fun isAlgorand(chain: Chain): Boolean = chain in listOf(Chain.ALGORAND_MAINNET, Chain.ALGORAND_TESTNET, Chain.ALGORAND_BETANET) + } diff --git a/src/main/resources/walt-default.yaml b/src/main/resources/walt-default.yaml index 495315c1..3628a525 100644 --- a/src/main/resources/walt-default.yaml +++ b/src/main/resources/walt-default.yaml @@ -21,12 +21,13 @@ providers: moonbeam: "https://rpc.api.moonbeam.network" unique: "https://rpc.unique.network" opal: "https://rpc-opal.unique.network" - shimmerevm: https://json-rpc.evm.testnet.shimmer.network + shimmerevm: "https://json-rpc.evm.testnet.shimmer.network" #privateKey: "bd4cb3e507f342ee3a710370cef39dda48f17b0a158b0b8dd3f000fbd5b2c2d9" privateKey: "fe96ea369abac7818a890da598d40e3e4709f1150e3ff35910f77f63484cffba" #privateKey: "a1fcab9b58015f452c9a89d4cde4807a80111ab27142730bfb96be936e576be1" +#privateKey: "bd4cb3e507f342ee3a710370cef39dda48f17b0a158b0b8dd3f000fbd5b2c2d9" keys: 0xaf87c5Ce7a1fb6BD5aaDB6dd9C0b8EF51EF1BC31: "bd4cb3e507f342ee3a710370cef39dda48f17b0a158b0b8dd3f000fbd5b2c2d9" @@ -61,6 +62,7 @@ apiKeys: alchemy: "QaHKxjJlUa4DGP8xISztrVcRjQ6DjqII" nftstorage: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweEIwNGU5YzMyNzczNjI1MEQ0QTkzQjZmYThjODUwNzQwQkI0N0YyMmYiLCJpc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6MTY2ODU1MDg4NjY2MywibmFtZSI6Ik5GVF9URVNUIn0._DnFeEpPXVF4KqIoRRRV2O67HgjGSyYJgpXFhhf-FD4" subscan: "" + shimmerBlockExplorer: ""