diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt index f1af16641e..6504c6d53a 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt @@ -461,10 +461,12 @@ internal class SwapInteractorImpl @Inject constructor( amount, currencyToSend.symbol, ), + fromAmountValue = amount.value, toAmount = amountFormatter.formatSwapAmountToUI( swapData.toTokenAmount, currencyToGet.symbol, ), + toAmountValue = swapData.toTokenAmount.value, txAddress = userWalletManager.getLastTransactionHash(networkId, derivationPath).orEmpty(), timestamp = System.currentTimeMillis(), ) @@ -541,10 +543,12 @@ internal class SwapInteractorImpl @Inject constructor( amount, currencyToSend.currency.symbol, ), + fromAmountValue = amount.value, toAmount = amountFormatter.formatSwapAmountToUI( exchangeData.dataModel.toTokenAmount, currencyToGet.currency.symbol, ), + toAmountValue = exchangeData.dataModel.toTokenAmount.value, txAddress = userWalletManager.getLastTransactionHash( currencyToSend.currency.network.backendId, derivationPath, diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/TxState.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/TxState.kt index a593888610..526b5b2a73 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/TxState.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/TxState.kt @@ -1,10 +1,14 @@ package com.tangem.feature.swap.domain.models.ui +import java.math.BigDecimal + sealed class TxState { data class TxSent( val fromAmount: String? = null, + val fromAmountValue: BigDecimal? = null, val toAmount: String? = null, + val toAmountValue: BigDecimal? = null, val txAddress: String, val txExternalUrl: String? = null, val timestamp: Long, diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt index 28d54f59f5..1330cb8db3 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt @@ -643,7 +643,7 @@ internal class StateBuilder( @Suppress("LongParameterList") fun createSuccessState( uiState: SwapStateHolder, - timeStamp: Long, + txState: TxState.TxSent, txUrl: String, dataState: SwapProcessDataState, onExploreClick: () -> Unit, @@ -652,18 +652,16 @@ internal class StateBuilder( val fee = requireNotNull(dataState.selectedFee) val fromCryptoCurrency = requireNotNull(dataState.fromCryptoCurrency) val toCryptoCurrency = requireNotNull(dataState.toCryptoCurrency) - val fromAmount = toBigDecimalOrNull(requireNotNull(dataState.amount)) - val toAmount = requireNotNull(dataState.swapDataModel?.toTokenAmount?.value) + val fromAmount = txState.fromAmountValue ?: BigDecimal.ZERO + val toAmount = txState.toAmountValue ?: BigDecimal.ZERO val providerState = uiState.providerState as ProviderState.Content - val fromCryptoAmount = BigDecimalFormatter.formatCryptoAmount(fromAmount, fromCryptoCurrency.currency) - val toCryptoAmount = BigDecimalFormatter.formatCryptoAmount(toAmount, toCryptoCurrency.currency) val fromFiatAmount = getFormattedFiatAmount(fromCryptoCurrency.value.fiatRate?.multiply(fromAmount)) val toFiatAmount = getFormattedFiatAmount(toCryptoCurrency.value.fiatRate?.multiply(toAmount)) return uiState.copy( successState = SwapSuccessStateHolder( - timestamp = timeStamp, + timestamp = txState.timestamp, txUrl = txUrl, providerName = stringReference(providerState.name), providerType = stringReference(providerState.type), @@ -671,8 +669,8 @@ internal class StateBuilder( providerIcon = providerState.iconUrl, rate = providerState.subtitle, fee = stringReference("${fee.feeCryptoFormatted} (${fee.feeFiatFormatted})"), - fromTokenAmount = stringReference(fromCryptoAmount), - toTokenAmount = stringReference(toCryptoAmount), + fromTokenAmount = stringReference(txState.fromAmount.orEmpty()), + toTokenAmount = stringReference(txState.toAmount.orEmpty()), fromTokenFiatAmount = stringReference(fromFiatAmount), toTokenFiatAmount = stringReference(toFiatAmount), fromTokenIconState = iconStateConverter.convert(fromCryptoCurrency), diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt index 4f736b29f7..acf3fff110 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt @@ -460,7 +460,7 @@ internal class SwapViewModel @Inject constructor( ) uiState = stateBuilder.createSuccessState( uiState = uiState, - timeStamp = it.timestamp, + txState = it, dataState = dataState, txUrl = url, onExploreClick = {