Updated on 2026-08-14

This commit is contained in:
Tangem 2025-03-19 13:24:37 +05:00
parent 06d435a58f
commit d4fe3896f3
10 changed files with 102 additions and 41 deletions

View file

@ -682,6 +682,12 @@ class DefaultWalletManagersFacade(
return walletManager.getAsset(collectionIdentifier, assetIdentifier)
}
override suspend fun isAccountInitialized(userWalletId: UserWalletId, network: Network): Boolean {
val walletManager = getOrCreateWalletManager(userWalletId = userWalletId, network = network)
val initializableAccountWalletManger = walletManager as? InitializableAccount ?: return false
return initializableAccountWalletManger.accountInitializationState == InitializableAccount.State.INITIALIZED
}
private fun updateWalletManagerTokensIfNeeded(walletManager: WalletManager, tokens: Set<CryptoCurrency.Token>) {
if (tokens.isEmpty()) return

View file

@ -265,4 +265,10 @@ interface WalletManagersFacade {
collectionIdentifier: NFTCollection.Identifier,
assetIdentifier: NFTAsset.Identifier,
): NFTAsset?
/**
* If wallet manager implements [InitializableAccount] then returns [InitializableAccount.isAccountInitialized]
* value. Otherwise always return true
*/
suspend fun isAccountInitialized(userWalletId: UserWalletId, network: Network): Boolean
}

View file

@ -18,6 +18,7 @@ dependencies {
implementation(deps.kotlin.serialization)
implementation(deps.jodatime)
implementation(projects.domain.legacy)
implementation(projects.domain.tokens.models)
implementation(projects.domain.wallets.models)

View file

@ -0,0 +1,13 @@
package com.tangem.domain.staking
import arrow.core.Either
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.walletmanager.WalletManagersFacade
import com.tangem.domain.wallets.models.UserWalletId
class CheckAccountInitializedUseCase(private val walletManagersFacade: WalletManagersFacade) {
suspend operator fun invoke(userWalletId: UserWalletId, network: Network): Either<Throwable, Boolean> {
return Either.catch { walletManagersFacade.isAccountInitialized(userWalletId, network) }
}
}