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

Do not allow adding non token addresses

This commit is contained in:
Dan Finlay 2017-06-27 15:02:15 -07:00
parent 5440ed23d6
commit 78af771c79

View File

@ -142,7 +142,13 @@ AddTokenScreen.prototype.render = function () {
if (!valid) return
const { address, symbol, decimals } = this.state
this.props.dispatch(actions.addToken(address.trim(), symbol.trim(), decimals))
this.checkIfToken(address.trim())
.then(() => {
this.props.dispatch(actions.addToken(address.trim(), symbol.trim(), decimals))
})
.catch((reason) => {
this.setState({ warning: 'Not a valid token address.' })
})
},
}, 'Add'),
]),
@ -202,6 +208,12 @@ AddTokenScreen.prototype.validateInputs = function () {
return isValid
}
AddTokenScreen.prototype.checkIfToken = async function (address) {
const contract = this.TokenContract.at(address)
const result = await contract.balance(address)
return result[0].toString()
}
AddTokenScreen.prototype.attemptToAutoFillTokenParams = async function (address) {
const contract = this.TokenContract.at(address)