1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix hashed address validation

This commit is contained in:
Dan Finlay 2016-06-02 18:42:09 -07:00
parent d0f8a14ace
commit 272bea31b5
2 changed files with 4 additions and 4 deletions

View File

@ -78,11 +78,11 @@ describe('util', function() {
}) })
it('should recognize this sample hashed address', function() { it('should recognize this sample hashed address', function() {
const address = '0x5Fda30Bb72B8Dfe20e48A00dFc108d0915BE9BbA' const address = '0x5Fda30Bb72B8Dfe20e48A00dFc108d0915BE9Bb0'
const result = util.isValidAddress(address) const result = util.isValidAddress(address)
const hashed = ethUtil.toChecksumAddress(address) const hashed = ethUtil.toChecksumAddress(address.toLowerCase())
assert.equal(hashed, address, 'example is hashed correctly') assert.equal(hashed, address, 'example is hashed correctly')
assert.ok(result) assert.ok(result, 'is valid by our check')
}) })
}) })

View File

@ -52,7 +52,7 @@ function addressSummary(address) {
function isValidAddress(address) { function isValidAddress(address) {
var prefixed = ethUtil.addHexPrefix(address) var prefixed = ethUtil.addHexPrefix(address)
return isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed) || ethUtil.isValidChecksumAddress(prefixed) return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed)
} }
function isAllOneCase(address) { function isAllOneCase(address) {