Skip to content

Commit

Permalink
Merge pull request #164 from walt-id/feat/appchain_integration
Browse files Browse the repository at this point in the history
feat : Add support to compliance appchain for IOTA KYC
  • Loading branch information
SuperBatata authored Feb 8, 2024
2 parents ca80553 + b3b0c3f commit 50c4102
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 23 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/id/walt/nftkit/Values.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +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 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_MUMBAI_SCAN_API_URL = "api-testnet.polygonscan.com"
const val SHIMMEREVM_APPCHAIN_BLOCK_EXPLORER_URL = ""

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,6 +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
}
val transactionManager: TransactionManager = RawTransactionManager(
web3j, credentials, chainId
Expand All @@ -318,4 +319,4 @@ object Erc721TokenStandard : IErc721TokenStandard {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ 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)){
val privateKey: String = if((signedAccount == null || "" == (signedAccount)) && chain == EVMChain.SHIMMEREVM_APPCHAIN){
WaltIdServices.loadChainConfig().privateKeyAppchain
}else if(signedAccount == null || "" == (signedAccount) ) {
WaltIdServices.loadChainConfig().privateKey
}else{
}
else{
val lowercaseAddress= WaltIdServices.loadAccountKeysConfig().keys.mapKeys { it.key.lowercase() }
lowercaseAddress[signedAccount.lowercase()]!!
lowercaseAddress[signedAccount?.lowercase()]!!
}

val credentials: Credentials = Credentials.create(privateKey)
Expand All @@ -46,6 +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
}
val transactionManager: TransactionManager = RawTransactionManager(
web3j, credentials, chainId
Expand Down Expand Up @@ -102,6 +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
}

val web3j = ProviderFactory.getProvider(chain)?.getWeb3j()
Expand Down Expand Up @@ -149,4 +154,4 @@ object SoulBoundTokenStandard : ISoulBoundTokenStandard {
): TransactionReceipt {
return loadContract(chain, contractAddress, signedAccount).unequip(tokenId).send()
}
}
}
4 changes: 3 additions & 1 deletion src/main/kotlin/id/walt/nftkit/services/NftService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ enum class Chain {
ALGORAND_MAINNET,
ALGORAND_TESTNET,
ALGORAND_BETANET,
SHIMMEREVM
SHIMMEREVM,
SHIMMEREVM_APPCHAIN
}

