Skip to content

Commit

Permalink
AND-8897: Add Canxium support
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeeei committed Oct 31, 2024
1 parent 5b83e10 commit debd40d
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ enum class Chain(val id: Int, val blockchain: Blockchain?) {
Core(id = 1116, blockchain = Blockchain.Core),
CoreTestnet(id = 1115, blockchain = Blockchain.CoreTestnet),
Xodex(id = 2415, blockchain = Blockchain.Xodex),
Canxium(id = 3003, blockchain = Blockchain.Canxium),
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal val Blockchain.isSupportEIP1559: Boolean
Blockchain.PulseChain,
Blockchain.Mantle,
Blockchain.Flare,
Blockchain.Canxium,
-> true
Blockchain.EthereumClassic, // eth_feeHistory all zeroes
Blockchain.EthereumPow, // eth_feeHistory with zeros
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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.OnlyPublicProvidersBuilder
import com.tangem.blockchain.common.network.providers.ProviderType

internal class CanxiumProvidersBuilder(
override val providerTypes: List<ProviderType>,
) : OnlyPublicProvidersBuilder<EthereumJsonRpcProvider>(
providerTypes = providerTypes,
) {
override fun createProvider(url: String, blockchain: Blockchain) = EthereumJsonRpcProvider(url)
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ enum class Blockchain(
CasperTestnet("casper/test", "CSPR", "Casper Testnet"),
Core("core", "CORE", "Core"),
CoreTestnet("core/test", "tCORE", "Core Testnet"),
Xodex("xodex", "XODEX", "XODEX"),
Xodex("xodex", "XODEX", "Xodex"),
Canxium("canxium", "CAU", "Canxium"),
;

private val externalLinkProvider: ExternalLinkProvider by lazy { ExternalLinkProviderFactory.makeProvider(this) }
Expand Down Expand Up @@ -268,6 +269,7 @@ enum class Blockchain(
EnergyWebX, EnergyWebXTestnet,
Core, CoreTestnet,
Xodex,
Canxium,
-> 18

Near, NearTestnet,
Expand Down Expand Up @@ -341,6 +343,7 @@ enum class Blockchain(
EnergyWebChain, EnergyWebChainTestnet,
Core, CoreTestnet,
Xodex,
Canxium,
-> EthereumAddressService()

XDC, XDCTestnet -> XDCAddressService()
Expand Down Expand Up @@ -544,6 +547,7 @@ enum class Blockchain(
Core, CoreTestnet,
Casper, CasperTestnet,
Xodex,
Canxium,
-> listOf(EllipticCurve.Secp256k1)

Stellar, StellarTestnet,
Expand Down Expand Up @@ -640,6 +644,7 @@ enum class Blockchain(
Core -> Chain.Core.id
CoreTestnet -> Chain.CoreTestnet.id
Xodex -> Chain.Xodex.id
Canxium -> Chain.Canxium.id
else -> null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class WalletManagerFactory(
Blockchain.EnergyWebChain, Blockchain.EnergyWebChainTestnet,
Blockchain.Core, Blockchain.CoreTestnet,
Blockchain.Xodex,
Blockchain.Canxium,
-> EthereumLikeWalletManagerAssembly

Blockchain.Mantle, Blockchain.MantleTestnet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class EstimationFeeAddressFactory {
Blockchain.EnergyWebChain, Blockchain.EnergyWebChainTestnet,
Blockchain.Core, Blockchain.CoreTestnet,
Blockchain.Xodex,
Blockchain.Canxium,
-> "0x52bb4012854f808CF9BAbd855e44E506dAf6C077"
// Polkadot-like
Blockchain.Polkadot, Blockchain.PolkadotTestnet ->
Expand Down Expand Up @@ -144,7 +145,7 @@ class EstimationFeeAddressFactory {
-> "0xbca45e36a271e106546c89984108685215724e488570a0049a187c473cd521bc"
Blockchain.EnergyWebX, Blockchain.EnergyWebXTestnet,
-> "5CogUCbb5PYYbEHhDVGDN6JRRYBkd4sFRVc4wwP8oy5Su34Z"
Blockchain.Casper, Blockchain.CasperTestnet -> TODO("Need to generate") // AND-8615
Blockchain.Casper, Blockchain.CasperTestnet -> ""
}
}

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.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 @@ -176,6 +176,8 @@ object DerivationConfigV1 : DerivationConfig() {
-> mapOf(AddressType.Default to DerivationPath("m/44'/506'/0'/0/0"))
Blockchain.Xodex,
-> mapOf(AddressType.Default to DerivationPath("m/44'/2415'/0'/0/0"))
Blockchain.Canxium,
-> mapOf(AddressType.Default to DerivationPath("m/44'/3003'/0'/0/0"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ object DerivationConfigV2 : DerivationConfig() {
Blockchain.EnergyWebChain,
Blockchain.Core,
Blockchain.Xodex,
Blockchain.Canxium,
-> 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
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ object DerivationConfigV3 : DerivationConfig() {
Blockchain.EnergyWebChain,
Blockchain.Core,
Blockchain.Xodex,
Blockchain.Canxium,
-> 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
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.Xodex -> XodexExternalLinkProvider()
Blockchain.Canxium -> CanxiumExternalLinkProvider()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.tangem.blockchain.externallinkprovider.providers

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

internal class CanxiumExternalLinkProvider : ExternalLinkProvider {

override val explorerBaseUrl: String = "https://scan.canxium.org/"

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 debd40d

Please sign in to comment.