From 6560a2c3af66940e9fbfcc9943655ca5c7282121 Mon Sep 17 00:00:00 2001
From: Kevin Serrano <kevin.serrano@consensys.net>
Date: Thu, 7 Sep 2017 17:55:34 -0700
Subject: Add front-end validation for own adddresses as a token contract
 address. Add information on token contract addresses.

---
 ui/app/add-token.js | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

(limited to 'ui/app/add-token.js')

diff --git a/ui/app/add-token.js b/ui/app/add-token.js
index 15ef7a852..81894247b 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,24 @@ 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',
+              }, [
+                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 +183,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 +203,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 contact address.'
+  }
+
+  const isValid = validAddress && validDecimals && !ownAddress
 
   if (!isValid) {
     this.setState({
@@ -216,4 +235,3 @@ AddTokenScreen.prototype.attemptToAutoFillTokenParams = async function (address)
     this.setState({ symbol: symbol[0], decimals: decimals[0].toString() })
   }
 }
-
-- 
cgit v1.2.3


From 54a5a117d55db826ac20059f70d748cd90516270 Mon Sep 17 00:00:00 2001
From: Kevin Serrano <kevin.serrano@consensys.net>
Date: Thu, 7 Sep 2017 18:00:45 -0700
Subject: Fix link to open new tab.

---
 ui/app/add-token.js | 1 +
 1 file changed, 1 insertion(+)

(limited to 'ui/app/add-token.js')

diff --git a/ui/app/add-token.js b/ui/app/add-token.js
index 81894247b..177adc572 100644
--- a/ui/app/add-token.js
+++ b/ui/app/add-token.js
@@ -74,6 +74,7 @@ AddTokenScreen.prototype.render = function () {
               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'),
-- 
cgit v1.2.3


From 0e6c11a3b5e7677d8d37da4d41bf19b09f85cd88 Mon Sep 17 00:00:00 2001
From: Kevin Serrano <kevin.serrano@consensys.net>
Date: Thu, 7 Sep 2017 18:01:39 -0700
Subject: Fix typo.

---
 ui/app/add-token.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'ui/app/add-token.js')

diff --git a/ui/app/add-token.js b/ui/app/add-token.js
index 177adc572..18adc7eb5 100644
--- a/ui/app/add-token.js
+++ b/ui/app/add-token.js
@@ -206,7 +206,7 @@ AddTokenScreen.prototype.validateInputs = function () {
 
   const ownAddress = identitiesList.includes(standardAddress)
   if (ownAddress) {
-    msg = 'Personal address detected. Input the token contact address.'
+    msg = 'Personal address detected. Input the token contract address.'
   }
 
   const isValid = validAddress && validDecimals && !ownAddress
-- 
cgit v1.2.3