Updated on 2026-08-14

This commit is contained in:
Tangem 2024-10-21 12:12:13 +04:00
parent 2ec61ee354
commit 2be1217ad7
3 changed files with 20 additions and 10 deletions

View file

@ -64,6 +64,9 @@ enum class ExchangeStatus {
@Json(name = "tx-failed")
TxFailed,
@Json(name = "paused")
Paused,
@Json(name = "unknown")
Unknown,
}

View file

@ -169,14 +169,15 @@ internal class DefaultSwapRepository(
return withContext(coroutineDispatcher.io) {
either {
catch(
{
block = {
exchangeStatusConverter.convert(
tangemExpressApi
.getExchangeStatus(txId)
.getOrThrow(),
)
},
{
catch = {
Timber.e("getExchangeStatus error: $it")
raise(UnknownError(it.message))
},
)

View file

@ -25,6 +25,7 @@ import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import timber.log.Timber
import java.math.BigDecimal
import java.util.Locale
@ -115,7 +116,10 @@ internal class TokenDetailsSwapTransactionsStateConverter(
refundToken: CryptoCurrency?,
isRefundTerminalStatus: Boolean,
): SwapTransactionsState {
if (statusModel == null || tx.activeStatus == statusModel.status) return tx
if (statusModel == null || tx.activeStatus == statusModel.status) {
Timber.e("UpdateTxStatus isn't required. Current status isn't changed")
return tx
}
val hasFailed = tx.hasFailed || statusModel.status == ExchangeStatus.Failed
val notifications = getNotification(statusModel.status, statusModel.txExternalUrl, refundToken)
val showProviderLink = getShowProviderLink(notifications, statusModel)
@ -217,13 +221,15 @@ internal class TokenDetailsSwapTransactionsStateConverter(
isPaused = isPaused,
),
)
add(
sendStep(
isSending = isSending,
isSendingDone = isSendingDone,
isRefunded = isRefunded,
),
)
if (!isPaused) {
add(
sendStep(
isSending = isSending,
isSendingDone = isSendingDone,
isRefunded = isRefunded,
),
)
}
}
}
}.toPersistentList()