Updated on 2026-08-14
This commit is contained in:
parent
3b2a867959
commit
cf0659d207
23 changed files with 679 additions and 316 deletions
|
|
@ -0,0 +1,124 @@
|
|||
package com.tangem.features.yield.supply.impl.entry
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.arkivanov.decompose.extensions.compose.stack.Children
|
||||
import com.arkivanov.decompose.extensions.compose.stack.animation.fade
|
||||
import com.arkivanov.decompose.extensions.compose.stack.animation.stackAnimation
|
||||
import com.arkivanov.decompose.extensions.compose.subscribeAsState
|
||||
import com.arkivanov.decompose.router.stack.StackNavigation
|
||||
import com.arkivanov.decompose.router.stack.childStack
|
||||
import com.arkivanov.decompose.router.stack.pop
|
||||
import com.tangem.core.decompose.context.AppComponentContext
|
||||
import com.tangem.core.decompose.context.childByContext
|
||||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
import com.tangem.core.decompose.navigation.inner.InnerRouter
|
||||
import com.tangem.core.ui.decompose.ComposableContentComponent
|
||||
import com.tangem.features.yield.supply.api.YieldSupplyActiveComponent
|
||||
import com.tangem.features.yield.supply.api.YieldSupplyEntryComponent
|
||||
import com.tangem.features.yield.supply.api.YieldSupplyPromoComponent
|
||||
import com.tangem.features.yield.supply.api.entry.YieldSupplyEntryRoute
|
||||
import com.tangem.features.yield.supply.impl.entry.model.YieldSupplyEntryModel
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
|
||||
internal class DefaultYieldSupplyEntryComponent @AssistedInject constructor(
|
||||
@Assisted appComponentContext: AppComponentContext,
|
||||
@Assisted private val params: YieldSupplyEntryComponent.Params,
|
||||
private val yieldSupplyPromoComponentFactory: YieldSupplyPromoComponent.Factory,
|
||||
private val yieldSupplyActiveComponentFactory: YieldSupplyActiveComponent.Factory,
|
||||
) : YieldSupplyEntryComponent, AppComponentContext by appComponentContext {
|
||||
|
||||
private val stackNavigation = StackNavigation<YieldSupplyEntryRoute>()
|
||||
|
||||
private val innerRouter = InnerRouter<YieldSupplyEntryRoute>(
|
||||
stackNavigation = stackNavigation,
|
||||
popCallback = { onChildBack() },
|
||||
)
|
||||
|
||||
private val model: YieldSupplyEntryModel = getOrCreateModel(
|
||||
params = params,
|
||||
router = innerRouter,
|
||||
)
|
||||
|
||||
private val childStack = childStack(
|
||||
key = "yieldSupplyEntryStack",
|
||||
source = stackNavigation,
|
||||
serializer = null,
|
||||
initialConfiguration = model.initialRoute,
|
||||
handleBackButton = true,
|
||||
childFactory = { configuration, factoryContext ->
|
||||
getChildComponent(
|
||||
configuration = configuration,
|
||||
factoryContext = childByContext(
|
||||
componentContext = factoryContext,
|
||||
router = innerRouter,
|
||||
),
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
@Composable
|
||||
override fun Content(modifier: Modifier) {
|
||||
val childStackValue by childStack.subscribeAsState()
|
||||
|
||||
Children(
|
||||
stack = childStackValue,
|
||||
modifier = modifier,
|
||||
animation = stackAnimation { fade() },
|
||||
) { child ->
|
||||
child.instance.Content(Modifier.fillMaxSize())
|
||||
}
|
||||
}
|
||||
|
||||
private fun getChildComponent(
|
||||
configuration: YieldSupplyEntryRoute,
|
||||
factoryContext: AppComponentContext,
|
||||
): ComposableContentComponent = when (configuration) {
|
||||
is YieldSupplyEntryRoute.Empty -> EmptyComponent
|
||||
is YieldSupplyEntryRoute.Promo -> yieldSupplyPromoComponentFactory.create(
|
||||
context = factoryContext,
|
||||
params = YieldSupplyPromoComponent.Params(
|
||||
userWalletId = params.userWalletId,
|
||||
currency = configuration.cryptoCurrency,
|
||||
apy = configuration.apy,
|
||||
),
|
||||
)
|
||||
is YieldSupplyEntryRoute.Active -> yieldSupplyActiveComponentFactory.create(
|
||||
context = factoryContext,
|
||||
params = YieldSupplyActiveComponent.Params(
|
||||
userWalletId = params.userWalletId,
|
||||
cryptoCurrency = configuration.cryptoCurrency,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private object EmptyComponent : ComposableContentComponent {
|
||||
@Composable
|
||||
override fun Content(modifier: Modifier) {
|
||||
Box(modifier = modifier)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onChildBack() {
|
||||
if (childStack.value.backStack.isEmpty() ||
|
||||
childStack.value.backStack.last().configuration is YieldSupplyEntryRoute.Empty
|
||||
) {
|
||||
router.pop()
|
||||
} else {
|
||||
stackNavigation.pop()
|
||||
}
|
||||
}
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory : YieldSupplyEntryComponent.Factory {
|
||||
override fun create(
|
||||
context: AppComponentContext,
|
||||
params: YieldSupplyEntryComponent.Params,
|
||||
): DefaultYieldSupplyEntryComponent
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.tangem.features.yield.supply.impl.entry.di
|
||||
|
||||
import com.tangem.core.decompose.di.ModelComponent
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.features.yield.supply.api.YieldSupplyEntryComponent
|
||||
import com.tangem.features.yield.supply.impl.entry.DefaultYieldSupplyEntryComponent
|
||||
import com.tangem.features.yield.supply.impl.entry.model.YieldSupplyEntryModel
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import dagger.multibindings.ClassKey
|
||||
import dagger.multibindings.IntoMap
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
internal interface YieldSupplyEntryBindsModule {
|
||||
@Binds
|
||||
@Singleton
|
||||
fun provideYieldSupplyEntryComponentFactory(
|
||||
impl: DefaultYieldSupplyEntryComponent.Factory,
|
||||
): YieldSupplyEntryComponent.Factory
|
||||
}
|
||||
|
||||
@Module
|
||||
@InstallIn(ModelComponent::class)
|
||||
internal interface YieldSupplyEntryModelModule {
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ClassKey(YieldSupplyEntryModel::class)
|
||||
fun provideYieldSupplyEntryModel(impl: YieldSupplyEntryModel): Model
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
package com.tangem.features.yield.supply.impl.entry.model
|
||||
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.core.decompose.navigation.Router
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.GetSingleCryptoCurrencyStatusUseCase
|
||||
import com.tangem.domain.tokens.model.details.NavigationAction
|
||||
import com.tangem.domain.yield.supply.usecase.YieldSupplyEnterStatusUseCase
|
||||
import com.tangem.features.yield.supply.api.YieldSupplyEntryComponent
|
||||
import com.tangem.features.yield.supply.api.entry.YieldSupplyEntryRoute
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@ModelScoped
|
||||
internal class YieldSupplyEntryModel @Inject constructor(
|
||||
paramsContainer: ParamsContainer,
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
private val router: Router,
|
||||
private val yieldSupplyEnterStatusUseCase: YieldSupplyEnterStatusUseCase,
|
||||
private val getSingleCryptoCurrencyStatusUseCase: GetSingleCryptoCurrencyStatusUseCase,
|
||||
) : Model() {
|
||||
|
||||
private val params = paramsContainer.require<YieldSupplyEntryComponent.Params>()
|
||||
|
||||
val initialRoute: YieldSupplyEntryRoute = YieldSupplyEntryRoute.Empty
|
||||
|
||||
init {
|
||||
navigateToInitialRoute()
|
||||
}
|
||||
|
||||
private fun navigateToInitialRoute() {
|
||||
val userWalletId = params.userWalletId
|
||||
val cryptoCurrency = params.cryptoCurrency
|
||||
modelScope.launch(dispatchers.default) {
|
||||
getSingleCryptoCurrencyStatusUseCase.invokeMultiWalletSync(
|
||||
userWalletId = userWalletId,
|
||||
cryptoCurrencyId = cryptoCurrency.id,
|
||||
).onLeft { error ->
|
||||
Timber.e("Failed to get CryptoCurrencyStatus: $error")
|
||||
router.pop()
|
||||
}.onRight { cryptoCurrencyStatus ->
|
||||
val route = getInitialRoute(cryptoCurrencyStatus)
|
||||
if (route != null) {
|
||||
router.replaceCurrent(route)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun getInitialRoute(cryptoCurrencyStatus: CryptoCurrencyStatus): YieldSupplyEntryRoute? {
|
||||
val userWalletId = params.userWalletId
|
||||
val cryptoCurrency = params.cryptoCurrency
|
||||
val token = cryptoCurrency as? CryptoCurrency.Token
|
||||
if (token == null) {
|
||||
router.pop()
|
||||
return null
|
||||
}
|
||||
|
||||
val tokenEnterStatus = yieldSupplyEnterStatusUseCase(
|
||||
userWalletId = userWalletId,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
).getOrNull()
|
||||
val isActiveYield = cryptoCurrencyStatus.value.yieldSupplyStatus?.isActive == true
|
||||
|
||||
if (tokenEnterStatus != null) {
|
||||
router.replaceCurrent(
|
||||
AppRoute.CurrencyDetails(
|
||||
userWalletId = userWalletId,
|
||||
currency = token,
|
||||
navigationAction = NavigationAction.YieldSupply(
|
||||
isActive = isActiveYield,
|
||||
),
|
||||
),
|
||||
)
|
||||
return null
|
||||
}
|
||||
|
||||
return if (isActiveYield) {
|
||||
YieldSupplyEntryRoute.Active(cryptoCurrency = token)
|
||||
} else {
|
||||
YieldSupplyEntryRoute.Promo(cryptoCurrency = token, apy = params.apy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,8 +2,6 @@ package com.tangem.features.yield.supply.impl.main.model
|
|||
|
||||
import arrow.core.getOrElse
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import android.os.SystemClock
|
||||
import com.tangem.common.routing.AppRoute.YieldSupplyPromo
|
||||
import com.tangem.common.routing.AppRouter
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
|
|
@ -25,8 +23,7 @@ import com.tangem.domain.models.yield.supply.YieldSupplyStatus
|
|||
import com.tangem.domain.networks.single.SingleNetworkStatusFetcher
|
||||
import com.tangem.domain.tokens.GetSingleCryptoCurrencyStatusUseCase
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
import com.tangem.domain.yield.supply.YieldSupplyRepository
|
||||
import com.tangem.domain.yield.supply.models.YieldSupplyEnterStatus
|
||||
import com.tangem.domain.yield.supply.models.YieldSupplyPendingStatus
|
||||
import com.tangem.domain.yield.supply.usecase.*
|
||||
import com.tangem.features.yield.supply.api.YieldSupplyComponent
|
||||
import com.tangem.features.yield.supply.api.analytics.YieldSupplyAnalytics
|
||||
|
|
@ -63,7 +60,7 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
private val yieldSupplyIsAvailableUseCase: YieldSupplyIsAvailableUseCase,
|
||||
private val yieldSupplyActivateUseCase: YieldSupplyActivateUseCase,
|
||||
private val yieldSupplyDeactivateUseCase: YieldSupplyDeactivateUseCase,
|
||||
private val yieldSupplyRepository: YieldSupplyRepository,
|
||||
private val yieldSupplyEnterStatusUseCase: YieldSupplyEnterStatusUseCase,
|
||||
private val yieldSupplyMinAmountUseCase: YieldSupplyMinAmountUseCase,
|
||||
private val yieldSupplyGetDustMinAmountUseCase: YieldSupplyGetDustMinAmountUseCase,
|
||||
) : Model(), YieldSupplyClickIntents {
|
||||
|
|
@ -76,11 +73,11 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
private val cryptoCurrency = params.cryptoCurrency
|
||||
private var appCurrency: AppCurrency = AppCurrency.Default
|
||||
var userWallet: UserWallet by Delegates.notNull()
|
||||
private var latestCryptoCurrencyStatus: CryptoCurrencyStatus? = null
|
||||
|
||||
private val fetchCurrencyJobHolder = JobHolder()
|
||||
private val loadStatusJobHolder = JobHolder()
|
||||
|
||||
private var lastStatusCheckTimestamp = 0L
|
||||
private val isFirstCryptoCurrencyStatusEmission = AtomicBoolean(true)
|
||||
|
||||
init {
|
||||
|
|
@ -116,6 +113,7 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
).onEach { maybeCryptoCurrency ->
|
||||
maybeCryptoCurrency.fold(
|
||||
ifRight = { cryptoCurrencyStatus ->
|
||||
latestCryptoCurrencyStatus = cryptoCurrencyStatus
|
||||
if (isFirstCryptoCurrencyStatusEmission.compareAndSet(true, false)) {
|
||||
sendInfoAboutProtocolStatus(cryptoCurrencyStatus)
|
||||
}
|
||||
|
|
@ -152,96 +150,55 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onStartEarningClick() {
|
||||
val apy = when (val yieldSupplyUM = uiState.value) {
|
||||
is YieldSupplyUM.Available -> yieldSupplyUM.apy
|
||||
is YieldSupplyUM.Content -> yieldSupplyUM.apy
|
||||
else -> ""
|
||||
}
|
||||
appRouter.push(
|
||||
YieldSupplyPromo(
|
||||
userWalletId = params.userWalletId,
|
||||
cryptoCurrency = params.cryptoCurrency,
|
||||
apy = apy,
|
||||
),
|
||||
)
|
||||
navigateToYieldSupplyEntry()
|
||||
}
|
||||
|
||||
override fun onActiveClick() {
|
||||
navigateToYieldSupplyEntry()
|
||||
}
|
||||
|
||||
private fun navigateToYieldSupplyEntry() {
|
||||
val cryptoCurrencyStatus = latestCryptoCurrencyStatus ?: return
|
||||
val apy = when (val yieldSupplyUM = uiState.value) {
|
||||
is YieldSupplyUM.Available -> yieldSupplyUM.apy
|
||||
is YieldSupplyUM.Content -> yieldSupplyUM.apy
|
||||
else -> ""
|
||||
}
|
||||
appRouter.push(
|
||||
AppRoute.YieldSupplyActive(
|
||||
AppRoute.YieldSupplyEntry(
|
||||
userWalletId = params.userWalletId,
|
||||
cryptoCurrency = params.cryptoCurrency,
|
||||
cryptoCurrency = cryptoCurrencyStatus.currency,
|
||||
apy = apy,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("MaximumLineLength")
|
||||
private fun onCryptoCurrencyStatusUpdated(cryptoCurrencyStatus: CryptoCurrencyStatus) = modelScope.launch(
|
||||
dispatchers.default,
|
||||
) {
|
||||
val yieldSupplyStatus = cryptoCurrencyStatus.value.yieldSupplyStatus
|
||||
val tokenProtocolStatus = yieldSupplyRepository.getTokenProtocolStatus(
|
||||
userWallet.walletId,
|
||||
cryptoCurrency,
|
||||
)
|
||||
val tokenPendingStatus = yieldSupplyRepository.getTokenPendingStatus(
|
||||
userWallet.walletId,
|
||||
cryptoCurrencyStatus,
|
||||
)
|
||||
|
||||
val isActive = yieldSupplyStatus?.isActive == true
|
||||
val isCryptoCurrencyStatusFromCache = cryptoCurrencyStatus.value.sources.networkSource != StatusSource.ACTUAL
|
||||
val processing = uiState.value is YieldSupplyUM.Processing
|
||||
Timber.d(
|
||||
"YIELD " +
|
||||
"yieldSupplyStatus $yieldSupplyStatus " +
|
||||
"tokenProtocolStatus $tokenProtocolStatus " +
|
||||
"tokenPendingStatus $tokenPendingStatus " +
|
||||
"isActive $isActive " +
|
||||
"processing $processing " +
|
||||
"isCryptoCurrencyStatusFromCache $isCryptoCurrencyStatusFromCache",
|
||||
)
|
||||
if (isCryptoCurrencyStatusFromCache && processing) {
|
||||
return@launch
|
||||
}
|
||||
|
||||
when {
|
||||
tokenProtocolStatus != null && tokenPendingStatus != null -> {
|
||||
showProcessing(tokenPendingStatus)
|
||||
lastStatusCheckTimestamp = 0L
|
||||
}
|
||||
tokenProtocolStatus == YieldSupplyEnterStatus.Exit && isActive ||
|
||||
tokenProtocolStatus == YieldSupplyEnterStatus.Enter && !isActive -> {
|
||||
if (lastStatusCheckTimestamp != 0L) {
|
||||
if (SystemClock.elapsedRealtime() - lastStatusCheckTimestamp > MAX_STATUS_CHECK_LIMIT) {
|
||||
loadStatus(cryptoCurrencyStatus)
|
||||
lastStatusCheckTimestamp = 0L
|
||||
} else {
|
||||
showProcessing(tokenProtocolStatus)
|
||||
}
|
||||
} else {
|
||||
showProcessing(tokenProtocolStatus)
|
||||
lastStatusCheckTimestamp = SystemClock.elapsedRealtime()
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
loadStatus(cryptoCurrencyStatus)
|
||||
lastStatusCheckTimestamp = 0L
|
||||
}
|
||||
val pendingStatus = yieldSupplyEnterStatusUseCase(
|
||||
userWalletId = userWallet.walletId,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
).getOrNull()
|
||||
|
||||
if (pendingStatus != null) {
|
||||
showProcessing(pendingStatus)
|
||||
} else {
|
||||
loadStatus(cryptoCurrencyStatus)
|
||||
}
|
||||
}.saveIn(loadStatusJobHolder)
|
||||
|
||||
private fun showProcessing(status: YieldSupplyEnterStatus) {
|
||||
private fun showProcessing(status: YieldSupplyPendingStatus) {
|
||||
uiState.update {
|
||||
when (status) {
|
||||
YieldSupplyEnterStatus.Enter -> YieldSupplyUM.Processing.Enter
|
||||
YieldSupplyEnterStatus.Exit -> YieldSupplyUM.Processing.Exit
|
||||
is YieldSupplyPendingStatus.Enter -> YieldSupplyUM.Processing.Enter
|
||||
is YieldSupplyPendingStatus.Exit -> YieldSupplyUM.Processing.Exit
|
||||
}
|
||||
}
|
||||
fetchCurrencyWithDelay()
|
||||
|
|
@ -249,11 +206,6 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
|
||||
private suspend fun loadStatus(cryptoCurrencyStatus: CryptoCurrencyStatus) {
|
||||
val yieldSupplyStatus = cryptoCurrencyStatus.value.yieldSupplyStatus
|
||||
yieldSupplyRepository.saveTokenProtocolStatus(
|
||||
userWalletId = userWallet.walletId,
|
||||
cryptoCurrency = cryptoCurrency,
|
||||
yieldSupplyEnterStatus = null,
|
||||
)
|
||||
if (yieldSupplyStatus?.isActive == true) {
|
||||
loadActiveState(
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
|
|
@ -385,6 +337,5 @@ internal class YieldSupplyModel @Inject constructor(
|
|||
|
||||
private companion object {
|
||||
const val PROCESSING_UPDATE_DELAY = 10_000L
|
||||
const val MAX_STATUS_CHECK_LIMIT = 10_000L
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ import com.tangem.domain.transaction.error.GetFeeError
|
|||
import com.tangem.domain.transaction.usecase.SendTransactionUseCase
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
import com.tangem.domain.yield.supply.YieldSupplyRepository
|
||||
import com.tangem.domain.yield.supply.models.YieldSupplyEnterStatus
|
||||
import com.tangem.domain.yield.supply.models.YieldSupplyPendingStatus
|
||||
import com.tangem.domain.yield.supply.usecase.*
|
||||
import com.tangem.features.yield.supply.api.analytics.YieldSupplyAnalytics
|
||||
import com.tangem.features.yield.supply.impl.R
|
||||
|
|
@ -245,18 +245,21 @@ internal class YieldSupplyStartEarningModel @Inject constructor(
|
|||
},
|
||||
)
|
||||
},
|
||||
ifRight = {
|
||||
onStartEarningTransactionSuccess(yieldSupplyFeeUM)
|
||||
ifRight = { txsData ->
|
||||
onStartEarningTransactionSuccess(yieldSupplyFeeUM, txsData)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun onStartEarningTransactionSuccess(yieldSupplyFeeUM: YieldSupplyFeeUM.Content) {
|
||||
yieldSupplyRepository.saveTokenProtocolStatus(
|
||||
userWalletId,
|
||||
cryptoCurrency,
|
||||
YieldSupplyEnterStatus.Enter,
|
||||
private suspend fun onStartEarningTransactionSuccess(
|
||||
yieldSupplyFeeUM: YieldSupplyFeeUM.Content,
|
||||
txsData: List<String>,
|
||||
) {
|
||||
yieldSupplyRepository.saveTokenProtocolPendingStatus(
|
||||
userWalletId = userWalletId,
|
||||
cryptoCurrency = cryptoCurrency,
|
||||
yieldSupplyPendingStatus = YieldSupplyPendingStatus.Enter(txsData),
|
||||
)
|
||||
val event = AnalyticsParam.TxSentFrom.Earning(
|
||||
blockchain = cryptoCurrency.network.name,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import com.tangem.domain.transaction.usecase.SendTransactionUseCase
|
|||
import com.tangem.domain.yield.supply.INCREASE_GAS_LIMIT_FOR_SUPPLY
|
||||
import com.tangem.domain.yield.supply.YieldSupplyRepository
|
||||
import com.tangem.domain.yield.supply.increaseGasLimitBy
|
||||
import com.tangem.domain.yield.supply.models.YieldSupplyEnterStatus
|
||||
import com.tangem.domain.yield.supply.models.YieldSupplyPendingStatus
|
||||
import com.tangem.domain.yield.supply.usecase.YieldSupplyDeactivateUseCase
|
||||
import com.tangem.domain.yield.supply.usecase.YieldSupplyStopEarningUseCase
|
||||
import com.tangem.features.yield.supply.api.analytics.YieldSupplyAnalytics
|
||||
|
|
@ -167,18 +167,18 @@ internal class YieldSupplyStopEarningModel @Inject constructor(
|
|||
)
|
||||
params.callback.onTransactionProgress(false)
|
||||
},
|
||||
ifRight = {
|
||||
onStopEarningTransactionSuccess()
|
||||
ifRight = { txData ->
|
||||
onStopEarningTransactionSuccess(txData)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun onStopEarningTransactionSuccess() {
|
||||
yieldSupplyRepository.saveTokenProtocolStatus(
|
||||
userWallet.walletId,
|
||||
cryptoCurrency,
|
||||
YieldSupplyEnterStatus.Exit,
|
||||
private suspend fun onStopEarningTransactionSuccess(txId: String) {
|
||||
yieldSupplyRepository.saveTokenProtocolPendingStatus(
|
||||
userWalletId = userWallet.walletId,
|
||||
cryptoCurrency = cryptoCurrency,
|
||||
yieldSupplyPendingStatus = YieldSupplyPendingStatus.Exit(listOf(txId)),
|
||||
)
|
||||
analytics.send(
|
||||
YieldSupplyAnalytics.FundsWithdrawn(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue