Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vanar blockchain semi-support #857

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -174,6 +174,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 @@ -273,6 +275,7 @@ enum class Blockchain(
EnergyWebX, EnergyWebXTestnet,
Core, CoreTestnet,
Chiliz, ChilizTestnet,
VanarChain, VanarChainTestnet,
Xodex,
Canxium,
-> 18
Expand Down Expand Up @@ -349,6 +352,7 @@ enum class Blockchain(
EnergyWebChain, EnergyWebChainTestnet,
Core, CoreTestnet,
Chiliz, ChilizTestnet,
VanarChain, VanarChainTestnet,
Xodex,
Canxium,
-> EthereumAddressService()
Expand Down Expand Up @@ -481,6 +485,7 @@ enum class Blockchain(
Casper, CasperTestnet -> CasperTestnet
Core, CoreTestnet -> CoreTestnet
Chiliz, ChilizTestnet -> ChilizTestnet
VanarChain, VanarChainTestnet -> VanarChainTestnet
else -> null
}
}
Expand Down Expand Up @@ -555,6 +560,7 @@ enum class Blockchain(
Core, CoreTestnet,
Casper, CasperTestnet,
Chiliz, ChilizTestnet,
VanarChain, VanarChainTestnet,
Xodex,
Canxium,
Clore,
Expand Down Expand Up @@ -657,6 +663,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 @@ -90,6 +90,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 @@ -91,6 +91,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")
}
}
Loading