diff --git a/packages/embark-ui/src/components/Accounts.js b/packages/embark-ui/src/components/Accounts.js index 61c3271c66..0228f91b18 100644 --- a/packages/embark-ui/src/components/Accounts.js +++ b/packages/embark-ui/src/components/Accounts.js @@ -6,6 +6,23 @@ import Pagination from './Pagination'; import CardTitleIdenticon from './CardTitleIdenticon'; +function displayTruncatedBalance (balance) { + const maxDisplayLength = 20; + if (balance.toString().length <= maxDisplayLength) { + return balance; + } + const [whole, fraction] = balance.toString().split('.'); + if (whole.length >= maxDisplayLength) { + balance = '9'.repeat(maxDisplayLength - 1) + '+'; + } else if (whole.length >= maxDisplayLength - 2) { + balance = whole + '+'; + } else { + balance = whole + '.' + + fraction.slice(0, maxDisplayLength - (whole.length + 2)) + '+'; + } + return balance; +} + const Accounts = ({accounts, changePage, currentPage, numberOfPages}) => ( @@ -23,7 +40,7 @@ const Accounts = ({accounts, changePage, currentPage, numberOfPages}) => ( Balance -
{account.balance} Ether
+
{displayTruncatedBalance(account.balance)} Ether
Tx Count