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 "<nil>" which can't be parsed as a valid Int256; see change cbf56fec. "<nil>" is not a valid json value, so this is still a workaround. Closes: #12330
This commit is contained in:
parent
cd4d92aef0
commit
a587e504ef
|
@ -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 "<nil>" 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)
|
||||
|
|
Loading…
Reference in New Issue