Updated on 2026-08-14
This commit is contained in:
parent
6ef8539672
commit
98ae29a49b
4 changed files with 15 additions and 9 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ internal class SwapViewModel @Inject constructor(
|
|||
)
|
||||
uiState = stateBuilder.createSuccessState(
|
||||
uiState = uiState,
|
||||
timeStamp = it.timestamp,
|
||||
txState = it,
|
||||
dataState = dataState,
|
||||
txUrl = url,
|
||||
onExploreClick = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue