Skip to content

Commit

Permalink
Vanar blockchain semi-support
Browse files Browse the repository at this point in the history
  • Loading branch information
nemelianov-tangem authored and kozarezvlad committed Dec 24, 2024
1 parent b8314dd commit 33844ee
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ enum class Chain(val id: Int, val blockchain: Blockchain?) {
Canxium(id = 3003, blockchain = Blockchain.Canxium),
Chiliz(id = 88888, blockchain = Blockchain.Chiliz),
ChilizTestnet(id = 88882, blockchain = Blockchain.ChilizTestnet),
VanarChain(id = 2040, blockchain = Blockchain.VanarChain),
VanarChainTestnet(id = 78600, blockchain = Blockchain.VanarChainTestnet),
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ internal val Blockchain.isSupportEIP1559: Boolean
Blockchain.Mantle,
Blockchain.Xodex,
Blockchain.Chiliz,
Blockchain.VanarChain,
-> false
else -> error("Don't forget about evm here")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.tangem.blockchain.blockchains.ethereum.providers

import com.tangem.blockchain.blockchains.ethereum.network.EthereumJsonRpcProvider
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.network.providers.NetworkProvidersBuilder
import com.tangem.blockchain.common.network.providers.ProviderType

internal class VanarChainProvidersBuilder(
override val providerTypes: List<ProviderType>,
) : NetworkProvidersBuilder<EthereumJsonRpcProvider>() {

override fun createProviders(blockchain: Blockchain): List<EthereumJsonRpcProvider> {
return listOf(
EthereumJsonRpcProvider("https://rpc.vanarchain.com"), // FIXME: use config during full integration
)
}

override fun createTestnetProviders(blockchain: Blockchain): List<EthereumJsonRpcProvider> {
return listOf(
EthereumJsonRpcProvider("https://rpc-vanguard.vanarchain.com"),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ enum class Blockchain(
Chiliz("chiliz", "CHZ", "Chiliz"),
ChilizTestnet("chiliz/test", "CHZ", "Chiliz Spicy Testnet"),
Clore("clore-ai", "CLORE", "Clore"),
VanarChain("vanar-chain", "VANRY", "Vanar Chain"),
VanarChainTestnet("vanar-chain/test", "VG", "Vanar Vanguard Testnet"),
;

private val externalLinkProvider: ExternalLinkProvider by lazy { ExternalLinkProviderFactory.makeProvider(this) }
Expand Down Expand Up @@ -276,6 +278,7 @@ enum class Blockchain(
EnergyWebX, EnergyWebXTestnet,
Core, CoreTestnet,
Chiliz, ChilizTestnet,
VanarChain, VanarChainTestnet,
Xodex,
Canxium,
-> 18
Expand Down Expand Up @@ -352,6 +355,7 @@ enum class Blockchain(
EnergyWebChain, EnergyWebChainTestnet,
Core, CoreTestnet,
Chiliz, ChilizTestnet,
VanarChain, VanarChainTestnet,
Xodex,
Canxium,
-> EthereumAddressService()
Expand Down Expand Up @@ -485,6 +489,7 @@ enum class Blockchain(
Casper, CasperTestnet -> CasperTestnet
Core, CoreTestnet -> CoreTestnet
Chiliz, ChilizTestnet -> ChilizTestnet
VanarChain, VanarChainTestnet -> VanarChainTestnet
else -> null
}
}
Expand Down Expand Up @@ -560,6 +565,7 @@ enum class Blockchain(
Core, CoreTestnet,
Casper, CasperTestnet,
Chiliz, ChilizTestnet,
VanarChain, VanarChainTestnet,
Xodex,
Canxium,
Clore,
Expand Down Expand Up @@ -662,6 +668,8 @@ enum class Blockchain(
Canxium -> Chain.Canxium.id
Chiliz -> Chain.Chiliz.id
ChilizTestnet -> Chain.ChilizTestnet.id
VanarChain -> Chain.VanarChain.id
VanarChainTestnet -> Chain.VanarChainTestnet.id
else -> null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class WalletManagerFactory(
Blockchain.EnergyWebChain, Blockchain.EnergyWebChainTestnet,
Blockchain.Core, Blockchain.CoreTestnet,
Blockchain.Chiliz, Blockchain.ChilizTestnet,
Blockchain.VanarChain, Blockchain.VanarChainTestnet,
Blockchain.Xodex,
Blockchain.Canxium,
-> EthereumLikeWalletManagerAssembly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class EstimationFeeAddressFactory {
Blockchain.EnergyWebChain, Blockchain.EnergyWebChainTestnet,
Blockchain.Core, Blockchain.CoreTestnet,
Blockchain.Chiliz, Blockchain.ChilizTestnet,
Blockchain.VanarChain, Blockchain.VanarChainTestnet,
Blockchain.Xodex,
Blockchain.Canxium,
-> "0x52bb4012854f808CF9BAbd855e44E506dAf6C077"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ internal object EthereumLikeWalletManagerAssembly : WalletManagerAssembly<Ethere
Blockchain.EnergyWebChain, Blockchain.EnergyWebChainTestnet -> EnergyWebChainProvidersBuilder(providerTypes)
Blockchain.Core, Blockchain.CoreTestnet -> CoreProvidersBuilder(providerTypes)
Blockchain.Chiliz, Blockchain.ChilizTestnet -> ChilizProvidersBuilder(providerTypes)
Blockchain.VanarChain, Blockchain.VanarChainTestnet -> VanarChainProvidersBuilder(providerTypes)
Blockchain.Xodex -> XodexProvidersBuilder(providerTypes)
Blockchain.Canxium -> CanxiumProvidersBuilder(providerTypes)
else -> error("Unsupported blockchain: $blockchain")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ object DerivationConfigV1 : DerivationConfig() {
Blockchain.Cyber,
Blockchain.Canxium,
Blockchain.Chiliz,
Blockchain.VanarChain,
Blockchain.Xodex,
-> mapOf(AddressType.Default to DerivationPath("m/44'/60'/0'/0/0"))
Blockchain.XDC -> mapOf(AddressType.Default to DerivationPath("m/44'/550'/0'/0/0"))
Expand Down Expand Up @@ -151,6 +152,7 @@ object DerivationConfigV1 : DerivationConfig() {
Blockchain.EnergyWebChainTestnet,
Blockchain.CoreTestnet,
Blockchain.ChilizTestnet,
Blockchain.VanarChainTestnet,
-> mapOf(AddressType.Default to DerivationPath("m/44'/1'/0'/0/0"))
Blockchain.Aptos,
Blockchain.AptosTestnet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ object DerivationConfigV2 : DerivationConfig() {
Blockchain.Xodex,
Blockchain.Canxium,
Blockchain.Chiliz,
Blockchain.VanarChain,
-> mapOf(AddressType.Default to DerivationPath("m/44'/60'/0'/0/0"))
Blockchain.XDC -> mapOf(AddressType.Default to DerivationPath("m/44'/550'/0'/0/0"))
Blockchain.Binance -> mapOf(AddressType.Default to DerivationPath("m/44'/714'/0'/0/0"))
Expand Down Expand Up @@ -151,6 +152,7 @@ object DerivationConfigV2 : DerivationConfig() {
Blockchain.EnergyWebChainTestnet,
Blockchain.CoreTestnet,
Blockchain.ChilizTestnet,
Blockchain.VanarChainTestnet,
-> mapOf(AddressType.Default to DerivationPath("m/44'/1'/0'/0/0"))
Blockchain.Aptos,
Blockchain.AptosTestnet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ object DerivationConfigV3 : DerivationConfig() {
Blockchain.Xodex,
Blockchain.Canxium,
Blockchain.Chiliz,
Blockchain.VanarChain,
-> mapOf(AddressType.Default to DerivationPath("m/44'/60'/0'/0/0"))
Blockchain.XDC -> mapOf(AddressType.Default to DerivationPath("m/44'/550'/0'/0/0"))
Blockchain.EthereumClassic -> mapOf(AddressType.Default to DerivationPath("m/44'/61'/0'/0/0"))
Expand Down Expand Up @@ -147,6 +148,7 @@ object DerivationConfigV3 : DerivationConfig() {
Blockchain.EnergyWebChainTestnet,
Blockchain.CoreTestnet,
Blockchain.ChilizTestnet,
Blockchain.VanarChainTestnet,
-> mapOf(AddressType.Default to DerivationPath("m/44'/1'/0'/0/0"))
Blockchain.Aptos,
Blockchain.AptosTestnet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ internal object ExternalLinkProviderFactory {
Blockchain.Casper, Blockchain.CasperTestnet -> CasperExternalLinkProvider(isTestnet)
Blockchain.Core, Blockchain.CoreTestnet -> CoreExternalLinkProvider(isTestnet)
Blockchain.Chiliz, Blockchain.ChilizTestnet -> ChilizExternalLinkProvider(isTestnet)
Blockchain.VanarChain, Blockchain.VanarChainTestnet -> VanarChainExternalLinkProvider(isTestnet)
Blockchain.Xodex -> XodexExternalLinkProvider()
Blockchain.Canxium -> CanxiumExternalLinkProvider()
Blockchain.Clore -> CloreExternalLinkProvider()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.tangem.blockchain.externallinkprovider.providers

import com.tangem.blockchain.externallinkprovider.ExternalLinkProvider
import com.tangem.blockchain.externallinkprovider.TxExploreState

internal class VanarChainExternalLinkProvider(isTestnet: Boolean) : ExternalLinkProvider {

override val explorerBaseUrl: String = if (isTestnet) {
"https://explorer-vanguard.vanarchain.com/"
} else {
"https://explorer.vanarchain.com/"
}

override val testNetTopUpUrl: String = "https://faucet.vanarchain.com/"

override fun explorerUrl(walletAddress: String, contractAddress: String?): String {
return "${explorerBaseUrl}address/$walletAddress"
}

override fun getExplorerTxUrl(transactionHash: String): TxExploreState {
return TxExploreState.Url("${explorerBaseUrl}tx/$transactionHash")
}
}

0 comments on commit 33844ee

Please sign in to comment.