enum class EVMChain {
Expand All @@ -106,6 +107,7 @@ enum class EVMChain {
ASTAR,
MOONBEAM,
SHIMMEREVM,
SHIMMEREVM_APPCHAIN
}

enum class TokenStandard {
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/id/walt/nftkit/services/WaltIdServices.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ data class Providers(
val moonbeam: String,
val opal: String,
val unique: String,
val shimmerevm: String
val shimmerevm: String,
val shimmerevmAppChain : String
)

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

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

Expand Down Expand Up @@ -146,6 +147,7 @@ object WaltIdServices {
EVMChain.POLYGON -> Values.POLYGON_MAINNET_BLOCK_EXPLORER_URL
EVMChain.MUMBAI -> Values.POLYGON_TESTNET_MUMBAI_BLOCK_EXPLORER_URL
EVMChain.SHIMMEREVM -> Values.SHIMMEREVM_TESTNET_BLOCK_EXPLORER_URL
EVMChain.SHIMMEREVM_APPCHAIN -> Values.SHIMMEREVM_APPCHAIN_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.MUMBAI, Chain.SHIMMEREVM)
val EVMChains= listOf(Chain.ETHEREUM, Chain.POLYGON, Chain.GOERLI, Chain.SEPOLIA, Chain.MUMBAI, Chain.SHIMMEREVM , Chain.SHIMMEREVM_APPCHAIN)
return chain in EVMChains
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/id/walt/nftkit/utilis/WaltIdGasProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ import java.math.BigInteger
// - https://polygonscan.com/address/0xb789711a8cf2a3938779d01866a4c376598b9fe6

// Config Gas: 80 Wei
object WaltIdGasProvider : StaticGasProvider(BigInteger.valueOf(1_000_000_000_000L), BigInteger.valueOf(2_498_868))
object WaltIdGasProvider : StaticGasProvider(BigInteger.valueOf(10000000000), BigInteger.valueOf(2_498_868))
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ object ProviderFactory {
EVMChain.ASTAR -> AstarWeb3()
EVMChain.MOONBEAM -> MoonbeamWeb3()
EVMChain.SHIMMEREVM -> IotaWeb3()
EVMChain.SHIMMEREVM_APPCHAIN -> ShimmerAppChain()
}
}

11 changes: 11 additions & 0 deletions src/main/kotlin/id/walt/nftkit/utilis/providers/ShimmerAppChain.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package id.walt.nftkit.utilis.providers

import id.walt.nftkit.services.WaltIdServices
import org.web3j.protocol.Web3j
import org.web3j.protocol.http.HttpService

class ShimmerAppChain : Web3jInstance {
override fun getWeb3j(): Web3j {
return Web3j.build(HttpService(WaltIdServices.loadChainConfig().providers.shimmerevmAppChain))
}
}
8 changes: 4 additions & 4 deletions src/main/resources/walt-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ 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"

shimmerevmAppChain: "https://fpgaonkrwz.dune.spyce5.com/wasp/api/v1/chains/rms1pzhlaz2aalpsktkqacayyl2xr6s3rsa5h69lmc7mleq4wnaryejkgnprd6k/evm"
shimmerevm : "https://json-rpc.evm.testnet.shimmer.network"

#privateKey: "bd4cb3e507f342ee3a710370cef39dda48f17b0a158b0b8dd3f000fbd5b2c2d9"
privateKey: "9224cd6478dc789815e4baaf3771709c69e55432ac8eb38dec4826a48840ddca"
privateKeyAppchain: "57901fd46ccf70f3f21e3f16815c9b18add89e0d7f2fcb3c847882ad8126408d"
#privateKey: "a1fcab9b58015f452c9a89d4cde4807a80111ab27142730bfb96be936e576be1"
#privateKey: "bd4cb3e507f342ee3a710370cef39dda48f17b0a158b0b8dd3f000fbd5b2c2d9"

privateKey: "9224cd6478dc789815e4baaf3771709c69e55432ac8eb38dec4826a48840ddca"
keys:
0xaf87c5Ce7a1fb6BD5aaDB6dd9C0b8EF51EF1BC31: "bd4cb3e507f342ee3a710370cef39dda48f17b0a158b0b8dd3f000fbd5b2c2d9"
0x8448Ff4b2733b52f62d81ca46d64bD16786299Cd: "d720ef2cb49c6cbe94175ed413d27e635c5acaa1b7cf03d1faad3a0abc2f53f3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@ class Erc721Standard : StringSpec({


"Verifying IPFS metadata using NFTs storage".config(){
val tokenid = BigInteger.valueOf(10)
var uri = NftService.getNftMetadataUri(EVMChain.MUMBAI,"0xf277BE034881eE38A9b270E5b6C5c6f333Af2517" ,tokenid)
val tokenid = BigInteger.valueOf(3)
var uri = NftService.getNftMetadataUri(EVMChain.MUMBAI,"0x7Bf34C715e9A7ADEc6c4fa1CFEE4120E2808fD8c" ,tokenid)
val result = NftService.getIPFSMetadataUsingNFTStorage(uri)
result.description shouldBe "string"
result.name shouldBe "string"
result.image shouldBe "string"
result.external_url shouldBe "string"
result.attributes?.get(0)!!.trait_type shouldBe "string"
(result.attributes?.get(0)!!.value?.content ?: "") shouldBe "15/7/2022 10:30:07"
result.description shouldBe "Walt Membership"
result.name shouldBe "Walt Membership"
result.image shouldBe "ipfs://bafkreicl5qtcwcckkblm2qdut4bwyu3dksq36wipfrzui5tnbdydzpuhcq"
result.external_url shouldBe ""
result.attributes?.get(0)!!.trait_type shouldBe "ceramic_hackathon_attendee"


}


})
})

0 comments on commit 50c4102

Please sign in to comment.