fix(@desktop/communities): Catch all exceptions and use default values for non deployed tokens

Fix #12315
This commit is contained in:
Michal Iskierko 2023-10-02 15:21:47 +02:00 committed by Michał Iskierko
parent 4d3d13a3f5
commit 4fcf0bfb06
2 changed files with 15 additions and 8 deletions

View File

@ -265,15 +265,22 @@ const getCommunityTokensDetailsTaskArg: Task = proc(argEncoded: string) {.gcsafe
proc createTokenItemJson(communityTokens: seq[CommunityTokenDto], tokenDto: CommunityTokenDto): JsonNode = proc createTokenItemJson(communityTokens: seq[CommunityTokenDto], tokenDto: CommunityTokenDto): JsonNode =
try: try:
let remainingSupply = if tokenDto.infiniteSupply: var remainingSupply = tokenDto.supply.toString(10)
var burnState = ContractTransactionStatus.Completed
var remoteDestructedAddresses: seq[string] = @[]
var destructedAmount = "0"
if tokenDto.deployState == DeployState.Deployed:
remainingSupply =
if tokenDto.infiniteSupply:
"0" "0"
else: else:
getRemainingSupply(tokenDto.chainId, tokenDto.address) getRemainingSupply(tokenDto.chainId, tokenDto.address)
let burnState = getCommunityTokenBurnState(tokenDto.chainId, tokenDto.address) burnState = getCommunityTokenBurnState(tokenDto.chainId, tokenDto.address)
let remoteDestructedAddresses = getRemoteDestructedAddresses(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 %* { return %* {
"address": tokenDto.address, "address": tokenDto.address,

View File

@ -507,7 +507,7 @@ QtObject:
communityTokens: communityTokens, communityTokens: communityTokens,
communityTokenJsonItems: communityTokenJsonItems, communityTokenJsonItems: communityTokenJsonItems,
)) ))
except RpcException as e: except Exception as e:
error "Error getting community tokens details", message = e.msg error "Error getting community tokens details", message = e.msg
proc getAllCommunityTokensAsync*(self: Service) = proc getAllCommunityTokensAsync*(self: Service) =