1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00

Add fix for zero balance shorten.

This commit is contained in:
Kevin Serrano 2016-08-07 17:23:35 -07:00
parent 260de6532c
commit fd37f5db65
3 changed files with 4 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -75,7 +75,7 @@
"txParams": { "txParams": {
"from": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", "from": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"to": "0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761", "to": "0x18a3462427bcc9133bb46e88bcbe39cd7ef0e761",
"value": "0x99966c8104aa57038000", "value": "0x0",
"origin": "thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com", "origin": "thelongestdomainnameintheworldandthensomeandthensomemoreandmore.com",
"metamaskId": 1467923203344608, "metamaskId": 1467923203344608,
"metamaskNetworkId": "2" "metamaskNetworkId": "2"

View File

@ -145,6 +145,8 @@ function shortenBalance (balance, decimalsToKeep = 1) {
} else if (convertedBalance > 1000) { } else if (convertedBalance > 1000) {
truncatedValue = (balance / 1000).toFixed(decimalsToKeep) truncatedValue = (balance / 1000).toFixed(decimalsToKeep)
return `>${truncatedValue}k` return `>${truncatedValue}k`
} else if (convertedBalance == 0) {
return '0'
} else if (convertedBalance < 1) { } else if (convertedBalance < 1) {
var exponent = balance.match(/\.0*/)[0].length var exponent = balance.match(/\.0*/)[0].length
truncatedValue = (convertedBalance * Math.pow(10, exponent)).toFixed(decimalsToKeep) truncatedValue = (convertedBalance * Math.pow(10, exponent)).toFixed(decimalsToKeep)