From e22331ec90e54e3c8be72aa5a4de90eba6f470b9 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 12 Mar 2026 15:28:52 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../tap/di/domain/TokensDomainModule.kt | 36 ---- domain/account/status/build.gradle.kts | 1 + .../status/di/AccountStatusUseCaseModule.kt | 13 ++ ...tFeePaidCryptoCurrencyStatusSyncUseCase.kt | 23 ++- .../tokens/error/AddCustomTokenError.kt | 6 - .../mapper/CurrencyStatusErrorMappers.kt | 17 -- .../error/mapper/TokenListErrorMappers.kt | 17 -- .../BaseCurrencyStatusOperations.kt | 154 ------------------ .../CurrenciesStatusesOperations.kt | 21 --- .../utils/CurrencyStatusProxyCreator.kt | 97 ----------- .../features/send/v2/send/model/SendModel.kt | 2 +- .../send/v2/sendnft/model/NFTSendModel.kt | 2 +- .../impl/presentation/model/StakingModel.kt | 1 + .../sendviaswap/model/SendWithSwapModel.kt | 2 +- .../feature/swap/domain/SwapInteractorImpl.kt | 1 + .../tangem/feature/swap/model/SwapModel.kt | 2 +- .../approve/model/YieldSupplyApproveModel.kt | 2 +- .../model/YieldSupplyStartEarningModel.kt | 2 +- .../model/YieldSupplyStopEarningModel.kt | 2 +- 19 files changed, 38 insertions(+), 363 deletions(-) rename domain/{tokens/src/main/kotlin/com/tangem/domain/tokens => account/status/src/main/java/com/tangem/domain/account/status/usecase}/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt (54%) delete mode 100644 domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/AddCustomTokenError.kt delete mode 100644 domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/mapper/CurrencyStatusErrorMappers.kt delete mode 100644 domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/mapper/TokenListErrorMappers.kt delete mode 100644 domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/BaseCurrencyStatusOperations.kt delete mode 100644 domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesOperations.kt delete mode 100644 domain/tokens/src/main/kotlin/com/tangem/domain/tokens/utils/CurrencyStatusProxyCreator.kt diff --git a/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt b/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt index 07920010a7..9dd18523ac 100644 --- a/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt +++ b/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt @@ -5,18 +5,14 @@ import com.tangem.domain.exchange.RampStateManager import com.tangem.domain.networks.multi.MultiNetworkStatusFetcher import com.tangem.domain.networks.repository.NetworksRepository import com.tangem.domain.networks.single.SingleNetworkStatusFetcher -import com.tangem.domain.networks.single.SingleNetworkStatusSupplier import com.tangem.domain.pay.flow.PaymentAccountStatusFetcher import com.tangem.domain.promo.PromoRepository import com.tangem.domain.quotes.multi.MultiQuoteStatusFetcher -import com.tangem.domain.quotes.single.SingleQuoteStatusSupplier import com.tangem.domain.staking.StakingIdFactory import com.tangem.domain.staking.multi.MultiStakingBalanceFetcher import com.tangem.domain.staking.repositories.StakingRepository import com.tangem.domain.staking.single.SingleStakingBalanceFetcher -import com.tangem.domain.staking.single.SingleStakingBalanceSupplier import com.tangem.domain.tokens.* -import com.tangem.domain.tokens.operations.BaseCurrencyStatusOperations import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.tokens.repository.CurrencyChecksRepository import com.tangem.domain.tokens.repository.TokenReceiveWarningsViewedRepository @@ -88,18 +84,6 @@ internal object TokensDomainModule { ) } - @Provides - @Singleton - fun provideGetFeePaidCryptoCurrencyStatusSyncUseCase( - currenciesRepository: CurrenciesRepository, - currencyStatusOperations: BaseCurrencyStatusOperations, - ): GetFeePaidCryptoCurrencyStatusSyncUseCase { - return GetFeePaidCryptoCurrencyStatusSyncUseCase( - currenciesRepository = currenciesRepository, - currencyStatusOperations = currencyStatusOperations, - ) - } - @Provides @Singleton fun provideGetMinimumTransactionAmountSyncUseCase( @@ -183,26 +167,6 @@ internal object TokensDomainModule { return GetCurrencyCheckUseCase(currencyChecksRepository, dispatchers) } - @Provides - @Singleton - fun provideBaseCurrencyStatusOperations( - currenciesRepository: CurrenciesRepository, - singleNetworkStatusSupplier: SingleNetworkStatusSupplier, - singleQuoteStatusSupplier: SingleQuoteStatusSupplier, - singleStakingBalanceSupplier: SingleStakingBalanceSupplier, - multiWalletCryptoCurrenciesSupplier: MultiWalletCryptoCurrenciesSupplier, - stakingIdFactory: StakingIdFactory, - ): BaseCurrencyStatusOperations { - return BaseCurrencyStatusOperations( - currenciesRepository = currenciesRepository, - singleNetworkStatusSupplier = singleNetworkStatusSupplier, - singleQuoteStatusSupplier = singleQuoteStatusSupplier, - singleStakingBalanceSupplier = singleStakingBalanceSupplier, - multiWalletCryptoCurrenciesSupplier = multiWalletCryptoCurrenciesSupplier, - stakingIdFactory = stakingIdFactory, - ) - } - @Provides @Singleton fun provideWalletBalanceFetcher( diff --git a/domain/account/status/build.gradle.kts b/domain/account/status/build.gradle.kts index 28daf7df24..d22d8549d9 100644 --- a/domain/account/status/build.gradle.kts +++ b/domain/account/status/build.gradle.kts @@ -27,6 +27,7 @@ dependencies { api(projects.domain.referral) api(projects.domain.staking) api(projects.domain.tokens) + api(projects.domain.tokens.models) api(projects.domain.walletManager) api(projects.domain.wallets) diff --git a/domain/account/status/src/main/java/com/tangem/domain/account/status/di/AccountStatusUseCaseModule.kt b/domain/account/status/src/main/java/com/tangem/domain/account/status/di/AccountStatusUseCaseModule.kt index 90ea428eda..e2b9696c89 100644 --- a/domain/account/status/src/main/java/com/tangem/domain/account/status/di/AccountStatusUseCaseModule.kt +++ b/domain/account/status/src/main/java/com/tangem/domain/account/status/di/AccountStatusUseCaseModule.kt @@ -3,6 +3,7 @@ package com.tangem.domain.account.status.di import com.tangem.domain.account.repository.AccountsCRUDRepository import com.tangem.domain.account.status.supplier.MultiAccountStatusListSupplier import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier +import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase import com.tangem.domain.account.status.usecase.* import com.tangem.domain.account.status.utils.CryptoCurrencyBalanceFetcher import com.tangem.domain.account.status.utils.CryptoCurrencyMetadataCleaner @@ -157,6 +158,18 @@ internal object AccountStatusUseCaseModule { ) } + @Provides + @Singleton + fun provideGetFeePaidCryptoCurrencyStatusSyncUseCase( + currenciesRepository: CurrenciesRepository, + singleAccountStatusListSupplier: SingleAccountStatusListSupplier, + ): GetFeePaidCryptoCurrencyStatusSyncUseCase { + return GetFeePaidCryptoCurrencyStatusSyncUseCase( + currenciesRepository = currenciesRepository, + singleAccountStatusListSupplier = singleAccountStatusListSupplier, + ) + } + @Provides @Singleton fun provideCryptoCurrencyMetadataCleaner( diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt b/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt similarity index 54% rename from domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt rename to domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt index 77bb61fb5e..21a209863f 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt +++ b/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt @@ -1,17 +1,19 @@ -package com.tangem.domain.tokens +package com.tangem.domain.account.status.usecase import arrow.core.Either import arrow.core.raise.either +import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier +import com.tangem.domain.account.status.utils.CryptoCurrencyStatusOperations.getCoinStatus +import com.tangem.domain.account.status.utils.CryptoCurrencyStatusOperations.getCryptoCurrencyStatus import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.tokens.error.TokenListError import com.tangem.domain.tokens.model.FeePaidCurrency -import com.tangem.domain.tokens.operations.BaseCurrencyStatusOperations import com.tangem.domain.tokens.repository.CurrenciesRepository class GetFeePaidCryptoCurrencyStatusSyncUseCase( - internal val currenciesRepository: CurrenciesRepository, - private val currencyStatusOperations: BaseCurrencyStatusOperations, + private val currenciesRepository: CurrenciesRepository, + private val singleAccountStatusListSupplier: SingleAccountStatusListSupplier, ) { suspend operator fun invoke( @@ -25,12 +27,17 @@ class GetFeePaidCryptoCurrencyStatusSyncUseCase( return either { when (feePaidCurrency) { is FeePaidCurrency.Coin -> { - currencyStatusOperations.getNetworkCoinSync(userWalletId, network.id, network.derivationPath) - .getOrNull() + val accountStatusList = singleAccountStatusListSupplier.getSyncOrNull(userWalletId) + + accountStatusList?.getCoinStatus(network)?.getOrNull() } is FeePaidCurrency.Token -> { - currencyStatusOperations.getCurrencyStatusSync(userWalletId, feePaidCurrency.tokenId) - .getOrNull() + val accountStatusList = singleAccountStatusListSupplier.getSyncOrNull(userWalletId) + + accountStatusList.getCryptoCurrencyStatus( + currencyId = feePaidCurrency.tokenId, + network = network, + ).getOrNull() } is FeePaidCurrency.SameCurrency, is FeePaidCurrency.FeeResource, diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/AddCustomTokenError.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/AddCustomTokenError.kt deleted file mode 100644 index fcbb456b66..0000000000 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/AddCustomTokenError.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.tangem.domain.tokens.error - -enum class AddCustomTokenError { - FIELD_IS_EMPTY, - INVALID_CONTRACT_ADDRESS, -} \ No newline at end of file diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/mapper/CurrencyStatusErrorMappers.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/mapper/CurrencyStatusErrorMappers.kt deleted file mode 100644 index 6fc01f0c95..0000000000 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/mapper/CurrencyStatusErrorMappers.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.tangem.domain.tokens.error.mapper - -import com.tangem.domain.tokens.error.CurrencyStatusError -import com.tangem.domain.tokens.operations.CurrenciesStatusesOperations - -internal fun CurrenciesStatusesOperations.Error.mapToCurrencyError(): CurrencyStatusError { - return when (this) { - is CurrenciesStatusesOperations.Error.DataError -> CurrencyStatusError.DataError(this.cause) - is CurrenciesStatusesOperations.Error.EmptyStakingBalances, - is CurrenciesStatusesOperations.Error.EmptyNetworksStatuses, - is CurrenciesStatusesOperations.Error.EmptyQuotes, - is CurrenciesStatusesOperations.Error.EmptyCurrencies, - is CurrenciesStatusesOperations.Error.EmptyAddresses, - is CurrenciesStatusesOperations.Error.UnableToCreateCurrencyStatus, - -> CurrencyStatusError.UnableToCreateCurrency - } -} \ No newline at end of file diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/mapper/TokenListErrorMappers.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/mapper/TokenListErrorMappers.kt deleted file mode 100644 index 51e08ac450..0000000000 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/error/mapper/TokenListErrorMappers.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.tangem.domain.tokens.error.mapper - -import com.tangem.domain.tokens.error.TokenListError -import com.tangem.domain.tokens.operations.CurrenciesStatusesOperations - -internal fun CurrenciesStatusesOperations.Error.mapToTokenListError(): TokenListError { - return when (this) { - is CurrenciesStatusesOperations.Error.DataError -> TokenListError.DataError(this.cause) - is CurrenciesStatusesOperations.Error.EmptyNetworksStatuses, - is CurrenciesStatusesOperations.Error.EmptyQuotes, - is CurrenciesStatusesOperations.Error.EmptyCurrencies, - is CurrenciesStatusesOperations.Error.EmptyAddresses, - is CurrenciesStatusesOperations.Error.UnableToCreateCurrencyStatus, - is CurrenciesStatusesOperations.Error.EmptyStakingBalances, - -> TokenListError.EmptyTokens - } -} \ No newline at end of file diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/BaseCurrencyStatusOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/BaseCurrencyStatusOperations.kt deleted file mode 100644 index 5714da190b..0000000000 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/BaseCurrencyStatusOperations.kt +++ /dev/null @@ -1,154 +0,0 @@ -package com.tangem.domain.tokens.operations - -import arrow.core.Either -import arrow.core.left -import arrow.core.raise.* -import arrow.core.right -import com.tangem.domain.models.currency.CryptoCurrency -import com.tangem.domain.models.currency.CryptoCurrencyStatus -import com.tangem.domain.models.network.Network -import com.tangem.domain.models.staking.StakingBalance -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.domain.networks.single.SingleNetworkStatusProducer -import com.tangem.domain.networks.single.SingleNetworkStatusSupplier -import com.tangem.domain.quotes.single.SingleQuoteStatusProducer -import com.tangem.domain.quotes.single.SingleQuoteStatusSupplier -import com.tangem.domain.staking.StakingIdFactory -import com.tangem.domain.staking.single.SingleStakingBalanceProducer -import com.tangem.domain.staking.single.SingleStakingBalanceSupplier -import com.tangem.domain.tokens.MultiWalletCryptoCurrenciesProducer -import com.tangem.domain.tokens.MultiWalletCryptoCurrenciesSupplier -import com.tangem.domain.tokens.operations.CurrenciesStatusesOperations.Error -import com.tangem.domain.tokens.repository.CurrenciesRepository -import com.tangem.domain.tokens.utils.CurrencyStatusProxyCreator -import kotlinx.coroutines.flow.firstOrNull - -/** - * Base operations for working with currency status - * - * @property currenciesRepository repository for currencies - * -[REDACTED_AUTHOR] - */ -@Suppress("LargeClass", "LongParameterList") -class BaseCurrencyStatusOperations( - private val currenciesRepository: CurrenciesRepository, - private val singleNetworkStatusSupplier: SingleNetworkStatusSupplier, - private val singleQuoteStatusSupplier: SingleQuoteStatusSupplier, - private val singleStakingBalanceSupplier: SingleStakingBalanceSupplier, - private val multiWalletCryptoCurrenciesSupplier: MultiWalletCryptoCurrenciesSupplier, - private val stakingIdFactory: StakingIdFactory, -) { - - private val currencyStatusProxyCreator = CurrencyStatusProxyCreator() - - suspend fun getNetworkCoinSync( - userWalletId: UserWalletId, - networkId: Network.ID, - derivationPath: Network.DerivationPath, - ): Either { - val currency = recover( - block = { getNetworkCoin(userWalletId, networkId, derivationPath) }, - recover = { return it.left() }, - ) - - return getCurrencyStatusSync(userWalletId, currency.id) - } - - suspend fun getCurrencyStatusSync( - userWalletId: UserWalletId, - cryptoCurrencyId: CryptoCurrency.ID, - isSingleWalletWithTokens: Boolean = false, - ): Either { - return either { - catch( - block = { - val currency = if (isSingleWalletWithTokens) { - currenciesRepository.getSingleCurrencyWalletWithCardCurrency(userWalletId, cryptoCurrencyId) - } else { - getMultiCurrencyWalletCurrency(userWalletId, cryptoCurrencyId) - } - - val quote = cryptoCurrencyId.rawCurrencyId?.let { rawId -> - singleQuoteStatusSupplier(params = SingleQuoteStatusProducer.Params(rawCurrencyId = rawId)) - .firstOrNull() - } - ?.right() - ?: Error.EmptyQuotes.left() - - val networkStatuses = singleNetworkStatusSupplier( - params = SingleNetworkStatusProducer.Params( - userWalletId = userWalletId, - network = currency.network, - ), - ) - .firstOrNull() - .right() - - val stakingBalances = getStakingBalanceSync(userWalletId, currency) - - return currencyStatusProxyCreator.createCurrencyStatus( - currency = currency, - maybeQuoteStatus = quote, - maybeNetworkStatus = networkStatuses, - maybeStakingBalance = stakingBalances, - ) - }, - catch = { raise(Error.DataError(it)) }, - ) - } - } - - private suspend fun Raise.getMultiCurrencyWalletCurrency( - userWalletId: UserWalletId, - currencyId: CryptoCurrency.ID, - ): CryptoCurrency { - return Either.catch { - multiWalletCryptoCurrenciesSupplier.getSyncOrNull( - params = MultiWalletCryptoCurrenciesProducer.Params(userWalletId), - ) - ?.firstOrNull { it.id == currencyId } - ?: error("Unable to find currency with ID: $currencyId") - } - .mapLeft(Error::DataError) - .bind() - } - - private suspend fun Raise.getNetworkCoin( - userWalletId: UserWalletId, - networkId: Network.ID, - derivationPath: Network.DerivationPath, - ): CryptoCurrency { - return Either.catch { - multiWalletCryptoCurrenciesSupplier.getSyncOrNull( - params = MultiWalletCryptoCurrenciesProducer.Params(userWalletId), - ) - ?.filterIsInstance() - ?.firstOrNull { it.network.id == networkId && it.network.derivationPath == derivationPath } - ?: error("Unable to create network coin with ID: $networkId") - } - .mapLeft { Error.DataError(it) } - .bind() - } - - private suspend fun getStakingBalanceSync( - userWalletId: UserWalletId, - cryptoCurrency: CryptoCurrency, - ): Either = either { - val stakingId = stakingIdFactory.create(userWalletId, cryptoCurrency) - .mapLeft { - val exception = IllegalStateException("$it") - Error.DataError(exception) - } - .bind() - - val yieldBalance = singleStakingBalanceSupplier.getSyncOrNull( - params = SingleStakingBalanceProducer.Params( - userWalletId = userWalletId, - stakingId = stakingId, - ), - ) - - ensureNotNull(yieldBalance) { Error.EmptyStakingBalances } - } -} \ No newline at end of file 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 deleted file mode 100644 index a8f25caebe..0000000000 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesOperations.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.tangem.domain.tokens.operations - -class CurrenciesStatusesOperations { - - sealed class Error { - - data object EmptyCurrencies : Error() - - data object EmptyQuotes : Error() - - data object EmptyNetworksStatuses : Error() - - data object EmptyAddresses : Error() - - data object UnableToCreateCurrencyStatus : Error() - - data class DataError(val cause: Throwable) : Error() - - data object EmptyStakingBalances : Error() - } -} \ No newline at end of file diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/utils/CurrencyStatusProxyCreator.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/utils/CurrencyStatusProxyCreator.kt deleted file mode 100644 index 59937cd45f..0000000000 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/utils/CurrencyStatusProxyCreator.kt +++ /dev/null @@ -1,97 +0,0 @@ -package com.tangem.domain.tokens.utils - -import arrow.core.Either -import arrow.core.NonEmptyList -import arrow.core.raise.either -import arrow.core.raise.recover -import arrow.core.toNonEmptySetOrNull -import arrow.core.toOption -import com.tangem.domain.models.currency.CryptoCurrency -import com.tangem.domain.models.currency.CryptoCurrencyStatus -import com.tangem.domain.models.network.NetworkStatus -import com.tangem.domain.models.network.getAddress -import com.tangem.domain.models.quote.QuoteStatus -import com.tangem.domain.models.staking.StakingBalance -import com.tangem.domain.models.staking.StakingID -import com.tangem.domain.staking.model.StakingIntegrationID -import com.tangem.domain.tokens.operations.CryptoCurrencyStatusFactory -import com.tangem.domain.tokens.operations.CurrenciesStatusesOperations.Error - -/** - * Proxy creator of [CryptoCurrencyStatus]. Used [CryptoCurrencyStatusFactory] to create statuses. - * -[REDACTED_AUTHOR] - */ -class CurrencyStatusProxyCreator { - - fun createCurrencyStatus( - currency: CryptoCurrency, - maybeQuoteStatus: Either, - maybeNetworkStatus: Either, - maybeStakingBalance: Either?, - ): Either = either { - val networkStatus = maybeNetworkStatus.bind() - val quote = recover( - block = { maybeQuoteStatus.bind() }, - recover = { null }, - ) - val stakingBalance = maybeStakingBalance?.getOrNull() - - createCurrencyStatus( - currency = currency, - quoteStatus = quote, - networkStatus = networkStatus, - stakingBalance = stakingBalance, - ) - } - - fun createCurrenciesStatuses( - currencies: NonEmptyList, - maybeQuotes: Either>?, - maybeNetworkStatuses: Either>, - maybeStakingBalances: Either>, - ): Either> = either { - val networksStatuses = maybeNetworkStatuses.bind().toNonEmptySetOrNull() - val quoteStatuses: Set? = maybeQuotes?.getOrNull()?.ifEmpty { null } - - val stakingBalances = maybeStakingBalances.getOrNull() - - currencies.map { currency -> - val quote = quoteStatuses?.firstOrNull { it.rawCurrencyId == currency.id.rawCurrencyId } - val networkStatus = networksStatuses?.firstOrNull { it.network == currency.network } - val address = networkStatus.getAddress() - - val supportedIntegration = StakingIntegrationID.create(currencyId = currency.id)?.value - - val stakingBalance = if (supportedIntegration != null && address != null) { - val stakingId = StakingID(integrationId = supportedIntegration, address = address) - - stakingBalances?.firstOrNull { it.stakingId == stakingId } - ?: StakingBalance.Error(stakingId = stakingId) - } else { - null - } - - createCurrencyStatus( - currency = currency, - quoteStatus = quote, - networkStatus = networkStatus, - stakingBalance = stakingBalance, - ) - } - } - - private fun createCurrencyStatus( - currency: CryptoCurrency, - quoteStatus: QuoteStatus?, - networkStatus: NetworkStatus?, - stakingBalance: StakingBalance?, - ): CryptoCurrencyStatus { - return CryptoCurrencyStatusFactory.create( - currency = currency, - maybeNetworkStatus = networkStatus.toOption(), - maybeQuoteStatus = quoteStatus.toOption(), - maybeStakingBalance = stakingBalance.toOption(), - ) - } -} \ No newline at end of file diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/model/SendModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/model/SendModel.kt index 16449c2fc5..5174229910 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/model/SendModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/model/SendModel.kt @@ -33,7 +33,7 @@ import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.qrscanning.models.SourceType import com.tangem.domain.qrscanning.usecases.ListenToQrScanningUseCase import com.tangem.domain.qrscanning.usecases.ParseQrCodeUseCase -import com.tangem.domain.tokens.GetFeePaidCryptoCurrencyStatusSyncUseCase +import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase import com.tangem.domain.transaction.error.GetFeeError import com.tangem.domain.transaction.models.TransactionFeeExtended import com.tangem.domain.transaction.usecase.CreateTransferTransactionUseCase diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/sendnft/model/NFTSendModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/sendnft/model/NFTSendModel.kt index 4d84c0b4a2..54b8e11901 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/sendnft/model/NFTSendModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/sendnft/model/NFTSendModel.kt @@ -27,7 +27,7 @@ import com.tangem.domain.models.account.Account import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.wallet.UserWallet -import com.tangem.domain.tokens.GetFeePaidCryptoCurrencyStatusSyncUseCase +import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase import com.tangem.domain.tokens.MultiWalletCryptoCurrenciesProducer import com.tangem.domain.tokens.MultiWalletCryptoCurrenciesSupplier import com.tangem.domain.transaction.error.GetFeeError diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt index d148b80650..27bf32458e 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt @@ -61,6 +61,7 @@ import com.tangem.domain.staking.model.stakekit.action.StakingAction import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType import com.tangem.domain.staking.model.stakekit.transaction.StakingTransaction import com.tangem.domain.staking.repositories.P2PEthPoolRepository +import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase import com.tangem.domain.tokens.* import com.tangem.domain.transaction.error.GetFeeError import com.tangem.domain.transaction.usecase.* diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt index dc868296e8..039d065657 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt @@ -17,7 +17,7 @@ import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.swap.models.SwapDirection -import com.tangem.domain.tokens.GetFeePaidCryptoCurrencyStatusSyncUseCase +import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase import com.tangem.domain.wallets.usecase.GetUserWalletUseCase import com.tangem.features.send.v2.api.analytics.CommonSendAnalyticEvents import com.tangem.features.send.v2.api.entity.FeeSelectorUM 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 1856211b21..0489edb872 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 @@ -38,6 +38,7 @@ import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.pay.TangemPayWithdrawExchangeState import com.tangem.domain.quotes.QuotesRepository import com.tangem.domain.quotes.multi.MultiQuoteStatusFetcher +import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase import com.tangem.domain.tokens.* import com.tangem.domain.tokens.model.FeePaidCurrency import com.tangem.domain.tokens.model.warnings.CryptoCurrencyCheck diff --git a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt index 1d1951f503..aca9ef968e 100644 --- a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt +++ b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt @@ -69,7 +69,7 @@ import com.tangem.domain.settings.usercountry.models.needApplyFCARestrictions import com.tangem.domain.tangempay.GetTangemPayCurrencyStatusUseCase import com.tangem.domain.tangempay.GetTangemPayCustomerIdUseCase import com.tangem.domain.tangempay.TangemPayWithdrawUseCase -import com.tangem.domain.tokens.GetFeePaidCryptoCurrencyStatusSyncUseCase +import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase import com.tangem.domain.tokens.GetMinimumTransactionAmountSyncUseCase import com.tangem.domain.tokens.UpdateDelayedNetworkStatusUseCase import com.tangem.domain.transaction.error.GetFeeError diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/approve/model/YieldSupplyApproveModel.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/approve/model/YieldSupplyApproveModel.kt index f817548872..08cbe91674 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/approve/model/YieldSupplyApproveModel.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/approve/model/YieldSupplyApproveModel.kt @@ -20,7 +20,7 @@ import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.wallet.isHotWallet -import com.tangem.domain.tokens.GetFeePaidCryptoCurrencyStatusSyncUseCase +import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase import com.tangem.domain.transaction.usecase.CreateApprovalTransactionUseCase import com.tangem.domain.transaction.usecase.GetFeeUseCase import com.tangem.domain.transaction.usecase.SendTransactionUseCase diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/YieldSupplyStartEarningModel.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/YieldSupplyStartEarningModel.kt index f66d505e7f..0e7ff956e2 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/YieldSupplyStartEarningModel.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/startearning/model/YieldSupplyStartEarningModel.kt @@ -20,7 +20,7 @@ import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.isHotWallet -import com.tangem.domain.tokens.GetFeePaidCryptoCurrencyStatusSyncUseCase +import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase import com.tangem.domain.transaction.error.GetFeeError import com.tangem.domain.transaction.usecase.SendTransactionUseCase import com.tangem.domain.wallets.usecase.GetUserWalletUseCase diff --git a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/stopearning/model/YieldSupplyStopEarningModel.kt b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/stopearning/model/YieldSupplyStopEarningModel.kt index dd0b697ccd..fbee3f5bb8 100644 --- a/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/stopearning/model/YieldSupplyStopEarningModel.kt +++ b/features/yield-supply/impl/src/main/java/com/tangem/features/yield/supply/impl/subcomponents/stopearning/model/YieldSupplyStopEarningModel.kt @@ -18,7 +18,7 @@ import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.wallet.isHotWallet -import com.tangem.domain.tokens.GetFeePaidCryptoCurrencyStatusSyncUseCase +import com.tangem.domain.account.status.usecase.GetFeePaidCryptoCurrencyStatusSyncUseCase import com.tangem.domain.transaction.usecase.GetFeeUseCase import com.tangem.domain.transaction.usecase.SendTransactionUseCase import com.tangem.domain.yield.supply.INCREASE_GAS_LIMIT_FOR_SUPPLY