Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-17 15:02:06 +04:00
parent b27e8171fb
commit 4ea8243da3
19 changed files with 375 additions and 126 deletions

View file

@ -7,6 +7,8 @@ import com.tangem.domain.account.producer.SingleAccountProducer
import com.tangem.domain.account.status.usecase.ManageCryptoCurrenciesUseCase
import com.tangem.domain.account.supplier.SingleAccountSupplier
import com.tangem.domain.managetokens.CheckIsCurrencyNotAddedUseCase
import com.tangem.domain.models.account.AccountId
import com.tangem.domain.models.account.DerivationIndex
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.tokens.AddCryptoCurrenciesUseCase
@ -27,7 +29,13 @@ internal class CustomTokenFormUseCasesFacade @AssistedInject constructor(
suspend fun addCryptoCurrenciesUseCase(currency: CryptoCurrency): Either<Throwable, Unit> = when (mode) {
is AddCustomTokenMode.Account -> {
manageCryptoCurrenciesUseCase(accountId = mode.accountId, add = currency)
manageCryptoCurrenciesUseCase(
accountId = AccountId.forCryptoPortfolio(
userWalletId = mode.userWalletId,
derivationIndex = DerivationIndex.Main,
),
add = currency,
)
}
is AddCustomTokenMode.Wallet -> {
addCryptoCurrenciesUseCase.invoke(

View file

@ -13,6 +13,7 @@ import com.tangem.core.ui.message.ToastMessage
import com.tangem.domain.account.status.usecase.GetCryptoCurrencyActionsUseCaseV2
import com.tangem.domain.markets.GetTokenMarketCryptoCurrency
import com.tangem.domain.markets.TokenMarketInfo
import com.tangem.domain.models.account.AccountStatus
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.UserWallet
@ -243,6 +244,7 @@ internal class AddToPortfolioModel @Inject constructor(
cryptoCurrency = createCryptoCurrency(
userWallet = selectedPortfolio.userWallet,
network = selectedNetwork,
account = selectedPortfolio.account,
) ?: return@transform null,
selectedNetwork = selectedNetwork,
availableMoreNetwork = !selectedPortfolio.account.isSingleNetwork,
@ -254,10 +256,12 @@ internal class AddToPortfolioModel @Inject constructor(
private suspend fun createCryptoCurrency(
userWallet: UserWallet,
network: TokenMarketInfo.Network,
account: AvailableToAddAccount,
): CryptoCurrency? = getTokenMarketCryptoCurrency(
userWalletId = userWallet.walletId,
tokenMarketParams = addToPortfolioManager.token,
network = network,
accountIndex = (account.account as? AccountStatus.CryptoPortfolio)?.account?.derivationIndex,
)
private fun routeToNetworkSelector(portfolio: SelectedPortfolio): AddToPortfolioRoutes.NetworkSelector {

View file

@ -66,12 +66,11 @@ internal class AddTokenModel @Inject constructor(
val blockchainNames = listOf(selectedNetwork.selectedNetwork)
.mapNotNull { BlockchainUtils.getNetworkInfo(it.networkId)?.name }
analyticsEventHandler.send(analyticsEventBuilder.addToPortfolioContinue(blockchainNames))
val cryptoCurrency = selectedNetwork.cryptoCurrency
val accountId = selectedPortfolio.account.account.account.accountId
manageCryptoCurrenciesUseCase(
accountId = accountId,
add = cryptoCurrency,
)
manageCryptoCurrenciesUseCase(accountId = accountId, add = cryptoCurrency)
val status = getAccountCurrencyStatusUseCase.invokeSync(
userWalletId = accountId.userWalletId,
currencyId = cryptoCurrency.id,