Updated on 2026-08-14
This commit is contained in:
parent
58d7b0f393
commit
1c1a968c39
4 changed files with 19 additions and 1 deletions
|
|
@ -1,9 +1,11 @@
|
|||
package com.tangem.feature.swap.domain
|
||||
|
||||
import java.util.Collections.synchronizedSet
|
||||
|
||||
class AllowPermissionsHandlerImpl : AllowPermissionsHandler {
|
||||
|
||||
// todo maybe need to save in store
|
||||
private val allowPermissionsInProgress = mutableSetOf<String>()
|
||||
private val allowPermissionsInProgress = synchronizedSet(mutableSetOf<String>())
|
||||
|
||||
override fun addAddressToInProgress(tokenAddress: String) {
|
||||
allowPermissionsInProgress.add(tokenAddress)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import javax.inject.Singleton
|
|||
internal class SwapDomainModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAllowPermissionsHandler(): AllowPermissionsHandler {
|
||||
return AllowPermissionsHandlerImpl()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue