Add specific error message for failed address checksum.

feature/default_network_editable
Kevin Serrano 7 years ago
parent cafebb6417
commit 7810880f0c
No known key found for this signature in database
GPG Key ID: BF999DEFC7371BA1
  1. 5
      ui/app/send.js
  2. 7
      ui/app/util.js

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

@ -37,6 +37,7 @@ module.exports = {
bnTable: bnTable, bnTable: bnTable,
isHex: isHex, isHex: isHex,
exportAsFile: exportAsFile, exportAsFile: exportAsFile,
isInvalidChecksumAddress,
} }
function valuesFor (obj) { function valuesFor (obj) {
@ -66,6 +67,12 @@ function isValidAddress (address) {
return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed) return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed)
} }
function isInvalidChecksumAddress (address) {
var prefixed = ethUtil.addHexPrefix(address)
if (address === '0x0000000000000000000000000000000000000000') return false
return ethUtil.isValidAddress(prefixed) && !ethUtil.isValidChecksumAddress(prefixed)
}
function isAllOneCase (address) { function isAllOneCase (address) {
if (!address) return true if (!address) return true
var lower = address.toLowerCase() var lower = address.toLowerCase()

Loading…
Cancel
Save