fix(wallet): fix getting balance of custom tokens

Fixes #4040
This commit is contained in:
Jonathan Rainville 2021-11-05 09:56:17 -04:00 committed by Iuri Matias
parent 9adbd37729
commit 480219b823
1 changed files with 8 additions and 4 deletions

View File

@ -67,9 +67,13 @@ proc fetchTokenBalance(tokenAddress, accountAddress: string, decimals: int): flo
if balanceCache.hasKey(key):
return balanceCache[key]
let tokenBalanceResponse = status_go_eth.getTokenBalance(tokenAddress, accountAddress)
result = parsefloat(hex2Balance(tokenBalanceResponse.result.getStr, decimals))
balanceCache[key] = result
try:
let tokenBalanceResponse = status_go_eth.getTokenBalance(tokenAddress, accountAddress)
result = parsefloat(hex2Balance(tokenBalanceResponse.result.getStr, decimals))
balanceCache[key] = result
except Exception as e:
error "Error getting token balance", msg = e.msg
proc fetchEthBalance(accountAddress: string): float64 =
let key = "0x0" & accountAddress
@ -158,7 +162,7 @@ method fetchPrices(self: Service): Table[string, float64] =
return prices
method refreshBalances(self: Service) =
method refreshBalances(self: Service) =
let prices = self.fetchPrices()
for account in toSeq(self.accounts.values):