Updated on 2026-08-14

This commit is contained in:
Tangem 2024-08-09 15:10:19 +03:00
parent d570dd215f
commit e045a08252
10 changed files with 21 additions and 20 deletions

View file

@ -3,15 +3,16 @@ package com.tangem.tap.common.extensions
import com.tangem.blockchain.common.Blockchain
import com.tangem.common.extensions.remove
fun Blockchain.getNetworkName(): String {
fun Blockchain.getNetworkStandardName(): String {
return when (this) {
Blockchain.Ethereum, Blockchain.EthereumTestnet -> "ERC20"
Blockchain.BSC, Blockchain.BSCTestnet -> "BEP20"
Blockchain.Binance, Blockchain.BinanceTestnet -> "BEP2"
Blockchain.Tron, Blockchain.TronTestnet -> "TRC20"
Blockchain.TON -> "TON"
else -> ""
}
}
val Blockchain.fullNameWithoutTestnet
get() = this.fullName.remove(" Testnet")
val Blockchain.networkNameWithoutTestnet
get() = this.getNetworkName().remove(" Testnet")

View file

@ -25,7 +25,7 @@ internal class DefaultCustomTokenRouter : CustomTokenRouter {
val alert = AppDialog.SimpleOkDialogRes(
headerId = R.string.common_warning,
messageId = R.string.alert_manage_tokens_unsupported_curve_message,
args = listOf(blockchain.fullName),
args = listOf(blockchain.getNetworkName()),
)
store.dispatchDialogShow(alert)
}

View file

@ -190,7 +190,7 @@ internal class AddCustomTokenViewModel @Inject constructor(
)
DerivationPathSelectorType.BLOCKCHAIN -> SelectorItem.TitleWithSubtitle(
title = TextReference.Str(derivationPath),
subtitle = TextReference.Str(blockchain.fullName),
subtitle = TextReference.Str(blockchain.getNetworkName()),
blockchain = blockchain,
)
}
@ -204,7 +204,7 @@ internal class AddCustomTokenViewModel @Inject constructor(
)
} else {
SelectorItem.Title(
title = TextReference.Str(blockchain.fullName),
title = TextReference.Str(blockchain.getNetworkName()),
blockchain = blockchain,
)
}
@ -501,7 +501,7 @@ internal class AddCustomTokenViewModel @Inject constructor(
return buildSet {
if (!isSupportedToken && !isContractAddressFieldEmpty) {
add(AddCustomTokenWarning.UnsupportedToken(networkSelectorValue.fullName))
add(AddCustomTokenWarning.UnsupportedToken(networkSelectorValue.getNetworkName()))
}
if (isCustomTokenAlreadyAdded()) {
add(AddCustomTokenWarning.TokenAlreadyAdded)

View file

@ -51,7 +51,7 @@ internal class DefaultTokensListRouter : TokensListRouter {
val alert = AppDialog.SimpleOkDialogRes(
headerId = R.string.common_warning,
messageId = R.string.alert_manage_tokens_unsupported_curve_message,
args = listOf(blockchain.fullName),
args = listOf(blockchain.getNetworkName()),
)
store.dispatchDialogShow(alert)
}

View file

@ -24,8 +24,8 @@ import com.tangem.domain.tokens.AddCryptoCurrenciesUseCase
import com.tangem.domain.tokens.GetCryptoCurrenciesUseCase
import com.tangem.domain.tokens.TokenWithBlockchain
import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase
import com.tangem.tap.common.extensions.fullNameWithoutTestnet
import com.tangem.tap.common.extensions.getNetworkName
import com.tangem.tap.common.extensions.networkNameWithoutTestnet
import com.tangem.tap.common.extensions.getNetworkStandardName
import com.tangem.tap.features.customtoken.impl.presentation.models.SupportBlockchainType
import com.tangem.tap.features.tokens.impl.domain.TokensListInteractor
import com.tangem.tap.features.tokens.impl.domain.models.Token
@ -185,7 +185,7 @@ internal class TokensListViewModel @Inject constructor(
private fun createManageNetworkContent(network: Network): NetworkItemState.ManageContent {
return NetworkItemState.ManageContent(
name = network.blockchain.fullNameWithoutTestnet.uppercase(),
name = network.blockchain.networkNameWithoutTestnet.uppercase(),
protocolName = getNetworkProtocolName(network),
iconResId = mutableIntStateOf(value = getNetworkIconResId(network.address, network.blockchain)),
isMainNetwork = isMainNetwork(network),
@ -214,7 +214,7 @@ internal class TokensListViewModel @Inject constructor(
private fun createReadNetworkContent(network: Network): NetworkItemState.ReadContent {
return NetworkItemState.ReadContent(
name = network.blockchain.fullNameWithoutTestnet.uppercase(),
name = network.blockchain.networkNameWithoutTestnet.uppercase(),
protocolName = getNetworkProtocolName(network),
iconResId = mutableIntStateOf(value = getNetworkIconResId(network.address, network.blockchain)),
isMainNetwork = isMainNetwork(network),
@ -227,7 +227,7 @@ internal class TokensListViewModel @Inject constructor(
return if (network.address == null) {
MAIN_NETWORK_LABEL
} else {
network.blockchain.getNetworkName().uppercase()
network.blockchain.getNetworkStandardName().uppercase()
}
}
@ -361,7 +361,7 @@ internal class TokensListViewModel @Inject constructor(
router.openUnableHideMainTokenAlert(
tokenName = blockchain.name,
tokenSymbol = blockchain.currency,
networkName = blockchain.fullName,
networkName = blockchain.getNetworkName(),
)
} else if (isAddedOnMainScreen) {
router.openRemoveWalletAlert(
@ -431,7 +431,7 @@ internal class TokensListViewModel @Inject constructor(
} else {
when (isUnsupportedToken(token.blockchain)) {
SupportTokensState.NetworkTokensUnsupported -> {
router.openNetworkTokensNotSupportAlert(token.blockchain.fullName)
router.openNetworkTokensNotSupportAlert(token.blockchain.getNetworkName())
}
SupportTokensState.SupportedToken -> {
analyticsSender.sendWhenTokenAdded(token.token)