Updated on 2026-08-14
This commit is contained in:
parent
66aedc97cb
commit
5f1a5494dc
24 changed files with 525 additions and 353 deletions
|
|
@ -5,6 +5,7 @@ plugins {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.domain.core)
|
||||
implementation(projects.domain.tokens)
|
||||
implementation(projects.domain.wallets.models)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
package com.tangem.data.tokens.repository
|
||||
|
||||
import arrow.core.Either
|
||||
import arrow.core.right
|
||||
import com.tangem.data.tokens.mock.MockNetworks
|
||||
import com.tangem.domain.tokens.error.TokensError
|
||||
import com.tangem.domain.tokens.model.Network
|
||||
import com.tangem.domain.tokens.model.NetworkStatus
|
||||
import com.tangem.domain.tokens.model.Token
|
||||
|
|
@ -14,23 +11,21 @@ import kotlinx.coroutines.flow.flowOf
|
|||
|
||||
internal class MockNetworksRepository : NetworksRepository {
|
||||
|
||||
override fun getNetworks(networksIds: Set<Network.ID>): Either<TokensError, Set<Network>> {
|
||||
override fun getNetworks(networksIds: Set<Network.ID>): Set<Network> {
|
||||
return MockNetworks.networks
|
||||
.filter { it.id in networksIds }
|
||||
.toSet()
|
||||
.right()
|
||||
}
|
||||
|
||||
override fun getNetworkStatuses(
|
||||
userWalletId: UserWalletId,
|
||||
networks: Map<Network.ID, Set<Token.ID>>,
|
||||
refresh: Boolean,
|
||||
): Flow<Either<TokensError, Set<NetworkStatus>>> {
|
||||
): Flow<Set<NetworkStatus>> {
|
||||
return flowOf(
|
||||
MockNetworks.networksStatuses
|
||||
.filter { it.networkId in networks.keys }
|
||||
.toSet()
|
||||
.right(),
|
||||
.toSet(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package com.tangem.data.tokens.repository
|
||||
|
||||
import arrow.core.Either
|
||||
import arrow.core.right
|
||||
import com.tangem.data.tokens.mock.MockQuotes
|
||||
import com.tangem.domain.tokens.error.TokensError
|
||||
import com.tangem.domain.tokens.model.Quote
|
||||
import com.tangem.domain.tokens.model.Token
|
||||
import com.tangem.domain.tokens.repository.QuotesRepository
|
||||
|
|
@ -12,12 +9,11 @@ import kotlinx.coroutines.flow.flowOf
|
|||
|
||||
internal class MockQuotesRepository : QuotesRepository {
|
||||
|
||||
override fun getQuotes(tokensIds: Set<Token.ID>, refresh: Boolean): Flow<Either<TokensError, Set<Quote>>> {
|
||||
override fun getQuotes(tokensIds: Set<Token.ID>, refresh: Boolean): Flow<Set<Quote>> {
|
||||
return flowOf(
|
||||
MockQuotes.quotes
|
||||
.filter { it.tokenId in tokensIds }
|
||||
.toSet()
|
||||
.right(),
|
||||
.toSet(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
package com.tangem.data.tokens.repository
|
||||
|
||||
import arrow.core.Either
|
||||
import arrow.core.left
|
||||
import arrow.core.right
|
||||
import com.tangem.data.tokens.mock.MockTokens
|
||||
import com.tangem.domain.tokens.error.TokensError
|
||||
import com.tangem.domain.tokens.model.Token
|
||||
import com.tangem.domain.tokens.repository.TokensRepository
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
|
|
@ -18,17 +14,17 @@ internal class MockTokensRepository : TokensRepository {
|
|||
sortedTokensIds: Set<Token.ID>,
|
||||
isGrouped: Boolean,
|
||||
isSortedByBalance: Boolean,
|
||||
): Either<TokensError, Unit> = Unit.right()
|
||||
) = Unit
|
||||
|
||||
override fun getTokens(userWalletId: UserWalletId, refresh: Boolean): Flow<Either<TokensError, Set<Token>>> {
|
||||
return flowOf(value = MockTokens.tokens[userWalletId]?.right() ?: TokensError.EmptyTokens.left())
|
||||
override fun getTokens(userWalletId: UserWalletId, refresh: Boolean): Flow<Set<Token>> {
|
||||
return flowOf(value = MockTokens.tokens[userWalletId]!!)
|
||||
}
|
||||
|
||||
override fun isTokensGrouped(userWalletId: UserWalletId): Flow<Either<TokensError, Boolean>> {
|
||||
return flowOf(MockTokens.isGrouped[userWalletId]?.right() ?: TokensError.EmptyTokens.left())
|
||||
override fun isTokensGrouped(userWalletId: UserWalletId): Flow<Boolean> {
|
||||
return flowOf(value = MockTokens.isGrouped[userWalletId]!!)
|
||||
}
|
||||
|
||||
override fun isTokensSortedByBalance(userWalletId: UserWalletId): Flow<Either<TokensError, Boolean>> {
|
||||
return flowOf(MockTokens.isSortedByBalance[userWalletId]?.right() ?: TokensError.EmptyTokens.left())
|
||||
override fun isTokensSortedByBalance(userWalletId: UserWalletId): Flow<Boolean> {
|
||||
return flowOf(value = MockTokens.isSortedByBalance[userWalletId]!!)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue