Updated on 2026-08-14
This commit is contained in:
parent
e6b4d2ae7b
commit
c2625a0de7
7 changed files with 29 additions and 12 deletions
|
|
@ -5,6 +5,7 @@ import com.tangem.core.decompose.di.ModelScoped
|
|||
import com.tangem.core.decompose.model.Model
|
||||
import com.tangem.core.decompose.model.ParamsContainer
|
||||
import com.tangem.domain.pay.TangemPaySwapDataFactory
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
import com.tangem.features.tangempay.components.TangemPayAddFundsComponent
|
||||
import com.tangem.features.tangempay.entity.TangemPayAddFundsUM
|
||||
import com.tangem.features.tangempay.model.transformers.TangemPayAddFundsUMConverter
|
||||
|
|
@ -17,6 +18,7 @@ internal class TangemPayAddFundsModel @Inject constructor(
|
|||
paramsContainer: ParamsContainer,
|
||||
override val dispatchers: CoroutineDispatcherProvider,
|
||||
private val tangemPaySwapDataFactory: TangemPaySwapDataFactory,
|
||||
private val getUserWalletUseCase: GetUserWalletUseCase,
|
||||
) : Model() {
|
||||
|
||||
private val params = paramsContainer.require<TangemPayAddFundsComponent.Params>()
|
||||
|
|
@ -24,7 +26,11 @@ internal class TangemPayAddFundsModel @Inject constructor(
|
|||
val uiState: TangemPayAddFundsUM = getInitialState()
|
||||
|
||||
private fun getInitialState(): TangemPayAddFundsUM {
|
||||
val userWallet = requireNotNull(
|
||||
getUserWalletUseCase(params.walletId).getOrNull(),
|
||||
) { "User wallet not found for id: ${params.walletId}" }
|
||||
val data = tangemPaySwapDataFactory.create(
|
||||
userWallet = userWallet,
|
||||
depositAddress = params.depositAddress,
|
||||
chainId = params.chainId,
|
||||
cryptoBalance = params.cryptoBalance,
|
||||
|
|
|
|||
|
|
@ -18,14 +18,15 @@ import com.tangem.core.ui.extensions.resourceReference
|
|||
import com.tangem.core.ui.message.SnackbarMessage
|
||||
import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
|
||||
import com.tangem.domain.models.TokenReceiveConfig
|
||||
import com.tangem.domain.pay.TangemPayTopUpData
|
||||
import com.tangem.domain.pay.TangemPaySwapDataFactory
|
||||
import com.tangem.domain.pay.TangemPayTopUpData
|
||||
import com.tangem.domain.pay.model.TangemPayCardBalance
|
||||
import com.tangem.domain.pay.repository.CustomerOrderRepository
|
||||
import com.tangem.domain.pay.repository.TangemPayCardDetailsRepository
|
||||
import com.tangem.domain.tangempay.TangemPayAnalyticsEvents
|
||||
import com.tangem.domain.visa.model.TangemPayCardFrozenState
|
||||
import com.tangem.domain.visa.model.TangemPayTxHistoryItem
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
import com.tangem.features.tangempay.TangemPayConstants
|
||||
import com.tangem.features.tangempay.components.AddFundsListener
|
||||
import com.tangem.features.tangempay.components.TangemPayDetailsContainerComponent
|
||||
|
|
@ -55,7 +56,7 @@ import kotlinx.coroutines.launch
|
|||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
@Suppress("LongParameterList", "LargeClass")
|
||||
@Stable
|
||||
@ModelScoped
|
||||
internal class TangemPayDetailsModel @Inject constructor(
|
||||
|
|
@ -71,6 +72,7 @@ internal class TangemPayDetailsModel @Inject constructor(
|
|||
private val txHistoryUpdateListener: TangemPayTxHistoryUpdateListener,
|
||||
private val tangemPaySwapDataFactory: TangemPaySwapDataFactory,
|
||||
private val orderRepository: CustomerOrderRepository,
|
||||
private val getUserWalletUseCase: GetUserWalletUseCase,
|
||||
) : Model(), TangemPayTxHistoryUiActions, TangemPayDetailIntents, AddFundsListener {
|
||||
|
||||
private val params: TangemPayDetailsContainerComponent.Params = paramsContainer.require()
|
||||
|
|
@ -234,7 +236,11 @@ internal class TangemPayDetailsModel @Inject constructor(
|
|||
if (hasActiveWithdrawal) {
|
||||
showBottomSheetError(TangemPayDetailsErrorType.WithdrawInProgress)
|
||||
} else {
|
||||
val userWallet = requireNotNull(
|
||||
getUserWalletUseCase(params.userWalletId).getOrNull(),
|
||||
) { "User wallet not found: ${params.userWalletId}" }
|
||||
val data = tangemPaySwapDataFactory.create(
|
||||
userWallet = userWallet,
|
||||
depositAddress = depositAddress,
|
||||
chainId = params.config.chainId,
|
||||
cryptoBalance = currentBalance.cryptoBalance,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ internal class TangemPayMainSubscriber @AssistedInject constructor(
|
|||
.distinctUntilChanged()
|
||||
.onEach { data ->
|
||||
val userWalletId = userWallet.walletId
|
||||
Timber.tag("scan===").e("onEach $userWalletId $data")
|
||||
val mainInfoData = data[userWalletId] ?: return@onEach
|
||||
mainInfoData.onLeft { tangemPayError ->
|
||||
when (tangemPayError) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue