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

move address check to util.isValidAddress

This commit is contained in:
frankiebee 2017-06-05 12:09:19 -07:00
parent 37fd32025f
commit 653319be10
3 changed files with 4 additions and 3 deletions

View File

@ -7,7 +7,7 @@ const clone = require('clone')
const ethUtil = require('ethereumjs-util')
const BN = ethUtil.BN
const hexToBn = require('../../../app/scripts/lib/hex-to-bn')
const util = require('../util')
const MiniAccountPanel = require('./mini-account-panel')
const EthBalance = require('./eth-balance')
const util = require('../util')
@ -45,7 +45,7 @@ PendingTx.prototype.render = function () {
const balance = account ? account.balance : '0x0'
// recipient check
const isValidAddress = !(txParams.to === '0x0000000000000000000000000000000000000000')
const isValidAddress = util.isValidAddress(txParams.to)
// Gas
const gas = txParams.gas

View File

@ -262,7 +262,7 @@ SendTransactionScreen.prototype.onSubmit = function () {
return this.props.dispatch(actions.displayWarning(message))
}
if ((!util.isValidAddress(recipient) && !txData) || (!recipient && !txData) || (recipient === '0x0000000000000000000000000000000000000000')) {
if ((!util.isValidAddress(recipient) && !txData) || (!recipient && !txData) {
message = 'Recipient address is invalid.'
return this.props.dispatch(actions.displayWarning(message))
}

View File

@ -61,6 +61,7 @@ function miniAddressSummary (address) {
function isValidAddress (address) {
var prefixed = ethUtil.addHexPrefix(address)
if (address === '0x0000000000000000000000000000000000000000') return false
return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed)
}