From e47774d3e4ae758c4bd28cdffdc139bd8d761483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20=C5=81ucka?= Date: Sat, 15 Aug 2020 00:18:46 +0200 Subject: [PATCH] Permit all-caps addresses (#9227) * permit all-caps addresses * handle empty address --- ui/app/helpers/utils/util.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/app/helpers/utils/util.js b/ui/app/helpers/utils/util.js index 7643519a8..a6726cdba 100644 --- a/ui/app/helpers/utils/util.js +++ b/ui/app/helpers/utils/util.js @@ -62,11 +62,11 @@ export function addressSummary (address, firstSegLength = 10, lastSegLength = 4, } export function isValidAddress (address) { - const prefixed = ethUtil.addHexPrefix(address) - if (address === '0x0000000000000000000000000000000000000000') { + if (!address || address === '0x0000000000000000000000000000000000000000') { return false } - return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed) + const prefixed = address.startsWith('0X') ? address : ethUtil.addHexPrefix(address) + return (isAllOneCase(prefixed.slice(2)) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed) } export function isValidDomainName (address) {