diff --git a/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt b/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt index 0e2cd53343..c36eb493ed 100644 --- a/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt +++ b/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt @@ -26,11 +26,11 @@ class DefaultTxHistoryRepository( private val txHistoryItemsStore: TxHistoryItemsStore, ) : TxHistoryRepository { - override suspend fun getTxHistoryItemsCount(userWalletId: UserWalletId, network: Network): Int { + override suspend fun getTxHistoryItemsCount(userWalletId: UserWalletId, currency: CryptoCurrency): Int { val userWallet = getUserWallet(userWalletId) val state = walletManagersFacade.getTxHistoryState( userWalletId = userWallet.walletId, - network = network, + currency = currency, ) return when (state) { is TxHistoryState.Failed.FetchError -> throw TxHistoryStateError.DataError(state.exception) diff --git a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt index 75ebd99c91..f9bc744566 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/DefaultWalletManagersFacade.kt @@ -157,12 +157,12 @@ class DefaultWalletManagersFacade( return blockchain.getExploreUrl(address, contractAddress) } - override suspend fun getTxHistoryState(userWalletId: UserWalletId, network: Network): TxHistoryState { - val blockchain = Blockchain.fromId(network.id.value) + override suspend fun getTxHistoryState(userWalletId: UserWalletId, currency: CryptoCurrency): TxHistoryState { + val blockchain = Blockchain.fromId(currency.network.id.value) val walletManager = getOrCreateWalletManager( userWalletId = userWalletId, blockchain = blockchain, - derivationPath = network.derivationPath.value, + derivationPath = currency.network.derivationPath.value, ) requireNotNull(walletManager) { @@ -170,7 +170,13 @@ class DefaultWalletManagersFacade( } return walletManager - .getTransactionHistoryState(walletManager.wallet.address) + .getTransactionHistoryState( + address = walletManager.wallet.address, + filterType = when (currency) { + is CryptoCurrency.Coin -> TransactionHistoryRequest.FilterType.Coin + is CryptoCurrency.Token -> TransactionHistoryRequest.FilterType.Contract(currency.contractAddress) + }, + ) .let(txHistoryStateConverter::convert) } diff --git a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/WalletManagersFacade.kt b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/WalletManagersFacade.kt index 2a17b00133..e4817280a7 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/WalletManagersFacade.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/WalletManagersFacade.kt @@ -77,9 +77,9 @@ interface WalletManagersFacade { * Returns transactions count * * @param userWalletId The ID of the user's wallet. - * @param network The network. + * @param currency currency. */ - suspend fun getTxHistoryState(userWalletId: UserWalletId, network: Network): TxHistoryState + suspend fun getTxHistoryState(userWalletId: UserWalletId, currency: CryptoCurrency): TxHistoryState /** * Returns transaction history items wrapped to pagination diff --git a/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/repository/TxHistoryRepository.kt b/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/repository/TxHistoryRepository.kt index 6ddb7efd6f..381d469f98 100644 --- a/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/repository/TxHistoryRepository.kt +++ b/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/repository/TxHistoryRepository.kt @@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.Flow interface TxHistoryRepository { @Throws(TxHistoryStateError::class) - suspend fun getTxHistoryItemsCount(userWalletId: UserWalletId, network: Network): Int + suspend fun getTxHistoryItemsCount(userWalletId: UserWalletId, currency: CryptoCurrency): Int @Throws(TxHistoryListError::class) fun getTxHistoryItems( diff --git a/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsCountUseCase.kt b/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsCountUseCase.kt index ab14187a02..bb717d1238 100644 --- a/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsCountUseCase.kt +++ b/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsCountUseCase.kt @@ -3,7 +3,7 @@ package com.tangem.domain.txhistory.usecase import arrow.core.Either import arrow.core.raise.catch import arrow.core.raise.either -import com.tangem.domain.tokens.model.Network +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.txhistory.models.TxHistoryStateError import com.tangem.domain.txhistory.repository.TxHistoryRepository import com.tangem.domain.wallets.models.UserWalletId @@ -11,10 +11,13 @@ import com.tangem.domain.wallets.models.UserWalletId // TODO: Add tests class GetTxHistoryItemsCountUseCase(private val repository: TxHistoryRepository) { - suspend operator fun invoke(userWalletId: UserWalletId, network: Network): Either { + suspend operator fun invoke( + userWalletId: UserWalletId, + currency: CryptoCurrency, + ): Either { return either { catch( - block = { repository.getTxHistoryItemsCount(userWalletId, network) }, + block = { repository.getTxHistoryItemsCount(userWalletId, currency) }, catch = { throwable -> raise( when (throwable) { diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt index b28f7998b7..cece9f729a 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt @@ -195,7 +195,7 @@ internal class TokenDetailsViewModel @Inject constructor( viewModelScope.launch(dispatchers.io) { val txHistoryItemsCountEither = txHistoryItemsCountUseCase( userWalletId = userWalletId, - network = cryptoCurrency.network, + currency = cryptoCurrency, ) // if countEither is left, handling error state run inside getLoadingTxHistoryState diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt index 59806ae1de..05d1796f2b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt @@ -1332,7 +1332,7 @@ internal class WalletViewModel @Inject constructor( viewModelScope.launch(dispatchers.io) { val txHistoryItemsCountEither = txHistoryItemsCountUseCase( userWalletId = userWalletId, - network = currencyStatus.currency.network, + currency = currencyStatus.currency, ) uiState = stateFactory.getLoadingTxHistoryState( diff --git a/gradle/dependencies.toml b/gradle/dependencies.toml index 786a889b19..601a7ca070 100644 --- a/gradle/dependencies.toml +++ b/gradle/dependencies.toml @@ -81,7 +81,7 @@ spr-client = "3.6.2" # endregion Other libraries # region Tangem -tangemBlockchainSdk = "release-app_5.0-369" +tangemBlockchainSdk = "release-app_5.0-370" #tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds tangemCardSdk = "release-app_5.0-309" #tangemCardSdk = "0.0.1" # Keep it! - used for local builds