Updated on 2026-08-14
This commit is contained in:
commit
f3dfb262c2
527 changed files with 12898 additions and 3301 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),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.blockchainsdk.utils
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.network.Network
|
||||
|
||||
/** Converts [Network] to [Blockchain] */
|
||||
|
|
@ -10,4 +11,8 @@ fun Network.toBlockchain(): Blockchain = id.toBlockchain()
|
|||
fun Network.ID.toBlockchain(): Blockchain = rawId.toBlockchain()
|
||||
|
||||
/** Converts [Network.RawID] to [Blockchain] */
|
||||
fun Network.RawID.toBlockchain(): Blockchain = Blockchain.fromId(id = value)
|
||||
fun Network.RawID.toBlockchain(): Blockchain = value.toBlockchain()
|
||||
|
||||
fun CryptoCurrency.ID.toBlockchain(): Blockchain = rawNetworkId.toBlockchain()
|
||||
|
||||
private fun String.toBlockchain(): Blockchain = Blockchain.fromNetworkId(this) ?: Blockchain.Unknown
|
||||
Loading…
Add table
Add a link
Reference in a new issue