Updated on 2026-08-14
This commit is contained in:
parent
682349e353
commit
0e370ae05f
2 changed files with 22 additions and 17 deletions
|
|
@ -37,6 +37,8 @@ import com.tangem.domain.walletmanager.utils.WalletManagerFactory
|
|||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import timber.log.Timber
|
||||
import java.math.BigDecimal
|
||||
import java.util.EnumSet
|
||||
|
|
@ -61,6 +63,8 @@ class DefaultWalletManagersFacade(
|
|||
private val requirementsConditionConverter by lazy { SdkRequirementsConditionConverter() }
|
||||
private val estimationFeeAddressFactory by lazy { EstimationFeeAddressFactory() }
|
||||
|
||||
private val initMutex = Mutex()
|
||||
|
||||
override suspend fun update(
|
||||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
|
|
@ -329,24 +333,25 @@ class DefaultWalletManagersFacade(
|
|||
blockchain: Blockchain,
|
||||
derivationPath: String?,
|
||||
): WalletManager? {
|
||||
val userWallet = getUserWallet(userWalletId)
|
||||
var walletManager = walletManagersStore.getSyncOrNull(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
derivationPath = derivationPath,
|
||||
)
|
||||
|
||||
if (walletManager == null) {
|
||||
walletManager = walletManagerFactory.createWalletManager(
|
||||
scanResponse = userWallet.scanResponse,
|
||||
initMutex.withLock {
|
||||
val userWallet = getUserWallet(userWalletId)
|
||||
var walletManager = walletManagersStore.getSyncOrNull(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
derivationPath = derivationPath?.let { DerivationPath(rawPath = it) },
|
||||
) ?: return null
|
||||
derivationPath = derivationPath,
|
||||
)
|
||||
if (walletManager == null) {
|
||||
walletManager = walletManagerFactory.createWalletManager(
|
||||
scanResponse = userWallet.scanResponse,
|
||||
blockchain = blockchain,
|
||||
derivationPath = derivationPath?.let { DerivationPath(rawPath = it) },
|
||||
)
|
||||
walletManager ?: return null
|
||||
|
||||
walletManagersStore.store(userWalletId, walletManager)
|
||||
walletManagersStore.store(userWalletId, walletManager)
|
||||
}
|
||||
return walletManager
|
||||
}
|
||||
|
||||
return walletManager
|
||||
}
|
||||
|
||||
@Deprecated("Will be removed in future")
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ internal class DefaultBlockchainSDKFactory(
|
|||
dispatchers: CoroutineDispatcherProvider,
|
||||
) : BlockchainSDKFactory {
|
||||
|
||||
private val walletManagerFactory: Flow<WalletManagerFactory?> by lazy(::createWalletManagerFactory)
|
||||
|
||||
private val mainScope = CoroutineScope(dispatchers.main)
|
||||
|
||||
private val walletManagerFactory: Flow<WalletManagerFactory?> = createWalletManagerFactory()
|
||||
|
||||
override suspend fun init() {
|
||||
coroutineScope {
|
||||
updateBlockchainSDKConfig()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue