Updated on 2026-08-14

This commit is contained in:
Tangem 2024-11-01 13:51:51 +03:00
parent a55e775ed4
commit b8d1c54957
4 changed files with 292 additions and 70 deletions

View file

@ -0,0 +1,145 @@
package com.tangem.tap.network.exchangeServices.mercuryo
import com.tangem.blockchain.common.Blockchain
/**
* Map [Blockchain] to ids from [link](https://api.mercuryo.io/v1.6/lib/currencies) [crypto_currencies]
*/
@Suppress("CyclomaticComplexMethod")
internal val Blockchain.mercuryoNetwork: String?
get() {
return when (this) {
Blockchain.Algorand -> "ALGORAND"
Blockchain.Arbitrum -> "ARBITRUM"
Blockchain.Avalanche -> "AVALANCHE"
Blockchain.BSC -> "BINANCESMARTCHAIN"
Blockchain.Bitcoin -> "BITCOIN"
Blockchain.BitcoinCash -> "BITCOINCASH"
Blockchain.Cardano -> "CARDANO"
Blockchain.Cosmos -> "COSMOS"
Blockchain.Dash -> "DASH"
Blockchain.Dogecoin -> "DOGECOIN"
Blockchain.Ethereum -> "ETHEREUM"
Blockchain.Fantom -> "FANTOM"
Blockchain.Kusama -> "KUSAMA"
Blockchain.Litecoin -> "LITECOIN"
Blockchain.Near -> "NEAR_PROTOCOL"
Blockchain.TON -> "NEWTON"
Blockchain.Optimism -> "OPTIMISM"
Blockchain.Polkadot -> "POLKADOT"
Blockchain.Polygon -> "POLYGON"
Blockchain.XRP -> "RIPPLE"
Blockchain.Solana -> "SOLANA"
Blockchain.Stellar -> "STELLAR"
Blockchain.Tezos -> "TEZOS"
Blockchain.Tron -> "TRON"
Blockchain.ZkSyncEra -> "ZKSYNC"
Blockchain.Base -> "BASE"
Blockchain.ArbitrumTestnet -> null
Blockchain.AvalancheTestnet -> null
Blockchain.Binance -> null
Blockchain.BinanceTestnet -> null
Blockchain.BSCTestnet -> null
Blockchain.BitcoinTestnet -> null
Blockchain.BitcoinCashTestnet -> null
Blockchain.CosmosTestnet -> null
Blockchain.Ducatus -> null
Blockchain.EthereumTestnet -> null
Blockchain.EthereumClassic -> null
Blockchain.EthereumClassicTestnet -> null
Blockchain.FantomTestnet -> null
Blockchain.NearTestnet -> null
Blockchain.PolkadotTestnet -> null
Blockchain.Kava -> null
Blockchain.KavaTestnet -> null
Blockchain.PolygonTestnet -> null
Blockchain.RSK -> null
Blockchain.Sei -> null
Blockchain.SeiTestnet -> null
Blockchain.StellarTestnet -> null
Blockchain.SolanaTestnet -> null
Blockchain.TronTestnet -> null
Blockchain.Gnosis -> null
Blockchain.OptimismTestnet -> null
Blockchain.Dischain -> null
Blockchain.EthereumPow -> null
Blockchain.EthereumPowTestnet -> null
Blockchain.Kaspa -> null
Blockchain.Telos -> null
Blockchain.TelosTestnet -> null
Blockchain.TONTestnet -> null
Blockchain.Ravencoin -> null
Blockchain.RavencoinTestnet -> null
Blockchain.TerraV1 -> null
Blockchain.TerraV2 -> null
Blockchain.Cronos -> null
Blockchain.AlephZero -> null
Blockchain.AlephZeroTestnet -> null
Blockchain.OctaSpace -> null
Blockchain.OctaSpaceTestnet -> null
Blockchain.Chia -> null
Blockchain.ChiaTestnet -> null
Blockchain.Decimal -> null
Blockchain.DecimalTestnet -> null
Blockchain.XDC -> null
Blockchain.XDCTestnet -> null
Blockchain.VeChain -> null
Blockchain.VeChainTestnet -> null
Blockchain.Aptos -> null
Blockchain.AptosTestnet -> null
Blockchain.Playa3ull -> null
Blockchain.Shibarium -> null
Blockchain.ShibariumTestnet -> null
Blockchain.AlgorandTestnet -> null
Blockchain.Hedera -> null
Blockchain.HederaTestnet -> null
Blockchain.Aurora -> null
Blockchain.AuroraTestnet -> null
Blockchain.Areon -> null
Blockchain.AreonTestnet -> null
Blockchain.PulseChain -> null
Blockchain.PulseChainTestnet -> null
Blockchain.ZkSyncEraTestnet -> null
Blockchain.Nexa -> null
Blockchain.NexaTestnet -> null
Blockchain.Moonbeam -> null
Blockchain.MoonbeamTestnet -> null
Blockchain.Manta -> null
Blockchain.MantaTestnet -> null
Blockchain.PolygonZkEVM -> null
Blockchain.PolygonZkEVMTestnet -> null
Blockchain.Radiant -> null
Blockchain.BaseTestnet -> null
Blockchain.Moonriver -> null
Blockchain.MoonriverTestnet -> null
Blockchain.Mantle -> null
Blockchain.MantleTestnet -> null
Blockchain.Flare -> null
Blockchain.FlareTestnet -> null
Blockchain.Taraxa -> null
Blockchain.TaraxaTestnet -> null
Blockchain.Koinos -> null
Blockchain.KoinosTestnet -> null
Blockchain.Joystream -> null
Blockchain.Bittensor -> null
Blockchain.Filecoin -> null
Blockchain.Blast -> null
Blockchain.BlastTestnet -> null
Blockchain.Cyber -> null
Blockchain.CyberTestnet -> null
Blockchain.InternetComputer -> null
Blockchain.Sui -> null
Blockchain.SuiTestnet -> null
Blockchain.EnergyWebChain -> null
Blockchain.EnergyWebChainTestnet -> null
Blockchain.EnergyWebX -> null
Blockchain.EnergyWebXTestnet -> null
Blockchain.Casper -> null
Blockchain.CasperTestnet -> null
Blockchain.Core -> null
Blockchain.CoreTestnet -> null
Blockchain.Unknown -> null
Blockchain.Xodex -> null
Blockchain.Canxium -> null
}
}

