From 40ab262597a53be6720cc0ebcb09bb42d796669f Mon Sep 17 00:00:00 2001 From: antonijzelinskij Date: Fri, 2 Aug 2024 09:44:22 +0200 Subject: [PATCH] Fixed crash in your delegation --- build.gradle | 4 +-- .../v2/Gov2DelegationsRepository.kt | 30 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index e89b768888..b0db7f24e1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ buildscript { ext { // App version - versionName = '8.3.0' - versionCode = 148 + versionName = '8.3.1' + versionCode = 150 applicationId = "io.novafoundation.nova" releaseApplicationSuffix = "market" diff --git a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/repository/v2/Gov2DelegationsRepository.kt b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/repository/v2/Gov2DelegationsRepository.kt index a40f80c6d6..0c8e5130b0 100644 --- a/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/repository/v2/Gov2DelegationsRepository.kt +++ b/feature-governance-impl/src/main/java/io/novafoundation/nova/feature_governance_impl/data/repository/v2/Gov2DelegationsRepository.kt @@ -57,22 +57,28 @@ class Gov2DelegationsRepository( recentVotesBlockThreshold: BlockNumber, chain: Chain ): List { - val externalApiLink = chain.externalApi()?.url ?: return emptyList() - val request = DelegateStatsRequest(recentVotesBlockThreshold) - val response = delegationsSubqueryApi.getDelegateStats(externalApiLink, request) - val delegateStats = response.data.delegates.nodes + return runCatching { + val externalApiLink = chain.externalApi()?.url ?: return emptyList() + val request = DelegateStatsRequest(recentVotesBlockThreshold) + val response = delegationsSubqueryApi.getDelegateStats(externalApiLink, request) + val delegateStats = response.data.delegates.nodes - return mapDelegateStats(delegateStats, chain) + mapDelegateStats(delegateStats, chain) + }.getOrNull() + .orEmpty() } override suspend fun getDelegatesStatsByAccountIds(recentVotesBlockThreshold: BlockNumber, accountIds: List, chain: Chain): List { - val externalApiLink = chain.externalApi()?.url ?: return emptyList() - val addresses = accountIds.map { chain.addressOf(it) } - val request = DelegateStatsByAddressesRequest(recentVotesBlockThreshold, addresses = addresses) - val response = delegationsSubqueryApi.getDelegateStats(externalApiLink, request) - val delegateStats = response.data.delegates.nodes - - return mapDelegateStats(delegateStats, chain) + return runCatching { + val externalApiLink = chain.externalApi()?.url ?: return emptyList() + val addresses = accountIds.map { chain.addressOf(it) } + val request = DelegateStatsByAddressesRequest(recentVotesBlockThreshold, addresses = addresses) + val response = delegationsSubqueryApi.getDelegateStats(externalApiLink, request) + val delegateStats = response.data.delegates.nodes + + mapDelegateStats(delegateStats, chain) + }.getOrNull() + .orEmpty() } override suspend fun getDetailedDelegateStats(