Updated on 2026-08-14
This commit is contained in:
parent
4570bc334c
commit
602e20a1d2
53 changed files with 489 additions and 368 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.blockchainsdk
|
||||
|
||||
import com.tangem.blockchain.assetsdiscovery.AssetsDiscoveryServiceFactory
|
||||
import com.tangem.blockchain.common.WalletManagerFactory
|
||||
import com.tangem.blockchain.common.memo.MemoValidatorFactory
|
||||
|
||||
|
|
@ -18,4 +19,7 @@ interface BlockchainSDKFactory {
|
|||
|
||||
/** Get [MemoValidatorFactory] synchronously */
|
||||
suspend fun getMemoValidatorFactorySync(): MemoValidatorFactory?
|
||||
|
||||
/** Get [AssetsDiscoveryServiceFactory] synchronously */
|
||||
suspend fun getAssetsDiscoveryServiceFactorySync(): AssetsDiscoveryServiceFactory?
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.blockchainsdk
|
||||
|
||||
import com.tangem.blockchain.assetsdiscovery.AssetsDiscoveryServiceFactory
|
||||
import com.tangem.blockchain.common.BlockchainSdkConfig
|
||||
import com.tangem.blockchain.common.WalletManagerFactory
|
||||
import com.tangem.blockchain.common.memo.MemoValidatorFactory
|
||||
|
|
@ -34,6 +35,8 @@ internal class DefaultBlockchainSDKFactory(
|
|||
|
||||
private val walletManagerFactory: Flow<WalletManagerFactory?> = createWalletManagerFactory()
|
||||
private val memoValidatorFactory: Flow<MemoValidatorFactory?> = createMemoValidatorFactory()
|
||||
private val assetsDiscoveryServiceFactory: Flow<AssetsDiscoveryServiceFactory?> =
|
||||
createAssetsDiscoveryServiceFactory()
|
||||
|
||||
override suspend fun init() {
|
||||
coroutineScope {
|
||||
|
|
@ -45,6 +48,9 @@ internal class DefaultBlockchainSDKFactory(
|
|||
|
||||
override suspend fun getMemoValidatorFactorySync(): MemoValidatorFactory? = memoValidatorFactory.firstOrNull()
|
||||
|
||||
override suspend fun getAssetsDiscoveryServiceFactorySync(): AssetsDiscoveryServiceFactory? =
|
||||
assetsDiscoveryServiceFactory.firstOrNull()
|
||||
|
||||
private fun createWalletManagerFactory(): Flow<WalletManagerFactory?> {
|
||||
return combine(
|
||||
flow = flowOf(blockchainSdkConfig),
|
||||
|
|
@ -56,6 +62,16 @@ internal class DefaultBlockchainSDKFactory(
|
|||
.stateIn(scope = mainScope, started = SharingStarted.Eagerly, initialValue = null)
|
||||
}
|
||||
|
||||
private fun createAssetsDiscoveryServiceFactory(): Flow<AssetsDiscoveryServiceFactory?> {
|
||||
return combine(
|
||||
flow = flowOf(blockchainSdkConfig),
|
||||
flow2 = blockchainProvidersTypesManager.get(),
|
||||
) { config, providerTypes ->
|
||||
AssetsDiscoveryServiceFactory(config = config, providerTypes = providerTypes)
|
||||
}
|
||||
.stateIn(scope = mainScope, started = SharingStarted.Eagerly, initialValue = null)
|
||||
}
|
||||
|
||||
private fun createMemoValidatorFactory(): Flow<MemoValidatorFactory?> {
|
||||
return combine(
|
||||
flow = flowOf(blockchainSdkConfig),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue