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:
parent
37fd32025f
commit
653319be10
@ -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
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user