Updated on 2026-08-14

This commit is contained in:
Tangem 2025-02-03 12:24:11 +03:00
parent dfa6798f07
commit 5883823eb3
71 changed files with 221 additions and 285 deletions

View file

@ -46,7 +46,7 @@ internal class DefaultHotCryptoLoader @Inject constructor(
override suspend fun update(currencies: List<CryptoCurrency>) {
updateInternal { hotToken ->
currencies.none {
it.id.rawCurrencyId == hotToken.id &&
it.id.rawCurrencyId?.value == hotToken.id &&
(it as? CryptoCurrency.Token)?.contractAddress == hotToken.contractAddress &&
it.network.id.value == hotToken.networkId
}

View file

@ -11,11 +11,9 @@ internal class DefaultQuotesStore(
private val dataStore: StringKeyDataStore<StoredQuote>,
) : QuotesStore {
override fun get(currenciesIds: Set<CryptoCurrency.ID>): Flow<Set<StoredQuote>> {
override fun get(currenciesIds: Set<CryptoCurrency.RawID>): Flow<Set<StoredQuote>> {
return channelFlow {
val flows = currenciesIds.mapNotNull { currencyId ->
currencyId.rawCurrencyId?.let(dataStore::get)
}
val flows = currenciesIds.map { currencyId -> dataStore.get(currencyId.value) }
if (dataStore.isEmpty() || flows.isEmpty()) {
send(emptySet())
@ -30,12 +28,8 @@ internal class DefaultQuotesStore(
}
}
override suspend fun getSync(currenciesIds: Set<CryptoCurrency.ID>): Set<StoredQuote> {
return currenciesIds.mapNotNull { currencyId ->
currencyId.rawCurrencyId?.let {
dataStore.getSyncOrNull(it)
}
}.toSet()
override suspend fun getSync(currenciesIds: Set<CryptoCurrency.RawID>): Set<StoredQuote> {
return currenciesIds.mapNotNull { currencyId -> dataStore.getSyncOrNull(currencyId.value) }.toSet()
}
override suspend fun store(response: QuotesResponse) {

View file

@ -7,9 +7,9 @@ import kotlinx.coroutines.flow.Flow
interface QuotesStore {
fun get(currenciesIds: Set<CryptoCurrency.ID>): Flow<Set<StoredQuote>>
fun get(currenciesIds: Set<CryptoCurrency.RawID>): Flow<Set<StoredQuote>>
suspend fun getSync(currenciesIds: Set<CryptoCurrency.ID>): Set<StoredQuote>
suspend fun getSync(currenciesIds: Set<CryptoCurrency.RawID>): Set<StoredQuote>
suspend fun store(response: QuotesResponse)
}