diff --git a/data/wallet-connect/build.gradle.kts b/data/wallet-connect/build.gradle.kts index bed46fd58b..b7fd3d93a1 100644 --- a/data/wallet-connect/build.gradle.kts +++ b/data/wallet-connect/build.gradle.kts @@ -12,6 +12,8 @@ android { dependencies { /* Project - Domain */ + implementation(projects.domain.account) + implementation(projects.domain.account.status) implementation(projects.domain.walletConnect) implementation(projects.domain.walletConnect.models) implementation(projects.domain.transaction) diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/di/WalletConnectDataModule.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/di/WalletConnectDataModule.kt index 780142a298..3a7c5c209d 100644 --- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/di/WalletConnectDataModule.kt +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/di/WalletConnectDataModule.kt @@ -21,6 +21,9 @@ import com.tangem.data.walletconnect.utils.WcScope import com.tangem.datasource.di.SdkMoshi import com.tangem.datasource.local.userwallet.UserWalletsStore import com.tangem.datasource.local.walletconnect.WalletConnectStore +import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles +import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier +import com.tangem.domain.account.supplier.MultiAccountListSupplier import com.tangem.domain.tokens.MultiWalletCryptoCurrenciesSupplier import com.tangem.domain.walletconnect.WcPairService import com.tangem.domain.walletconnect.WcRequestService @@ -92,6 +95,7 @@ internal object WalletConnectDataModule { getWallets: GetWalletsUseCase, wcNetworksConverter: WcNetworksConverter, analytics: AnalyticsEventHandler, + accountsFeatureToggles: AccountsFeatureToggles, wcScope: WcScope, ): DefaultWcSessionsManager { return DefaultWcSessionsManager( @@ -100,6 +104,7 @@ internal object WalletConnectDataModule { getWallets = getWallets, wcNetworksConverter = wcNetworksConverter, analytics = analytics, + accountsFeatureToggles = accountsFeatureToggles, scope = wcScope, ) } @@ -179,22 +184,24 @@ internal object WalletConnectDataModule { namespaceConverters: Set<@JvmSuppressWildcards WcNamespaceConverter>, walletManagersFacade: WalletManagersFacade, multiWalletCryptoCurrenciesSupplier: MultiWalletCryptoCurrenciesSupplier, + singleAccountStatusListSupplier: SingleAccountStatusListSupplier, ): WcNetworksConverter = WcNetworksConverter( namespaceConverters = namespaceConverters, walletManagersFacade = walletManagersFacade, + singleAccountStatusListSupplier = singleAccountStatusListSupplier, multiWalletCryptoCurrenciesSupplier = multiWalletCryptoCurrenciesSupplier, ) @Provides @Singleton fun associateNetworksDelegate( - namespaceConverters: Set<@JvmSuppressWildcards WcNamespaceConverter>, + networksConverter: WcNetworksConverter, + multiAccountListSupplier: MultiAccountListSupplier, getWallets: GetWalletsUseCase, - multiWalletCryptoCurrenciesSupplier: MultiWalletCryptoCurrenciesSupplier, ): AssociateNetworksDelegate = AssociateNetworksDelegate( - namespaceConverters = namespaceConverters, getWallets = getWallets, - multiWalletCryptoCurrenciesSupplier = multiWalletCryptoCurrenciesSupplier, + networksConverter = networksConverter, + multiAccountListSupplier = multiAccountListSupplier, ) @Provides diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/AssociateNetworksDelegate.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/AssociateNetworksDelegate.kt index 705efb5df5..bd17a27eae 100644 --- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/AssociateNetworksDelegate.kt +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/AssociateNetworksDelegate.kt @@ -2,22 +2,25 @@ package com.tangem.data.walletconnect.pair import com.reown.walletkit.client.Wallet import com.reown.walletkit.client.Wallet.Model.Namespace -import com.tangem.data.walletconnect.utils.WcNamespaceConverter -import com.tangem.domain.models.currency.CryptoCurrency +import com.tangem.data.walletconnect.utils.WcNetworksConverter +import com.tangem.domain.account.supplier.MultiAccountListSupplier +import com.tangem.domain.models.account.Account +import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.network.Network import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId +import com.tangem.domain.models.wallet.isLocked import com.tangem.domain.models.wallet.isMultiCurrency -import com.tangem.domain.tokens.MultiWalletCryptoCurrenciesProducer -import com.tangem.domain.tokens.MultiWalletCryptoCurrenciesSupplier import com.tangem.domain.walletconnect.model.WcPairError import com.tangem.domain.walletconnect.model.WcSessionProposal.ProposalNetwork import com.tangem.domain.wallets.usecase.GetWalletsUseCase +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.first internal class AssociateNetworksDelegate( - private val namespaceConverters: Set, + private val networksConverter: WcNetworksConverter, + private val multiAccountListSupplier: MultiAccountListSupplier, private val getWallets: GetWalletsUseCase, - private val multiWalletCryptoCurrenciesSupplier: MultiWalletCryptoCurrenciesSupplier, ) { @Throws(WcPairError.UnsupportedBlockchains::class) @@ -29,18 +32,48 @@ internal class AssociateNetworksDelegate( .subtract(requiredNamespaces) return userWallets.associateWith { wallet -> - mapNetworksForWallet(wallet, requiredNamespaces, optionalNamespaces, sessionProposal) + mapNetworksForPortfolio(wallet, null, requiredNamespaces, optionalNamespaces, sessionProposal) } } + @Throws(WcPairError.UnsupportedBlockchains::class) + suspend fun associateAccounts(sessionProposal: Wallet.Model.SessionProposal): Map { + val userWallets = getWallets.invokeSync() + .filter { it.isMultiCurrency && !it.isLocked } + val requiredNamespaces: Set = sessionProposal.requiredNamespaces.setOfChainId() + val optionalNamespaces: Set = sessionProposal.optionalNamespaces.setOfChainId() + // remove duplicates + .subtract(requiredNamespaces) + val allAccounts = multiAccountListSupplier.invoke() + .filter { it.isNotEmpty() } + .first() + .filter { accountList -> userWallets.any { accountList.userWalletId == it.walletId } } + .map { accountList -> accountList to userWallets.first { it.walletId == accountList.userWalletId } } + + return allAccounts + .map { (accountList, wallet) -> accountList.accounts.map { account -> account to wallet } } + .flatten() + .associate { (account, wallet) -> + account.accountId to mapNetworksForPortfolio( + wallet = wallet, + account = account, + requiredNamespaces = requiredNamespaces, + optionalNamespaces = optionalNamespaces, + sessionProposal = sessionProposal, + ) + } + } + @Suppress("ComplexCondition") - private suspend fun mapNetworksForWallet( + private suspend fun mapNetworksForPortfolio( wallet: UserWallet, + account: Account?, requiredNamespaces: Set, optionalNamespaces: Set, sessionProposal: Wallet.Model.SessionProposal, ): ProposalNetwork { - val walletNetworks = getWalletNetworks(userWalletId = wallet.walletId) + val portfolioNetworks = account?.let { getAccountNetworks(it.accountId) } + ?: getWalletNetworks(userWalletId = wallet.walletId) val unknownRequired = mutableSetOf() val unknownOptional = mutableSetOf() @@ -50,28 +83,28 @@ internal class AssociateNetworksDelegate( val notAdded = mutableSetOf() requiredNamespaces.forEach { chainId -> - val wcNetwork = namespaceConverters.firstNotNullOfOrNull { it.toNetwork(chainId, wallet) } + val wcNetwork = networksConverter.createNetwork(chainId, wallet) if (wcNetwork == null) { unknownRequired.add(missingNetworkName(chainId)) return@forEach } - val walletNetwork = walletNetworks.find { network -> wcNetwork.rawId == network.rawId } + val portfolioNetwork = portfolioNetworks.find { network -> wcNetwork.rawId == network.rawId } - if (walletNetwork == null) { + if (portfolioNetwork == null) { missingRequired.add(wcNetwork) } else { - required.add(walletNetwork) + required.add(portfolioNetwork) } } optionalNamespaces.forEach { chainId -> - val wcNetwork = namespaceConverters.firstNotNullOfOrNull { it.toNetwork(chainId, wallet) } + val wcNetwork = networksConverter.createNetwork(chainId, wallet) if (wcNetwork == null) { unknownOptional.add(missingNetworkName(chainId)) return@forEach } - val walletNetwork = walletNetworks.find { network -> wcNetwork.rawId == network.rawId } - if (walletNetwork != null) { - available.add(walletNetwork) + val portfolioNetwork = portfolioNetworks.find { network -> wcNetwork.rawId == network.rawId } + if (portfolioNetwork != null) { + available.add(portfolioNetwork) } else { notAdded.add(wcNetwork) } @@ -88,16 +121,18 @@ internal class AssociateNetworksDelegate( required = required, available = available, notAdded = notAdded, + account = account, ) } private suspend fun getWalletNetworks(userWalletId: UserWalletId): List { - return multiWalletCryptoCurrenciesSupplier.getSyncOrNull( - params = MultiWalletCryptoCurrenciesProducer.Params(userWalletId = userWalletId), - ) - .orEmpty() - .filterIsInstance() - .map(CryptoCurrency.Coin::network) + return networksConverter.getWalletNetworks(userWalletId) + // flatten all derivation + .distinctBy { it.rawId } + } + + private suspend fun getAccountNetworks(accountId: AccountId): List { + return networksConverter.getAccountNetworks(accountId) // flatten all derivation .distinctBy { it.rawId } } diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/DefaultWcPairUseCase.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/DefaultWcPairUseCase.kt index 529f7a9302..d060e85384 100644 --- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/DefaultWcPairUseCase.kt +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/DefaultWcPairUseCase.kt @@ -10,6 +10,7 @@ import com.reown.walletkit.client.Wallet import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.data.walletconnect.utils.WC_TAG import com.tangem.data.walletconnect.utils.getDappOriginUrl +import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles import com.tangem.domain.blockaid.BlockAidVerifier import com.tangem.domain.walletconnect.WcAnalyticEvents import com.tangem.domain.walletconnect.model.* @@ -34,6 +35,7 @@ internal class DefaultWcPairUseCase @AssistedInject constructor( private val sdkDelegate: WcPairSdkDelegate, private val blockAidVerifier: BlockAidVerifier, private val analytics: AnalyticsEventHandler, + private val accountsFeatureToggles: AccountsFeatureToggles, @Assisted private val pairRequest: WcPairRequest, ) : WcPairUseCase { @@ -111,6 +113,7 @@ internal class DefaultWcPairUseCase @AssistedInject constructor( val sessionDTO = WcSessionDTO( topic = "", walletId = sessionForApprove.wallet.walletId, + accountId = sessionForApprove.account?.accountId, url = sdkVerifyContext.getDappOriginUrl(), securityStatus = proposalState.dAppSession.securityStatus, connectingTime = connectingTime, @@ -196,6 +199,11 @@ internal class DefaultWcPairUseCase @AssistedInject constructor( verifyContext: Wallet.Model.VerifyContext, ): Either = runCatching { val proposalNetwork = associateNetworksDelegate.associate(sessionProposal) + val proposalAccountNetwork = if (accountsFeatureToggles.isFeatureEnabled) { + associateNetworksDelegate.associateAccounts(sessionProposal) + } else { + null + } val verificationInfo = when { verifyContext.validation == Wallet.Model.Validation.INVALID -> CheckDAppResult.UNSAFE verifyContext.isScam == true -> CheckDAppResult.UNSAFE @@ -204,7 +212,7 @@ internal class DefaultWcPairUseCase @AssistedInject constructor( CheckDAppResult.FAILED_TO_VERIFY } } - val requestedNetworks = proposalNetwork + val requestedNetworks = (proposalAccountNetwork ?: proposalNetwork) .values.map { it.available.plus(it.required) }.flatten().toSet() analytics.send( WcAnalyticEvents.PairRequested( @@ -225,6 +233,7 @@ internal class DefaultWcPairUseCase @AssistedInject constructor( dAppMetaData = appMetaData, proposalNetwork = proposalNetwork, securityStatus = verificationInfo, + proposalAccountNetwork = proposalAccountNetwork, ) WcPairState.Proposal(dAppSession) }.fold( diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sessions/DefaultWcSessionsManager.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sessions/DefaultWcSessionsManager.kt index 6786e8a318..659e65de2d 100644 --- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sessions/DefaultWcSessionsManager.kt +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sessions/DefaultWcSessionsManager.kt @@ -8,6 +8,7 @@ import com.reown.walletkit.client.WalletKit import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.data.walletconnect.utils.* import com.tangem.datasource.local.walletconnect.WalletConnectStore +import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.walletconnect.WcAnalyticEvents import com.tangem.domain.walletconnect.model.WcSession @@ -31,6 +32,7 @@ internal class DefaultWcSessionsManager( private val dispatchers: CoroutineDispatcherProvider, private val wcNetworksConverter: WcNetworksConverter, private val analytics: AnalyticsEventHandler, + private val accountsFeatureToggles: AccountsFeatureToggles, private val scope: WcScope, ) : WcSessionsManager, WcSdkObserver { @@ -90,7 +92,11 @@ internal class DefaultWcSessionsManager( val wcSessions = savedPending.plus(inStore).mapNotNull { storeSession -> val wallet = wallets.find { it.walletId == storeSession.walletId } ?: return@mapNotNull null val sdkSession = inSdk.find { it.topic == storeSession.topic } ?: return@mapNotNull null - val networks = wcNetworksConverter.findWalletNetworks(wallet, sdkSession) + val account = storeSession.accountId?.let { wcNetworksConverter.getAccount(it) } + if (accountsFeatureToggles.isFeatureEnabled && account == null) { + return@mapNotNull null + } + val networks = wcNetworksConverter.findWalletNetworks(wallet, account, sdkSession) val originUrl = storeSession.url ?: sdkSession.metaData?.url ?: "" WcSession( wallet = wallet, @@ -102,6 +108,7 @@ internal class DefaultWcSessionsManager( ), securityStatus = storeSession.securityStatus, networks = networks, + account = account, connectingTime = storeSession.connectingTime, showWalletInfo = wallets.size > 1, ) diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/utils/WcNetworksConverter.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/utils/WcNetworksConverter.kt index 9d998db372..ced2f6ecdb 100644 --- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/utils/WcNetworksConverter.kt +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/utils/WcNetworksConverter.kt @@ -3,6 +3,11 @@ package com.tangem.data.walletconnect.utils import com.reown.walletkit.client.Wallet import com.tangem.data.common.currency.isCustomCoin import com.tangem.data.walletconnect.model.CAIP10 +import com.tangem.domain.account.status.producer.SingleAccountStatusListProducer +import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier +import com.tangem.domain.models.account.Account +import com.tangem.domain.models.account.AccountId +import com.tangem.domain.models.account.AccountStatus import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.network.Network import com.tangem.domain.models.wallet.UserWallet @@ -18,6 +23,7 @@ import javax.inject.Inject internal class WcNetworksConverter @Inject constructor( private val namespaceConverters: Set, private val walletManagersFacade: WalletManagersFacade, + private val singleAccountStatusListSupplier: SingleAccountStatusListSupplier, private val multiWalletCryptoCurrenciesSupplier: MultiWalletCryptoCurrenciesSupplier, ) { @@ -67,8 +73,13 @@ internal class WcNetworksConverter @Inject constructor( return allCoinNetwork } - suspend fun findWalletNetworks(wallet: UserWallet, sdkSession: Wallet.Model.Session): Set { - val walletNetworks = getWalletNetworks(wallet.walletId) + suspend fun findWalletNetworks( + wallet: UserWallet, + account: Account?, + sdkSession: Wallet.Model.Session, + ): Set { + val portfolioNetworks = account?.let { getAccountNetworks(it.accountId) } + ?: getWalletNetworks(wallet.walletId) val existNetworks = sdkSession.namespaces.values .map { it.accounts }.flatten().toSet() .mapNotNull { CAIP10.fromRaw(it) } @@ -76,7 +87,7 @@ internal class WcNetworksConverter @Inject constructor( val blockchain = namespaceConverters .firstNotNullOfOrNull { it.toBlockchain(caip10.chainId) } ?: return@mapNotNullTo null - walletNetworks + portfolioNetworks // find all derivation .filter { it.rawId == blockchain.id } // find equal address @@ -89,18 +100,38 @@ internal class WcNetworksConverter @Inject constructor( return existNetworks } + suspend fun getAccount(accountId: AccountId): Account? { + return getAccountStatus(accountId)?.account + } + suspend fun convertNetworksForApprove(sessionForApprove: WcSessionApprove): List { - val walletNetworks = getWalletNetworks(sessionForApprove.wallet.walletId) + val portfolioNetworks = sessionForApprove.account?.let { getAccountNetworks(it.accountId) } + ?: getWalletNetworks(sessionForApprove.wallet.walletId) return sessionForApprove.network - .map { network -> walletNetworks.filter { walletNetwork -> walletNetwork.rawId == network.rawId } } + .map { network -> portfolioNetworks.filter { walletNetwork -> walletNetwork.rawId == network.rawId } } .flatten() } - private suspend fun getWalletNetworks(userWalletId: UserWalletId): List { + suspend fun getWalletNetworks(userWalletId: UserWalletId): List { return multiWalletCryptoCurrenciesSupplier.getSyncOrNull( params = MultiWalletCryptoCurrenciesProducer.Params(userWalletId = userWalletId), ) .orEmpty() .filterIsInstance().map(CryptoCurrency.Coin::network) } + + private suspend fun getAccountStatus(accountId: AccountId): AccountStatus? { + return singleAccountStatusListSupplier.getSyncOrNull( + SingleAccountStatusListProducer.Params(accountId.userWalletId), + )?.accountStatuses?.find { it.account.accountId == accountId } + } + + suspend fun getAccountNetworks(accountId: AccountId): List { + return getAccountStatus(accountId) + ?.flattenCurrencies() + ?.map { it.currency } + ?.filterIsInstance() + ?.map(CryptoCurrency.Coin::network) + ?: emptyList() + } } \ No newline at end of file diff --git a/data/wallet-connect/src/test/kotlin/com/tangem/domain/walletconnect/DefaultWcPairUseCaseTest.kt b/data/wallet-connect/src/test/kotlin/com/tangem/domain/walletconnect/DefaultWcPairUseCaseTest.kt index 60a4fe2b99..6313e3ddf4 100644 --- a/data/wallet-connect/src/test/kotlin/com/tangem/domain/walletconnect/DefaultWcPairUseCaseTest.kt +++ b/data/wallet-connect/src/test/kotlin/com/tangem/domain/walletconnect/DefaultWcPairUseCaseTest.kt @@ -14,9 +14,13 @@ import com.tangem.data.walletconnect.pair.CaipNamespaceDelegate import com.tangem.data.walletconnect.pair.DefaultWcPairUseCase import com.tangem.data.walletconnect.pair.WcPairSdkDelegate import com.tangem.data.walletconnect.utils.WcSdkSessionConverter +import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles import com.tangem.domain.blockaid.BlockAidVerifier import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.domain.walletconnect.model.* +import com.tangem.domain.walletconnect.model.WcPairError +import com.tangem.domain.walletconnect.model.WcPairRequest +import com.tangem.domain.walletconnect.model.WcSession +import com.tangem.domain.walletconnect.model.WcSessionApprove import com.tangem.domain.walletconnect.usecase.pair.WcPairState import io.mockk.coEvery import io.mockk.coVerifyOrder @@ -33,6 +37,7 @@ internal class DefaultWcPairUseCaseTest { private val analytics: AnalyticsEventHandler = mockk(relaxed = true) private val sdkDelegate: WcPairSdkDelegate = mockk() private val blockAidVerifier: BlockAidVerifier = mockk() + private val accountsFeatureToggles = mockk() private val url = "testUrl" private val source = WcPairRequest.Source.QR @@ -70,6 +75,7 @@ internal class DefaultWcPairUseCaseTest { get() = WcSessionApprove( wallet = MockUserWalletFactory.create(), network = listOf(), + account = null, ) private val sdkApprove: Wallet.Params.SessionApprove @@ -102,6 +108,7 @@ internal class DefaultWcPairUseCaseTest { networks = setOf(), connectingTime = null, showWalletInfo = false, + account = null, ) private fun useCaseFactory() = DefaultWcPairUseCase( @@ -110,12 +117,14 @@ internal class DefaultWcPairUseCaseTest { sdkDelegate = sdkDelegate, blockAidVerifier = blockAidVerifier, analytics = analytics, + accountsFeatureToggles = accountsFeatureToggles, pairRequest = WcPairRequest(userWalletId = UserWalletId(""), uri = url, source = source), ) @Before fun setup() { coEvery { associateNetworksDelegate.associate(sdkProposal) } returns mapOf() + coEvery { accountsFeatureToggles.isFeatureEnabled } returns false coEvery { caipNamespaceDelegate.associate( sessionProposal = sdkProposal, diff --git a/data/wallet-connect/src/test/kotlin/com/tangem/domain/walletconnect/WcSignUseCaseDelegateTest.kt b/data/wallet-connect/src/test/kotlin/com/tangem/domain/walletconnect/WcSignUseCaseDelegateTest.kt index 15049820a7..d703676123 100644 --- a/data/wallet-connect/src/test/kotlin/com/tangem/domain/walletconnect/WcSignUseCaseDelegateTest.kt +++ b/data/wallet-connect/src/test/kotlin/com/tangem/domain/walletconnect/WcSignUseCaseDelegateTest.kt @@ -58,6 +58,7 @@ internal class WcSignUseCaseDelegateTest { session = WcSession( wallet = MockUserWalletFactory.create(), networks = setOf(), + account = null, securityStatus = CheckDAppResult.FAILED_TO_VERIFY, connectingTime = 0L, sdkModel = WcSdkSession( diff --git a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSession.kt b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSession.kt index 7931afed92..49ae45531a 100644 --- a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSession.kt +++ b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSession.kt @@ -1,12 +1,14 @@ package com.tangem.domain.walletconnect.model import com.domain.blockaid.models.dapp.CheckDAppResult +import com.tangem.domain.models.account.Account import com.tangem.domain.models.network.Network import com.tangem.domain.walletconnect.model.sdkcopy.WcSdkSession import com.tangem.domain.models.wallet.UserWallet data class WcSession( val wallet: UserWallet, + val account: Account?, val networks: Set, val sdkModel: WcSdkSession, val securityStatus: CheckDAppResult, diff --git a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionApprove.kt b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionApprove.kt index 1122347614..e55e69f940 100644 --- a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionApprove.kt +++ b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionApprove.kt @@ -1,9 +1,11 @@ package com.tangem.domain.walletconnect.model +import com.tangem.domain.models.account.Account import com.tangem.domain.models.network.Network import com.tangem.domain.models.wallet.UserWallet data class WcSessionApprove( val wallet: UserWallet, + val account: Account?, val network: List, ) \ No newline at end of file diff --git a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionDTO.kt b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionDTO.kt index 15ccc11fc1..eaee191c92 100644 --- a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionDTO.kt +++ b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionDTO.kt @@ -2,12 +2,14 @@ package com.tangem.domain.walletconnect.model import com.domain.blockaid.models.dapp.CheckDAppResult import com.squareup.moshi.JsonClass +import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.wallet.UserWalletId @JsonClass(generateAdapter = true) data class WcSessionDTO( val topic: String, val walletId: UserWalletId, + val accountId: AccountId? = null, val url: String?, val securityStatus: CheckDAppResult = CheckDAppResult.FAILED_TO_VERIFY, val connectingTime: Long? = null, diff --git a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionProposal.kt b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionProposal.kt index c6d611f166..dbec25e6d2 100644 --- a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionProposal.kt +++ b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSessionProposal.kt @@ -1,18 +1,22 @@ package com.tangem.domain.walletconnect.model import com.domain.blockaid.models.dapp.CheckDAppResult +import com.tangem.domain.models.account.Account +import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.network.Network -import com.tangem.domain.walletconnect.model.sdkcopy.WcAppMetaData import com.tangem.domain.models.wallet.UserWallet +import com.tangem.domain.walletconnect.model.sdkcopy.WcAppMetaData data class WcSessionProposal( val dAppMetaData: WcAppMetaData, val proposalNetwork: Map, + val proposalAccountNetwork: Map?, val securityStatus: CheckDAppResult, ) { data class ProposalNetwork( val wallet: UserWallet, + val account: Account?, val missingRequired: Set, val required: Set, val available: Set, diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt index 7cc617b264..c0ac9da317 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt @@ -186,6 +186,7 @@ internal class WcPairModel @Inject constructor( WcSessionApprove( wallet = selectedUserWalletFlow.value, network = enabledAvailableNetworks + proposalNetwork.required, + account = null, // todo account ), ) }