aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/util.js
diff options
context:
space:
mode:
authorDan Finlay <somniac@me.com>2016-07-08 06:11:21 +0800
committerGitHub <noreply@github.com>2016-07-08 06:11:21 +0800
commit2bd31c3e5024ca88b18190c145008ba87736f129 (patch)
tree27b3f32b69b302de0ac0750ad5b8a34f5f868da5 /ui/app/util.js
parent3fb36b2dd388d7344fd7b3b7e32dcbafeabc9b48 (diff)
parentac808e681fe6a8666a4842cf7fde23345f63e96a (diff)
downloadtangerine-wallet-browser-2bd31c3e5024ca88b18190c145008ba87736f129.tar.gz
tangerine-wallet-browser-2bd31c3e5024ca88b18190c145008ba87736f129.tar.zst
tangerine-wallet-browser-2bd31c3e5024ca88b18190c145008ba87736f129.zip
Merge pull request #406 from MetaMask/ConfirmationStyle
Update transaction confirmation style
Diffstat (limited to 'ui/app/util.js')
-rw-r--r--ui/app/util.js17
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]