diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListMigration.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListMigration.kt index 8340df9959..6614f66d20 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListMigration.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListMigration.kt @@ -9,7 +9,7 @@ import com.tangem.domain.common.util.derivationStyleProvider import com.tangem.domain.tokens.GetCryptoCurrenciesUseCase import com.tangem.domain.tokens.TokenWithBlockchain import com.tangem.domain.tokens.TokensAction -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.usecase.GetSelectedWalletUseCase import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles diff --git a/app/src/main/java/com/tangem/tap/features/tokens/legacy/redux/TokensMiddleware.kt b/app/src/main/java/com/tangem/tap/features/tokens/legacy/redux/TokensMiddleware.kt index bbea323a16..d93ec4d36d 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/legacy/redux/TokensMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/legacy/redux/TokensMiddleware.kt @@ -17,7 +17,7 @@ import com.tangem.domain.common.util.supportsHdWallet import com.tangem.domain.models.scan.ScanResponse import com.tangem.domain.tokens.TokenWithBlockchain import com.tangem.domain.tokens.TokensAction -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.wallets.models.UserWalletId import com.tangem.operations.derivation.ExtendedPublicKeysMap import com.tangem.tap.* diff --git a/app/src/main/java/com/tangem/tap/features/wallet/converters/CryptoCurrencyConverter.kt b/app/src/main/java/com/tangem/tap/features/wallet/converters/CryptoCurrencyConverter.kt index 8506d82036..891841469c 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/converters/CryptoCurrencyConverter.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/converters/CryptoCurrencyConverter.kt @@ -4,7 +4,7 @@ import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.Token import com.tangem.data.tokens.utils.CryptoCurrencyFactory import com.tangem.domain.common.util.derivationStyleProvider -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.tap.features.wallet.models.Currency import com.tangem.tap.store import com.tangem.utils.converter.TwoWayConverter diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt index 6b321e4e9d..6a00cefa48 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt @@ -12,8 +12,8 @@ import com.tangem.core.navigation.NavigationAction import com.tangem.domain.common.extensions.toCoinId import com.tangem.domain.common.extensions.toNetworkId import com.tangem.domain.tokens.legacy.TradeCryptoAction -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.feature.swap.presentation.SwapFragment import com.tangem.tap.common.analytics.events.AnalyticsParam import com.tangem.tap.common.analytics.events.Token diff --git a/app/src/main/java/com/tangem/tap/network/exchangeServices/DefaultRampManager.kt b/app/src/main/java/com/tangem/tap/network/exchangeServices/DefaultRampManager.kt index 9c9184e488..b8a3e32d55 100644 --- a/app/src/main/java/com/tangem/tap/network/exchangeServices/DefaultRampManager.kt +++ b/app/src/main/java/com/tangem/tap/network/exchangeServices/DefaultRampManager.kt @@ -1,7 +1,7 @@ package com.tangem.tap.network.exchangeServices import com.tangem.domain.exchange.RampStateManager -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.tap.features.wallet.converters.CryptoCurrencyConverter class DefaultRampManager(private val exchangeService: ExchangeService?) : RampStateManager { diff --git a/core/datasource/src/main/java/com/tangem/datasource/di/NetworksStatusesStoreModule.kt b/core/datasource/src/main/java/com/tangem/datasource/di/NetworksStatusesStoreModule.kt new file mode 100644 index 0000000000..d9cb5b5946 --- /dev/null +++ b/core/datasource/src/main/java/com/tangem/datasource/di/NetworksStatusesStoreModule.kt @@ -0,0 +1,21 @@ +package com.tangem.datasource.di + +import com.tangem.datasource.local.datastore.RuntimeDataStore +import com.tangem.datasource.local.network.DefaultNetworksStatusesStore +import com.tangem.datasource.local.network.NetworksStatusesStore +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent + +@Module +@InstallIn(SingletonComponent::class) +internal object NetworksStatusesStoreModule { + + @Provides + fun provideNetworksStatusesStore(): NetworksStatusesStore { + return DefaultNetworksStatusesStore( + dataStore = RuntimeDataStore(), + ) + } +} \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/cache/DefaultCacheKeysStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/cache/DefaultCacheKeysStore.kt index a2788d6a87..0dd225b6af 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/cache/DefaultCacheKeysStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/cache/DefaultCacheKeysStore.kt @@ -2,15 +2,10 @@ package com.tangem.datasource.local.cache import com.tangem.datasource.local.cache.model.CacheKey import com.tangem.datasource.local.datastore.core.StringKeyDataStore -import com.tangem.datasource.local.datastore.core.StringKeyDataStoreDecorator internal class DefaultCacheKeysStore( dataStore: StringKeyDataStore, -) : CacheKeysStore, StringKeyDataStoreDecorator(dataStore) { - - override fun provideStringKey(key: String): String { - return key - } +) : CacheKeysStore, StringKeyDataStore by dataStore { override suspend fun store(key: CacheKey) { store(key.id, key) diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/FileDataStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/FileDataStore.kt index cc65a7ff21..44038e9880 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/FileDataStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/FileDataStore.kt @@ -4,7 +4,10 @@ import com.squareup.moshi.JsonAdapter import com.tangem.datasource.files.FileReader import com.tangem.datasource.local.datastore.core.StringKeyDataStore import com.tangem.datasource.local.datastore.utils.Trigger -import kotlinx.coroutines.flow.* +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.filterNotNull +import kotlinx.coroutines.flow.map import timber.log.Timber @Deprecated("Use shared preferences data store instead") @@ -33,16 +36,16 @@ internal class FileDataStore( return getInternal(key) } - override suspend fun getAllSyncOrNull(): List { + override suspend fun getAllSyncOrNull(): List? { val e = NotImplementedError("`getAllSyncOrNull()` function not implemented for `FileDataStore`") Timber.e(e) throw e } - override suspend fun store(key: String, item: Value) { + override suspend fun store(key: String, value: Value) { try { - val json = adapter.toJson(item) + val json = adapter.toJson(value) fileReader.rewriteFile(json, key) writeTrigger.trigger() @@ -51,8 +54,8 @@ internal class FileDataStore( } } - override suspend fun store(items: Map) { - items.forEach { (key, item) -> + override suspend fun store(values: Map) { + values.forEach { (key, item) -> store(key, item) } } diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/RuntimeDataStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/RuntimeDataStore.kt index 2d4149648f..1a295689db 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/RuntimeDataStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/RuntimeDataStore.kt @@ -5,37 +5,45 @@ import kotlinx.coroutines.flow.* internal class RuntimeDataStore : StringKeyDataStore { - private val store = MutableStateFlow>(hashMapOf()) + private val store: MutableSharedFlow?> = MutableSharedFlow(replay = 1) + + init { + store.tryEmit(value = null) + } override fun get(key: String): Flow { return store - .map { value -> value[key] } + .map { value -> + value?.get(key) + } .filterNotNull() } override fun getAll(): Flow> { - return store.map { value -> value.values.toList() } - } - - override suspend fun getSyncOrNull(key: String): Data? { - return store.value[key] - } - - override suspend fun getAllSyncOrNull(): List { - return store.value.values.toList() - } - - override suspend fun store(key: String, item: Data) { - store.update { value -> - value[key] = item - - value + return store.map { value -> + value?.values?.toList().orEmpty() } } - override suspend fun store(items: Map) { - store.update { value -> - items.forEach { (key, item) -> + override suspend fun getSyncOrNull(key: String): Data? { + return store.firstOrNull()?.get(key) + } + + override suspend fun getAllSyncOrNull(): List? { + return store.firstOrNull()?.values?.toList() + } + + override suspend fun store(key: String, value: Data) { + updateValue { storedValue -> + storedValue[key] = value + + storedValue + } + } + + override suspend fun store(values: Map) { + updateValue { value -> + values.forEach { (key, item) -> value[key] = item } @@ -44,7 +52,7 @@ internal class RuntimeDataStore : StringKeyDataStore { } override suspend fun remove(key: String) { - store.update { value -> + updateValue { value -> value.remove(key) value @@ -52,6 +60,13 @@ internal class RuntimeDataStore : StringKeyDataStore { } override suspend fun clear() { - store.update { hashMapOf() } + store.emit(value = null) + } + + private suspend inline fun updateValue(update: (HashMap) -> HashMap) { + val storedData = store.firstOrNull() ?: hashMapOf() + val updatedData = update(storedData) + + store.emit(updatedData) } } \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/SharedPreferencesDataStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/SharedPreferencesDataStore.kt index cd2ed5c463..f3854bc37d 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/SharedPreferencesDataStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/SharedPreferencesDataStore.kt @@ -46,9 +46,9 @@ internal class SharedPreferencesDataStore( return getAllInternal() } - override suspend fun store(key: String, item: Value) { + override suspend fun store(key: String, value: Value) { try { - val json = adapter.toJson(item) + val json = adapter.toJson(value) sharedPreferences.edit { putString(key, json) } writeTrigger.trigger() @@ -57,8 +57,8 @@ internal class SharedPreferencesDataStore( } } - override suspend fun store(items: Map) { - items.forEach { (key, item) -> + override suspend fun store(values: Map) { + values.forEach { (key, item) -> store(key, item) } } diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/core/DataStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/core/DataStore.kt index 4ac5668e44..edc3a4bbd8 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/core/DataStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/core/DataStore.kt @@ -10,11 +10,11 @@ internal interface DataStore { suspend fun getSyncOrNull(key: Key): Value? - suspend fun getAllSyncOrNull(): List + suspend fun getAllSyncOrNull(): List? - suspend fun store(key: Key, item: Value) + suspend fun store(key: Key, value: Value) - suspend fun store(items: Map) + suspend fun store(values: Map) suspend fun remove(key: Key) diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/core/StringKeyDataStoreDecorator.kt b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/core/StringKeyDataStoreDecorator.kt index e6afee1d93..2e79bda3fd 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/datastore/core/StringKeyDataStoreDecorator.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/datastore/core/StringKeyDataStoreDecorator.kt @@ -16,7 +16,7 @@ internal abstract class StringKeyDataStoreDecorator( return wrappedDataStore.getAll() } - override suspend fun getAllSyncOrNull(): List { + override suspend fun getAllSyncOrNull(): List? { return wrappedDataStore.getAllSyncOrNull() } @@ -24,13 +24,13 @@ internal abstract class StringKeyDataStoreDecorator( return wrappedDataStore.getSyncOrNull(provideStringKey(key)) } - override suspend fun store(key: Key, item: Value) { - wrappedDataStore.store(provideStringKey(key), item) + override suspend fun store(key: Key, value: Value) { + wrappedDataStore.store(provideStringKey(key), value) } - override suspend fun store(items: Map) { + override suspend fun store(values: Map) { wrappedDataStore.store( - items = items.mapKeys { (key, _) -> provideStringKey(key) }, + values = values.mapKeys { (key, _) -> provideStringKey(key) }, ) } diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/network/DefaultNetworksStatusesStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/network/DefaultNetworksStatusesStore.kt new file mode 100644 index 0000000000..276587c5f5 --- /dev/null +++ b/core/datasource/src/main/java/com/tangem/datasource/local/network/DefaultNetworksStatusesStore.kt @@ -0,0 +1,24 @@ +package com.tangem.datasource.local.network + +import com.tangem.datasource.local.datastore.core.StringKeyDataStore +import com.tangem.datasource.local.datastore.core.StringKeyDataStoreDecorator +import com.tangem.domain.tokens.model.NetworkStatus +import com.tangem.domain.wallets.models.UserWalletId +import com.tangem.utils.extensions.addOrReplace + +internal class DefaultNetworksStatusesStore( + dataStore: StringKeyDataStore>, +) : NetworksStatusesStore, StringKeyDataStoreDecorator>(dataStore) { + + override fun provideStringKey(key: UserWalletId): String { + return key.stringValue + } + + override suspend fun store(key: UserWalletId, value: NetworkStatus) { + val newValues = getSyncOrNull(key) + ?.addOrReplace(value) { it.network == value.network } + ?: setOf(value) + + store(key, newValues) + } +} \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/network/NetworksStatusesStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/network/NetworksStatusesStore.kt new file mode 100644 index 0000000000..a30a1b49ab --- /dev/null +++ b/core/datasource/src/main/java/com/tangem/datasource/local/network/NetworksStatusesStore.kt @@ -0,0 +1,14 @@ +package com.tangem.datasource.local.network + +import com.tangem.domain.tokens.model.NetworkStatus +import com.tangem.domain.wallets.models.UserWalletId +import kotlinx.coroutines.flow.Flow + +interface NetworksStatusesStore { + + fun get(key: UserWalletId): Flow> + + suspend fun getSyncOrNull(key: UserWalletId): Set? + + suspend fun store(key: UserWalletId, value: NetworkStatus) +} \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/quote/DefaultQuotesStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/quote/DefaultQuotesStore.kt index 78e6ffb72b..4d547208a2 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/quote/DefaultQuotesStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/quote/DefaultQuotesStore.kt @@ -3,7 +3,7 @@ package com.tangem.datasource.local.quote import com.tangem.datasource.api.tangemTech.models.QuotesResponse import com.tangem.datasource.local.datastore.core.StringKeyDataStore import com.tangem.datasource.local.quote.model.StoredQuote -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/quote/QuotesStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/quote/QuotesStore.kt index f34d0039b8..64b3bf2c9c 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/quote/QuotesStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/quote/QuotesStore.kt @@ -2,7 +2,7 @@ package com.tangem.datasource.local.quote import com.tangem.datasource.api.tangemTech.models.QuotesResponse import com.tangem.datasource.local.quote.model.StoredQuote -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import kotlinx.coroutines.flow.Flow interface QuotesStore { diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/token/UserTokensStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/token/UserTokensStore.kt index ed175a871a..08fcb31438 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/token/UserTokensStore.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/token/UserTokensStore.kt @@ -10,5 +10,5 @@ interface UserTokensStore { suspend fun getSyncOrNull(key: UserWalletId): UserTokensResponse? - suspend fun store(key: UserWalletId, item: UserTokensResponse) + suspend fun store(key: UserWalletId, value: UserTokensResponse) } \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/extensions/CryptoCurrency.kt b/core/ui/src/main/java/com/tangem/core/ui/extensions/CryptoCurrency.kt index c30323a1b2..cf0b07bbfe 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/extensions/CryptoCurrency.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/extensions/CryptoCurrency.kt @@ -5,7 +5,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.luminance import androidx.core.graphics.toColorInt import com.tangem.core.ui.res.TangemColorPalette -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency private const val LIGHT_LUMINANCE = 0.5f private const val COLOR_HEX_START_INDEX = 2 diff --git a/data/common/build.gradle.kts b/data/common/build.gradle.kts index 7ddd807653..eee47186e3 100644 --- a/data/common/build.gradle.kts +++ b/data/common/build.gradle.kts @@ -5,11 +5,16 @@ plugins { id("configuration") } +android { + namespace = "com.tangem.data.common" +} + dependencies { implementation(projects.core.datasource) implementation(deps.kotlin.coroutines) implementation(deps.jodatime) + implementation(deps.timber) implementation(deps.hilt.android) kapt(deps.hilt.kapt) diff --git a/data/common/src/main/AndroidManifest.xml b/data/common/src/main/AndroidManifest.xml deleted file mode 100644 index 5a762109a1..0000000000 --- a/data/common/src/main/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/data/common/src/main/kotlin/com/tangem/data/common/cache/DefaultCacheRegistry.kt b/data/common/src/main/kotlin/com/tangem/data/common/cache/DefaultCacheRegistry.kt index b8380debee..6c06ce7b88 100644 --- a/data/common/src/main/kotlin/com/tangem/data/common/cache/DefaultCacheRegistry.kt +++ b/data/common/src/main/kotlin/com/tangem/data/common/cache/DefaultCacheRegistry.kt @@ -4,6 +4,7 @@ import com.tangem.datasource.local.cache.CacheKeysStore import com.tangem.datasource.local.cache.model.CacheKey import org.joda.time.Duration import org.joda.time.LocalDateTime +import timber.log.Timber internal class DefaultCacheRegistry( private val cacheKeysStore: CacheKeysStore, @@ -18,10 +19,12 @@ internal class DefaultCacheRegistry( } override suspend fun invalidate(key: String) { + Timber.d("Invalidate the cache key: $key") cacheKeysStore.remove(key) } override suspend fun invalidateAll() { + Timber.d("Invalidate all cache keys") cacheKeysStore.clear() } @@ -29,11 +32,19 @@ internal class DefaultCacheRegistry( key: String, skipCache: Boolean, expireIn: Duration, - block: suspend () -> Unit, + action: suspend () -> Unit, ) { val isExpired = isExpired(key) || skipCache if (!isExpired) return + try { + Timber.d("Invoke the action associated with the cache key: $key") + action() + } catch (e: Throwable) { + Timber.w(e, "The action related to the cache key has failed: $key") + throw e + } + cacheKeysStore.store( key = CacheKey( id = key, @@ -41,12 +52,5 @@ internal class DefaultCacheRegistry( expiresIn = expireIn, ), ) - - try { - block() - } catch (e: Throwable) { - invalidate(key) - throw e - } } } \ No newline at end of file diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/di/TokensDataModule.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/di/TokensDataModule.kt index cd55cde081..f8e33206dd 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/di/TokensDataModule.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/di/TokensDataModule.kt @@ -7,6 +7,7 @@ import com.tangem.data.tokens.repository.DefaultNetworksRepository import com.tangem.data.tokens.repository.DefaultQuotesRepository import com.tangem.datasource.api.tangemTech.TangemTechApi import com.tangem.datasource.local.appcurrency.SelectedAppCurrencyStore +import com.tangem.datasource.local.network.NetworksStatusesStore import com.tangem.datasource.local.quote.QuotesStore import com.tangem.datasource.local.token.UserMarketCoinsStore import com.tangem.datasource.local.token.UserTokensStore @@ -68,6 +69,7 @@ internal object TokensDataModule { @Provides @Singleton fun provideNetworksRepository( + networksStatusesStore: NetworksStatusesStore, walletManagersFacade: WalletManagersFacade, userWalletsStore: UserWalletsStore, userTokensStore: UserTokensStore, @@ -75,6 +77,7 @@ internal object TokensDataModule { dispatchers: CoroutineDispatcherProvider, ): NetworksRepository { return DefaultNetworksRepository( + networksStatusesStore = networksStatusesStore, walletManagersFacade = walletManagersFacade, userWalletsStore = userWalletsStore, userTokensStore = userTokensStore, diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrenciesRepository.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrenciesRepository.kt index 855817e2da..0967a4a262 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrenciesRepository.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrenciesRepository.kt @@ -8,24 +8,23 @@ import com.tangem.datasource.api.tangemTech.models.UserTokensResponse import com.tangem.datasource.local.token.UserMarketCoinsStore import com.tangem.datasource.local.token.UserTokensStore import com.tangem.datasource.local.userwallet.UserWalletsStore -import com.tangem.domain.common.extensions.toCoinId import com.tangem.domain.common.extensions.toNetworkId import com.tangem.domain.common.util.derivationStyleProvider import com.tangem.domain.core.error.DataError import com.tangem.domain.demo.DemoConfig -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.models.UserWalletId import com.tangem.utils.coroutines.CoroutineDispatcherProvider -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.channelFlow -import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import retrofit2.HttpException import timber.log.Timber +import java.net.ConnectException +import java.net.UnknownHostException internal class DefaultCurrenciesRepository( private val tangemTechApi: TangemTechApi, @@ -110,14 +109,6 @@ internal class DefaultCurrenciesRepository( } } - private fun List.hasCoinForToken(token: CryptoCurrency.Token): Boolean { - return any { - val blockchain = getBlockchain(networkId = token.network.id) - - it.id == blockchain.toCoinId() - } - } - override suspend fun removeCurrency(userWalletId: UserWalletId, currency: CryptoCurrency) = withContext(dispatchers.io) { val savedCurrencies = requireNotNull( @@ -166,13 +157,14 @@ internal class DefaultCurrenciesRepository( ensureIsCorrectUserWallet(userWallet, isMultiCurrencyWalletExpected = true) launch(dispatchers.io) { - getMultiCurrencyWalletCurrencies(userWallet).collect(::send) + getMultiCurrencyWalletCurrencies(userWallet) + .collectLatest(::send) } - launch(dispatchers.io) { + withContext(dispatchers.io) { fetchTokensIfCacheExpired(userWallet, refresh = false) } - } + }.cancellable() } override suspend fun getMultiCurrencyWalletCurrenciesSync( @@ -232,7 +224,7 @@ internal class DefaultCurrenciesRepository( .map { it.group == UserTokensResponse.GroupType.NETWORK } .collect(::send) } - } + }.cancellable() } override fun isTokensSortedByBalance(userWalletId: UserWalletId): Flow { @@ -244,7 +236,7 @@ internal class DefaultCurrenciesRepository( .map { it.sort == UserTokensResponse.SortType.BALANCE } .collect(::send) } - } + }.cancellable() } private fun getMultiCurrencyWalletCurrencies(userWallet: UserWallet): Flow> { @@ -272,8 +264,8 @@ internal class DefaultCurrenciesRepository( // The response may contain repeated tokens copy(tokens = tokens.distinct()) } - } catch (e: HttpException) { - handleCurrenciesNotFoundOrThrow(userWallet, e) + } catch (e: Throwable) { + handleFetchTokensError(userWallet, e) } userTokensStore.store(userWallet.walletId, response) @@ -296,19 +288,8 @@ internal class DefaultCurrenciesRepository( } } - private suspend fun handleCurrenciesNotFoundOrThrow( - userWallet: UserWallet, - httpException: HttpException, - ): UserTokensResponse { + private suspend fun handleFetchTokensError(userWallet: UserWallet, throwable: Throwable): UserTokensResponse { val userWalletId = userWallet.walletId - - if (httpException.code() != NOT_FOUND_HTTP_CODE) { - Timber.e(httpException, "Unable to fetch currencies for: $userWalletId") - throw httpException - } - - Timber.d("Requested currencies could not be found in the remote store for: $userWalletId") - val response = userTokensStore.getSyncOrNull(userWalletId) ?: userTokensResponseFactory.createUserTokensResponse( currencies = cardCurrenciesFactory.createDefaultCoinsForMultiCurrencyCard(userWallet.scanResponse), @@ -316,7 +297,28 @@ internal class DefaultCurrenciesRepository( isSortedByBalance = false, ) - tangemTechApi.saveUserTokens(userWalletId.stringValue, response) + when (throwable) { + is ConnectException, + is UnknownHostException, + -> { + Timber.e("Unable to fetch currencies due to lack of internet connection") + } + is HttpException -> { + if (throwable.code() == NOT_FOUND_HTTP_CODE) { + Timber.w( + throwable, + "Requested currencies could not be found in the remote store for: $userWalletId", + ) + + tangemTechApi.saveUserTokens(userWalletId.stringValue, response) + } else { + Timber.e(throwable, "Unable to fetch currencies for: $userWalletId") + } + } + else -> { + throw throwable + } + } return response } diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultMarketCryptoCurrencyRepository.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultMarketCryptoCurrencyRepository.kt index 838775885f..441f3f97d2 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultMarketCryptoCurrencyRepository.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultMarketCryptoCurrencyRepository.kt @@ -3,7 +3,7 @@ package com.tangem.data.tokens.repository import com.tangem.blockchain.common.Blockchain import com.tangem.datasource.local.token.UserMarketCoinsStore import com.tangem.domain.common.extensions.toNetworkId -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.repository.MarketCryptoCurrencyRepository import com.tangem.domain.wallets.models.UserWalletId diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultNetworksRepository.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultNetworksRepository.kt index 667bf5c512..b8c62585a9 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultNetworksRepository.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultNetworksRepository.kt @@ -4,21 +4,27 @@ import com.tangem.data.common.cache.CacheRegistry import com.tangem.data.tokens.utils.CardCryptoCurrenciesFactory import com.tangem.data.tokens.utils.NetworkStatusFactory import com.tangem.data.tokens.utils.ResponseCryptoCurrenciesFactory +import com.tangem.datasource.local.network.NetworksStatusesStore import com.tangem.datasource.local.token.UserTokensStore import com.tangem.datasource.local.userwallet.UserWalletsStore import com.tangem.domain.demo.DemoConfig +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.CryptoCurrency -import com.tangem.domain.tokens.models.Network import com.tangem.domain.tokens.repository.NetworksRepository import com.tangem.domain.walletmanager.WalletManagersFacade +import com.tangem.domain.walletmanager.model.UpdateWalletManagerResult import com.tangem.domain.wallets.models.UserWalletId import com.tangem.utils.coroutines.CoroutineDispatcherProvider -import com.tangem.utils.extensions.addOrReplace import kotlinx.coroutines.* -import kotlinx.coroutines.flow.* +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.cancellable +import kotlinx.coroutines.flow.channelFlow +import kotlinx.coroutines.flow.collectLatest +import timber.log.Timber internal class DefaultNetworksRepository( + private val networksStatusesStore: NetworksStatusesStore, private val walletManagersFacade: WalletManagersFacade, private val userWalletsStore: UserWalletsStore, private val userTokensStore: UserTokensStore, @@ -31,20 +37,19 @@ internal class DefaultNetworksRepository( private val responseCurrenciesFactory by lazy { ResponseCryptoCurrenciesFactory(demoConfig) } private val networkStatusFactory by lazy { NetworkStatusFactory() } - private val networksStatuses: MutableStateFlow> = MutableStateFlow(hashSetOf()) - override fun getNetworkStatusesUpdates( userWalletId: UserWalletId, networks: Set, ): Flow> = channelFlow { launch(dispatchers.io) { - networksStatuses.collect(::send) + networksStatusesStore.get(userWalletId) + .collectLatest(::send) } - launch(dispatchers.io) { + withContext(dispatchers.io) { fetchNetworksStatusesIfCacheExpired(userWalletId, networks, refresh = false) } - } + }.cancellable() override suspend fun getNetworkStatusesSync( userWalletId: UserWalletId, @@ -52,7 +57,7 @@ internal class DefaultNetworksRepository( refresh: Boolean, ): Set = withContext(dispatchers.io) { fetchNetworksStatusesIfCacheExpired(userWalletId, networks, refresh) - networksStatuses.first().toSet() + networksStatusesStore.getSyncOrNull(userWalletId).orEmpty() } private suspend fun fetchNetworksStatusesIfCacheExpired( @@ -92,17 +97,15 @@ internal class DefaultNetworksRepository( extraTokens = currencies.filterIsInstance().toSet(), ) + invalidateCacheKeyIfNeeded(userWalletId, network, result) + val networkStatus = networkStatusFactory.createNetworkStatus( network = network, result = result, currencies = currencies.toSet(), ) - networksStatuses.update { statuses -> - statuses.addOrReplace(networkStatus) { it.network == networkStatus.network } - } - - invalidateCacheKeyIfNeeded(userWalletId, networkStatus) + networksStatusesStore.store(userWalletId, networkStatus) } private suspend fun getCurrencies(userWalletId: UserWalletId, network: Network): Sequence { @@ -125,18 +128,32 @@ internal class DefaultNetworksRepository( return currencies.filter { it.network == network } } - private suspend fun invalidateCacheKeyIfNeeded(userWalletId: UserWalletId, networkStatus: NetworkStatus) { - when (networkStatus.value) { - is NetworkStatus.Verified, - is NetworkStatus.NoAccount, + private suspend fun invalidateCacheKeyIfNeeded( + userWalletId: UserWalletId, + network: Network, + result: UpdateWalletManagerResult, + ) { + when (result) { + is UpdateWalletManagerResult.Verified, + is UpdateWalletManagerResult.NoAccount, -> Unit - is NetworkStatus.Unreachable, - is NetworkStatus.MissedDerivation, - -> cacheRegistry.invalidate(getNetworksStatusesCacheKey(userWalletId, networkStatus.network)) + is UpdateWalletManagerResult.Unreachable, + is UpdateWalletManagerResult.MissedDerivation, + -> { + Timber.w( + """ + Invalidate network cache key + |- User wallet ID: $userWalletId + |- Network: ${network.id} + """.trimIndent(), + ) + + cacheRegistry.invalidate(getNetworksStatusesCacheKey(userWalletId, network)) + } } } private fun getNetworksStatusesCacheKey(userWalletId: UserWalletId, network: Network): String { - return "network_status_${userWalletId}_${network.id}_${network.derivationPath.value}" + return "network_status_${userWalletId}_${network.id.value}_${network.derivationPath.value}" } } \ No newline at end of file diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultQuotesRepository.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultQuotesRepository.kt index a288240656..f0fc985d25 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultQuotesRepository.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultQuotesRepository.kt @@ -5,8 +5,8 @@ import com.tangem.data.tokens.utils.QuotesConverter import com.tangem.datasource.api.tangemTech.TangemTechApi import com.tangem.datasource.local.appcurrency.SelectedAppCurrencyStore import com.tangem.datasource.local.quote.QuotesStore -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Quote +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Quote import com.tangem.domain.tokens.repository.QuotesRepository import com.tangem.utils.coroutines.CoroutineDispatcherProvider import kotlinx.coroutines.flow.* @@ -24,23 +24,22 @@ internal class DefaultQuotesRepository( private val quotesConverter = QuotesConverter() + @Volatile private var quotesFetchedForAppCurrency: String? = null - override fun getQuotesUpdates(currenciesIds: Set): Flow> { - return channelFlow { - launch(dispatchers.io) { - quotesStore.get(currenciesIds) - .map(quotesConverter::convertSet) - .collect(::send) - } + override fun getQuotesUpdates(currenciesIds: Set): Flow> = channelFlow { + launch(dispatchers.io) { + quotesStore.get(currenciesIds) + .map(quotesConverter::convertSet) + .collectLatest(::send) + } - launch(dispatchers.io) { - selectedAppCurrencyStore.get().collectLatest { appCurrency -> - fetchExpiredQuotes(currenciesIds, appCurrency.id, refresh = false) - } + withContext(dispatchers.io) { + selectedAppCurrencyStore.get().collectLatest { appCurrency -> + fetchExpiredQuotes(currenciesIds, appCurrency.id, refresh = false) } } - } + }.cancellable() override suspend fun getQuotesSync(currenciesIds: Set, refresh: Boolean): Set { return withContext(dispatchers.io) { @@ -73,17 +72,15 @@ internal class DefaultQuotesRepository( } private suspend fun fetchQuotes(rawCurrenciesIds: Set, appCurrencyId: String) { - try { - val response = tangemTechApi.getQuotes( - currencyId = appCurrencyId, - coinIds = rawCurrenciesIds.joinToString(separator = ","), - ) - - quotesStore.store(response) + val response = try { + val coinIds = rawCurrenciesIds.joinToString(separator = ",") + tangemTechApi.getQuotes(appCurrencyId, coinIds) } catch (e: Throwable) { Timber.e(e, "Unable to fetch quotes for: $rawCurrenciesIds") throw e } + + quotesStore.store(response) } private suspend fun filterExpiredCurrenciesIds( diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/CardCryptoCurrenciesFactory.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/CardCryptoCurrenciesFactory.kt index aa96c7a9b5..11e573b876 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/CardCryptoCurrenciesFactory.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/CardCryptoCurrenciesFactory.kt @@ -6,7 +6,7 @@ import com.tangem.domain.common.util.cardTypesResolver import com.tangem.domain.common.util.derivationStyleProvider import com.tangem.domain.demo.DemoConfig import com.tangem.domain.models.scan.ScanResponse -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency internal class CardCryptoCurrenciesFactory(private val demoConfig: DemoConfig) { diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/CryptoCurrencyFactory.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/CryptoCurrencyFactory.kt index e12c65ff37..f102b2b7fa 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/CryptoCurrencyFactory.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/CryptoCurrencyFactory.kt @@ -3,7 +3,7 @@ package com.tangem.data.tokens.utils import com.tangem.blockchain.common.Blockchain import com.tangem.domain.common.DerivationStyleProvider import com.tangem.domain.common.extensions.toCoinId -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import timber.log.Timber import com.tangem.blockchain.common.Token as SdkToken diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/NetworkOperations.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/NetworkOperations.kt index 85c223f1cc..5e87555133 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/NetworkOperations.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/NetworkOperations.kt @@ -2,7 +2,7 @@ package com.tangem.data.tokens.utils import com.tangem.blockchain.common.Blockchain import com.tangem.domain.common.DerivationStyleProvider -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.Network import timber.log.Timber internal fun getBlockchain(networkId: Network.ID): Blockchain { diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/NetworkStatusFactory.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/NetworkStatusFactory.kt index 76f28d82a3..dd60f99866 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/NetworkStatusFactory.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/NetworkStatusFactory.kt @@ -1,9 +1,9 @@ package com.tangem.data.tokens.utils +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.domain.tokens.model.NetworkAddress import com.tangem.domain.tokens.model.NetworkStatus -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.walletmanager.model.CryptoCurrencyAmount import com.tangem.domain.walletmanager.model.CryptoCurrencyTransaction diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/QuotesConverter.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/QuotesConverter.kt index b771150c67..145eaf9800 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/QuotesConverter.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/QuotesConverter.kt @@ -1,7 +1,7 @@ package com.tangem.data.tokens.utils import com.tangem.datasource.local.quote.model.StoredQuote -import com.tangem.domain.tokens.models.Quote +import com.tangem.domain.tokens.model.Quote import com.tangem.utils.converter.Converter internal class QuotesConverter : Converter { diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/ResponseCryptoCurrenciesFactory.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/ResponseCryptoCurrenciesFactory.kt index b46fac6953..d0f16e8762 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/ResponseCryptoCurrenciesFactory.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/ResponseCryptoCurrenciesFactory.kt @@ -9,7 +9,7 @@ import com.tangem.domain.common.extensions.toCoinId import com.tangem.domain.common.util.derivationStyleProvider import com.tangem.domain.demo.DemoConfig import com.tangem.domain.models.scan.ScanResponse -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import timber.log.Timber import com.tangem.blockchain.common.Token as SdkToken diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/TokensOperations.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/TokensOperations.kt index 5f5e666c48..d4549a6243 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/TokensOperations.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/TokensOperations.kt @@ -2,16 +2,18 @@ package com.tangem.data.tokens.utils import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.IconsUtil +import com.tangem.datasource.api.tangemTech.models.UserTokensResponse import com.tangem.domain.common.extensions.toCoinId import com.tangem.domain.common.extensions.toNetworkId -import com.tangem.domain.tokens.models.CryptoCurrency.ID -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency.ID +import com.tangem.domain.tokens.model.Network import com.tangem.blockchain.common.Token as SdkToken -import com.tangem.domain.tokens.models.CryptoCurrency.ID.Body as CurrencyIdBody -import com.tangem.domain.tokens.models.CryptoCurrency.ID.Prefix.COIN_PREFIX as COIN_ID_PREFIX -import com.tangem.domain.tokens.models.CryptoCurrency.ID.Prefix.TOKEN_PREFIX as TOKEN_ID_PREFIX -import com.tangem.domain.tokens.models.CryptoCurrency.ID.Suffix.ContractAddress as CustomCurrencyIdSuffix -import com.tangem.domain.tokens.models.CryptoCurrency.ID.Suffix.RawID as CurrencyIdSuffix +import com.tangem.domain.tokens.model.CryptoCurrency.ID.Body as CurrencyIdBody +import com.tangem.domain.tokens.model.CryptoCurrency.ID.Prefix.COIN_PREFIX as COIN_ID_PREFIX +import com.tangem.domain.tokens.model.CryptoCurrency.ID.Prefix.TOKEN_PREFIX as TOKEN_ID_PREFIX +import com.tangem.domain.tokens.model.CryptoCurrency.ID.Suffix.ContractAddress as CustomCurrencyIdSuffix +import com.tangem.domain.tokens.model.CryptoCurrency.ID.Suffix.RawID as CurrencyIdSuffix private const val DEFAULT_TOKENS_ICONS_HOST = "https://s3.eu-central-1.amazonaws.com/tangem.api/coins" private const val TOKEN_ICON_SIZE = "large" @@ -60,6 +62,14 @@ internal fun getCoinIconUrl(blockchain: Blockchain): String? { return coinId?.let(::getTokenIconUrlFromDefaultHost) } +internal fun List.hasCoinForToken(token: CryptoCurrency.Token): Boolean { + return any { + val blockchain = getBlockchain(networkId = token.network.id) + + it.id == blockchain.toCoinId() + } +} + private fun getCurrencyIdBody(network: Network): CurrencyIdBody { return when (val path = network.derivationPath) { is Network.DerivationPath.Custom -> CurrencyIdBody.NetworkIdWithDerivationPath( diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/UserTokensResponseFactory.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/UserTokensResponseFactory.kt index c8cb48b178..6f752af1a6 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/UserTokensResponseFactory.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/utils/UserTokensResponseFactory.kt @@ -2,7 +2,7 @@ package com.tangem.data.tokens.utils import com.tangem.datasource.api.tangemTech.models.UserTokensResponse import com.tangem.domain.common.extensions.toNetworkId -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency internal class UserTokensResponseFactory { 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 a490199e35..718cfe7037 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 @@ -5,8 +5,8 @@ import androidx.paging.PagingConfig import androidx.paging.PagingData import com.tangem.data.txhistory.repository.paging.TxHistoryPagingSource import com.tangem.datasource.local.userwallet.UserWalletsStore -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.txhistory.models.TxHistoryState import com.tangem.domain.txhistory.models.TxHistoryStateError diff --git a/domain/legacy/src/main/java/com/tangem/domain/exchange/RampStateManager.kt b/domain/legacy/src/main/java/com/tangem/domain/exchange/RampStateManager.kt index b6a2e29f06..29712ab27c 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/exchange/RampStateManager.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/exchange/RampStateManager.kt @@ -1,6 +1,6 @@ package com.tangem.domain.exchange -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency /** * Manager that holds info about available actions as Sell and Buy diff --git a/domain/legacy/src/main/java/com/tangem/domain/tokens/TokensAction.kt b/domain/legacy/src/main/java/com/tangem/domain/tokens/TokensAction.kt index 4dcca75874..3cfbe08917 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/tokens/TokensAction.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/tokens/TokensAction.kt @@ -3,7 +3,7 @@ package com.tangem.domain.tokens import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.Token import com.tangem.domain.models.scan.ScanResponse -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.wallets.models.UserWallet import org.rekotlin.Action 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 64553c5f35..bf2e77df79 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 @@ -2,7 +2,10 @@ package com.tangem.domain.walletmanager import com.tangem.blockchain.blockchains.polkadot.ExistentialDepositProvider import com.tangem.blockchain.blockchains.solana.RentProvider -import com.tangem.blockchain.common.* +import com.tangem.blockchain.common.AmountType +import com.tangem.blockchain.common.Blockchain +import com.tangem.blockchain.common.BlockchainSdkError +import com.tangem.blockchain.common.WalletManager import com.tangem.blockchain.common.address.Address import com.tangem.blockchain.common.txhistory.TransactionHistoryRequest import com.tangem.blockchain.extensions.Result @@ -12,15 +15,14 @@ import com.tangem.datasource.local.userwallet.UserWalletsStore import com.tangem.datasource.local.walletmanager.WalletManagersStore import com.tangem.domain.common.util.hasDerivation import com.tangem.domain.demo.DemoConfig -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network -import com.tangem.domain.tokens.models.warnings.CryptoCurrencyWarning +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network +import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.domain.txhistory.models.PaginationWrapper import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.txhistory.models.TxHistoryState import com.tangem.domain.walletmanager.model.UpdateWalletManagerResult import com.tangem.domain.walletmanager.utils.* -import com.tangem.domain.walletmanager.utils.WalletManagerFactory import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.models.UserWalletId import timber.log.Timber @@ -142,13 +144,13 @@ class DefaultWalletManagersFacade( val scanResponse = userWallet.scanResponse if (derivationPath != null && !scanResponse.hasDerivation(blockchain, derivationPath)) { - Timber.e("Derivation missed for: $blockchain") + Timber.w("Derivation missed for: $blockchain") return UpdateWalletManagerResult.MissedDerivation } val walletManager = getOrCreateWalletManager(userWallet, blockchain, derivationPath) if (walletManager == null || blockchain == Blockchain.Unknown) { - Timber.e("Unable to get a wallet manager for blockchain: $blockchain") + Timber.w("Unable to get a wallet manager for blockchain: $blockchain") return UpdateWalletManagerResult.Unreachable } @@ -180,7 +182,7 @@ class DefaultWalletManagersFacade( } catch (e: BlockchainSdkError.AccountNotFound) { resultFactory.getNoAccountResult(walletManager) } catch (e: Throwable) { - Timber.e(e, "Unable to update a wallet manager for: ${walletManager.wallet.blockchain}") + Timber.w(e, "Unable to update a wallet manager for: ${walletManager.wallet.blockchain}") UpdateWalletManagerResult.Unreachable } 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 23e5a9fd8c..2e8872700a 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 @@ -1,12 +1,12 @@ package com.tangem.domain.walletmanager +import com.tangem.blockchain.blockchains.solana.RentProvider import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.WalletManager import com.tangem.blockchain.common.address.Address -import com.tangem.blockchain.blockchains.solana.RentProvider -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network -import com.tangem.domain.tokens.models.warnings.CryptoCurrencyWarning +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network +import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.domain.txhistory.models.PaginationWrapper import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.txhistory.models.TxHistoryState diff --git a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/SdkTokenConverter.kt b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/SdkTokenConverter.kt index a6ceecff07..0071195b1b 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/SdkTokenConverter.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/SdkTokenConverter.kt @@ -1,6 +1,6 @@ package com.tangem.domain.walletmanager.utils -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.utils.converter.Converter import com.tangem.blockchain.common.Token as SdkToken diff --git a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/UpdateWalletManagerResultFactory.kt b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/UpdateWalletManagerResultFactory.kt index 0855841539..874e412e3f 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/UpdateWalletManagerResultFactory.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/walletmanager/utils/UpdateWalletManagerResultFactory.kt @@ -37,22 +37,22 @@ internal class UpdateWalletManagerResultFactory { ) } - fun getNoAccountResult(walletManager: WalletManager): UpdateWalletManagerResult.NoAccount { + fun getNoAccountResult(walletManager: WalletManager): UpdateWalletManagerResult { val wallet = walletManager.wallet val blockchain = wallet.blockchain - val amountToCreateAccount = blockchain.amountToCreateAccount( - token = wallet.getTokens().firstOrNull(), - ) + val firstWalletToken = wallet.getTokens().firstOrNull() + val amountToCreateAccount = blockchain.amountToCreateAccount(firstWalletToken) - requireNotNull(amountToCreateAccount) { - "Unable to get required amount to create account for: $blockchain" + return if (amountToCreateAccount == null) { + Timber.w("Unable to get required amount to create account for: $blockchain") + UpdateWalletManagerResult.Unreachable + } else { + UpdateWalletManagerResult.NoAccount( + defaultAddress = wallet.address, + addresses = getAvailableAddresses(wallet.addresses), + amountToCreateAccount = amountToCreateAccount, + ) } - - return UpdateWalletManagerResult.NoAccount( - defaultAddress = wallet.address, - addresses = getAvailableAddresses(wallet.addresses), - amountToCreateAccount = amountToCreateAccount, - ) } private fun getTokensAmounts(amounts: Set): Set { @@ -153,7 +153,7 @@ internal class UpdateWalletManagerResultFactory { TxHistoryItem.TransactionDirection.Outgoing(TxHistoryItem.Address.Single(toAddress)) } else -> { - Timber.e( + Timber.w( """ Unable to find transaction direction |- To address: ${data.destinationAddress} @@ -175,7 +175,7 @@ internal class UpdateWalletManagerResultFactory { val value = amount.value if (value == null) { - Timber.e("Currency amount must not be null: ${amount.currencySymbol}") + Timber.w("Currency amount must not be null: ${amount.currencySymbol}") } return value @@ -185,7 +185,7 @@ internal class UpdateWalletManagerResultFactory { val value = amount.value if (value == null) { - Timber.e("Transaction amount must not be null: ${amount.currencySymbol}") + Timber.w("Transaction amount must not be null: ${amount.currencySymbol}") } return value diff --git a/domain/tokens/models/build.gradle.kts b/domain/tokens/models/build.gradle.kts index 7ff7fb7522..7efdd44423 100644 --- a/domain/tokens/models/build.gradle.kts +++ b/domain/tokens/models/build.gradle.kts @@ -1,4 +1,8 @@ plugins { alias(deps.plugins.kotlin.jvm) id("configuration") +} + +dependencies { + implementation(projects.domain.txhistory.models) } \ No newline at end of file diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/CryptoCurrency.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/CryptoCurrency.kt similarity index 99% rename from domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/CryptoCurrency.kt rename to domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/CryptoCurrency.kt index c4f9d25b2b..b32c9ef6cc 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/CryptoCurrency.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/CryptoCurrency.kt @@ -1,4 +1,4 @@ -package com.tangem.domain.tokens.models +package com.tangem.domain.tokens.model import java.io.Serializable diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/CryptoCurrencyStatus.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/CryptoCurrencyStatus.kt similarity index 99% rename from domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/CryptoCurrencyStatus.kt rename to domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/CryptoCurrencyStatus.kt index 603ffb73f7..a838b45b10 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/CryptoCurrencyStatus.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/CryptoCurrencyStatus.kt @@ -1,6 +1,5 @@ package com.tangem.domain.tokens.model -import com.tangem.domain.tokens.models.CryptoCurrency import com.tangem.domain.txhistory.models.TxHistoryItem import java.math.BigDecimal diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/Network.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/Network.kt similarity index 98% rename from domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/Network.kt rename to domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/Network.kt index c58935ed82..a161d9c3ca 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/Network.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/Network.kt @@ -1,4 +1,4 @@ -package com.tangem.domain.tokens.models +package com.tangem.domain.tokens.model import java.io.Serializable diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/NetworkAddress.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/NetworkAddress.kt similarity index 100% rename from domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/NetworkAddress.kt rename to domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/NetworkAddress.kt diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/NetworkStatus.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/NetworkStatus.kt similarity index 95% rename from domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/NetworkStatus.kt rename to domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/NetworkStatus.kt index ef1c54b04f..97838a8889 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/NetworkStatus.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/NetworkStatus.kt @@ -1,7 +1,5 @@ package com.tangem.domain.tokens.model -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network import com.tangem.domain.txhistory.models.TxHistoryItem import java.math.BigDecimal diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/Quote.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/Quote.kt similarity index 92% rename from domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/Quote.kt rename to domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/Quote.kt index 835e84fe4f..899574d5e4 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/Quote.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/Quote.kt @@ -1,4 +1,4 @@ -package com.tangem.domain.tokens.models +package com.tangem.domain.tokens.model import java.math.BigDecimal diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/remove/RemoveCurrencyError.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/remove/RemoveCurrencyError.kt similarity index 73% rename from domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/remove/RemoveCurrencyError.kt rename to domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/remove/RemoveCurrencyError.kt index 0c6f1a0561..475a90e2a8 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/remove/RemoveCurrencyError.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/remove/RemoveCurrencyError.kt @@ -1,4 +1,4 @@ -package com.tangem.domain.tokens.models.remove +package com.tangem.domain.tokens.model.remove sealed class RemoveCurrencyError : Throwable() { data class DataError(override val cause: Throwable) : RemoveCurrencyError() diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/warnings/CryptoCurrencyWarning.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt similarity index 89% rename from domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/warnings/CryptoCurrencyWarning.kt rename to domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt index 538d306a82..89663cf0fa 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/models/warnings/CryptoCurrencyWarning.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyWarning.kt @@ -1,6 +1,6 @@ -package com.tangem.domain.tokens.models.warnings +package com.tangem.domain.tokens.model.warnings -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import java.math.BigDecimal sealed class CryptoCurrencyWarning { diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/ApplyTokenListSortingUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/ApplyTokenListSortingUseCase.kt index 39e2ea82db..82059ca4fd 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/ApplyTokenListSortingUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/ApplyTokenListSortingUseCase.kt @@ -8,11 +8,10 @@ import arrow.core.raise.ensureNotNull import arrow.core.toNonEmptyListOrNull import arrow.core.toNonEmptySetOrNull import com.tangem.domain.tokens.error.TokenListSortingError -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.wallets.models.UserWalletId import com.tangem.utils.coroutines.CoroutineDispatcherProvider -import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.withContext class ApplyTokenListSortingUseCase( @@ -68,12 +67,12 @@ class ApplyTokenListSortingUseCase( private suspend fun Raise.getCurrencies(userWalletId: UserWalletId): List { val tokens = catch( block = { - currenciesRepository.getMultiCurrencyWalletCurrenciesUpdates(userWalletId).firstOrNull() + currenciesRepository.getMultiCurrencyWalletCurrenciesSync(userWalletId, refresh = false) }, catch = { raise(TokenListSortingError.DataError(it)) }, ) - return ensureNotNull(tokens?.toNonEmptyListOrNull()) { + return ensureNotNull(tokens.toNonEmptyListOrNull()) { TokenListSortingError.TokenListIsEmpty } } diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/FetchCurrencyStatusUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/FetchCurrencyStatusUseCase.kt index 91f7e713a4..eeeea7c9ec 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/FetchCurrencyStatusUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/FetchCurrencyStatusUseCase.kt @@ -5,8 +5,8 @@ import arrow.core.raise.Raise import arrow.core.raise.catch import arrow.core.raise.either import com.tangem.domain.tokens.error.CurrencyStatusError -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.tokens.repository.NetworksRepository import com.tangem.domain.tokens.repository.QuotesRepository diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/FetchTokenListUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/FetchTokenListUseCase.kt index 9dc971195a..0fe7e8b345 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/FetchTokenListUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/FetchTokenListUseCase.kt @@ -7,8 +7,8 @@ import arrow.core.raise.either import arrow.core.raise.ensureNotNull import arrow.core.toNonEmptyListOrNull import com.tangem.domain.tokens.error.TokenListError -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.tokens.repository.NetworksRepository import com.tangem.domain.tokens.repository.QuotesRepository @@ -91,11 +91,11 @@ class FetchTokenListUseCase( } } - private suspend fun Raise.fetchQuotes(currenciesIds: Set, refresh: Boolean) { + private suspend fun fetchQuotes(currenciesIds: Set, refresh: Boolean) { catch( block = { quotesRepository.getQuotesSync(currenciesIds, refresh) }, ) { - raise(TokenListError.DataError(it)) + /* Ignore error */ } } } \ No newline at end of file diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrenciesUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrenciesUseCase.kt index 4595413fa6..1ead96bd8a 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrenciesUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrenciesUseCase.kt @@ -4,7 +4,7 @@ import arrow.core.Either import arrow.core.raise.catch import arrow.core.raise.either import com.tangem.domain.tokens.error.GetCurrenciesError -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.wallets.models.UserWalletId diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt index cc04f6f0ba..f7edf4686e 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt @@ -1,9 +1,9 @@ package com.tangem.domain.tokens import com.tangem.domain.exchange.RampStateManager +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.TokenActionsState -import com.tangem.domain.tokens.models.CryptoCurrency import com.tangem.domain.tokens.repository.MarketCryptoCurrencyRepository import com.tangem.domain.wallets.models.UserWalletId import com.tangem.utils.coroutines.CoroutineDispatcherProvider diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyStatusUpdatesUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyStatusUpdatesUseCase.kt index 068b7b1572..d018b74e85 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyStatusUpdatesUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyStatusUpdatesUseCase.kt @@ -3,8 +3,8 @@ package com.tangem.domain.tokens import arrow.core.Either import com.tangem.domain.tokens.error.CurrencyStatusError import com.tangem.domain.tokens.error.mapper.mapToCurrencyError +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus -import com.tangem.domain.tokens.models.CryptoCurrency import com.tangem.domain.tokens.operations.CurrenciesStatusesOperations import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.tokens.repository.NetworksRepository diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt index 8e206bdeb7..d11e7b8f93 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyWarningsUseCase.kt @@ -1,8 +1,8 @@ package com.tangem.domain.tokens -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network -import com.tangem.domain.tokens.models.warnings.CryptoCurrencyWarning +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network +import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.domain.tokens.operations.CurrenciesStatusesOperations import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.tokens.repository.NetworksRepository @@ -81,6 +81,6 @@ class GetCurrencyWarningsUseCase( } private fun BigDecimal?.isZero(): Boolean { - return this?.compareTo(BigDecimal.ZERO) == 0 + return this?.signum() == 0 } } \ No newline at end of file diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetNetworkCoinStatusUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetNetworkCoinStatusUseCase.kt index 23ecf06a99..999d6e15af 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetNetworkCoinStatusUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetNetworkCoinStatusUseCase.kt @@ -4,7 +4,7 @@ import arrow.core.Either import com.tangem.domain.tokens.error.CurrencyStatusError import com.tangem.domain.tokens.error.mapper.mapToCurrencyError import com.tangem.domain.tokens.model.CryptoCurrencyStatus -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.Network import com.tangem.domain.tokens.operations.CurrenciesStatusesOperations import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.tokens.repository.NetworksRepository diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetPrimaryCurrencyStatusUpdatesUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetPrimaryCurrencyStatusUpdatesUseCase.kt index 7ae1e238aa..f1216be10f 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetPrimaryCurrencyStatusUpdatesUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetPrimaryCurrencyStatusUpdatesUseCase.kt @@ -31,7 +31,6 @@ class GetPrimaryCurrencyStatusUpdatesUseCase( * Invokes the use case. * * @param userWalletId The unique identifier of the user's wallet. - * @param refresh A boolean flag indicating whether the data should be refreshed. * @return A [Flow] emitting either a [CurrencyStatusError] or a [CryptoCurrencyStatus], indicating the result of the fetch operation. */ operator fun invoke(userWalletId: UserWalletId): Flow> { diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetTokenListUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetTokenListUseCase.kt index 99c107632a..1266f0cc23 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetTokenListUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetTokenListUseCase.kt @@ -15,9 +15,9 @@ import com.tangem.domain.wallets.models.UserWalletId import com.tangem.utils.coroutines.CoroutineDispatcherProvider import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flatMapMerge -import kotlinx.coroutines.flow.flowOf +import kotlinx.coroutines.flow.emitAll import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.transformLatest class GetTokenListUseCase( internal val currenciesRepository: CurrenciesRepository, @@ -28,13 +28,13 @@ class GetTokenListUseCase( @OptIn(ExperimentalCoroutinesApi::class) operator fun invoke(userWalletId: UserWalletId): Flow> { - return getTokensStatuses(userWalletId).flatMapMerge { maybeTokens -> + return getTokensStatuses(userWalletId).transformLatest { maybeTokens -> maybeTokens.fold( ifLeft = { error -> - flowOf(error.left()) + emit(error.left()) }, ifRight = { tokens -> - createTokenList(userWalletId, tokens) + emitAll(createTokenList(userWalletId, tokens)) }, ) } diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/RemoveCurrencyUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/RemoveCurrencyUseCase.kt index e2a908df3b..da933c144f 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/RemoveCurrencyUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/RemoveCurrencyUseCase.kt @@ -3,8 +3,8 @@ package com.tangem.domain.tokens import arrow.core.Either import arrow.core.raise.catch import arrow.core.raise.either -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.remove.RemoveCurrencyError +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.remove.RemoveCurrencyError import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.wallets.models.UserWalletId import com.tangem.utils.coroutines.CoroutineDispatcherProvider diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/legacy/TradeCryptoAction.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/legacy/TradeCryptoAction.kt index e9c3430207..36ea2aa3c9 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/legacy/TradeCryptoAction.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/legacy/TradeCryptoAction.kt @@ -1,7 +1,7 @@ package com.tangem.domain.tokens.legacy +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus -import com.tangem.domain.tokens.models.CryptoCurrency import com.tangem.domain.wallets.models.UserWallet import org.rekotlin.Action import java.math.BigDecimal diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/NetworkGroup.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/NetworkGroup.kt index d2463c0f16..57a74bd19d 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/NetworkGroup.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/NetworkGroup.kt @@ -1,7 +1,5 @@ package com.tangem.domain.tokens.model -import com.tangem.domain.tokens.models.Network - /** * Represents a group of cryptocurrencies associated with a specific network. * diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesOperations.kt index 07a72dbee4..445b076284 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesOperations.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesOperations.kt @@ -3,11 +3,7 @@ package com.tangem.domain.tokens.operations import arrow.core.* import arrow.core.raise.* import com.tangem.domain.tokens.GetTokenListUseCase -import com.tangem.domain.tokens.model.CryptoCurrencyStatus -import com.tangem.domain.tokens.model.NetworkStatus -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network -import com.tangem.domain.tokens.models.Quote +import com.tangem.domain.tokens.model.* import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.tokens.repository.NetworksRepository import com.tangem.domain.tokens.repository.QuotesRepository @@ -68,7 +64,7 @@ internal class CurrenciesStatusesOperations( } emitAll(currenciesFlow) - }.conflate() + } } suspend fun getCurrencyStatusFlow(currencyId: CryptoCurrency.ID): Flow> { diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrencyStatusOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrencyStatusOperations.kt index 4e043eaa52..90687996b9 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrencyStatusOperations.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrencyStatusOperations.kt @@ -1,9 +1,9 @@ package com.tangem.domain.tokens.operations +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.NetworkStatus -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Quote +import com.tangem.domain.tokens.model.Quote import java.math.BigDecimal internal class CurrencyStatusOperations( diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListOperations.kt index 2fee6a75c0..984cd6ddfc 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListOperations.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListOperations.kt @@ -1,7 +1,9 @@ package com.tangem.domain.tokens.operations import arrow.core.* -import arrow.core.raise.* +import arrow.core.raise.Raise +import arrow.core.raise.either +import arrow.core.raise.withError import com.tangem.domain.tokens.GetTokenListUseCase import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.TokenList @@ -125,6 +127,7 @@ internal class TokenListOperations( .map> { it.right() } .catch { emit(Error.DataError(it).left()) } .onEmpty { emit(value = false.right()) } + .cancellable() } private fun getIsSortedByBalance(): Flow> { @@ -132,6 +135,7 @@ internal class TokenListOperations( .map> { it.right() } .catch { emit(Error.DataError(it).left()) } .onEmpty { emit(value = false.right()) } + .cancellable() } sealed class Error { diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListSortingOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListSortingOperations.kt index 281d35a8ba..47bc1054bb 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListSortingOperations.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/TokenListSortingOperations.kt @@ -8,9 +8,9 @@ import arrow.core.raise.ensure import arrow.core.raise.ensureNotNull import arrow.core.toNonEmptyListOrNull 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 java.math.BigDecimal internal class TokenListSortingOperations( diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/CurrenciesRepository.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/CurrenciesRepository.kt index ce523cb34a..5554ee3990 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/CurrenciesRepository.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/CurrenciesRepository.kt @@ -1,7 +1,7 @@ package com.tangem.domain.tokens.repository -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.domain.wallets.models.UserWalletId import kotlinx.coroutines.flow.Flow diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/MarketCryptoCurrencyRepository.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/MarketCryptoCurrencyRepository.kt index a8c12b480d..0186226918 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/MarketCryptoCurrencyRepository.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/MarketCryptoCurrencyRepository.kt @@ -1,6 +1,6 @@ package com.tangem.domain.tokens.repository -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.wallets.models.UserWalletId /** diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/NetworksRepository.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/NetworksRepository.kt index a69acb7bec..30baab37f3 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/NetworksRepository.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/NetworksRepository.kt @@ -1,7 +1,7 @@ package com.tangem.domain.tokens.repository +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 diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/QuotesRepository.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/QuotesRepository.kt index 7e82d77d52..a44b1e6c99 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/QuotesRepository.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/QuotesRepository.kt @@ -1,7 +1,7 @@ package com.tangem.domain.tokens.repository -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Quote +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Quote import kotlinx.coroutines.flow.Flow /** diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/ApplyTokenListSortingUseCaseTest.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/ApplyTokenListSortingUseCaseTest.kt index c40e5fc94b..a7c421e527 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/ApplyTokenListSortingUseCaseTest.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/ApplyTokenListSortingUseCaseTest.kt @@ -6,7 +6,7 @@ import arrow.core.right import com.tangem.domain.core.error.DataError import com.tangem.domain.tokens.error.TokenListSortingError import com.tangem.domain.tokens.mock.MockTokens -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.repository.MockCurrenciesRepository import com.tangem.domain.wallets.models.UserWalletId import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/GetPrimaryCurrencyStatusUpdatesUseCaseTest.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/GetPrimaryCurrencyStatusUpdatesUseCaseTest.kt index a1f9e62bf9..010976fe3a 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/GetPrimaryCurrencyStatusUpdatesUseCaseTest.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/GetPrimaryCurrencyStatusUpdatesUseCaseTest.kt @@ -9,10 +9,10 @@ import com.tangem.domain.tokens.mock.MockNetworks import com.tangem.domain.tokens.mock.MockQuotes import com.tangem.domain.tokens.mock.MockTokens import com.tangem.domain.tokens.mock.MockTokensStates +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.NetworkStatus -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Quote +import com.tangem.domain.tokens.model.Quote import com.tangem.domain.tokens.repository.MockCurrenciesRepository import com.tangem.domain.tokens.repository.MockNetworksRepository import com.tangem.domain.tokens.repository.MockQuotesRepository diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/GetTokenListUseCaseTest.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/GetTokenListUseCaseTest.kt index 0affccbec6..90d8481285 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/GetTokenListUseCaseTest.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/GetTokenListUseCaseTest.kt @@ -9,10 +9,10 @@ import com.tangem.domain.tokens.mock.MockNetworks 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.NetworkStatus +import com.tangem.domain.tokens.model.Quote import com.tangem.domain.tokens.model.TokenList -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Quote import com.tangem.domain.tokens.repository.MockCurrenciesRepository import com.tangem.domain.tokens.repository.MockNetworksRepository import com.tangem.domain.tokens.repository.MockQuotesRepository diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockNetworks.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockNetworks.kt index f29e8b3a74..78517832f3 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockNetworks.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockNetworks.kt @@ -2,9 +2,9 @@ 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.NetworkAddress import com.tangem.domain.tokens.model.NetworkStatus -import com.tangem.domain.tokens.models.Network import java.math.BigDecimal @Suppress("MemberVisibilityCanBePrivate") diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockQuotes.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockQuotes.kt index a7e128d112..68de5e729a 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockQuotes.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockQuotes.kt @@ -1,7 +1,7 @@ package com.tangem.domain.tokens.mock import arrow.core.nonEmptySetOf -import com.tangem.domain.tokens.models.Quote +import com.tangem.domain.tokens.model.Quote import java.math.BigDecimal @Suppress("MemberVisibilityCanBePrivate") diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokens.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokens.kt index 7a045b5662..25b37db845 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokens.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockTokens.kt @@ -1,7 +1,7 @@ package com.tangem.domain.tokens.mock -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.CryptoCurrency.ID +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency.ID internal object MockTokens { diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockCurrenciesRepository.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockCurrenciesRepository.kt index 8238bc90d6..8cdec88feb 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockCurrenciesRepository.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockCurrenciesRepository.kt @@ -3,8 +3,8 @@ package com.tangem.domain.tokens.repository import arrow.core.Either import arrow.core.getOrElse import com.tangem.domain.core.error.DataError -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.domain.wallets.models.UserWalletId import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.first diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockNetworksRepository.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockNetworksRepository.kt index 6d5026250c..ffefd750e0 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockNetworksRepository.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockNetworksRepository.kt @@ -3,8 +3,8 @@ package com.tangem.domain.tokens.repository import arrow.core.Either import arrow.core.getOrElse import com.tangem.domain.core.error.DataError +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.first diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockQuotesRepository.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockQuotesRepository.kt index 3a1470ba1a..6d1c1e1a27 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockQuotesRepository.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/repository/MockQuotesRepository.kt @@ -3,8 +3,8 @@ package com.tangem.domain.tokens.repository import arrow.core.Either import arrow.core.getOrElse import com.tangem.domain.core.error.DataError -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Quote +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Quote import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map 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 7d180a783b..0c778f81ae 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 @@ -1,8 +1,8 @@ package com.tangem.domain.txhistory.repository import androidx.paging.PagingData -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.txhistory.models.TxHistoryListError import com.tangem.domain.txhistory.models.TxHistoryStateError 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 df9a8013cc..de458c7a51 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.models.Network +import com.tangem.domain.tokens.model.Network import com.tangem.domain.txhistory.models.TxHistoryStateError import com.tangem.domain.txhistory.repository.TxHistoryRepository diff --git a/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsUseCase.kt b/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsUseCase.kt index e72cbdca2b..6c9c0f682f 100644 --- a/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsUseCase.kt +++ b/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetTxHistoryItemsUseCase.kt @@ -3,7 +3,7 @@ package com.tangem.domain.txhistory.usecase import androidx.paging.PagingData import arrow.core.Either import arrow.core.raise.either -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.txhistory.models.TxHistoryListError import com.tangem.domain.txhistory.repository.TxHistoryRepository diff --git a/domain/wallets/src/main/java/com/tangem/domain/wallets/usecase/GetExploreUrlUseCase.kt b/domain/wallets/src/main/java/com/tangem/domain/wallets/usecase/GetExploreUrlUseCase.kt index f255563e7f..67af34a16d 100644 --- a/domain/wallets/src/main/java/com/tangem/domain/wallets/usecase/GetExploreUrlUseCase.kt +++ b/domain/wallets/src/main/java/com/tangem/domain/wallets/usecase/GetExploreUrlUseCase.kt @@ -1,7 +1,7 @@ package com.tangem.domain.wallets.usecase import arrow.core.raise.catch -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.Network import com.tangem.domain.walletmanager.WalletManagersFacade import com.tangem.domain.wallets.models.UserWalletId diff --git a/features/swap/data/src/main/java/com/tangem/feature/swap/SwapRepositoryImpl.kt b/features/swap/data/src/main/java/com/tangem/feature/swap/SwapRepositoryImpl.kt index f939cde5dd..897c742670 100644 --- a/features/swap/data/src/main/java/com/tangem/feature/swap/SwapRepositoryImpl.kt +++ b/features/swap/data/src/main/java/com/tangem/feature/swap/SwapRepositoryImpl.kt @@ -10,8 +10,8 @@ import com.tangem.datasource.api.tangemTech.TangemTechApi import com.tangem.datasource.config.ConfigManager import com.tangem.domain.common.extensions.fromNetworkId import com.tangem.domain.common.util.derivationStyleProvider -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.domain.wallets.models.UserWallet import com.tangem.feature.swap.converters.ApproveConverter import com.tangem.feature.swap.converters.QuotesConverter diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractor.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractor.kt index 73e969dc06..3cae5f1d7e 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractor.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractor.kt @@ -1,6 +1,6 @@ package com.tangem.feature.swap.domain -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.Network import com.tangem.feature.swap.domain.models.SwapAmount import com.tangem.feature.swap.domain.models.domain.Currency import com.tangem.feature.swap.domain.models.domain.PermissionOptions diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt index 17556ec17b..8eb7545ecb 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt @@ -1,6 +1,6 @@ package com.tangem.feature.swap.domain -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.Network import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.wallets.models.UserWallet import com.tangem.domain.wallets.usecase.GetSelectedWalletUseCase diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapRepository.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapRepository.kt index 6d1f5e2c00..449df97cdb 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapRepository.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapRepository.kt @@ -1,7 +1,7 @@ package com.tangem.feature.swap.domain -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network import com.tangem.domain.wallets.models.UserWallet import com.tangem.feature.swap.domain.models.data.AggregatedSwapDataModel import com.tangem.feature.swap.domain.models.domain.ApproveModel diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt index acddac5150..1dc5566832 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt @@ -9,7 +9,7 @@ import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.core.ui.utils.InputNumberFormatter import com.tangem.domain.balancehiding.IsBalanceHiddenUseCase import com.tangem.domain.balancehiding.ListenToFlipsUseCase -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.Network import com.tangem.feature.swap.analytics.SwapEvents import com.tangem.feature.swap.domain.BlockchainInteractor import com.tangem.feature.swap.domain.SwapInteractor @@ -17,7 +17,10 @@ import com.tangem.feature.swap.domain.models.domain.Currency import com.tangem.feature.swap.domain.models.domain.PermissionOptions import com.tangem.feature.swap.domain.models.formatToUIRepresentation import com.tangem.feature.swap.domain.models.ui.* -import com.tangem.feature.swap.models.* +import com.tangem.feature.swap.models.SwapPermissionState +import com.tangem.feature.swap.models.SwapStateHolder +import com.tangem.feature.swap.models.UiActions +import com.tangem.feature.swap.models.toDomainApproveType import com.tangem.feature.swap.presentation.SwapFragment import com.tangem.feature.swap.router.SwapNavScreen import com.tangem.feature.swap.router.SwapRouter @@ -26,14 +29,16 @@ import com.tangem.utils.coroutines.CoroutineDispatcherProvider import com.tangem.utils.coroutines.Debouncer import com.tangem.utils.coroutines.runCatching import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.* +import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import kotlinx.serialization.json.Json import timber.log.Timber import java.text.DecimalFormat import java.text.NumberFormat -import java.util.* +import java.util.Locale import javax.inject.Inject import kotlin.properties.Delegates diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt index d42022a22d..0b461acf11 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/components/TokenDetailsNotification.kt @@ -5,7 +5,7 @@ import com.tangem.core.ui.components.notifications.NotificationConfig import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.networkIconResId import com.tangem.core.ui.extensions.wrappedList -import com.tangem.domain.tokens.models.warnings.CryptoCurrencyWarning +import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.features.tokendetails.impl.R // TODO: Finalize notification strings [REDACTED_JIRA] diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt index 385592d737..6dffee2a74 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsNotificationConverter.kt @@ -1,6 +1,6 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.state.factory -import com.tangem.domain.tokens.models.warnings.CryptoCurrencyWarning +import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsNotification import com.tangem.feature.tokendetails.presentation.tokendetails.viewmodels.TokenDetailsClickIntents diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt index 3d5bc47a22..ff5e00b4f4 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt @@ -5,7 +5,7 @@ import com.tangem.core.ui.components.transactions.state.TxHistoryState import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.networkIconResId import com.tangem.core.ui.res.TangemTheme -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.feature.tokendetails.presentation.tokendetails.state.* import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsActionButton import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsPullToRefreshConfig diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt index 874f8bc7e9..4e016eb152 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt @@ -9,10 +9,10 @@ import com.tangem.core.ui.components.bottomsheets.tokenreceive.AddressModel import com.tangem.core.ui.components.bottomsheets.tokenreceive.TokenReceiveBottomSheetConfig import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.tokens.error.CurrencyStatusError +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.TokenActionsState -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.warnings.CryptoCurrencyWarning +import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.txhistory.models.TxHistoryListError import com.tangem.domain.txhistory.models.TxHistoryStateError 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 3824db3ec1..61a52ba80f 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 @@ -14,8 +14,8 @@ import com.tangem.domain.balancehiding.ListenToFlipsUseCase import com.tangem.domain.redux.ReduxStateHolder import com.tangem.domain.tokens.* import com.tangem.domain.tokens.legacy.TradeCryptoAction +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus -import com.tangem.domain.tokens.models.CryptoCurrency import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsCountUseCase import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsUseCase import com.tangem.domain.walletmanager.WalletManagersFacade diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/utils/CryptoCurrencyToIconStateConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/utils/CryptoCurrencyToIconStateConverter.kt index 8c07d881af..5bca05307e 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/utils/CryptoCurrencyToIconStateConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/utils/CryptoCurrencyToIconStateConverter.kt @@ -3,8 +3,8 @@ package com.tangem.feature.wallet.presentation.common.utils import com.tangem.core.ui.extensions.getTintForTokenIcon import com.tangem.core.ui.extensions.networkIconResId import com.tangem.core.ui.extensions.tryGetBackgroundForTokenIcon +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus -import com.tangem.domain.tokens.models.CryptoCurrency import com.tangem.feature.wallet.presentation.common.state.TokenItemState import com.tangem.utils.converter.Converter diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/CryptoCurrenciesIdsResolver.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/CryptoCurrenciesIdsResolver.kt index 5c7d1de901..4fa74e5171 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/CryptoCurrenciesIdsResolver.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/CryptoCurrenciesIdsResolver.kt @@ -1,7 +1,7 @@ package com.tangem.feature.wallet.presentation.organizetokens.utils +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.TokenList -import com.tangem.domain.tokens.models.CryptoCurrency import com.tangem.feature.wallet.presentation.organizetokens.model.DraggableItem import com.tangem.feature.wallet.presentation.organizetokens.model.OrganizeTokensListState diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/common/IdsOperations.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/common/IdsOperations.kt index 5cf4e81e8e..3ea46b1752 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/common/IdsOperations.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/common/IdsOperations.kt @@ -1,7 +1,7 @@ package com.tangem.feature.wallet.presentation.organizetokens.utils.common -import com.tangem.domain.tokens.models.CryptoCurrency -import com.tangem.domain.tokens.models.Network +import com.tangem.domain.tokens.model.CryptoCurrency +import com.tangem.domain.tokens.model.Network internal fun getTokenItemId(currencyId: CryptoCurrency.ID): String = currencyId.value diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt index ceaeead504..c4bfb43ead 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/DefaultWalletRouter.kt @@ -19,7 +19,7 @@ import androidx.navigation.navArgument import com.tangem.core.navigation.AppScreen import com.tangem.core.navigation.NavigationAction import com.tangem.core.navigation.ReduxNavController -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.wallets.models.UserWalletId import com.tangem.feature.wallet.presentation.WalletFragment import com.tangem.feature.wallet.presentation.organizetokens.OrganizeTokensScreen diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/InnerWalletRouter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/InnerWalletRouter.kt index b5b2ff23e1..e48e601399 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/InnerWalletRouter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/router/InnerWalletRouter.kt @@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable import androidx.fragment.app.FragmentManager import com.tangem.core.navigation.AppScreen -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.wallets.models.UserWalletId import com.tangem.features.wallet.navigation.WalletRouter diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt index 7d909ffbde..f4b1ade111 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt @@ -18,10 +18,6 @@ import com.tangem.domain.txhistory.models.TxHistoryItem import com.tangem.domain.txhistory.models.TxHistoryListError import com.tangem.domain.txhistory.models.TxHistoryStateError import com.tangem.domain.wallets.models.UserWallet -import com.tangem.feature.wallet.presentation.wallet.state.ActionsBottomSheetConfig -import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState -import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState -import com.tangem.feature.wallet.presentation.wallet.state.WalletState import com.tangem.feature.wallet.presentation.wallet.state.* import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification import com.tangem.feature.wallet.presentation.wallet.state.factory.txhistory.WalletLoadedTxHistoryConverter diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt index de962fb838..23fe4c6ba0 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt @@ -1,7 +1,7 @@ package com.tangem.feature.wallet.presentation.wallet.viewmodels +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus -import com.tangem.domain.tokens.models.CryptoCurrency import com.tangem.domain.wallets.models.UserWalletId @Suppress("TooManyFunctions") diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt index 183f993df2..4935e3ac1b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletNotificationsListFactory.kt @@ -4,8 +4,8 @@ import com.tangem.domain.card.GetCardWasScannedUseCase import com.tangem.domain.common.CardTypesResolver import com.tangem.domain.demo.IsDemoCardUseCase import com.tangem.domain.settings.IsUserAlreadyRateAppUseCase +import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus -import com.tangem.domain.tokens.models.CryptoCurrency import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList 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 0d90d2c801..a3a4576625 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 @@ -36,10 +36,7 @@ import com.tangem.domain.settings.IsUserAlreadyRateAppUseCase import com.tangem.domain.settings.ShouldShowSaveWalletScreenUseCase import com.tangem.domain.tokens.* import com.tangem.domain.tokens.legacy.TradeCryptoAction -import com.tangem.domain.tokens.model.CryptoCurrencyStatus -import com.tangem.domain.tokens.model.NetworkGroup -import com.tangem.domain.tokens.model.TokenList -import com.tangem.domain.tokens.models.CryptoCurrency +import com.tangem.domain.tokens.model.* import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsCountUseCase import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsUseCase import com.tangem.domain.userwallets.UserWalletBuilder