Updated on 2026-08-14
This commit is contained in:
parent
e87d946e40
commit
a3a18854c8
48 changed files with 544 additions and 328 deletions
|
|
@ -6,6 +6,8 @@ import arrow.core.getOrElse
|
|||
import com.tangem.blockchain.common.address.AddressType
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.common.routing.AppRouter
|
||||
import com.tangem.common.ui.bottomsheet.receive.AddressModel
|
||||
import com.tangem.common.ui.bottomsheet.receive.mapToAddressModels
|
||||
import com.tangem.common.ui.expressStatus.ExpressStatusBottomSheetConfig
|
||||
import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateUM
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
|
|
@ -17,8 +19,6 @@ import com.tangem.core.decompose.model.ParamsContainer
|
|||
import com.tangem.core.decompose.ui.UiMessageSender
|
||||
import com.tangem.core.navigation.share.ShareManager
|
||||
import com.tangem.core.ui.clipboard.ClipboardManager
|
||||
import com.tangem.common.ui.bottomsheet.receive.AddressModel
|
||||
import com.tangem.common.ui.bottomsheet.receive.mapToAddressModels
|
||||
import com.tangem.core.ui.components.transactions.state.TxHistoryState
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
|
|
@ -166,7 +166,7 @@ internal class TokenDetailsModel @Inject constructor(
|
|||
appCurrencyProvider = Provider { selectedAppCurrencyFlow.value },
|
||||
currentStateProvider = Provider { uiState.value },
|
||||
cryptoCurrencyStatusProvider = Provider { cryptoCurrencyStatus },
|
||||
userWalletId = userWalletId,
|
||||
userWallet = userWallet,
|
||||
cryptoCurrency = cryptoCurrency,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ import com.tangem.domain.tokens.model.CryptoCurrency
|
|||
import com.tangem.domain.tokens.model.Quote
|
||||
import com.tangem.domain.tokens.model.analytics.TokenExchangeAnalyticsEvent
|
||||
import com.tangem.domain.tokens.repository.QuotesRepository
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.swap.domain.SwapTransactionRepository
|
||||
import com.tangem.feature.swap.domain.api.SwapRepository
|
||||
import com.tangem.feature.swap.domain.models.domain.*
|
||||
|
|
@ -29,7 +28,6 @@ import kotlinx.collections.immutable.PersistentList
|
|||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
|
|
@ -39,14 +37,13 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
|
|||
private val quotesRepository: QuotesRepository,
|
||||
private val quotesRepositoryV2: QuotesRepositoryV2,
|
||||
private val tokensFeatureToggles: TokensFeatureToggles,
|
||||
private val getSelectedWalletSyncUseCase: GetSelectedWalletSyncUseCase,
|
||||
private val addCryptoCurrenciesUseCase: AddCryptoCurrenciesUseCase,
|
||||
private val swapTransactionStatusStore: SwapTransactionStatusStore,
|
||||
private val analyticsEventsHandler: AnalyticsEventHandler,
|
||||
@Assisted private val clickIntents: TokenDetailsClickIntents,
|
||||
@Assisted private val appCurrencyProvider: Provider<AppCurrency>,
|
||||
@Assisted private val currentStateProvider: Provider<TokenDetailsState>,
|
||||
@Assisted private val userWalletId: UserWalletId,
|
||||
@Assisted private val userWallet: UserWallet,
|
||||
@Assisted private val cryptoCurrency: CryptoCurrency,
|
||||
) {
|
||||
|
||||
|
|
@ -60,14 +57,9 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
|
|||
}
|
||||
|
||||
suspend operator fun invoke(): Flow<PersistentList<ExchangeUM>> {
|
||||
val selectedWallet = getSelectedWalletSyncUseCase().fold(
|
||||
ifLeft = { return emptyFlow() },
|
||||
ifRight = { it },
|
||||
)
|
||||
return swapTransactionRepository.getTransactions(
|
||||
userWalletId = userWalletId,
|
||||
userWallet = userWallet,
|
||||
cryptoCurrencyId = cryptoCurrency.id,
|
||||
scanResponse = selectedWallet.scanResponse,
|
||||
).conflate()
|
||||
.map { savedTransactions ->
|
||||
val quotes = savedTransactions
|
||||
|
|
@ -91,7 +83,7 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
|
|||
val shouldDispose = selectedTx.activeStatus?.isAutoDisposable == true || isForceDispose
|
||||
if (shouldDispose) {
|
||||
swapTransactionRepository.removeTransaction(
|
||||
userWalletId = userWalletId,
|
||||
userWalletId = userWallet.walletId,
|
||||
fromCryptoCurrency = selectedTx.fromCryptoCurrency,
|
||||
toCryptoCurrency = selectedTx.toCryptoCurrency,
|
||||
txId = selectedTx.info.txId,
|
||||
|
|
@ -117,7 +109,7 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private suspend fun getExchangeStatus(txId: String, provider: SwapProvider): ExchangeStatusModel? {
|
||||
return swapRepository.getExchangeStatus(txId)
|
||||
return swapRepository.getExchangeStatus(userWallet = userWallet, txId = txId)
|
||||
.fold(
|
||||
ifLeft = { null },
|
||||
ifRight = { statusModel ->
|
||||
|
|
@ -157,7 +149,7 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
|
|||
val refundContractAddress = status.refundContractAddress
|
||||
if (refundNetwork != null && refundContractAddress != null) {
|
||||
return addCryptoCurrenciesUseCase(
|
||||
userWalletId = userWalletId,
|
||||
userWalletId = userWallet.walletId,
|
||||
contractAddress = refundContractAddress,
|
||||
networkId = refundNetwork,
|
||||
).getOrNull()
|
||||
|
|
@ -219,7 +211,7 @@ internal class ExchangeStatusFactory @AssistedInject constructor(
|
|||
clickIntents: TokenDetailsClickIntents,
|
||||
appCurrencyProvider: Provider<AppCurrency>,
|
||||
currentStateProvider: Provider<TokenDetailsState>,
|
||||
userWalletId: UserWalletId,
|
||||
userWallet: UserWallet,
|
||||
cryptoCurrency: CryptoCurrency,
|
||||
): ExchangeStatusFactory
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
|||
import com.tangem.domain.tokens.model.analytics.TokenExchangeAnalyticsEvent
|
||||
import com.tangem.domain.tokens.model.analytics.TokenOnrampAnalyticsEvent
|
||||
import com.tangem.domain.tokens.model.analytics.TokenScreenAnalyticsEvent
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.swap.domain.models.domain.ExchangeStatus
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsClickIntents
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.ExchangeStatusNotification
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.express.ExchangeUM
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import dagger.assisted.Assisted
|
||||
|
|
@ -36,7 +36,7 @@ internal class ExpressStatusFactory @AssistedInject constructor(
|
|||
@Assisted private val clickIntents: TokenDetailsClickIntents,
|
||||
@Assisted private val cryptoCurrency: CryptoCurrency,
|
||||
@Assisted appCurrencyProvider: Provider<AppCurrency>,
|
||||
@Assisted userWalletId: UserWalletId,
|
||||
@Assisted userWallet: UserWallet,
|
||||
@Assisted cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus?>,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
private val analyticsEventsHandler: AnalyticsEventHandler,
|
||||
|
|
@ -49,7 +49,7 @@ internal class ExpressStatusFactory @AssistedInject constructor(
|
|||
clickIntents = clickIntents,
|
||||
appCurrencyProvider = appCurrencyProvider,
|
||||
currentStateProvider = currentStateProvider,
|
||||
userWalletId = userWalletId,
|
||||
userWallet = userWallet,
|
||||
cryptoCurrency = cryptoCurrency,
|
||||
)
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ internal class ExpressStatusFactory @AssistedInject constructor(
|
|||
appCurrencyProvider = appCurrencyProvider,
|
||||
clickIntents = clickIntents,
|
||||
cryptoCurrency = cryptoCurrency,
|
||||
userWalletId = userWalletId,
|
||||
userWallet = userWallet,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ internal class ExpressStatusFactory @AssistedInject constructor(
|
|||
clickIntents: TokenDetailsClickIntents,
|
||||
appCurrencyProvider: Provider<AppCurrency>,
|
||||
currentStateProvider: Provider<TokenDetailsState>,
|
||||
userWalletId: UserWalletId,
|
||||
userWallet: UserWallet,
|
||||
cryptoCurrency: CryptoCurrency,
|
||||
cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus?>,
|
||||
): ExpressStatusFactory
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import com.tangem.domain.onramp.model.OnrampStatus.Status.*
|
|||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.analytics.TokenOnrampAnalyticsEvent
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsClickIntents
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.TokenDetailsOnrampTransactionStateConverter
|
||||
import com.tangem.utils.Provider
|
||||
|
|
@ -39,7 +39,7 @@ internal class OnrampStatusFactory @AssistedInject constructor(
|
|||
@Assisted private val appCurrencyProvider: Provider<AppCurrency>,
|
||||
@Assisted private val clickIntents: TokenDetailsClickIntents,
|
||||
@Assisted private val cryptoCurrency: CryptoCurrency,
|
||||
@Assisted private val userWalletId: UserWalletId,
|
||||
@Assisted private val userWallet: UserWallet,
|
||||
) {
|
||||
|
||||
private val onrampTransactionStateConverter by lazy(LazyThreadSafetyMode.NONE) {
|
||||
|
|
@ -54,7 +54,7 @@ internal class OnrampStatusFactory @AssistedInject constructor(
|
|||
|
||||
operator fun invoke(): Flow<List<ExpressTransactionStateUM.OnrampUM>> {
|
||||
return getOnrampTransactionsUseCase(
|
||||
userWalletId = userWalletId,
|
||||
userWalletId = userWallet.walletId,
|
||||
cryptoCurrencyId = cryptoCurrency.id,
|
||||
).map { maybeTransaction ->
|
||||
maybeTransaction.fold(
|
||||
|
|
@ -82,7 +82,7 @@ internal class OnrampStatusFactory @AssistedInject constructor(
|
|||
return if (onrampTx.activeStatus.isTerminal) {
|
||||
onrampTx
|
||||
} else {
|
||||
getOnrampStatusUseCase(onrampTx.info.txId).fold(
|
||||
getOnrampStatusUseCase(userWallet = userWallet, onrampTx.info.txId).fold(
|
||||
ifLeft = {
|
||||
Timber.e("Couldn't update onramp status. $it")
|
||||
onrampTx
|
||||
|
|
@ -150,7 +150,7 @@ internal class OnrampStatusFactory @AssistedInject constructor(
|
|||
appCurrencyProvider: Provider<AppCurrency>,
|
||||
clickIntents: TokenDetailsClickIntents,
|
||||
cryptoCurrency: CryptoCurrency,
|
||||
userWalletId: UserWalletId,
|
||||
userWallet: UserWallet,
|
||||
): OnrampStatusFactory
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue