diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/express/models/response/ExchangeStatusResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/express/models/response/ExchangeStatusResponse.kt index 3be2a6ebec..6af6ee2409 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/express/models/response/ExchangeStatusResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/express/models/response/ExchangeStatusResponse.kt @@ -49,7 +49,7 @@ enum class ExchangeStatus { @Json(name = "verifying") VERIFYING, - @Json(name = "cancelled") + @Json(name = "expired") CANCELLED, } diff --git a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt index 03cdd7a611..72290294eb 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt @@ -251,7 +251,7 @@ class DefaultWalletManagersFacade( derivationPath = derivationPath, ) if (walletManager == null || blockchain == Blockchain.Unknown) { - Timber.w("Unable to get a wallet manager for blockchain: $blockchain") + Timber.w("Unable to create or find a wallet manager for $blockchain") return UpdateWalletManagerResult.Unreachable } diff --git a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/WalletManagerFactory.kt b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/WalletManagerFactory.kt index cd0b2a670b..9e83e20e3a 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/WalletManagerFactory.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/WalletManagerFactory.kt @@ -10,6 +10,7 @@ import com.tangem.domain.common.DerivationStyleProvider import com.tangem.domain.common.extensions.makeWalletManagerForApp import com.tangem.domain.common.util.derivationStyleProvider import com.tangem.domain.models.scan.ScanResponse +import timber.log.Timber internal class WalletManagerFactory( private val configManager: ConfigManager, @@ -26,11 +27,16 @@ internal class WalletManagerFactory( ): WalletManager? { val derivationParams = getDerivationParams(derivationPath, scanResponse.derivationStyleProvider) - return sdkWalletManagerFactory.makeWalletManagerForApp( - scanResponse = scanResponse, - blockchain = blockchain, - derivationParams = derivationParams, - ) + return try { + sdkWalletManagerFactory.makeWalletManagerForApp( + scanResponse = scanResponse, + blockchain = blockchain, + derivationParams = derivationParams, + ) + } catch (e: Throwable) { + Timber.w(e, "Failed to create wallet manager for $blockchain") + null + } } private fun getDerivationParams( diff --git a/features/swap/data/src/main/java/com/tangem/feature/swap/DefaultSwapRepository.kt b/features/swap/data/src/main/java/com/tangem/feature/swap/DefaultSwapRepository.kt index e176e30ad1..c241793b1a 100644 --- a/features/swap/data/src/main/java/com/tangem/feature/swap/DefaultSwapRepository.kt +++ b/features/swap/data/src/main/java/com/tangem/feature/swap/DefaultSwapRepository.kt @@ -293,7 +293,7 @@ internal class DefaultSwapRepository @Inject constructor( if (txDetails.requestId != requestId) { return@withContext DataError.InvalidRequestIdError().left() } - if (toAddress != txDetails.payoutAddress) { + if (!toAddress.equals(txDetails.payoutAddress, ignoreCase = true)) { return@withContext DataError.InvalidPayoutAddressError().left() } expressDataConverter.convert( 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 a1420cc27f..38f55b3561 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 @@ -852,19 +852,12 @@ internal class SwapInteractorImpl @Inject constructor( amount: SwapAmount, fromToken: CryptoCurrency, ): IncludeFeeInAmount { - if (fromToken is CryptoCurrency.Token) { - return IncludeFeeInAmount.Excluded - } - val tokenForFeeBalance = userWalletManager.getNativeTokenBalance( networkId, fromToken.network.derivationPath.value, ) ?: ProxyAmount.empty() - if (amount.value > tokenForFeeBalance.value) { - return IncludeFeeInAmount.BalanceNotEnough - } val feeValue = when (txFee) { TxFeeState.Empty -> BigDecimal.ZERO is TxFeeState.MultipleFeeState -> txFee.priorityFee.feeValue @@ -872,19 +865,33 @@ internal class SwapInteractorImpl @Inject constructor( } val amountWithFee = amount.value + feeValue - return if (amountWithFee < tokenForFeeBalance.value) { - IncludeFeeInAmount.Excluded - } else { - if (feeValue < amount.value) { - IncludeFeeInAmount.Included( - SwapAmount( - tokenForFeeBalance.value - feeValue, - transactionManager.getNativeTokenDecimals(networkId), - ), - ) - } else { + + return when { + fromToken is CryptoCurrency.Token -> { + if (feeValue > tokenForFeeBalance.value) { + IncludeFeeInAmount.BalanceNotEnough + } else { + IncludeFeeInAmount.Excluded + } + } + amount.value > tokenForFeeBalance.value -> { IncludeFeeInAmount.BalanceNotEnough } + amountWithFee < tokenForFeeBalance.value -> { + IncludeFeeInAmount.Excluded + } + else -> { + if (feeValue < amount.value) { + IncludeFeeInAmount.Included( + SwapAmount( + tokenForFeeBalance.value - feeValue, + transactionManager.getNativeTokenDecimals(networkId), + ), + ) + } else { + IncludeFeeInAmount.BalanceNotEnough + } + } } }