Updated on 2026-08-14
This commit is contained in:
parent
16e32259c6
commit
27ae1ee2a0
6 changed files with 72 additions and 69 deletions
|
|
@ -1,62 +0,0 @@
|
|||
package com.tangem.tap.domain.configurable.warningMessage
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import com.squareup.moshi.Json
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
data class WarningMessage(
|
||||
val title: String,
|
||||
val message: String,
|
||||
val type: Type,
|
||||
val priority: Priority,
|
||||
val location: List<Location>,
|
||||
private val blockchains: List<String>?,
|
||||
@StringRes val titleResId: Int? = null,
|
||||
@StringRes val messageResId: Int? = null,
|
||||
val origin: Origin = Origin.Remote,
|
||||
@StringRes val buttonTextId: Int? = null,
|
||||
val titleFormatArg: String? = null,
|
||||
val messageFormatArg: String? = null,
|
||||
) {
|
||||
val blockchainList: List<Blockchain>? by lazy {
|
||||
blockchains?.map { Blockchain.fromId(it.uppercase()) }
|
||||
}
|
||||
|
||||
var isHidden = false
|
||||
|
||||
enum class Priority {
|
||||
@Json(name = "critical")
|
||||
Critical,
|
||||
|
||||
@Json(name = "warning")
|
||||
Warning,
|
||||
|
||||
@Json(name = "info")
|
||||
Info,
|
||||
}
|
||||
|
||||
enum class Type {
|
||||
@Json(name = "permanent")
|
||||
Permanent, // нельзя скрыть
|
||||
|
||||
@Json(name = "temporary")
|
||||
Temporary, // можно скрыть (кнопка ОК)
|
||||
|
||||
AppRating,
|
||||
|
||||
TestCard,
|
||||
}
|
||||
|
||||
enum class Location {
|
||||
|
||||
@Json(name = "send")
|
||||
SendScreen,
|
||||
}
|
||||
|
||||
enum class Origin {
|
||||
Remote,
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.tangem.data.managetokens.utils
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.compatibility.applyL2Compatibility
|
||||
import com.tangem.blockchainsdk.compatibility.getL2CompatibilityTokenComparison
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.blockchainsdk.utils.isSupportedInApp
|
||||
import com.tangem.blockchainsdk.utils.toCoinId
|
||||
|
|
@ -90,12 +92,13 @@ internal class ManagedCryptoCurrencyFactory {
|
|||
): ManagedCryptoCurrency? {
|
||||
if (coinResponse.networks.isEmpty() || !coinResponse.active) return null
|
||||
|
||||
val updatedNetworks = coinResponse.networks.applyL2Compatibility(coinResponse.id)
|
||||
return ManagedCryptoCurrency.Token(
|
||||
id = ManagedCryptoCurrency.ID(coinResponse.id),
|
||||
name = coinResponse.name,
|
||||
symbol = coinResponse.symbol,
|
||||
iconUrl = getIconUrl(coinResponse.id, imageHost),
|
||||
availableNetworks = coinResponse.networks.mapNotNull { network ->
|
||||
availableNetworks = updatedNetworks.mapNotNull { network ->
|
||||
createSource(network, derivationStyleProvider)
|
||||
},
|
||||
addedIn = findAddedInNetworks(coinResponse.id, tokensResponse, derivationStyleProvider),
|
||||
|
|
@ -136,7 +139,7 @@ internal class ManagedCryptoCurrencyFactory {
|
|||
if (tokensResponse == null) return emptySet()
|
||||
|
||||
return tokensResponse.tokens
|
||||
.filter { it.id == currencyId }
|
||||
.filter { getL2CompatibilityTokenComparison(it, currencyId) }
|
||||
.mapNotNullTo(mutableSetOf()) { token ->
|
||||
val blockchain = Blockchain.fromNetworkId(token.networkId)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.data.markets
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.compatibility.applyL2Compatibility
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
||||
import com.tangem.data.common.currency.getNetwork
|
||||
|
|
@ -144,7 +145,8 @@ internal class DefaultMarketsTokenRepository(
|
|||
language = languageCode,
|
||||
)
|
||||
|
||||
return TokenMarketInfoConverter.convert(response.getOrThrow())
|
||||
val resultResponse = response.getOrThrow().applyL2Compatibility(tokenId)
|
||||
return TokenMarketInfoConverter.convert(resultResponse)
|
||||
}
|
||||
|
||||
override suspend fun getTokenQuotes(fiatCurrencyCode: String, tokenId: String): TokenQuotes {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.tangem.data.tokens.repository
|
|||
|
||||
import arrow.core.raise.catch
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.compatibility.getL2CompatibilityTokenComparison
|
||||
import com.tangem.blockchainsdk.utils.toCoinId
|
||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||
import com.tangem.data.common.api.safeApiCall
|
||||
|
|
@ -488,7 +489,9 @@ internal class DefaultCurrenciesRepository(
|
|||
.map { userWallet ->
|
||||
if (userWallet.isMultiCurrency) {
|
||||
getSavedUserTokensResponse(userWallet.walletId).map { storedTokens ->
|
||||
val filterResponse = storedTokens.tokens.filter { it.id == currencyRawId }
|
||||
val filterResponse = storedTokens.tokens.filter {
|
||||
getL2CompatibilityTokenComparison(it, currencyRawId)
|
||||
}
|
||||
|
||||
responseCurrenciesFactory.createCurrencies(
|
||||
response = storedTokens.copy(tokens = filterResponse),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.tangem.feature.swap.converters
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||
import com.tangem.datasource.api.express.models.request.LeastTokenInfo
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
|
@ -11,7 +9,7 @@ class LeastTokenInfoConverter : Converter<CryptoCurrency, LeastTokenInfo> {
|
|||
override fun convert(value: CryptoCurrency): LeastTokenInfo {
|
||||
return LeastTokenInfo(
|
||||
contractAddress = (value as? CryptoCurrency.Token)?.contractAddress ?: "0",
|
||||
network = Blockchain.fromId(value.id.rawNetworkId).toNetworkId(),
|
||||
network = value.network.backendId,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.tangem.blockchainsdk.compatibility
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toCoinId
|
||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||
import com.tangem.datasource.api.markets.models.response.TokenMarketInfoResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.CoinsResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
||||
|
||||
val l2NetworksList = listOf(
|
||||
Blockchain.Optimism,
|
||||
Blockchain.Arbitrum,
|
||||
Blockchain.ZkSyncEra,
|
||||
Blockchain.Manta,
|
||||
Blockchain.PolygonZkEVM,
|
||||
Blockchain.Aurora,
|
||||
Blockchain.Base,
|
||||
Blockchain.Blast,
|
||||
Blockchain.Cyber,
|
||||
)
|
||||
|
||||
fun getL2CompatibilityTokenComparison(token: UserTokensResponse.Token, currencyId: String): Boolean {
|
||||
return if (currencyId == ETHEREUM_COIN_ID) {
|
||||
l2NetworksList.map { it.toCoinId() }.contains(token.id) || currencyId == token.id
|
||||
} else {
|
||||
token.id == currencyId
|
||||
}
|
||||
}
|
||||
|
||||
fun List<CoinsResponse.Coin.Network>.applyL2Compatibility(coinId: String): List<CoinsResponse.Coin.Network> {
|
||||
return if (coinId == ETHEREUM_COIN_ID) {
|
||||
val l2Networks = l2NetworksList.map {
|
||||
CoinsResponse.Coin.Network(
|
||||
networkId = it.toNetworkId(),
|
||||
)
|
||||
}
|
||||
this + l2Networks
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
fun TokenMarketInfoResponse.applyL2Compatibility(coinId: String): TokenMarketInfoResponse {
|
||||
val networks = this.networks ?: return this
|
||||
return if (coinId == ETHEREUM_COIN_ID) {
|
||||
val l2Networks = l2NetworksList.map {
|
||||
TokenMarketInfoResponse.Network(
|
||||
networkId = it.toNetworkId(),
|
||||
contractAddress = null,
|
||||
decimalCount = null,
|
||||
)
|
||||
}
|
||||
this.copy(networks = networks + l2Networks)
|
||||
} else {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
const val ETHEREUM_COIN_ID = "ethereum"
|
||||
Loading…
Add table
Add a link
Reference in a new issue