aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-09-08 11:26:31 +0800
committerGitHub <noreply@github.com>2017-09-08 11:26:31 +0800
commita704e1d14370056a9a1a8af43c702bb00142532d (patch)
tree68af5d3464f56567d0647b92eb075689d16a9eca
parent941ea65af753be7f29c1d96f71ec2369c6e5454d (diff)
parent0e6c11a3b5e7677d8d37da4d41bf19b09f85cd88 (diff)
downloadtangerine-wallet-browser-a704e1d14370056a9a1a8af43c702bb00142532d.tar
tangerine-wallet-browser-a704e1d14370056a9a1a8af43c702bb00142532d.tar.gz
tangerine-wallet-browser-a704e1d14370056a9a1a8af43c702bb00142532d.tar.bz2
tangerine-wallet-browser-a704e1d14370056a9a1a8af43c702bb00142532d.tar.lz
tangerine-wallet-browser-a704e1d14370056a9a1a8af43c702bb00142532d.tar.xz
tangerine-wallet-browser-a704e1d14370056a9a1a8af43c702bb00142532d.tar.zst
tangerine-wallet-browser-a704e1d14370056a9a1a8af43c702bb00142532d.zip
Merge pull request #2048 from MetaMask/i1984-tokenvalidations
Add Token Validations and Info
-rw-r--r--CHANGELOG.md2
-rw-r--r--ui/app/add-token.js31
2 files changed, 27 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0c3aab200..a63a8604a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## Current Master
- Readded loose keyring label back into the account list.
+- Add info on token contract addresses.
+- Add validation preventing users from inputting their own addresses as token tracking addresses.
## 3.9.12 2017-9-6
diff --git a/ui/app/add-token.js b/ui/app/add-token.js
index 15ef7a852..18adc7eb5 100644
--- a/ui/app/add-token.js
+++ b/ui/app/add-token.js
@@ -3,6 +3,8 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const actions = require('./actions')
+const Tooltip = require('./components/tooltip.js')
+
const ethUtil = require('ethereumjs-util')
const abi = require('human-standard-token-abi')
@@ -15,6 +17,7 @@ module.exports = connect(mapStateToProps)(AddTokenScreen)
function mapStateToProps (state) {
return {
+ identities: state.metamask.identities,
}
}
@@ -64,15 +67,25 @@ AddTokenScreen.prototype.render = function () {
}, [
h('div', [
- h('span', {
- style: { fontWeight: 'bold', paddingRight: '10px'},
- }, 'Token Address'),
+ h(Tooltip, {
+ position: 'top',
+ title: 'The contract of the actual token contract. Click for more info.',
+ }, [
+ h('a', {
+ style: { fontWeight: 'bold', paddingRight: '10px'},
+ href: 'https://consensyssupport.happyfox.com/staff/kb/article/24-what-is-a-token-contract-address',
+ target: '_blank',
+ }, [
+ h('span', 'Token Contract Address '),
+ h('i.fa.fa-question-circle'),
+ ]),
+ ]),
]),
h('section.flex-row.flex-center', [
h('input#token-address', {
name: 'address',
- placeholder: 'Token Address',
+ placeholder: 'Token Contract Address',
onChange: this.tokenAddressDidChange.bind(this),
style: {
width: 'inherit',
@@ -171,7 +184,9 @@ AddTokenScreen.prototype.tokenAddressDidChange = function (event) {
AddTokenScreen.prototype.validateInputs = function () {
let msg = ''
const state = this.state
+ const identitiesList = Object.keys(this.props.identities)
const { address, symbol, decimals } = state
+ const standardAddress = ethUtil.addHexPrefix(address).toLowerCase()
const validAddress = ethUtil.isValidAddress(address)
if (!validAddress) {
@@ -189,7 +204,12 @@ AddTokenScreen.prototype.validateInputs = function () {
msg += 'Symbol must be between 0 and 10 characters.'
}
- const isValid = validAddress && validDecimals
+ const ownAddress = identitiesList.includes(standardAddress)
+ if (ownAddress) {
+ msg = 'Personal address detected. Input the token contract address.'
+ }
+
+ const isValid = validAddress && validDecimals && !ownAddress
if (!isValid) {
this.setState({
@@ -216,4 +236,3 @@ AddTokenScreen.prototype.attemptToAutoFillTokenParams = async function (address)
this.setState({ symbol: symbol[0], decimals: decimals[0].toString() })
}
}
-