diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2016-07-08 07:33:06 +0800 |
---|---|---|
committer | Kevin Serrano <kevgagser@gmail.com> | 2016-07-08 07:33:06 +0800 |
commit | 86b7cc6637edefd2f628238a2abff540c82e1a78 (patch) | |
tree | a6126d8b83ec7b66cd2a138c670863beedbefba1 /ui/app/util.js | |
parent | 9a9c1f2cd48235be47e65b42c84bd9bf55ecbec4 (diff) | |
parent | 44a45f38be5251eacd2c43ebbc55acf34f65084c (diff) | |
download | tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar.gz tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar.bz2 tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar.lz tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar.xz tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar.zst tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.zip |
Resolve merge conflict.
Diffstat (limited to 'ui/app/util.js')
-rw-r--r-- | ui/app/util.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ui/app/util.js b/ui/app/util.js index befb2aad8..b86bc6035 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -21,6 +21,7 @@ for (var currency in valueTable) { module.exports = { valuesFor: valuesFor, addressSummary: addressSummary, + miniAddressSummary: miniAddressSummary, isAllOneCase: isAllOneCase, isValidAddress: isValidAddress, numericBalance: numericBalance, @@ -44,10 +45,19 @@ function valuesFor (obj) { .map(function (key) { return obj[key] }) } -function addressSummary (address) { +function addressSummary (address, firstSegLength = 10, lastSegLength = 4, includeHex = true) { + if (!address) return '' + let checked = ethUtil.toChecksumAddress(address) + if (!includeHex) { + checked = ethUtil.stripHexPrefix(checked) + } + return checked ? checked.slice(0, firstSegLength) + '...' + checked.slice(checked.length - lastSegLength) : '...' +} + +function miniAddressSummary (address) { if (!address) return '' var checked = ethUtil.toChecksumAddress(address) - return checked ? checked.slice(0, 2 + 8) + '...' + checked.slice(-4) : '...' + return checked ? checked.slice(0, 4) + '...' + checked.slice(-4) : '...' } function isValidAddress (address) { @@ -95,7 +105,8 @@ function parseBalance (balance) { return [beforeDecimal, afterDecimal] } -// Takes wei hex, returns "None" or "${formattedAmount} ETH" +// Takes wei hex, returns an object with three properties. +// Its "formatted" property is what we generally use to render values. function formatBalance (balance, decimalsToKeep) { var parsed = parseBalance(balance) var beforeDecimal = parsed[0] |