Updated on 2026-08-14

This commit is contained in:
Tangem 2023-11-02 17:00:01 +03:00
parent 2c8c2cb579
commit 3f20fb5bac
12 changed files with 15 additions and 90 deletions

View file

@ -81,6 +81,7 @@ internal class SendViewModel @Inject constructor(
userWalletId = userWalletId,
currencyId = cryptoCurrency.id,
derivationPath = cryptoCurrency.network.derivationPath,
contractAddress = (cryptoCurrency as? CryptoCurrency.Token)?.contractAddress,
isSingleWalletWithTokens = isSingleWallet,
)
.flowWithLifecycle(owner.lifecycle)

View file

@ -24,7 +24,7 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) {
iconResId = iconResId,
buttonsState = buttonsState,
),
) {
)
sealed class Informational(
title: TextReference,
@ -108,35 +108,5 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) {
id = R.string.warning_send_blocked_pending_transactions_message,
formatArgs = wrappedList(coinSymbol),
),
) {
data class RentInfo(
private val rentInfo: CryptoCurrencyWarning.Rent,
private val onCloseClick: () -> Unit,
) : Informational(
title = TextReference.Res(R.string.warning_rent_fee_title),
subtitle = TextReference.Res(
id = R.string.warning_solana_rent_fee_message,
formatArgs = wrappedList(rentInfo.rent, rentInfo.exemptionAmount),
),
onCloseClick = onCloseClick,
)
data class ExistentialDeposit(
private val existentialInfo: CryptoCurrencyWarning.ExistentialDeposit,
) : Informational(
title = resourceReference(R.string.warning_existential_deposit_title),
subtitle = TextReference.Res(
id = R.string.warning_existential_deposit_message,
formatArgs = wrappedList(existentialInfo.currencyName, existentialInfo.edStringValueWithSymbol),
),
)
class NetworksNoAccount(val network: String, val symbol: String, val amount: String) : Informational(
title = resourceReference(R.string.warning_no_account_title),
subtitle = resourceReference(
R.string.no_account_generic,
wrappedList(network, amount, symbol),
),
)
}
)
}

View file

@ -41,7 +41,7 @@ internal class TokenDetailsLoadedBalanceConverter(
return state.copy(
tokenBalanceBlockState = TokenDetailsBalanceBlockState.Error(state.tokenBalanceBlockState.actionButtons),
marketPriceBlockState = MarketPriceBlockState.Error(state.marketPriceBlockState.currencySymbol),
notifications = persistentListOf(TokenDetailsNotification.Warning.NetworksUnreachable),
notifications = persistentListOf(TokenDetailsNotification.NetworksUnreachable),
)
}

View file

@ -19,20 +19,20 @@ internal class TokenDetailsNotificationConverter(
fun removeRentInfo(currentState: TokenDetailsState): ImmutableList<TokenDetailsNotification> {
val newNotifications = currentState.notifications.toMutableList()
newNotifications.removeBy { it is TokenDetailsNotification.Informational.RentInfo }
newNotifications.removeBy { it is TokenDetailsNotification.RentInfo }
return newNotifications.toImmutableList()
}
private fun mapToNotification(warning: CryptoCurrencyWarning): TokenDetailsNotification {
return when (warning) {
is CryptoCurrencyWarning.BalanceNotEnoughForFee -> TokenDetailsNotification.Warning.NetworkFee(
is CryptoCurrencyWarning.BalanceNotEnoughForFee -> TokenDetailsNotification.NetworkFee(
feeInfo = warning,
onBuyClick = { clickIntents.onBuyCoinClick(warning.coinCurrency) },
)
is CryptoCurrencyWarning.ExistentialDeposit -> TokenDetailsNotification.Informational.ExistentialDeposit(
is CryptoCurrencyWarning.ExistentialDeposit -> TokenDetailsNotification.ExistentialDeposit(
existentialInfo = warning,
)
is CryptoCurrencyWarning.Rent -> TokenDetailsNotification.Informational.RentInfo(
is CryptoCurrencyWarning.Rent -> TokenDetailsNotification.RentInfo(
rentInfo = warning,
onCloseClick = clickIntents::onCloseRentInfoNotification,
)

View file

@ -159,18 +159,6 @@ internal class WalletNotificationsListFactory(
addMissingAddressesNotification(maybeMissedAddressCurrencies)
}
private fun MutableList<WalletNotification>.addInformationalNotifications(
cardTypesResolver: CardTypesResolver,
maybeMissedAddressCurrencies: Either<GetCurrenciesError, List<CryptoCurrency>>,
) {
addIf(
element = WalletNotification.Informational.DemoCard,
condition = isDemoCardUseCase(cardId = cardTypesResolver.getCardId()),
)
addMissingAddressesNotification(maybeMissedAddressCurrencies)
}
private fun MutableList<WalletNotification>.addIf(element: WalletNotification, condition: Boolean) {
if (condition) {
add(element = element)

View file

@ -115,7 +115,6 @@ internal class WalletViewModel @Inject constructor(
private val shouldShowSaveWalletScreenUseCase: ShouldShowSaveWalletScreenUseCase,
private val canUseBiometryUseCase: CanUseBiometryUseCase,
private val shouldSaveUserWalletsUseCase: ShouldSaveUserWalletsUseCase,
private val isBalanceHiddenUseCase: IsBalanceHiddenUseCase,
private val getBalanceHidingSettingsUseCase: GetBalanceHidingSettingsUseCase,
private val listenToFlipsUseCase: ListenToFlipsUseCase,
private val removeCurrencyUseCase: RemoveCurrencyUseCase,