diff options
author | Jonathan Smirnoff <7558841+jonathansmirnoff@users.noreply.github.com> | 2019-02-14 04:30:46 +0800 |
---|---|---|
committer | Frankie <frankie.diamond@gmail.com> | 2019-02-14 04:30:46 +0800 |
commit | 8dddf48904323d47685516ccc76f9e267dbd188a (patch) | |
tree | 3e1c11920da2be888271e4bc48d8dce61e64b944 /ui/app/util.js | |
parent | f7ab4577f637dd9e96cec0f08848bc70c489f9d3 (diff) | |
download | tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar.gz tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar.bz2 tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar.lz tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar.xz tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.tar.zst tangerine-wallet-browser-8dddf48904323d47685516ccc76f9e267dbd188a.zip |
Fixed issue #5838 (#6001)
Update changelog file
Diffstat (limited to 'ui/app/util.js')
-rw-r--r-- | ui/app/util.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ui/app/util.js b/ui/app/util.js index 31757e7c3..e27956a45 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -60,6 +60,15 @@ module.exports = { getTokenAddressFromTokenObject, checksumAddress, addressSlicer, + isEthNetwork, +} + +function isEthNetwork (netId) { + if (!netId || netId === '1' || netId === '3' || netId === '4' || netId === '42' || netId === '5777') { + return true + } + + return false } function valuesFor (obj) { @@ -83,9 +92,10 @@ function miniAddressSummary (address) { return checked ? checked.slice(0, 4) + '...' + checked.slice(-4) : '...' } -function isValidAddress (address) { +function isValidAddress (address, network) { var prefixed = ethUtil.addHexPrefix(address) if (address === '0x0000000000000000000000000000000000000000') return false + if (!isEthNetwork(network)) return (ethUtil.isValidAddress(prefixed) && address === address.toLowerCase()) return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed) } @@ -299,10 +309,13 @@ function getTokenAddressFromTokenObject (token) { * Safely checksumms a potentially-null address * * @param {String} [address] - address to checksum + * @param {String} [network] - network id * @returns {String} - checksummed address + * */ -function checksumAddress (address) { - return address ? ethUtil.toChecksumAddress(address) : '' +function checksumAddress (address, network) { + const checksummed = address ? ethUtil.toChecksumAddress(address) : '' + return checksummed && network && !isEthNetwork(network) ? checksummed.toLowerCase() : checksummed } function addressSlicer (address = '') { |