From 95ebe65e573899b3f411a3b0f30efec546ba8539 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 2 Feb 2026 13:08:39 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../feature/swap/domain/SwapInteractorImpl.kt | 10 ++++------ .../tangem/feature/swap/DefaultSwapComponent.kt | 14 ++++---------- 2 files changed, 8 insertions(+), 16 deletions(-) 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 286471b0a0..217144c02a 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 @@ -1535,9 +1535,7 @@ internal class SwapInteractorImpl @AssistedInject constructor( swapAmount = amount, quotesLoadedState = swapState, isAllowedToSpend = isAllowedToSpend, - spenderAddress = requireNotNull(quoteModel.allowanceContract) { - "allowanceContract is required for DEX" - }, + spenderAddress = quoteModel.allowanceContract, ) if (state !is SwapState.QuotesLoadedState) return state state.copy( @@ -2079,14 +2077,14 @@ internal class SwapInteractorImpl @AssistedInject constructor( ) ?: TxFeeState.Empty } - @Suppress("LongParameterList", "LongMethod") + @Suppress("LongParameterList", "LongMethod", "CanBeNonNullable") private suspend fun updatePermissionState( networkId: String, fromTokenStatus: CryptoCurrencyStatus, fromAccount: Account.CryptoPortfolio?, swapAmount: SwapAmount, quotesLoadedState: SwapState.QuotesLoadedState, - spenderAddress: String, + spenderAddress: String?, isAllowedToSpend: Boolean, ): SwapState { val fromToken = fromTokenStatus.currency @@ -2110,7 +2108,7 @@ internal class SwapInteractorImpl @AssistedInject constructor( val derivationPath = fromToken.network.derivationPath.value // setting up amount for approve with given amount for swap [SwapApproveType.Limited] val callData = SmartContractCallDataProviderFactory.getApprovalCallData( - spenderAddress = spenderAddress, + spenderAddress = requireNotNull(spenderAddress) { "spenderAddress cant be null" }, amount = swapAmount.value.convertToSdkAmount(fromTokenStatus), blockchain = fromToken.network.toBlockchain(), ) diff --git a/features/swap/impl/src/main/java/com/tangem/feature/swap/DefaultSwapComponent.kt b/features/swap/impl/src/main/java/com/tangem/feature/swap/DefaultSwapComponent.kt index 55e17a1292..6e9495b238 100644 --- a/features/swap/impl/src/main/java/com/tangem/feature/swap/DefaultSwapComponent.kt +++ b/features/swap/impl/src/main/java/com/tangem/feature/swap/DefaultSwapComponent.kt @@ -2,9 +2,7 @@ package com.tangem.feature.swap import androidx.compose.animation.Crossfade import androidx.compose.foundation.background -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue +import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.arkivanov.decompose.ComponentContext @@ -103,13 +101,9 @@ internal class DefaultSwapComponent @AssistedInject constructor( @Composable override fun Content(modifier: Modifier) { if (sendFeatureToggles.isGaslessTransactionsEnabled) { - val fromCryptoCurrency = if (model.isOrderReversed) { - model.dataState.toCryptoCurrency - } else { - model.dataState.fromCryptoCurrency - } - val feePaidCryptoCurrency = model.dataState.feePaidCryptoCurrency - val amount = model.dataState.amount + val fromCryptoCurrency by remember { derivedStateOf { model.dataState.fromCryptoCurrency } } + val feePaidCryptoCurrency by remember { derivedStateOf { model.dataState.feePaidCryptoCurrency } } + val amount by remember { derivedStateOf { model.dataState.amount } } LaunchedEffect(fromCryptoCurrency, feePaidCryptoCurrency, amount.isNullOrBlank()) { if (amount.isNullOrBlank()) {