Updated on 2026-08-14
This commit is contained in:
parent
f349d39c5d
commit
7ce088145c
2 changed files with 26 additions and 11 deletions
|
|
@ -133,11 +133,29 @@ internal class DefaultLegacyWalletConnectRepository(
|
|||
return
|
||||
}
|
||||
|
||||
val optionalMissingNetwork = findMissingNetworks(
|
||||
namespaces = sessionProposal.optionalNamespaces,
|
||||
userNamespaces = this@DefaultLegacyWalletConnectRepository.userNamespaces ?: emptyMap(),
|
||||
)
|
||||
|
||||
val optionalWithoutMissingNetworks = removeMissingNetworks(
|
||||
namespaces = sessionProposal.optionalNamespaces,
|
||||
userNamespaces = this@DefaultLegacyWalletConnectRepository.userNamespaces ?: emptyMap(),
|
||||
)
|
||||
|
||||
// for cases when optionalNamespaces is not empty but we doesn't support none of them
|
||||
if (optionalMissingNetwork.isNotEmpty() && optionalWithoutMissingNetworks.isEmpty()) {
|
||||
Timber.i("Not added optional blockchains: $optionalMissingNetwork")
|
||||
scope.launch {
|
||||
_events.emit(
|
||||
WalletConnectEvents.SessionApprovalError(
|
||||
WalletConnectError.ApprovalErrorMissingNetworks(optionalMissingNetwork.toList()),
|
||||
),
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
val requiredChainIds = sessionProposal.requiredNamespaces.values.flatMap { it.chains ?: emptyList() }
|
||||
val optionalChainIds = optionalWithoutMissingNetworks.toList()
|
||||
val networks = (requiredChainIds + optionalChainIds)
|
||||
|
|
|
|||
|
|
@ -149,21 +149,18 @@ class WalletConnectInteractor(
|
|||
Timber.i("WalletConnect: event: $wcEvent")
|
||||
when (wcEvent) {
|
||||
is WalletConnectEvents.SessionProposal -> {
|
||||
val unsupportedNetworks = wcEvent.requiredChainIds.filter {
|
||||
blockchainHelper.chainIdToNetworkIdOrNull(it) == null
|
||||
}
|
||||
|
||||
val supportedNetworks = (wcEvent.requiredChainIds + wcEvent.optionalChainIds)
|
||||
.mapNotNull(blockchainHelper::chainIdToFullNameOrNull)
|
||||
.distinct()
|
||||
|
||||
if (unsupportedNetworks.isNotEmpty() || supportedNetworks.isEmpty()) {
|
||||
val unsupportedNetworks = wcEvent.requiredChainIds
|
||||
.filter { blockchainHelper.chainIdToNetworkIdOrNull(it) == null }
|
||||
if (unsupportedNetworks.isNotEmpty()) {
|
||||
val error = WalletConnectError.ApprovalErrorUnsupportedNetwork(unsupportedNetworks)
|
||||
handler.onSessionRejected(error)
|
||||
return@onEach
|
||||
}
|
||||
|
||||
handler.onProposalReceived(proposal = wcEvent, networksFormatted = supportedNetworks.toString())
|
||||
val networksFormatted = (wcEvent.requiredChainIds + wcEvent.optionalChainIds)
|
||||
.mapNotNull { blockchainHelper.chainIdToFullNameOrNull(it) }
|
||||
.distinct()
|
||||
.toString()
|
||||
handler.onProposalReceived(proposal = wcEvent, networksFormatted = networksFormatted)
|
||||
}
|
||||
is WalletConnectEvents.SessionApprovalError -> {
|
||||
val error = when (wcEvent.error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue