mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Merge pull request #1545 from MetaMask/inValidAddressFix
Dissallow transactions to be sent to 0x000...
This commit is contained in:
commit
95d20e9b76
@ -21,6 +21,7 @@ EnsInput.prototype.render = function () {
|
|||||||
const opts = extend(props, {
|
const opts = extend(props, {
|
||||||
list: 'addresses',
|
list: 'addresses',
|
||||||
onChange: () => {
|
onChange: () => {
|
||||||
|
this.setState({ ensResolution: '0x0000000000000000000000000000000000000000' })
|
||||||
const network = this.props.network
|
const network = this.props.network
|
||||||
const networkHasEnsSupport = getNetworkEnsSupport(network)
|
const networkHasEnsSupport = getNetworkEnsSupport(network)
|
||||||
if (!networkHasEnsSupport) return
|
if (!networkHasEnsSupport) return
|
||||||
@ -95,12 +96,14 @@ EnsInput.prototype.lookupEnsName = function () {
|
|||||||
log.info(`ENS attempting to resolve name: ${recipient}`)
|
log.info(`ENS attempting to resolve name: ${recipient}`)
|
||||||
this.ens.lookup(recipient.trim())
|
this.ens.lookup(recipient.trim())
|
||||||
.then((address) => {
|
.then((address) => {
|
||||||
|
if (address === '0x0000000000000000000000000000000000000000') throw new Error('No address has been set for this name.')
|
||||||
if (address !== ensResolution) {
|
if (address !== ensResolution) {
|
||||||
this.setState({
|
this.setState({
|
||||||
loadingEns: false,
|
loadingEns: false,
|
||||||
ensResolution: address,
|
ensResolution: address,
|
||||||
nickname: recipient.trim(),
|
nickname: recipient.trim(),
|
||||||
hoverText: address + '\nClick to Copy',
|
hoverText: address + '\nClick to Copy',
|
||||||
|
ensFailure: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -108,6 +111,7 @@ EnsInput.prototype.lookupEnsName = function () {
|
|||||||
log.error(reason)
|
log.error(reason)
|
||||||
return this.setState({
|
return this.setState({
|
||||||
loadingEns: false,
|
loadingEns: false,
|
||||||
|
ensResolution: '0x0000000000000000000000000000000000000000',
|
||||||
ensFailure: true,
|
ensFailure: true,
|
||||||
hoverText: reason.message,
|
hoverText: reason.message,
|
||||||
})
|
})
|
||||||
|
@ -7,11 +7,10 @@ const clone = require('clone')
|
|||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const BN = ethUtil.BN
|
const BN = ethUtil.BN
|
||||||
const hexToBn = require('../../../app/scripts/lib/hex-to-bn')
|
const hexToBn = require('../../../app/scripts/lib/hex-to-bn')
|
||||||
|
const util = require('../util')
|
||||||
const MiniAccountPanel = require('./mini-account-panel')
|
const MiniAccountPanel = require('./mini-account-panel')
|
||||||
const Copyable = require('./copyable')
|
const Copyable = require('./copyable')
|
||||||
const EthBalance = require('./eth-balance')
|
const EthBalance = require('./eth-balance')
|
||||||
const util = require('../util')
|
|
||||||
const addressSummary = util.addressSummary
|
const addressSummary = util.addressSummary
|
||||||
const nameForAddress = require('../../lib/contract-namer')
|
const nameForAddress = require('../../lib/contract-namer')
|
||||||
const BNInput = require('./bn-as-decimal-input')
|
const BNInput = require('./bn-as-decimal-input')
|
||||||
@ -45,6 +44,9 @@ PendingTx.prototype.render = function () {
|
|||||||
const account = props.accounts[address]
|
const account = props.accounts[address]
|
||||||
const balance = account ? account.balance : '0x0'
|
const balance = account ? account.balance : '0x0'
|
||||||
|
|
||||||
|
// recipient check
|
||||||
|
const isValidAddress = util.isValidAddress(txParams.to)
|
||||||
|
|
||||||
// Gas
|
// Gas
|
||||||
const gas = txParams.gas
|
const gas = txParams.gas
|
||||||
const gasBn = hexToBn(gas)
|
const gasBn = hexToBn(gas)
|
||||||
@ -267,6 +269,15 @@ PendingTx.prototype.render = function () {
|
|||||||
}, 'Transaction Error. Exception thrown in contract code.')
|
}, 'Transaction Error. Exception thrown in contract code.')
|
||||||
: null,
|
: null,
|
||||||
|
|
||||||
|
!isValidAddress ?
|
||||||
|
h('.error', {
|
||||||
|
style: {
|
||||||
|
marginLeft: 50,
|
||||||
|
fontSize: '0.9em',
|
||||||
|
},
|
||||||
|
}, 'Recipient address is invalid. Sending this transaction will result in a loss of ETH.')
|
||||||
|
: null,
|
||||||
|
|
||||||
insufficientBalance ?
|
insufficientBalance ?
|
||||||
h('span.error', {
|
h('span.error', {
|
||||||
style: {
|
style: {
|
||||||
@ -304,7 +315,7 @@ PendingTx.prototype.render = function () {
|
|||||||
type: 'submit',
|
type: 'submit',
|
||||||
value: 'ACCEPT',
|
value: 'ACCEPT',
|
||||||
style: { marginLeft: '10px' },
|
style: { marginLeft: '10px' },
|
||||||
disabled: insufficientBalance || !this.state.valid,
|
disabled: insufficientBalance || !this.state.valid || !isValidAddress,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
h('button.cancel.btn-red', {
|
h('button.cancel.btn-red', {
|
||||||
|
@ -48,6 +48,7 @@ ConfirmTxScreen.prototype.render = function () {
|
|||||||
var txParams = txData.params || {}
|
var txParams = txData.params || {}
|
||||||
var isNotification = isPopupOrNotification() === 'notification'
|
var isNotification = isPopupOrNotification() === 'notification'
|
||||||
|
|
||||||
|
|
||||||
log.info(`rendering a combined ${unconfTxList.length} unconf msg & txs`)
|
log.info(`rendering a combined ${unconfTxList.length} unconf msg & txs`)
|
||||||
if (unconfTxList.length === 0) return h(Loading, { isLoading: true })
|
if (unconfTxList.length === 0) return h(Loading, { isLoading: true })
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ function miniAddressSummary (address) {
|
|||||||
|
|
||||||
function isValidAddress (address) {
|
function isValidAddress (address) {
|
||||||
var prefixed = ethUtil.addHexPrefix(address)
|
var prefixed = ethUtil.addHexPrefix(address)
|
||||||
|
if (address === '0x0000000000000000000000000000000000000000') return false
|
||||||
return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed)
|
return (isAllOneCase(prefixed) && ethUtil.isValidAddress(prefixed)) || ethUtil.isValidChecksumAddress(prefixed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user