Updated on 2026-08-14
This commit is contained in:
parent
b280cd9e5e
commit
a0f6e4a008
6 changed files with 10 additions and 22 deletions
|
|
@ -297,9 +297,6 @@ abstract class TangemApplication : Application(), ImageLoaderFactory, Configurat
|
|||
appScope.launch {
|
||||
launch(Dispatchers.IO) {
|
||||
loadNativeLibraries()
|
||||
walletConnect2Repository.init(
|
||||
projectId = environmentConfigStorage.getConfigSync().walletConnectProjectId,
|
||||
)
|
||||
updateLogFiles()
|
||||
}
|
||||
}
|
||||
|
|
@ -323,6 +320,9 @@ abstract class TangemApplication : Application(), ImageLoaderFactory, Configurat
|
|||
)
|
||||
|
||||
appStateHolder.mainStore = store
|
||||
walletConnect2Repository.init(
|
||||
projectId = environmentConfigStorage.getConfigSync().walletConnectProjectId,
|
||||
)
|
||||
}
|
||||
|
||||
private fun createReduxStore(): Store<AppState> {
|
||||
|
|
|
|||
|
|
@ -45,10 +45,9 @@ internal class DefaultLegacyWalletConnectRepositoryFacade constructor(
|
|||
if (isNewWc) stub.currentSessions else legacy.currentSessions
|
||||
}
|
||||
|
||||
override suspend fun init(projectId: String) {
|
||||
override fun init(projectId: String) {
|
||||
if (isNewWc) {
|
||||
stub.init(projectId)
|
||||
wcInitializeUseCase.init() // TODO(wc) Nikolai: Delete after RoutingComponent finished.
|
||||
wcInitializeUseCase.init(projectId)
|
||||
} else {
|
||||
legacy.init(projectId)
|
||||
}
|
||||
|
|
@ -96,7 +95,7 @@ internal class LegacyWalletConnectRepositoryStub : LegacyWalletConnectRepository
|
|||
override val activeSessions: Flow<List<WalletConnectSession>> = emptyFlow()
|
||||
override val currentSessions: List<WalletConnectSession> = listOf()
|
||||
|
||||
override suspend fun init(projectId: String) = Unit
|
||||
override fun init(projectId: String) = Unit
|
||||
|
||||
override fun setUserNamespaces(userNamespaces: Map<NetworkNamespace, List<Account>>) = Unit
|
||||
|
||||
|
|
@ -141,7 +140,7 @@ internal class DefaultLegacyWalletConnectRepository(
|
|||
/**
|
||||
* @param projectId Project ID at https://cloud.walletconnect.com/
|
||||
*/
|
||||
override suspend fun init(projectId: String) {
|
||||
override fun init(projectId: String) {
|
||||
val relayUrl = "relay.walletconnect.com"
|
||||
val serverUrl = "wss://$relayUrl?projectId=$projectId"
|
||||
val connectionType = ConnectionType.AUTOMATIC
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ interface LegacyWalletConnectRepository {
|
|||
|
||||
val currentSessions: List<WalletConnectSession>
|
||||
|
||||
suspend fun init(projectId: String)
|
||||
fun init(projectId: String)
|
||||
|
||||
fun setUserNamespaces(userNamespaces: Map<NetworkNamespace, List<Account>>)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import com.tangem.data.walletconnect.respond.WcRespondService
|
|||
import com.tangem.data.walletconnect.sessions.DefaultWcSessionsManager
|
||||
import com.tangem.data.walletconnect.utils.WcNamespaceConverter
|
||||
import com.tangem.datasource.di.SdkMoshi
|
||||
import com.tangem.datasource.local.config.environment.EnvironmentConfigStorage
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.datasource.local.walletconnect.WalletConnectStore
|
||||
import com.tangem.domain.tokens.repository.CurrenciesRepository
|
||||
|
|
@ -61,15 +60,11 @@ internal object WalletConnectDataModule {
|
|||
sessionsManager: DefaultWcSessionsManager,
|
||||
networkService: DefaultWcRequestService,
|
||||
pairSdkDelegate: WcPairSdkDelegate,
|
||||
environmentConfigStorage: EnvironmentConfigStorage,
|
||||
dispatchers: CoroutineDispatcherProvider,
|
||||
): WcInitializeUseCase = DefaultWcInitializeUseCase(
|
||||
application = application,
|
||||
sessionsManager = sessionsManager,
|
||||
networkService = networkService,
|
||||
pairSdkDelegate = pairSdkDelegate,
|
||||
environmentConfigStorage = environmentConfigStorage,
|
||||
dispatchers = dispatchers,
|
||||
)
|
||||
|
||||
@Provides
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ import com.tangem.data.walletconnect.pair.WcPairSdkDelegate
|
|||
import com.tangem.data.walletconnect.request.DefaultWcRequestService
|
||||
import com.tangem.data.walletconnect.sessions.DefaultWcSessionsManager
|
||||
import com.tangem.data.walletconnect.utils.WcSdkObserver
|
||||
import com.tangem.datasource.local.config.environment.EnvironmentConfigStorage
|
||||
import com.tangem.domain.walletconnect.usecase.initialize.WcInitializeUseCase
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
|
||||
internal class DefaultWcInitializeUseCase(
|
||||
|
|
@ -21,8 +18,6 @@ internal class DefaultWcInitializeUseCase(
|
|||
private val sessionsManager: DefaultWcSessionsManager,
|
||||
private val networkService: DefaultWcRequestService,
|
||||
private val pairSdkDelegate: WcPairSdkDelegate,
|
||||
private val environmentConfigStorage: EnvironmentConfigStorage,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
) : WcInitializeUseCase {
|
||||
|
||||
private val wcSdkObservers = mutableSetOf<WcSdkObserver>(
|
||||
|
|
@ -31,8 +26,7 @@ internal class DefaultWcInitializeUseCase(
|
|||
pairSdkDelegate,
|
||||
)
|
||||
|
||||
override suspend fun init() = withContext(dispatchers.io) {
|
||||
val projectId = environmentConfigStorage.getConfigSync().walletConnectProjectId
|
||||
override fun init(projectId: String) {
|
||||
val relayUrl = "relay.walletconnect.com"
|
||||
val serverUrl = "wss://$relayUrl?projectId=$projectId"
|
||||
val connectionType = ConnectionType.AUTOMATIC
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
package com.tangem.domain.walletconnect.usecase.initialize
|
||||
|
||||
interface WcInitializeUseCase {
|
||||
suspend fun init()
|
||||
fun init(projectId: String)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue