Updated on 2026-08-14

This commit is contained in:
Tangem 2026-04-09 17:56:28 +05:00
parent 58d7b0f393
commit 1c1a968c39
4 changed files with 19 additions and 1 deletions

View file

@ -74,6 +74,7 @@ import com.tangem.feature.swap.analytics.SwapEvents
import com.tangem.feature.swap.choosetoken.api.ChooseTokenBridge
import com.tangem.feature.swap.component.SwapFeeSelectorBlockComponent
import com.tangem.feature.swap.converters.SwapTransactionErrorStateConverter
import com.tangem.feature.swap.domain.AllowPermissionsHandler
import com.tangem.feature.swap.domain.SwapInteractor
import com.tangem.feature.swap.domain.TransactionFeeResult
import com.tangem.feature.swap.domain.TxFeeSealedState
@ -88,6 +89,7 @@ import com.tangem.feature.swap.router.SwapNavScreen
import com.tangem.feature.swap.router.SwapRouter
import com.tangem.feature.swap.ui.StateBuilder
import com.tangem.feature.swap.utils.formatToUIRepresentation
import com.tangem.feature.swap.utils.getContractAddress
import com.tangem.features.approval.api.GiveApprovalComponent
import com.tangem.features.approval.api.GiveApprovalFeatureToggles
import com.tangem.features.send.v2.api.entity.FeeSelectorUM
@ -144,6 +146,7 @@ internal class SwapModel @Inject constructor(
private val appsFlyerStore: AppsFlyerStore,
private val holdToConfirmButtonFeatureToggles: HoldToConfirmButtonFeatureToggles,
private val messageSender: UiMessageSender,
private val allowPermissionsHandler: AllowPermissionsHandler,
chooseTokenBridgeFactory: ChooseTokenBridge.Factory,
giveApprovalFeatureToggles: GiveApprovalFeatureToggles,
) : Model() {
@ -256,6 +259,10 @@ internal class SwapModel @Inject constructor(
}
override fun onApproveDone() {
val fromContractAddress = dataState.fromCryptoCurrency?.currency?.getContractAddress()
if (fromContractAddress != null) {
allowPermissionsHandler.addAddressToInProgress(fromContractAddress)
}
approvalSlotNavigation.dismiss()
updateWalletBalance()
uiState = stateBuilder.loadingPermissionState(uiState)

View file

@ -5,6 +5,7 @@ import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.core.ui.format.bigdecimal.simple
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.feature.swap.domain.models.ExpressDataError
import com.tangem.feature.swap.domain.models.SwapAmount
import com.tangem.feature.swap.presentation.R
@ -52,4 +53,11 @@ internal fun getExpressErrorTitle(expressDataError: ExpressDataError): TextRefer
internal fun SwapAmount.formatToUIRepresentation(): String {
return value.format { simple(decimals = decimals) }
}
internal fun CryptoCurrency.getContractAddress(): String {
return when (this) {
is CryptoCurrency.Token -> this.contractAddress
is CryptoCurrency.Coin -> "0"
}
}