From a587e504ef450a39315020b59ba54912c8823a72 Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 4 Oct 2023 19:20:37 +0300 Subject: [PATCH] fix(wallet) forever loading balances Allow the balances to be nil in the BalanceDTO. It seems in some corner-cases the balances are returned with rawBalance as "" which can't be parsed as a valid Int256; see change cbf56fec. "" is not a valid json value, so this is still a workaround. Closes: #12330 --- src/app_service/service/wallet_account/dto/balance_dto.nim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app_service/service/wallet_account/dto/balance_dto.nim b/src/app_service/service/wallet_account/dto/balance_dto.nim index a5344086c3..901f2a6420 100644 --- a/src/app_service/service/wallet_account/dto/balance_dto.nim +++ b/src/app_service/service/wallet_account/dto/balance_dto.nim @@ -22,7 +22,12 @@ proc getCurrencyBalance*(self: BalanceDto, currencyPrice: float64): float64 = proc toBalanceDto*(jsonObj: JsonNode): BalanceDto = result = BalanceDto() - result.rawBalance = jsonObj{"rawBalance"}.getStr.parse(Uint256) + + # Expecting "" values comming from status-go when the entry is nil + let rawBalanceStr = jsonObj{"rawBalance"}.getStr + if not rawBalanceStr.contains("nil"): + result.rawBalance = rawBalanceStr.parse(Uint256) + result.balance = jsonObj{"balance"}.getStr.parseFloat() discard jsonObj.getProp("address", result.address) discard jsonObj.getProp("chainId", result.chainId)