From 4fcf0bfb06b3eda6cc0eb367764aa2267a56f79d Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Mon, 2 Oct 2023 15:21:47 +0200 Subject: [PATCH] fix(@desktop/communities): Catch all exceptions and use default values for non deployed tokens Fix #12315 --- .../service/community_tokens/async_tasks.nim | 21 ++++++++++++------- .../service/community_tokens/service.nim | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/app_service/service/community_tokens/async_tasks.nim b/src/app_service/service/community_tokens/async_tasks.nim index efbf4742f3..183c911147 100644 --- a/src/app_service/service/community_tokens/async_tasks.nim +++ b/src/app_service/service/community_tokens/async_tasks.nim @@ -265,15 +265,22 @@ const getCommunityTokensDetailsTaskArg: Task = proc(argEncoded: string) {.gcsafe proc createTokenItemJson(communityTokens: seq[CommunityTokenDto], tokenDto: CommunityTokenDto): JsonNode = try: - let remainingSupply = if tokenDto.infiniteSupply: - "0" - else: - getRemainingSupply(tokenDto.chainId, tokenDto.address) + var remainingSupply = tokenDto.supply.toString(10) + var burnState = ContractTransactionStatus.Completed + var remoteDestructedAddresses: seq[string] = @[] + var destructedAmount = "0" - let burnState = getCommunityTokenBurnState(tokenDto.chainId, tokenDto.address) - let remoteDestructedAddresses = getRemoteDestructedAddresses(tokenDto.chainId, tokenDto.address) + if tokenDto.deployState == DeployState.Deployed: + remainingSupply = + if tokenDto.infiniteSupply: + "0" + else: + getRemainingSupply(tokenDto.chainId, tokenDto.address) + + burnState = getCommunityTokenBurnState(tokenDto.chainId, tokenDto.address) + remoteDestructedAddresses = getRemoteDestructedAddresses(tokenDto.chainId, tokenDto.address) - let destructedAmount = getRemoteDestructedAmount(communityTokens, tokenDto.chainId, tokenDto.address) + destructedAmount = getRemoteDestructedAmount(communityTokens, tokenDto.chainId, tokenDto.address) return %* { "address": tokenDto.address, diff --git a/src/app_service/service/community_tokens/service.nim b/src/app_service/service/community_tokens/service.nim index a3c2bdea05..d94768a7f6 100644 --- a/src/app_service/service/community_tokens/service.nim +++ b/src/app_service/service/community_tokens/service.nim @@ -507,7 +507,7 @@ QtObject: communityTokens: communityTokens, communityTokenJsonItems: communityTokenJsonItems, )) - except RpcException as e: + except Exception as e: error "Error getting community tokens details", message = e.msg proc getAllCommunityTokensAsync*(self: Service) =