diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/ResponseCryptoCurrenciesFactory.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/ResponseCryptoCurrenciesFactory.kt index 5157d1430d..5435cebfd9 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/ResponseCryptoCurrenciesFactory.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/ResponseCryptoCurrenciesFactory.kt @@ -74,23 +74,40 @@ class ResponseCryptoCurrenciesFactory { ): CryptoCurrency.Coin? { val network = getNetwork(blockchain, responseToken.derivationPath, derivationStyleProvider) ?: return null - // workaround: Dischain was renamed but backend still returns the old name, - // get name and symbol from enum Blockchain until backend renamed - // [REDACTED_JIRA] - val name = if (blockchain == Blockchain.Dischain) blockchain.fullName else responseToken.name - val symbol = if (blockchain == Blockchain.Dischain) blockchain.currency else responseToken.symbol - return CryptoCurrency.Coin( id = getCoinId(network, blockchain.toCoinId()), network = network, - name = name, - symbol = symbol, + name = blockchain.getNameForCoin(responseToken), + symbol = blockchain.getSymbolForCoin(responseToken), decimals = responseToken.decimals, iconUrl = getCoinIconUrl(blockchain), isCustom = isCustomCoin(network), ) } + private fun Blockchain.getNameForCoin(responseToken: UserTokensResponse.Token): String { + return when (this) { + // workaround: Dischain was renamed but backend still returns the old name, + // get name and symbol from enum Blockchain until backend renamed + // [REDACTED_JIRA] + Blockchain.Dischain, + Blockchain.Arbitrum, + -> this.fullName + else -> responseToken.name + } + } + + private fun Blockchain.getSymbolForCoin(responseToken: UserTokensResponse.Token): String { + return when (this) { + // workaround: Dischain was renamed but backend still returns the old name, + // get name and symbol from enum Blockchain until backend renamed + // [REDACTED_JIRA] + Blockchain.Dischain, + -> this.currency + else -> responseToken.symbol + } + } + private fun createToken( blockchain: Blockchain, sdkToken: Token, diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt index b90d787043..6e477d8a10 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt @@ -24,7 +24,7 @@ sealed class CryptoCurrencyWarning { val feeCurrencySymbol: String, ) : CryptoCurrencyWarning() - object SomeNetworksUnreachable : CryptoCurrencyWarning() + data object SomeNetworksUnreachable : CryptoCurrencyWarning() data class SomeNetworksNoAccount( val amountToCreateAccount: BigDecimal, diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/FeeNotificationFactory.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/FeeNotificationFactory.kt index da1277412a..7b31b34d3d 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/FeeNotificationFactory.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/FeeNotificationFactory.kt @@ -1,9 +1,11 @@ package com.tangem.features.send.impl.presentation.state.fee +import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.transaction.Fee import com.tangem.blockchain.common.transaction.TransactionFee import com.tangem.core.ui.extensions.networkIconResId import com.tangem.core.ui.utils.parseToBigDecimal +import com.tangem.domain.common.extensions.fromNetworkId import com.tangem.domain.tokens.GetBalanceNotEnoughForFeeWarningUseCase import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning @@ -90,6 +92,7 @@ internal class FeeNotificationFactory( ifRight = { it }, ) ?: return + val mergeFeeNetworkName = cryptoCurrencyStatus.shouldMergeFeeNetworkName() when (warning) { is CryptoCurrencyWarning.BalanceNotEnoughForFee -> { add( @@ -99,6 +102,7 @@ internal class FeeNotificationFactory( currencyName = cryptoCurrencyStatus.currency.name, feeName = warning.coinCurrency.name, feeSymbol = warning.coinCurrency.symbol, + mergeFeeNetworkName = mergeFeeNetworkName, onClick = { clickIntents.onTokenDetailsClick( userWalletId = userWalletId, @@ -117,6 +121,7 @@ internal class FeeNotificationFactory( feeName = warning.feeCurrencyName, feeSymbol = warning.feeCurrencySymbol, networkName = warning.networkName, + mergeFeeNetworkName = mergeFeeNetworkName, onClick = currency?.let { { clickIntents.onTokenDetailsClick( @@ -132,6 +137,11 @@ internal class FeeNotificationFactory( } } + // workaround for networks that users have misunderstanding + private fun CryptoCurrencyStatus.shouldMergeFeeNetworkName(): Boolean { + return Blockchain.fromNetworkId(this.currency.network.backendId) == Blockchain.Arbitrum + } + companion object { private val FEE_MAX_DIFF = BigDecimal(5) private const val HIGH_FEE_DIFF_DECIMALS = 0 diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/SendFeeNotification.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/SendFeeNotification.kt index c82f072f6a..b3a2846e5f 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/SendFeeNotification.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/SendFeeNotification.kt @@ -56,6 +56,7 @@ sealed class SendFeeNotification(val config: NotificationConfig) { val feeName: String, val feeSymbol: String, val networkName: String, + val mergeFeeNetworkName: Boolean = false, val onClick: (() -> Unit)? = null, ) : Error( title = resourceReference( @@ -69,7 +70,16 @@ sealed class SendFeeNotification(val config: NotificationConfig) { iconResId = networkIconId, buttonsState = onClick?.let { NotificationConfig.ButtonsState.SecondaryButtonConfig( - text = resourceReference(R.string.common_buy_currency, wrappedList(feeName)), + text = resourceReference( + R.string.common_buy_currency, + wrappedList( + if (mergeFeeNetworkName) { + "$currencyName ($feeSymbol)" + } else { + feeName + }, + ), + ), onClick = onClick, ) }, diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt index 185abeff5d..669c2e24f6 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt @@ -99,6 +99,7 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) { private val networkName: String, private val feeCurrencyName: String, private val feeCurrencySymbol: String, + val mergeFeeNetworkName: Boolean = false, private val onBuyClick: () -> Unit, ) : Warning( title = TextReference.Res( @@ -120,7 +121,13 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) { NotificationConfig.ButtonsState.SecondaryButtonConfig( text = resourceReference( id = R.string.common_buy_currency, - formatArgs = wrappedList(feeCurrencySymbol), + formatArgs = wrappedList( + if (mergeFeeNetworkName) { + "$feeCurrencyName ($feeCurrencySymbol)" + } else { + feeCurrencySymbol + }, + ), ), onClick = onBuyClick, ), diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt index bf37784e25..eaeb7f760a 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt @@ -1,5 +1,8 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.state.factory +import com.tangem.blockchain.common.Blockchain +import com.tangem.domain.common.extensions.fromNetworkId +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsNotification @@ -28,9 +31,10 @@ internal class TokenDetailsNotificationConverter( return when (warning) { is CryptoCurrencyWarning.BalanceNotEnoughForFee -> NetworkFeeWithBuyButton( currency = warning.tokenCurrency, - networkName = warning.coinCurrency.name, + networkName = warning.coinCurrency.network.name, feeCurrencyName = warning.coinCurrency.name, feeCurrencySymbol = warning.coinCurrency.symbol, + mergeFeeNetworkName = warning.coinCurrency.shouldMergeFeeNetworkName(), onBuyClick = { clickIntents.onBuyCoinClick(warning.coinCurrency) }, ) is CryptoCurrencyWarning.CustomTokenNotEnoughForFee -> { @@ -41,6 +45,7 @@ internal class TokenDetailsNotificationConverter( networkName = feeCurrency.network.name, feeCurrencyName = warning.feeCurrencyName, feeCurrencySymbol = warning.feeCurrencySymbol, + mergeFeeNetworkName = warning.currency.shouldMergeFeeNetworkName(), onBuyClick = { clickIntents.onBuyCoinClick(feeCurrency) }, ) } else { @@ -75,4 +80,9 @@ internal class TokenDetailsNotificationConverter( ) } } + + // workaround for networks that users have misunderstanding + private fun CryptoCurrency.shouldMergeFeeNetworkName(): Boolean { + return Blockchain.fromNetworkId(this.network.backendId) == Blockchain.Arbitrum + } } \ No newline at end of file diff --git a/gradle/dependencies.toml b/gradle/dependencies.toml index 47d3487f7f..5b36453cde 100644 --- a/gradle/dependencies.toml +++ b/gradle/dependencies.toml @@ -85,7 +85,7 @@ web3j = "4.10.1" # endregion Other libraries # region Tangem -tangemBlockchainSdk = "develop-497" +tangemBlockchainSdk = "develop-503" #tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds tangemCardSdk = "develop-324" #tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^