Updated on 2026-08-14
This commit is contained in:
commit
fe2cfac54d
1140 changed files with 23493 additions and 8579 deletions
|
|
@ -25,12 +25,12 @@ 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.preferences.AppPreferencesStore
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.domain.exchange.RampStateManager
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||
import com.tangem.domain.wallets.legacy.UserWalletsListManager
|
||||
import com.tangem.feature.swap.converters.*
|
||||
import com.tangem.feature.swap.domain.api.SwapRepository
|
||||
import com.tangem.feature.swap.domain.models.ExpressDataError
|
||||
|
|
@ -51,7 +51,7 @@ internal class DefaultSwapRepository(
|
|||
private val tangemExpressApi: TangemExpressApi,
|
||||
private val coroutineDispatcher: CoroutineDispatcherProvider,
|
||||
private val walletManagersFacade: WalletManagersFacade,
|
||||
private val userWalletsListManager: UserWalletsListManager,
|
||||
private val userWalletsStore: UserWalletsStore,
|
||||
private val errorsDataConverter: ErrorsDataConverter,
|
||||
private val dataSignatureVerifier: DataSignatureVerifier,
|
||||
private val appPreferencesStore: AppPreferencesStore,
|
||||
|
|
@ -411,7 +411,7 @@ internal class DefaultSwapRepository(
|
|||
cryptoCurrencyFactory.createCoin(
|
||||
blockchain = blockchain,
|
||||
extraDerivationPath = null,
|
||||
userWallet = requireNotNull(userWalletsListManager.selectedUserWalletSync),
|
||||
userWallet = requireNotNull(userWalletsStore.selectedUserWalletOrNull),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,21 +92,37 @@ internal class DefaultSwapTransactionRepository(
|
|||
key = PreferencesKeys.SWAP_TRANSACTIONS_STATUSES_KEY,
|
||||
),
|
||||
) { savedTransactions, txStatuses ->
|
||||
val currencyTxs = savedTransactions?.filter {
|
||||
it.userWalletId == userWallet.walletId.stringValue &&
|
||||
(
|
||||
it.toCryptoCurrencyId == cryptoCurrencyId.value ||
|
||||
it.fromCryptoCurrencyId == cryptoCurrencyId.value
|
||||
)
|
||||
|
||||
val currencyToTxs = savedTransactions?.filter {
|
||||
val isUserWallet = it.userWalletId == userWallet.walletId.stringValue
|
||||
val toCurrency = it.toCryptoCurrencyId == cryptoCurrencyId.value
|
||||
isUserWallet && toCurrency
|
||||
}
|
||||
|
||||
currencyTxs?.mapNotNull {
|
||||
val currencyFromTxs = savedTransactions?.filter {
|
||||
val isUserWallet = it.userWalletId == userWallet.walletId.stringValue
|
||||
val fromCurrency = it.fromCryptoCurrencyId == cryptoCurrencyId.value
|
||||
isUserWallet && fromCurrency
|
||||
}
|
||||
|
||||
val toTxs = currencyToTxs?.mapNotNull {
|
||||
converter.convertBack(
|
||||
value = it,
|
||||
userWallet = userWallet,
|
||||
txStatuses = txStatuses,
|
||||
onFilter = { it.swapTxTypeDTO == SwapTxTypeDTO.Swap },
|
||||
)
|
||||
}.orEmpty()
|
||||
|
||||
val fromTxs = currencyFromTxs?.mapNotNull {
|
||||
converter.convertBack(
|
||||
value = it,
|
||||
userWallet = userWallet,
|
||||
txStatuses = txStatuses,
|
||||
)
|
||||
}
|
||||
}.orEmpty()
|
||||
|
||||
fromTxs + toTxs
|
||||
}
|
||||
.flowOn(dispatchers.default)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ internal class SavedSwapTransactionListConverter(
|
|||
value: SavedSwapTransactionListModelInner,
|
||||
userWallet: UserWallet,
|
||||
txStatuses: Map<String, ExchangeStatusModel>,
|
||||
onFilter: (SavedSwapTransactionModel) -> Boolean = { true },
|
||||
): SavedSwapTransactionListModel? {
|
||||
val fromToken = value.fromTokensResponse
|
||||
val toToken = value.toTokensResponse
|
||||
|
|
@ -50,17 +51,19 @@ internal class SavedSwapTransactionListConverter(
|
|||
) ?: return null
|
||||
|
||||
return SavedSwapTransactionListModel(
|
||||
transactions = value.transactions.map { tx ->
|
||||
val status = txStatuses[tx.txId]
|
||||
val refundCurrency = status?.refundTokensResponse?.let { id ->
|
||||
responseCryptoCurrenciesFactory.createCurrency(
|
||||
responseToken = id,
|
||||
userWallet = userWallet,
|
||||
)
|
||||
}
|
||||
val statusWithRefundCurrency = status?.copy(refundCurrency = refundCurrency)
|
||||
tx.copy(status = statusWithRefundCurrency)
|
||||
},
|
||||
transactions = value.transactions
|
||||
.filter(onFilter)
|
||||
.map { tx ->
|
||||
val status = txStatuses[tx.txId]
|
||||
val refundCurrency = status?.refundTokensResponse?.let { id ->
|
||||
responseCryptoCurrenciesFactory.createCurrency(
|
||||
responseToken = id,
|
||||
userWallet = userWallet,
|
||||
)
|
||||
}
|
||||
val statusWithRefundCurrency = status?.copy(refundCurrency = refundCurrency)
|
||||
tx.copy(status = statusWithRefundCurrency)
|
||||
},
|
||||
userWalletId = value.userWalletId,
|
||||
fromCryptoCurrencyId = value.fromCryptoCurrencyId,
|
||||
toCryptoCurrencyId = value.toCryptoCurrencyId,
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import com.tangem.datasource.api.express.models.response.ExpressErrorResponse
|
|||
import com.tangem.datasource.crypto.DataSignatureVerifier
|
||||
import com.tangem.datasource.di.NetworkMoshi
|
||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.domain.exchange.RampStateManager
|
||||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||
import com.tangem.domain.wallets.legacy.UserWalletsListManager
|
||||
import com.tangem.feature.swap.DefaultSwapRepository
|
||||
import com.tangem.feature.swap.DefaultSwapTransactionRepository
|
||||
import com.tangem.feature.swap.converters.ErrorsDataConverter
|
||||
|
|
@ -34,7 +34,7 @@ internal class SwapDataModule {
|
|||
coroutineDispatcher: CoroutineDispatcherProvider,
|
||||
dataSignature: DataSignatureVerifier,
|
||||
walletManagerFacade: WalletManagersFacade,
|
||||
userWalletsListManager: UserWalletsListManager,
|
||||
userWalletsStore: UserWalletsStore,
|
||||
errorsDataConverter: ErrorsDataConverter,
|
||||
@NetworkMoshi moshi: Moshi,
|
||||
excludedBlockchains: ExcludedBlockchains,
|
||||
|
|
@ -45,7 +45,7 @@ internal class SwapDataModule {
|
|||
tangemExpressApi = tangemExpressApi,
|
||||
coroutineDispatcher = coroutineDispatcher,
|
||||
walletManagersFacade = walletManagerFacade,
|
||||
userWalletsListManager = userWalletsListManager,
|
||||
userWalletsStore = userWalletsStore,
|
||||
errorsDataConverter = errorsDataConverter,
|
||||
dataSignatureVerifier = dataSignature,
|
||||
moshi = moshi,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue