diff --git a/core/res/src/main/res/values-ru/strings-blockchain.xml b/core/res/src/main/res/values-ru/strings-blockchain.xml
index fcec1f9e0c..0744b44f6b 100644
--- a/core/res/src/main/res/values-ru/strings-blockchain.xml
+++ b/core/res/src/main/res/values-ru/strings-blockchain.xml
@@ -7,7 +7,7 @@
Недостаточно средств для совершения транзакции. Пожалуйста, пополните свой аккаунт.
Произошла ошибка. Код: %s.
Из-за ограничений Kaspa в одну транзакцию может поместиться только %1$d UTXO. Это означает, что вы можете отправить только %2$s или меньше. Вам нужно уменьшить сумму.
- Пополните счет на %1$s+ %2$s, чтобы создать аккаунт
+ Чтобы использовать сеть %1$s, вы должны оплатить резерв аккаунта (%2$s %3$s), который блокируется и не используется в вашем балансе.
Аккаунт получателя не активирован. Отправьте %s или более для активации аккаунта.
Минимальная сумма: %s
Сдача слишком мала
diff --git a/core/res/src/main/res/values/strings-blockchain.xml b/core/res/src/main/res/values/strings-blockchain.xml
index 7e938d5420..bb28ad284c 100644
--- a/core/res/src/main/res/values/strings-blockchain.xml
+++ b/core/res/src/main/res/values/strings-blockchain.xml
@@ -7,7 +7,7 @@
Not enough funds for the transaction. Please top up your account.
An error occurred. Code: %s.
Due to Kaspa limitations only %1$d UTXOs can fit in a single transaction. This means you can only send %2$s or less. You need to reduce the amount.
- Load %1$s+ %2$s to create account
+ To use the %1$s network, you must pay the account reserve (%2$s %3$s), which locks up and hides that amount indefinitely.
Destination account is not active. Send %s or more to activate the account.
Minimum amount is %s
Change is too small
diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml
index b04bede936..9e2b6673a4 100644
--- a/core/res/src/main/res/values/strings.xml
+++ b/core/res/src/main/res/values/strings.xml
@@ -608,7 +608,6 @@
Some networks currently are unreachable. Please try again later.
Some networks are unreachable
This is a Testnet card. Don\'t accept it as a payment. This card must only be used for testing and development purposes.
- Note top up
Discard
You have an interrupted backup. Do you want to resume?
Yes, resume
diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/CryptoCurrencyStatus.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/CryptoCurrencyStatus.kt
index b4187361d6..8f49493cc5 100644
--- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/CryptoCurrencyStatus.kt
+++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/CryptoCurrencyStatus.kt
@@ -71,10 +71,10 @@ data class CryptoCurrencyStatus(
/**
* Represents a state where there is no account associated with the cryptocurrency
*
- * @property errorMessage error message
+ * @property amountToCreateAccount base reserve amount for account creation
*/
data class NoAccount(
- val errorMessage: String,
+ val amountToCreateAccount: BigDecimal,
override val priceChange: BigDecimal?,
override val fiatRate: BigDecimal?,
) : Status(isError = false) {
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 89663cf0fa..6c8ec13eb1 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
@@ -18,6 +18,11 @@ sealed class CryptoCurrencyWarning {
object SomeNetworksUnreachable : CryptoCurrencyWarning()
+ data class SomeNetworksNoAccount(
+ val amountToCreateAccount: BigDecimal,
+ val amountCurrency: CryptoCurrency,
+ ) : CryptoCurrencyWarning()
+
/**
* Represents wallet blockchain rent
* @param rent Amount that will be charged in overtime if the blockchain does not have an amount greater than
diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt
index 227161d34f..b35a730d3a 100644
--- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt
+++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt
@@ -40,7 +40,8 @@ class GetCurrencyWarningsUseCase(
flowOf(walletManagersFacade.getRentInfo(userWalletId, currency.network)),
flowOf(walletManagersFacade.getExistentialDeposit(userWalletId, currency.network)),
flowOf(getNetworkUnavailableWarning(currencyStatus)),
- ) { maybeFeeWarning, maybeRentWarning, maybeEdWarning, maybeNetworkUnavailable ->
+ flowOf(getNetworkNoAccountWarning(currencyStatus)),
+ ) { maybeFeeWarning, maybeRentWarning, maybeEdWarning, maybeNetworkUnavailable, maybeNetworkNoAccount ->
setOfNotNull(
maybeRentWarning,
maybeEdWarning?.let {
@@ -51,6 +52,7 @@ class GetCurrencyWarningsUseCase(
},
maybeFeeWarning,
maybeNetworkUnavailable,
+ maybeNetworkNoAccount,
)
}.flowOn(dispatchers.io)
}
@@ -106,6 +108,15 @@ class GetCurrencyWarningsUseCase(
}
}
+ private fun getNetworkNoAccountWarning(currencyStatus: CryptoCurrencyStatus): CryptoCurrencyWarning? {
+ return (currencyStatus.value as? CryptoCurrencyStatus.NoAccount)?.let {
+ CryptoCurrencyWarning.SomeNetworksNoAccount(
+ amountToCreateAccount = it.amountToCreateAccount,
+ amountCurrency = currencyStatus.currency,
+ )
+ }
+ }
+
private fun BigDecimal?.isZero(): Boolean {
return this?.signum() == 0
}
diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrencyStatusOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrencyStatusOperations.kt
index 804c8a58bc..89f506ab39 100644
--- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrencyStatusOperations.kt
+++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrencyStatusOperations.kt
@@ -20,7 +20,7 @@ internal class CurrencyStatusOperations(
null -> CryptoCurrencyStatus.Loading
is NetworkStatus.MissedDerivation -> createMissedDerivationStatus()
is NetworkStatus.Unreachable -> createUnreachableStatus()
- is NetworkStatus.NoAccount -> createNoAccountStatus(status.errorMessage)
+ is NetworkStatus.NoAccount -> createNoAccountStatus(status.amountToCreateAccount)
is NetworkStatus.Verified -> createStatus(status)
}
}
@@ -31,11 +31,12 @@ internal class CurrencyStatusOperations(
private fun createUnreachableStatus(): CryptoCurrencyStatus.Unreachable =
CryptoCurrencyStatus.Unreachable(priceChange = quote?.priceChange, fiatRate = quote?.fiatRate)
- private fun createNoAccountStatus(message: String): CryptoCurrencyStatus.NoAccount = CryptoCurrencyStatus.NoAccount(
- errorMessage = message,
- priceChange = quote?.priceChange,
- fiatRate = quote?.fiatRate,
- )
+ private fun createNoAccountStatus(amount: BigDecimal): CryptoCurrencyStatus.NoAccount =
+ CryptoCurrencyStatus.NoAccount(
+ amountToCreateAccount = amount,
+ priceChange = quote?.priceChange,
+ fiatRate = quote?.fiatRate,
+ )
private fun createStatus(status: NetworkStatus.Verified): CryptoCurrencyStatus.Status {
val amount = status.amounts[currency.id]
diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokenLists.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokenLists.kt
index fb41b5aa56..0cbc4a5d5c 100644
--- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokenLists.kt
+++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokenLists.kt
@@ -48,7 +48,7 @@ internal object MockTokenLists {
val loadingUngroupedTokenList = with(failedUngroupedTokenList) {
copy(
- currencies = currencies.map { it.copy(value = CryptoCurrencyStatus.Loading) },
+ currencies = currencies.map { it.copy(value = CryptoCurrencyStatus.Loading) }.toNonEmptyListOrNull() ?: emptyList(),
totalFiatBalance = TokenList.FiatBalance.Loading,
)
}
diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokensStates.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokensStates.kt
index 69e1b66b5c..d1410765aa 100644
--- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokensStates.kt
+++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokensStates.kt
@@ -60,7 +60,7 @@ internal object MockTokensStates {
value = CryptoCurrencyStatus.NoAccount(
priceChange = MockQuotes.quote7.priceChange,
fiatRate = MockQuotes.quote7.fiatRate,
- errorMessage = "",
+ amountToCreateAccount = MockNetworks.amountToCreateAccount,
),
)
@@ -69,7 +69,7 @@ internal object MockTokensStates {
value = CryptoCurrencyStatus.NoAccount(
priceChange = MockQuotes.quote8.priceChange,
fiatRate = MockQuotes.quote8.fiatRate,
- errorMessage = "",
+ amountToCreateAccount = MockNetworks.amountToCreateAccount,
),
)
@@ -78,7 +78,7 @@ internal object MockTokensStates {
value = CryptoCurrencyStatus.NoAccount(
priceChange = MockQuotes.quote9.priceChange,
fiatRate = MockQuotes.quote9.fiatRate,
- errorMessage = "",
+ amountToCreateAccount = MockNetworks.amountToCreateAccount,
),
)
@@ -87,7 +87,7 @@ internal object MockTokensStates {
value = CryptoCurrencyStatus.NoAccount(
priceChange = MockQuotes.quote10.priceChange,
fiatRate = MockQuotes.quote10.fiatRate,
- errorMessage = "",
+ amountToCreateAccount = MockNetworks.amountToCreateAccount,
),
)
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 fd43bdcd6e..6a6488777c 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
@@ -9,9 +9,8 @@ import com.tangem.core.ui.extensions.wrappedList
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning
import com.tangem.features.tokendetails.impl.R
-// TODO: Finalize notification strings [REDACTED_JIRA]
@Immutable
-sealed class TokenDetailsNotification {
+internal sealed class TokenDetailsNotification {
abstract val config: NotificationConfig
@@ -83,4 +82,15 @@ sealed class TokenDetailsNotification {
iconResId = R.drawable.img_attention_20,
)
}
+
+ class NetworksNoAccount(val network: String, val symbol: String, val amount: String) : Informational() {
+ override val config = NotificationConfig(
+ title = resourceReference(R.string.warning_no_account_title),
+ subtitle = resourceReference(
+ R.string.no_account_generic,
+ wrappedList(network, amount, symbol),
+ ),
+ iconResId = R.drawable.ic_alert_circle_24,
+ )
+ }
}
\ No newline at end of file
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 945fd6107e..6a20547a9f 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
@@ -37,6 +37,11 @@ internal class TokenDetailsNotificationConverter(
onCloseClick = clickIntents::onCloseRentInfoNotification,
)
CryptoCurrencyWarning.SomeNetworksUnreachable -> TokenDetailsNotification.NetworksUnreachable
+ is CryptoCurrencyWarning.SomeNetworksNoAccount -> TokenDetailsNotification.NetworksNoAccount(
+ network = warning.amountCurrency.name,
+ amount = warning.amountToCreateAccount.toString(),
+ symbol = warning.amountCurrency.symbol,
+ )
}
}
}
\ No newline at end of file
diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletNotification.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletNotification.kt
index 6c3fd2d2d8..4f62061929 100644
--- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletNotification.kt
+++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/components/WalletNotification.kt
@@ -2,7 +2,10 @@ package com.tangem.feature.wallet.presentation.wallet.state.components
import androidx.compose.runtime.Immutable
import com.tangem.core.ui.components.notifications.NotificationConfig
-import com.tangem.core.ui.extensions.*
+import com.tangem.core.ui.extensions.TextReference
+import com.tangem.core.ui.extensions.pluralReference
+import com.tangem.core.ui.extensions.resourceReference
+import com.tangem.core.ui.extensions.wrappedList
import com.tangem.feature.wallet.impl.R
/**
@@ -88,11 +91,6 @@ sealed class WalletNotification(val config: NotificationConfig) {
subtitle = resourceReference(id = R.string.warning_some_networks_unreachable_message),
)
- data class TopUpNote(val errorMessage: String) : Warning(
- title = resourceReference(id = R.string.warning_title_note_top_up),
- subtitle = stringReference(value = errorMessage),
- )
-
data class NumberOfSignedHashesIncorrect(val onCloseClick: () -> Unit) : Warning(
title = resourceReference(id = R.string.common_warning),
subtitle = resourceReference(id = R.string.alert_card_signed_transactions),
@@ -117,6 +115,17 @@ sealed class WalletNotification(val config: NotificationConfig) {
),
)
+ data class NoAccount(val network: String, val symbol: String, val amount: String) : WalletNotification(
+ config = NotificationConfig(
+ title = resourceReference(id = R.string.warning_no_account_title),
+ subtitle = resourceReference(
+ id = R.string.no_account_generic,
+ wrappedList(network, amount, symbol),
+ ),
+ iconResId = R.drawable.ic_alert_circle_24,
+ ),
+ )
+
data class UnlockWallets(val onClick: () -> Unit) : WalletNotification(
config = NotificationConfig(
title = resourceReference(id = R.string.common_unlock_needed),
diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletNotifications.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletNotifications.kt
index 22c20dcfc7..1ef6f61148 100644
--- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletNotifications.kt
+++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletNotifications.kt
@@ -32,6 +32,7 @@ internal fun LazyListScope.notifications(configs: ImmutableList TangemTheme.colors.icon.accent
is WalletNotification.RateApp -> TangemTheme.colors.icon.attention
is WalletNotification.UnlockWallets -> TangemTheme.colors.icon.primary1
+ is WalletNotification.NoAccount -> TangemTheme.colors.icon.accent
is WalletNotification.Warning -> null
},
)
diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt
index 859b8ccf58..4b160e908b 100644
--- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt
+++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt
@@ -143,10 +143,7 @@ internal class WalletNotificationsListFactory(
condition = cryptoCurrencyList.hasUnreachableNetworks(),
)
- val errorMessage = cryptoCurrencyList.geNoAccountStatusMessage()
- if (errorMessage != null) {
- add(element = WalletNotification.Warning.TopUpNote(errorMessage = errorMessage))
- }
+ addNoAccountWarning(cryptoCurrencyList)
addIf(
element = WalletNotification.Warning.NumberOfSignedHashesIncorrect(
@@ -169,12 +166,19 @@ internal class WalletNotificationsListFactory(
return any { it.value is CryptoCurrencyStatus.Unreachable }
}
- private fun List.geNoAccountStatusMessage(): String? {
- return this
- .map(CryptoCurrencyStatus::value)
- .filterIsInstance()
- .firstOrNull()
- ?.errorMessage
+ private fun MutableList.addNoAccountWarning(cryptoCurrencyList: List) {
+ val noAccountNetwork = cryptoCurrencyList.firstOrNull { it.value is CryptoCurrencyStatus.NoAccount }
+ if (noAccountNetwork != null) {
+ val amountToCreateAccount = (noAccountNetwork.value as? CryptoCurrencyStatus.NoAccount)
+ ?.amountToCreateAccount.toString()
+ add(
+ element = WalletNotification.NoAccount(
+ network = noAccountNetwork.currency.name,
+ amount = amountToCreateAccount,
+ symbol = noAccountNetwork.currency.symbol,
+ ),
+ )
+ }
}
/**