Updated on 2026-08-14

This commit is contained in:
Tangem 2023-08-04 15:48:39 +08:00
parent ff985dec4e
commit cd78832ff1
30 changed files with 89 additions and 23 deletions

View file

@ -8,7 +8,7 @@ import arrow.core.raise.ensureNotNull
import arrow.core.toNonEmptySetOrNull
import com.tangem.domain.tokens.error.TokenListSortingError
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.models.Network
import com.tangem.domain.tokens.repository.TokensRepository
import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.utils.coroutines.CoroutineDispatcherProvider

View file

@ -7,8 +7,8 @@ import arrow.core.raise.either
import arrow.core.raise.ensure
import com.tangem.domain.tokens.error.TokenListSortingError
import com.tangem.domain.tokens.error.mapper.mapToTokenListSortingError
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.model.TokenList
import com.tangem.domain.tokens.models.Network
import com.tangem.domain.tokens.operations.TokenListSortingOperations
import com.tangem.domain.tokens.repository.NetworksRepository
import com.tangem.utils.coroutines.CoroutineDispatcherProvider

View file

@ -1,5 +1,7 @@
package com.tangem.domain.tokens.model
import com.tangem.domain.tokens.models.Network
/**
* Represents a generic cryptocurrency.
*

View file

@ -1,32 +0,0 @@
package com.tangem.domain.tokens.model
/**
* Represents a blockchain network, identified by a unique ID and a human-readable name.
*
* @property id The unique identifier of the network, encapsulated as an inline value class.
* @property name The human-readable name of the network, such as "Ethereum" or "Bitcoin".
*
* @throws IllegalArgumentException If the name or ID is blank.
*/
data class Network(
val id: ID,
val name: String,
) {
init {
require(name.isNotBlank()) { "Network name must not be blank" }
}
/**
* Represents a unique identifier for a network.
*
* @property value The string value of the network ID.
*/
@JvmInline
value class ID(val value: String) {
init {
require(value.isNotBlank()) { "Network ID must not be blank" }
}
}
}

View file

@ -1,5 +1,7 @@
package com.tangem.domain.tokens.model
import com.tangem.domain.tokens.models.Network
/**
* Represents a group of cryptocurrencies associated with a specific network.
*

View file

@ -1,5 +1,6 @@
package com.tangem.domain.tokens.model
import com.tangem.domain.tokens.models.Network
import java.math.BigDecimal
/**

View file

@ -6,6 +6,7 @@ import arrow.core.raise.catch
import com.tangem.domain.core.raise.DelegatedRaise
import com.tangem.domain.tokens.GetTokenListUseCase
import com.tangem.domain.tokens.model.*
import com.tangem.domain.tokens.models.Network
import com.tangem.domain.tokens.repository.NetworksRepository
import com.tangem.domain.tokens.repository.QuotesRepository
import com.tangem.domain.tokens.repository.TokensRepository

View file

@ -8,8 +8,8 @@ import arrow.core.toNonEmptySetOrNull
import com.tangem.domain.core.raise.DelegatedRaise
import com.tangem.domain.tokens.GetTokenListUseCase
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.model.TokenList
import com.tangem.domain.tokens.models.Network
import com.tangem.domain.tokens.repository.NetworksRepository
import com.tangem.domain.tokens.repository.TokensRepository
import com.tangem.domain.wallets.models.UserWalletId

View file

@ -7,9 +7,9 @@ import arrow.core.raise.ensureNotNull
import arrow.core.toNonEmptySetOrNull
import com.tangem.domain.core.raise.DelegatedRaise
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.model.NetworkGroup
import com.tangem.domain.tokens.model.TokenList
import com.tangem.domain.tokens.models.Network
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.withContext
import java.math.BigDecimal

View file

@ -1,8 +1,8 @@
package com.tangem.domain.tokens.repository
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.model.NetworkStatus
import com.tangem.domain.tokens.models.Network
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow

View file

@ -10,9 +10,9 @@ import com.tangem.domain.tokens.mock.MockQuotes
import com.tangem.domain.tokens.mock.MockTokenLists
import com.tangem.domain.tokens.mock.MockTokens
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.model.NetworkStatus
import com.tangem.domain.tokens.model.Quote
import com.tangem.domain.tokens.models.Network
import com.tangem.domain.tokens.repository.MockNetworksRepository
import com.tangem.domain.tokens.repository.MockQuotesRepository
import com.tangem.domain.tokens.repository.MockTokensRepository

View file

@ -7,7 +7,7 @@ import com.tangem.domain.core.error.DataError
import com.tangem.domain.tokens.error.TokenListSortingError
import com.tangem.domain.tokens.mock.MockNetworks
import com.tangem.domain.tokens.mock.MockTokenLists
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.models.Network
import com.tangem.domain.tokens.repository.MockNetworksRepository
import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider
import junit.framework.TestCase.assertEquals

View file

@ -2,8 +2,8 @@ package com.tangem.domain.tokens.mock
import arrow.core.NonEmptySet
import arrow.core.nonEmptySetOf
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.model.NetworkStatus
import com.tangem.domain.tokens.models.Network
import java.math.BigDecimal
@Suppress("MemberVisibilityCanBePrivate")

View file

@ -4,8 +4,8 @@ import arrow.core.Either
import arrow.core.getOrElse
import com.tangem.domain.core.error.DataError
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.model.NetworkStatus
import com.tangem.domain.tokens.models.Network
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map