From cef1f2a65f27d594b12afd021dea73fcaf569af5 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 14 Apr 2016 21:19:08 -0700 Subject: ui - util - fixes#110 formatBalance --- ui/app/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/app/util.js b/ui/app/util.js index 74e2c19aa..67b7c8f67 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -66,11 +66,11 @@ function weiToEth(bn) { var decimalsToKeep = 4 function formatBalance(balance) { - if (!balance) return 'None' + if (!balance || balance === '0x0') return 'None' var wei = numericBalance(balance) var padded = wei.toString(10) var len = padded.length - var nonZeroIndex = padded.match(/[^0]/).index + var nonZeroIndex = padded.match(/[^0]/) && padded.match(/[^0]/).index var beforeDecimal = padded.substr(nonZeroIndex ? nonZeroIndex : 0, len - 18) var afterDecimal = padded.substr(len - 18, decimalsToKeep) return `${beforeDecimal}.${afterDecimal} ETH` -- cgit