Updated on 2026-08-14
This commit is contained in:
parent
81a16c8bb1
commit
23aac9041c
16 changed files with 263 additions and 26 deletions
|
|
@ -32,6 +32,7 @@ internal object MockNetworks {
|
|||
MockTokens.token2.id to BigDecimal("42.2"),
|
||||
MockTokens.token3.id to BigDecimal("1000000000.5"),
|
||||
),
|
||||
hasTransactionsInProgress = false,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -49,6 +50,7 @@ internal object MockNetworks {
|
|||
MockTokens.token9.id to BigDecimal.TEN,
|
||||
MockTokens.token10.id to BigDecimal.TEN,
|
||||
),
|
||||
hasTransactionsInProgress = false,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ internal fun CurrenciesStatusesOperations.Error.mapToTokenError(): TokenError {
|
|||
is CurrenciesStatusesOperations.Error.EmptyNetworksStatuses,
|
||||
is CurrenciesStatusesOperations.Error.EmptyQuotes,
|
||||
is CurrenciesStatusesOperations.Error.EmptyCurrencies,
|
||||
is CurrenciesStatusesOperations.Error.UnableToCreateCurrencyStatus,
|
||||
-> TokenError.UnableToCreateToken
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ internal fun CurrenciesStatusesOperations.Error.mapToTokenListError(): TokenList
|
|||
is CurrenciesStatusesOperations.Error.EmptyNetworksStatuses,
|
||||
is CurrenciesStatusesOperations.Error.EmptyQuotes,
|
||||
is CurrenciesStatusesOperations.Error.EmptyCurrencies,
|
||||
is CurrenciesStatusesOperations.Error.UnableToCreateCurrencyStatus,
|
||||
-> TokenListError.EmptyTokens
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
package com.tangem.domain.tokens.model
|
||||
|
||||
/**
|
||||
* Represents a generic cryptocurrency.
|
||||
*
|
||||
* @property id Unique identifier for the cryptocurrency.
|
||||
* @property networkId Identifier for the network to which the cryptocurrency belongs.
|
||||
* @property name Human-readable name of the cryptocurrency.
|
||||
* @property symbol Symbol of the cryptocurrency.
|
||||
* @property decimals Number of decimal places used by the cryptocurrency.
|
||||
* @property iconUrl Optional URL of the cryptocurrency icon. `null` if not found.
|
||||
* @property derivationPath Optional path used for key derivation. `null` if the wallet does not support the
|
||||
* [HD Wallet](https://coinsutra.com/hd-wallets-deterministic-wallet/) feature.
|
||||
*/
|
||||
sealed class CryptoCurrency {
|
||||
|
||||
abstract val id: ID
|
||||
|
|
@ -10,6 +22,9 @@ sealed class CryptoCurrency {
|
|||
abstract val iconUrl: String?
|
||||
abstract val derivationPath: String?
|
||||
|
||||
/**
|
||||
* Represents a native coin in the blockchain network.
|
||||
*/
|
||||
data class Coin(
|
||||
override val id: ID,
|
||||
override val networkId: Network.ID,
|
||||
|
|
@ -25,6 +40,12 @@ sealed class CryptoCurrency {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a token in the blockchain network, typically a non-native asset.
|
||||
*
|
||||
* @property contractAddress Address of the contract managing the token.
|
||||
* @property isCustom Indicates whether the token is a custom user-added token or not.
|
||||
*/
|
||||
data class Token(
|
||||
override val id: ID,
|
||||
override val networkId: Network.ID,
|
||||
|
|
@ -43,6 +64,11 @@ sealed class CryptoCurrency {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Value class for uniquely identifying a cryptocurrency.
|
||||
*
|
||||
* @property value The unique identifier value.
|
||||
*/
|
||||
@JvmInline
|
||||
value class ID(val value: String) {
|
||||
|
||||
|
|
|
|||
|
|
@ -2,27 +2,64 @@ package com.tangem.domain.tokens.model
|
|||
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* Represents the status of a cryptocurrency asset within a network.
|
||||
*
|
||||
* This class encapsulates the details of a specific cryptocurrency, either a coin or token,
|
||||
* along with its current status within the blockchain network. The status can include various states
|
||||
* like Loading, Unreachable, Loaded, etc.
|
||||
*
|
||||
* @property currency The details of the cryptocurrency asset, including its type, name, symbol, and other properties.
|
||||
* @property value The current status of the cryptocurrency, reflecting its state within the network.
|
||||
*/
|
||||
data class CryptoCurrencyStatus(
|
||||
val currency: CryptoCurrency,
|
||||
val value: Status,
|
||||
) {
|
||||
|
||||
/**
|
||||
* Represents the various states a token can have, encapsulating different information based on the state.
|
||||
*/
|
||||
sealed class Status {
|
||||
|
||||
/** The amount of the token. */
|
||||
open val amount: BigDecimal? = null
|
||||
|
||||
/** The fiat equivalent of the token's amount. */
|
||||
open val fiatAmount: BigDecimal? = null
|
||||
|
||||
/** The exchange rate used for converting the token amount to fiat. */
|
||||
open val fiatRate: BigDecimal? = null
|
||||
|
||||
/** The change in price of the token. */
|
||||
open val priceChange: BigDecimal? = null
|
||||
|
||||
/** Indicates if there are any transactions in progress related to the token. */
|
||||
open val hasTransactionsInProgress: Boolean = false
|
||||
}
|
||||
|
||||
/** Represents the Loading state of a token, typically while fetching its details. */
|
||||
object Loading : Status()
|
||||
|
||||
/** Represents a state where the token is not reachable. */
|
||||
object Unreachable : Status()
|
||||
|
||||
/** Represents a state where the token's derivation is missed. */
|
||||
object MissedDerivation : Status()
|
||||
|
||||
/** Represents a state where there is no account associated with the token. */
|
||||
object NoAccount : Status()
|
||||
|
||||
/**
|
||||
* Represents a Loaded state of a token with complete information.
|
||||
*
|
||||
* @property amount The amount of the token.
|
||||
* @property fiatAmount The fiat equivalent of the token's amount.
|
||||
* @property fiatRate The exchange rate used for converting the token amount to fiat.
|
||||
* @property priceChange The change in price of the token.
|
||||
* @property hasTransactionsInProgress Indicates if there are any transactions in progress related to the token
|
||||
* network.
|
||||
*/
|
||||
data class Loaded(
|
||||
override val amount: BigDecimal,
|
||||
override val fiatAmount: BigDecimal,
|
||||
|
|
@ -31,6 +68,16 @@ data class CryptoCurrencyStatus(
|
|||
override val hasTransactionsInProgress: Boolean,
|
||||
) : Status()
|
||||
|
||||
/**
|
||||
* Represents a Custom state of a token, typically used for user-defined tokens.
|
||||
*
|
||||
* @property amount The amount of the token.
|
||||
* @property fiatAmount The fiat equivalent of the token's amount (optional).
|
||||
* @property fiatRate The exchange rate used for converting the token amount to fiat (optional).
|
||||
* @property priceChange The change in price of the token (optional).
|
||||
* @property hasTransactionsInProgress Indicates if there are any transactions in progress related to the token
|
||||
* network.
|
||||
*/
|
||||
data class Custom(
|
||||
override val amount: BigDecimal,
|
||||
override val fiatAmount: BigDecimal?,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
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,
|
||||
|
|
@ -9,6 +17,11 @@ data class Network(
|
|||
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) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
package com.tangem.domain.tokens.model
|
||||
|
||||
/**
|
||||
* Represents a group of cryptocurrencies associated with a specific network.
|
||||
*
|
||||
* This class encapsulates a collection of cryptocurrency statuses, all of which are part of the same blockchain network.
|
||||
*
|
||||
* @property network The blockchain network associated with the group.
|
||||
* @property currencies A set of cryptocurrency statuses that belong to the network.
|
||||
*/
|
||||
data class NetworkGroup(
|
||||
val network: Network,
|
||||
val currencies: Set<CryptoCurrencyStatus>,
|
||||
|
|
|
|||
|
|
@ -2,22 +2,49 @@ package com.tangem.domain.tokens.model
|
|||
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* Represents the status of a specific blockchain network.
|
||||
*
|
||||
* @property networkId The unique identifier of the network for which the status is provided.
|
||||
* @property value The specific status value, represented as a sealed class to encapsulate the various possible states of the network.
|
||||
*/
|
||||
data class NetworkStatus(
|
||||
val networkId: Network.ID,
|
||||
val value: Status,
|
||||
) {
|
||||
|
||||
sealed class Status {
|
||||
open val amounts: Map<CryptoCurrency.ID, BigDecimal>? = null
|
||||
}
|
||||
/**
|
||||
* Represents the various possible statuses of a network.
|
||||
*
|
||||
* This sealed class includes different states like unreachable, missed derivation, verified, and no account.
|
||||
*/
|
||||
sealed class Status
|
||||
|
||||
/**
|
||||
* Represents the state where the network is unreachable.
|
||||
*/
|
||||
object Unreachable : Status()
|
||||
|
||||
/**
|
||||
* Represents the state where a derivation has been missed.
|
||||
*/
|
||||
object MissedDerivation : Status()
|
||||
|
||||
data class TransactionInProgress(override val amounts: Map<CryptoCurrency.ID, BigDecimal>) : Status()
|
||||
|
||||
data class Verified(override val amounts: Map<CryptoCurrency.ID, BigDecimal>) : Status()
|
||||
/**
|
||||
* Represents the verified state of the network, including the amounts associated with different cryptocurrencies and whether there are transactions in progress.
|
||||
*
|
||||
* @property amounts A map containing the amounts associated with different cryptocurrencies within the network.
|
||||
* @property hasTransactionsInProgress A boolean indicating whether there are transactions in progress within the network.
|
||||
*/
|
||||
data class Verified(
|
||||
val amounts: Map<CryptoCurrency.ID, BigDecimal>,
|
||||
val hasTransactionsInProgress: Boolean,
|
||||
) : Status()
|
||||
|
||||
/**
|
||||
* Represents the state where there is no account, and an amount is required to create one.
|
||||
*
|
||||
* @property amountToCreateAccount The amount required to create an account within the network.
|
||||
*/
|
||||
data class NoAccount(val amountToCreateAccount: BigDecimal) : Status()
|
||||
}
|
||||
|
|
@ -2,6 +2,13 @@ package com.tangem.domain.tokens.model
|
|||
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* Represents a financial quote for a specific cryptocurrency, including its fiat exchange rate and price change.
|
||||
*
|
||||
* @property currencyId The unique identifier of the cryptocurrency for which the quote is provided.
|
||||
* @property fiatRate The current fiat exchange rate for the cryptocurrency.
|
||||
* @property priceChange The price change for the cryptocurrency.
|
||||
*/
|
||||
data class Quote(
|
||||
val currencyId: CryptoCurrency.ID,
|
||||
val fiatRate: BigDecimal,
|
||||
|
|
|
|||
|
|
@ -2,33 +2,75 @@ package com.tangem.domain.tokens.model
|
|||
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* Represents a list of cryptocurrency tokens, which can be grouped by network or ungrouped.
|
||||
*
|
||||
* The tokens can be represented in two forms: either grouped by the network or as an ungrouped collection.
|
||||
* Additional details like the total fiat balance and the sorting type can be associated with the list.
|
||||
*
|
||||
* @property totalFiatBalance The total fiat balance across all tokens, which could be in a loading state, failed, or loaded with a specific amount.
|
||||
* @property sortedBy The criteria used for sorting the tokens.
|
||||
*/
|
||||
sealed class TokenList {
|
||||
open val totalFiatBalance: FiatBalance = FiatBalance.Loading
|
||||
open val sortedBy: SortType = SortType.NONE
|
||||
|
||||
/**
|
||||
* Represents tokens that are grouped by their network.
|
||||
*
|
||||
* @property groups A set of network groups containing tokens.
|
||||
* @property totalFiatBalance The total fiat balance across all groups.
|
||||
* @property sortedBy The criteria used for sorting the tokens within the groups.
|
||||
*/
|
||||
data class GroupedByNetwork(
|
||||
val groups: Set<NetworkGroup>,
|
||||
override val totalFiatBalance: FiatBalance,
|
||||
override val sortedBy: SortType,
|
||||
) : TokenList()
|
||||
|
||||
/**
|
||||
* Represents tokens that are not grouped by any specific criteria.
|
||||
*
|
||||
* @property currencies A set of cryptocurrency statuses.
|
||||
* @property totalFiatBalance The total fiat balance across all currencies.
|
||||
* @property sortedBy The criteria used for sorting the currencies.
|
||||
*/
|
||||
data class Ungrouped(
|
||||
val currencies: Set<CryptoCurrencyStatus>,
|
||||
override val totalFiatBalance: FiatBalance,
|
||||
override val sortedBy: SortType,
|
||||
) : TokenList()
|
||||
|
||||
/** Represents a state where the token list is not initialized. */
|
||||
object NotInitialized : TokenList()
|
||||
|
||||
/** Defines the possible sorting criteria for the tokens. */
|
||||
enum class SortType {
|
||||
NONE, BALANCE,
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the possible states of the fiat balance, including loading, failure, or a loaded amount.
|
||||
*/
|
||||
sealed class FiatBalance {
|
||||
/**
|
||||
* Represents the loading state of the fiat balance.
|
||||
* This state indicates that the fiat balance is currently being retrieved or calculated.
|
||||
*/
|
||||
object Loading : FiatBalance()
|
||||
|
||||
/**
|
||||
* Represents the failure state of the fiat balance.
|
||||
* This state indicates that an attempt to retrieve or calculate the fiat balance has failed.
|
||||
*/
|
||||
object Failed : FiatBalance()
|
||||
|
||||
/**
|
||||
* Represents the successfully loaded state of the fiat balance.
|
||||
*
|
||||
* @property amount The loaded fiat balance amount.
|
||||
* @property isAllAmountsSummarized Indicates whether the amount includes a summary of all underlying amounts.
|
||||
*/
|
||||
data class Loaded(
|
||||
val amount: BigDecimal,
|
||||
val isAllAmountsSummarized: Boolean,
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ internal class CurrenciesStatusesOperations<E>(
|
|||
quote = quote,
|
||||
networkStatus = networkStatus,
|
||||
dispatchers = dispatchers,
|
||||
raise = this,
|
||||
transformError = { Error.UnableToCreateCurrencyStatus },
|
||||
)
|
||||
|
||||
return currencyStatusOperations.createTokenStatus()
|
||||
|
|
@ -161,6 +163,8 @@ internal class CurrenciesStatusesOperations<E>(
|
|||
|
||||
object EmptyNetworksStatuses : Error()
|
||||
|
||||
object UnableToCreateCurrencyStatus : Error()
|
||||
|
||||
data class DataError(val cause: Throwable) : Error()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
package com.tangem.domain.tokens.operations
|
||||
|
||||
import arrow.core.raise.Raise
|
||||
import arrow.core.raise.ensureNotNull
|
||||
import com.tangem.domain.core.raise.DelegatedRaise
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.NetworkStatus
|
||||
|
|
@ -8,18 +11,17 @@ import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
|||
import kotlinx.coroutines.withContext
|
||||
import java.math.BigDecimal
|
||||
|
||||
internal class CurrencyStatusOperations(
|
||||
internal class CurrencyStatusOperations<OtherError>(
|
||||
private val currency: CryptoCurrency,
|
||||
private val quote: Quote?,
|
||||
private val networkStatus: NetworkStatus?,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
) {
|
||||
raise: Raise<OtherError>,
|
||||
transformError: (Error) -> OtherError,
|
||||
) : DelegatedRaise<CurrencyStatusOperations.Error, OtherError>(raise, transformError) {
|
||||
|
||||
suspend fun createTokenStatus(): CryptoCurrencyStatus = withContext(dispatchers.default) {
|
||||
CryptoCurrencyStatus(
|
||||
currency = currency,
|
||||
value = createStatus(),
|
||||
)
|
||||
CryptoCurrencyStatus(currency, createStatus())
|
||||
}
|
||||
|
||||
private fun createStatus(): CryptoCurrencyStatus.Status {
|
||||
|
|
@ -28,23 +30,22 @@ internal class CurrencyStatusOperations(
|
|||
is NetworkStatus.MissedDerivation -> CryptoCurrencyStatus.MissedDerivation
|
||||
is NetworkStatus.Unreachable -> CryptoCurrencyStatus.Unreachable
|
||||
is NetworkStatus.NoAccount -> CryptoCurrencyStatus.NoAccount
|
||||
is NetworkStatus.TransactionInProgress,
|
||||
is NetworkStatus.Verified,
|
||||
-> createStatus(
|
||||
amount = getTokenAmount(),
|
||||
hasTransactionsInProgress = status is NetworkStatus.TransactionInProgress,
|
||||
)
|
||||
is NetworkStatus.Verified -> createStatus(status)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createStatus(amount: BigDecimal, hasTransactionsInProgress: Boolean): CryptoCurrencyStatus.Status {
|
||||
private fun createStatus(status: NetworkStatus.Verified): CryptoCurrencyStatus.Status {
|
||||
val amount = ensureNotNull(status.amounts[currency.id]) {
|
||||
Error.UnableToFindAmount(currency.id)
|
||||
}
|
||||
|
||||
return when {
|
||||
currency is CryptoCurrency.Token && currency.isCustom -> CryptoCurrencyStatus.Custom(
|
||||
amount = amount,
|
||||
fiatAmount = calculateFiatAmountOrNull(amount, quote?.fiatRate),
|
||||
fiatRate = quote?.fiatRate,
|
||||
priceChange = quote?.priceChange,
|
||||
hasTransactionsInProgress = hasTransactionsInProgress,
|
||||
hasTransactionsInProgress = status.hasTransactionsInProgress,
|
||||
)
|
||||
quote == null -> CryptoCurrencyStatus.Loading
|
||||
else -> CryptoCurrencyStatus.Loaded(
|
||||
|
|
@ -52,16 +53,11 @@ internal class CurrencyStatusOperations(
|
|||
fiatAmount = calculateFiatAmount(amount, quote.fiatRate),
|
||||
fiatRate = quote.fiatRate,
|
||||
priceChange = quote.priceChange,
|
||||
hasTransactionsInProgress = hasTransactionsInProgress,
|
||||
hasTransactionsInProgress = status.hasTransactionsInProgress,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getTokenAmount(): BigDecimal {
|
||||
val amount = networkStatus?.value?.amounts?.get(currency.id)
|
||||
return amount ?: error("Incorrect network status: $networkStatus")
|
||||
}
|
||||
|
||||
private fun calculateFiatAmountOrNull(amount: BigDecimal, fiatRate: BigDecimal?): BigDecimal? {
|
||||
if (fiatRate == null) return null
|
||||
|
||||
|
|
@ -71,4 +67,9 @@ internal class CurrencyStatusOperations(
|
|||
private fun calculateFiatAmount(amount: BigDecimal, fiatRate: BigDecimal): BigDecimal {
|
||||
return amount * fiatRate
|
||||
}
|
||||
|
||||
sealed class Error {
|
||||
|
||||
data class UnableToFindAmount(val currencyId: CryptoCurrency.ID) : Error()
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,22 @@ import kotlinx.coroutines.flow.Flow
|
|||
* */
|
||||
interface NetworksRepository {
|
||||
|
||||
/**
|
||||
* Retrieves the details of the specified blockchain networks, identified by their unique IDs.
|
||||
*
|
||||
* @param networksIds The unique identifiers of the networks to be retrieved.
|
||||
* @return A set of [Network] objects corresponding to the specified network IDs.
|
||||
*/
|
||||
fun getNetworks(networksIds: Set<Network.ID>): Set<Network>
|
||||
|
||||
/**
|
||||
* Retrieves the statuses of specified blockchain networks for a specific user wallet.
|
||||
*
|
||||
* @param userWalletId The unique identifier of the user wallet.
|
||||
* @param networks A map of network IDs to sets of cryptocurrency IDs, representing the networks for which statuses are to be retrieved.
|
||||
* @param refresh A boolean flag indicating whether the data should be refreshed.
|
||||
* @return A [Flow] emitting a set of [NetworkStatus] objects corresponding to the specified networks.
|
||||
*/
|
||||
fun getNetworkStatuses(
|
||||
userWalletId: UserWalletId,
|
||||
networks: Map<Network.ID, Set<CryptoCurrency.ID>>,
|
||||
|
|
|
|||
|
|
@ -9,5 +9,12 @@ import kotlinx.coroutines.flow.Flow
|
|||
* */
|
||||
interface QuotesRepository {
|
||||
|
||||
/**
|
||||
* Retrieves the quotes for a set of specified cryptocurrencies, identified by their unique IDs.
|
||||
*
|
||||
* @param tokensIds The unique identifiers of the cryptocurrencies for which quotes are to be retrieved.
|
||||
* @param refresh A boolean flag indicating whether the data should be refreshed.
|
||||
* @return A [Flow] emitting a set of quotes corresponding to the specified cryptocurrencies.
|
||||
*/
|
||||
fun getQuotes(tokensIds: Set<CryptoCurrency.ID>, refresh: Boolean): Flow<Set<Quote>>
|
||||
}
|
||||
|
|
@ -9,6 +9,15 @@ import kotlinx.coroutines.flow.Flow
|
|||
* */
|
||||
interface TokensRepository {
|
||||
|
||||
/**
|
||||
* Saves the given set of cryptocurrencies, along with the preferences for grouping and sorting, for a specific
|
||||
* multi-currency user wallet.
|
||||
*
|
||||
* @param userWalletId The unique identifier of the user wallet.
|
||||
* @param currencies The set of cryptocurrencies to be saved.
|
||||
* @param isGroupedByNetwork A boolean flag indicating whether the tokens should be grouped by network.
|
||||
* @param isSortedByBalance A boolean flag indicating whether the tokens should be sorted by balance.
|
||||
*/
|
||||
suspend fun saveTokens(
|
||||
userWalletId: UserWalletId,
|
||||
currencies: Set<CryptoCurrency>,
|
||||
|
|
@ -16,11 +25,36 @@ interface TokensRepository {
|
|||
isSortedByBalance: Boolean,
|
||||
)
|
||||
|
||||
/**
|
||||
* Retrieves the primary cryptocurrency for a specific single-currency user wallet.
|
||||
*
|
||||
* @param userWalletId The unique identifier of the user wallet.
|
||||
* @return The primary cryptocurrency associated with the user wallet.
|
||||
*/
|
||||
suspend fun getPrimaryCurrency(userWalletId: UserWalletId): CryptoCurrency
|
||||
|
||||
/**
|
||||
* Retrieves the set of cryptocurrencies within a multi-currency wallet.
|
||||
*
|
||||
* @param userWalletId The unique identifier of the user wallet.
|
||||
* @param refresh A boolean flag indicating whether the data should be refreshed.
|
||||
* @return A [Flow] emitting the set of cryptocurrencies associated with the user wallet.
|
||||
*/
|
||||
fun getMultiCurrencyWalletCurrencies(userWalletId: UserWalletId, refresh: Boolean): Flow<Set<CryptoCurrency>>
|
||||
|
||||
/**
|
||||
* Determines whether the tokens within a specific multi-currency user wallet are grouped.
|
||||
*
|
||||
* @param userWalletId The unique identifier of the user wallet.
|
||||
* @return A [Flow] emitting a boolean value indicating whether the tokens are grouped.
|
||||
*/
|
||||
fun isTokensGrouped(userWalletId: UserWalletId): Flow<Boolean>
|
||||
|
||||
/**
|
||||
* Determines whether the tokens within a specific multi-currency user wallet are sorted by balance.
|
||||
*
|
||||
* @param userWalletId The unique identifier of the user wallet.
|
||||
* @return A [Flow] emitting a boolean value indicating whether the tokens are sorted by balance.
|
||||
*/
|
||||
fun isTokensSortedByBalance(userWalletId: UserWalletId): Flow<Boolean>
|
||||
}
|
||||
|
|
@ -55,6 +55,7 @@ internal object MockNetworks {
|
|||
MockTokens.token2.id to BigDecimal.TEN,
|
||||
MockTokens.token3.id to BigDecimal.TEN,
|
||||
),
|
||||
hasTransactionsInProgress = false,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -66,6 +67,7 @@ internal object MockNetworks {
|
|||
MockTokens.token5.id to BigDecimal.TEN,
|
||||
MockTokens.token6.id to BigDecimal.TEN,
|
||||
),
|
||||
hasTransactionsInProgress = false,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -78,6 +80,7 @@ internal object MockNetworks {
|
|||
MockTokens.token9.id to BigDecimal.TEN,
|
||||
MockTokens.token10.id to BigDecimal.TEN,
|
||||
),
|
||||
hasTransactionsInProgress = false,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue