Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-30 13:34:09 +04:00
parent 0eae1c84fa
commit 066ab573b3
19 changed files with 784 additions and 113 deletions

View file

@ -15,15 +15,14 @@ import com.tangem.datasource.api.express.models.request.PairsRequestBody
import com.tangem.datasource.api.express.models.response.ExchangeDataResponseWithTxDetails
import com.tangem.datasource.api.express.models.response.SwapPair
import com.tangem.datasource.api.express.models.response.SwapPairsWithProviders
import com.tangem.data.common.txhistory.ExpressHistoryRepository
import com.tangem.datasource.api.express.models.response.TxDetails
import com.tangem.datasource.crypto.DataSignatureVerifier
import com.tangem.datasource.exchangeservice.swap.ExpressUtils
import com.tangem.datasource.local.converter.toEntity
import com.tangem.datasource.local.preferences.AppPreferencesStore
import com.tangem.datasource.local.preferences.PreferencesKeys
import com.tangem.datasource.local.preferences.utils.getObjectSyncOrNull
import com.tangem.datasource.local.preferences.utils.storeObject
import com.tangem.datasource.local.txhistory.db.dao.ExpressHistoryDao
import com.tangem.domain.express.models.ExpressOperationType
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.wallet.UserWallet
@ -50,7 +49,7 @@ internal class DefaultSwapRepository(
private val errorsDataConverter: ErrorsDataConverter,
private val dataSignatureVerifier: DataSignatureVerifier,
private val appPreferencesStore: AppPreferencesStore,
private val expressHistoryDao: ExpressHistoryDao,
private val expressHistoryRepository: ExpressHistoryRepository,
private val txHistoryFeatureToggles: TxHistoryFeatureToggles,
moshi: Moshi,
) : SwapRepository {
@ -157,9 +156,11 @@ internal class DefaultSwapRepository(
)
.getOrThrow()
val entity = response.toEntity(ownerAddress = response.fromAddress.orEmpty())
if (txHistoryFeatureToggles.isNewTxHistoryEnabled) {
expressHistoryDao.upsertExchanges(listOf(entity))
expressHistoryRepository.storeExchanges(
ownerAddress = response.fromAddress.orEmpty(),
items = listOf(response),
)
}
exchangeStatusConverter.convert(response)

View file

@ -3,6 +3,7 @@ package com.tangem.feature.swap.di
import com.squareup.moshi.Moshi
import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory
import com.tangem.data.common.network.NetworkFactory
import com.tangem.data.common.txhistory.ExpressHistoryRepository
import com.tangem.datasource.api.express.TangemExpressApi
import com.tangem.datasource.api.express.models.response.ExpressErrorResponse
import com.tangem.datasource.api.surveysparrow.SurveySparrowApi
@ -10,7 +11,6 @@ import com.tangem.datasource.crypto.DataSignatureVerifier
import com.tangem.datasource.di.NetworkMoshi
import com.tangem.datasource.local.config.environment.EnvironmentConfig
import com.tangem.datasource.local.preferences.AppPreferencesStore
import com.tangem.datasource.local.txhistory.db.dao.ExpressHistoryDao
import com.tangem.domain.account.supplier.SingleAccountListSupplier
import com.tangem.domain.txhistory.TxHistoryFeatureToggles
import com.tangem.feature.swap.DefaultSwapFeedbackRepository
@ -41,7 +41,7 @@ internal class SwapDataModule {
errorsDataConverter: ErrorsDataConverter,
@NetworkMoshi moshi: Moshi,
appPreferencesStore: AppPreferencesStore,
expressHistoryDao: ExpressHistoryDao,
expressHistoryRepository: ExpressHistoryRepository,
txHistoryFeatureToggles: TxHistoryFeatureToggles,
): SwapRepository {
return DefaultSwapRepository(
@ -51,7 +51,7 @@ internal class SwapDataModule {
dataSignatureVerifier = dataSignature,
moshi = moshi,
appPreferencesStore = appPreferencesStore,
expressHistoryDao = expressHistoryDao,
expressHistoryRepository = expressHistoryRepository,
txHistoryFeatureToggles = txHistoryFeatureToggles,
)
}