View file

@ -30,7 +30,7 @@ internal class MercuryoService(private val environment: MercuryoEnvironment) : E
override fun availableForBuy(scanResponse: ScanResponse, currency: Currency): Boolean {
if (!isBuyAllowed()) return false
val mercuryoNetwork = currency.blockchain.mercuryoNetwork()
val mercuryoNetwork = currency.blockchain.mercuryoNetwork
val contractAddress = (currency as? Currency.Token)?.token?.contractAddress ?: ""
val availableCurrency = availableMercuryoCurrencies.firstOrNull {
it.currencySymbol == currency.currencySymbol &&
@ -77,7 +77,7 @@ internal class MercuryoService(private val environment: MercuryoEnvironment) : E
.appendQueryParameter("redirect_url", ExchangeUrlBuilder.SUCCESS_URL)
if (isDarkTheme) builder.appendQueryParameter("theme", "1inch")
blockchain.mercuryoNetwork()?.let {
blockchain.mercuryoNetwork?.let {
builder.appendQueryParameter("network", it)
}
@ -91,37 +91,6 @@ internal class MercuryoService(private val environment: MercuryoEnvironment) : E
availableMercuryoCurrencies.addAll(data.config.cryptoCurrencies)
}
@Suppress("CyclomaticComplexMethod")
private fun Blockchain.mercuryoNetwork(): String? {
return when (this) {
// Blockchain.Algorand -> "ALGORAND" //TODO: Uncomment with algo support
Blockchain.Arbitrum -> "ARBITRUM"
Blockchain.Avalanche -> "AVALANCHE"
Blockchain.BSC -> "BINANCESMARTCHAIN"
Blockchain.Bitcoin -> "BITCOIN"
Blockchain.BitcoinCash -> "BITCOINCASH"
Blockchain.Cardano -> "CARDANO"
Blockchain.Cosmos -> "COSMOS"
Blockchain.Dash -> "DASH"
Blockchain.Dogecoin -> "DOGECOIN"
Blockchain.Ethereum -> "ETHEREUM"
Blockchain.Fantom -> "FANTOM"
Blockchain.Kusama -> "KUSAMA"
Blockchain.Litecoin -> "LITECOIN"
Blockchain.Near -> "NEAR_PROTOCOL"
Blockchain.TON -> "NEWTON"
Blockchain.Optimism -> "OPTIMISM"
Blockchain.Polkadot -> "POLKADOT"
Blockchain.Polygon -> "POLYGON"
Blockchain.XRP -> "RIPPLE"
Blockchain.Solana -> "SOLANA"
Blockchain.Stellar -> "STELLAR"
Blockchain.Tezos -> "TEZOS"
Blockchain.Tron -> "TRON"
else -> null
}
}
private fun signature(address: String) = (address + environment.secret).calculateSha512().toHexString().lowercase()
private companion object {

View file

@ -1,37 +0,0 @@
package com.tangem.tap.network.exchangeServices.moonpay
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.Blockchain.*
import com.tangem.tap.network.exchangeServices.moonpay.models.MoonPaySupportedCurrency
internal val Blockchain.moonPaySupportedCurrency: MoonPaySupportedCurrency?
get() = when (this) {
Algorand -> MoonPaySupportedCurrency(networkCode = "algorand", currencyCode = "algo")
Aptos -> MoonPaySupportedCurrency(networkCode = "aptos", currencyCode = "apt")
Arbitrum -> MoonPaySupportedCurrency(networkCode = "arbitrum", currencyCode = "eth_arbitrum")
Avalanche -> MoonPaySupportedCurrency(networkCode = "avalanche_c_chain", currencyCode = "avax_cchain")
Binance -> MoonPaySupportedCurrency(networkCode = "bnb_chain", currencyCode = "bnb")
Bitcoin -> MoonPaySupportedCurrency(networkCode = "bitcoin", currencyCode = "btc")
BitcoinCash -> MoonPaySupportedCurrency(networkCode = "bitcoin_cash", currencyCode = "bch")
BSC -> MoonPaySupportedCurrency(networkCode = "binance_smart_chain", currencyCode = "bnb_bsc")
Cardano -> MoonPaySupportedCurrency(networkCode = "cardano", currencyCode = "ada")
Cosmos -> MoonPaySupportedCurrency(networkCode = "cosmos", currencyCode = "atom")
Dogecoin -> MoonPaySupportedCurrency(networkCode = "dogecoin", currencyCode = "doge")
Ethereum -> MoonPaySupportedCurrency(networkCode = "ethereum", currencyCode = "eth")
EthereumClassic -> MoonPaySupportedCurrency(networkCode = "ethereum_classic", currencyCode = "etc")
Hedera -> MoonPaySupportedCurrency(networkCode = "hedera", currencyCode = "hbar")
Litecoin -> MoonPaySupportedCurrency(networkCode = "litecoin", currencyCode = "ltc")
Near -> MoonPaySupportedCurrency(networkCode = "near", currencyCode = "near")
Optimism -> MoonPaySupportedCurrency(networkCode = "optimism", currencyCode = "eth_optimism")
Polkadot -> MoonPaySupportedCurrency(networkCode = "polkadot", currencyCode = "dot")
Polygon -> MoonPaySupportedCurrency(networkCode = "polygon", currencyCode = "matic_polygon")
Ravencoin -> MoonPaySupportedCurrency(networkCode = "ravencoin", currencyCode = "rvn")
Solana -> MoonPaySupportedCurrency(networkCode = "solana", currencyCode = "sol")
Stellar -> MoonPaySupportedCurrency(networkCode = "stellar", currencyCode = "xlm")
Tezos -> MoonPaySupportedCurrency(networkCode = "tezos", currencyCode = "xtz")
TON -> MoonPaySupportedCurrency(networkCode = "ton", currencyCode = "ton")
Tron -> MoonPaySupportedCurrency(networkCode = "tron", currencyCode = "trx")
VeChain -> MoonPaySupportedCurrency(networkCode = "vechain", currencyCode = "vet")
XRP -> MoonPaySupportedCurrency(networkCode = "ripple", currencyCode = "xrp")
else -> null
}

View file

@ -0,0 +1,145 @@
package com.tangem.tap.network.exchangeServices.moonpay
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.Blockchain.*
import com.tangem.tap.network.exchangeServices.moonpay.models.MoonPaySupportedCurrency
/**
* Map [Blockchain] to [MoonPaySupportedCurrency.networkCode] and [MoonPaySupportedCurrency.currencyCode]
* from [link](https://api.moonpay.com/v3/currencies/)
*/
internal val Blockchain.moonPaySupportedCurrency: MoonPaySupportedCurrency?
get() = when (this) {
Algorand -> MoonPaySupportedCurrency(networkCode = "algorand", currencyCode = "algo")
Aptos -> MoonPaySupportedCurrency(networkCode = "aptos", currencyCode = "apt")
Arbitrum -> MoonPaySupportedCurrency(networkCode = "arbitrum", currencyCode = "eth_arbitrum")
Avalanche -> MoonPaySupportedCurrency(networkCode = "avalanche_c_chain", currencyCode = "avax_cchain")
Binance -> MoonPaySupportedCurrency(networkCode = "bnb_chain", currencyCode = "bnb")
Bitcoin -> MoonPaySupportedCurrency(networkCode = "bitcoin", currencyCode = "btc")
BitcoinCash -> MoonPaySupportedCurrency(networkCode = "bitcoin_cash", currencyCode = "bch")
BSC -> MoonPaySupportedCurrency(networkCode = "binance_smart_chain", currencyCode = "bnb_bsc")
Cardano -> MoonPaySupportedCurrency(networkCode = "cardano", currencyCode = "ada")
Cosmos -> MoonPaySupportedCurrency(networkCode = "cosmos", currencyCode = "atom")
Dogecoin -> MoonPaySupportedCurrency(networkCode = "dogecoin", currencyCode = "doge")
Ethereum -> MoonPaySupportedCurrency(networkCode = "ethereum", currencyCode = "eth")
EthereumClassic -> MoonPaySupportedCurrency(networkCode = "ethereum_classic", currencyCode = "etc")
Hedera -> MoonPaySupportedCurrency(networkCode = "hedera", currencyCode = "hbar")
Litecoin -> MoonPaySupportedCurrency(networkCode = "litecoin", currencyCode = "ltc")
Near -> MoonPaySupportedCurrency(networkCode = "near", currencyCode = "near")
Optimism -> MoonPaySupportedCurrency(networkCode = "optimism", currencyCode = "eth_optimism")
Polkadot -> MoonPaySupportedCurrency(networkCode = "polkadot", currencyCode = "dot")
Polygon -> MoonPaySupportedCurrency(networkCode = "polygon", currencyCode = "matic_polygon")
Ravencoin -> MoonPaySupportedCurrency(networkCode = "ravencoin", currencyCode = "rvn")
Solana -> MoonPaySupportedCurrency(networkCode = "solana", currencyCode = "sol")
Stellar -> MoonPaySupportedCurrency(networkCode = "stellar", currencyCode = "xlm")
Tezos -> MoonPaySupportedCurrency(networkCode = "tezos", currencyCode = "xtz")
TON -> MoonPaySupportedCurrency(networkCode = "ton", currencyCode = "ton")
Tron -> MoonPaySupportedCurrency(networkCode = "tron", currencyCode = "trx")
VeChain -> MoonPaySupportedCurrency(networkCode = "vechain", currencyCode = "vet")
XRP -> MoonPaySupportedCurrency(networkCode = "ripple", currencyCode = "xrp")
Sei -> MoonPaySupportedCurrency(networkCode = "sei", currencyCode = "sei_sei")
ZkSyncEra -> MoonPaySupportedCurrency(networkCode = "zksync", currencyCode = "eth_zksync")
Base -> MoonPaySupportedCurrency(networkCode = "base", currencyCode = "eth_base")
Filecoin -> MoonPaySupportedCurrency(networkCode = "filecoin", currencyCode = "fil")
Sui -> MoonPaySupportedCurrency(networkCode = "sui", currencyCode = "sui")
Core -> MoonPaySupportedCurrency(networkCode = "core", currencyCode = "core")
ArbitrumTestnet -> null
AvalancheTestnet -> null
BinanceTestnet -> null
BSCTestnet -> null
BitcoinTestnet -> null
BitcoinCashTestnet -> null
CosmosTestnet -> null
Ducatus -> null
EthereumTestnet -> null
EthereumClassicTestnet -> null
Fantom -> null
FantomTestnet -> null
NearTestnet -> null
PolkadotTestnet -> null
Kava -> null // doesn't support KavaEvm
KavaTestnet -> null
Kusama -> null
PolygonTestnet -> null
RSK -> null
SeiTestnet -> null
StellarTestnet -> null
SolanaTestnet -> null
TronTestnet -> null
Gnosis -> null
Dash -> null
OptimismTestnet -> null
Dischain -> null
EthereumPow -> null
EthereumPowTestnet -> null
Kaspa -> null
Telos -> null
TelosTestnet -> null
TONTestnet -> null
RavencoinTestnet -> null
TerraV1 -> null
TerraV2 -> null
Cronos -> null
AlephZero -> null
AlephZeroTestnet -> null
OctaSpace -> null
OctaSpaceTestnet -> null
Chia -> null
ChiaTestnet -> null
Decimal -> null
DecimalTestnet -> null
XDC -> null
XDCTestnet -> null
VeChainTestnet -> null
AptosTestnet -> null
Playa3ull -> null
Shibarium -> null
ShibariumTestnet -> null
AlgorandTestnet -> null
HederaTestnet -> null
Aurora -> null
AuroraTestnet -> null
Areon -> null
AreonTestnet -> null
PulseChain -> null
PulseChainTestnet -> null
ZkSyncEraTestnet -> null
Nexa -> null
NexaTestnet -> null
Moonbeam -> null
MoonbeamTestnet -> null
Manta -> null
MantaTestnet -> null
PolygonZkEVM -> null
PolygonZkEVMTestnet -> null
Radiant -> null
BaseTestnet -> null
Moonriver -> null
MoonriverTestnet -> null
Mantle -> null
MantleTestnet -> null
Flare -> null
FlareTestnet -> null
Taraxa -> null
TaraxaTestnet -> null
Koinos -> null
KoinosTestnet -> null
Joystream -> null
Bittensor -> null
Blast -> null
BlastTestnet -> null
Cyber -> null
CyberTestnet -> null
InternetComputer -> null
SuiTestnet -> null
EnergyWebChain -> null
EnergyWebChainTestnet -> null
EnergyWebX -> null
EnergyWebXTestnet -> null
Casper -> null
CasperTestnet -> null
CoreTestnet -> null
Unknown -> null
Xodex -> null
Canxium -> null
}