mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge branch 'master' into i1938-removecryptopermissions
This commit is contained in:
commit
bcb60f8ef2
@ -3,6 +3,8 @@
|
|||||||
## Current Master
|
## Current Master
|
||||||
- Readded loose keyring label back into the account list.
|
- Readded loose keyring label back into the account list.
|
||||||
- Remove cryptonator from chrome permissions.
|
- Remove cryptonator from chrome permissions.
|
||||||
|
- 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
|
## 3.9.12 2017-9-6
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ const Component = require('react').Component
|
|||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
const actions = require('./actions')
|
const actions = require('./actions')
|
||||||
|
const Tooltip = require('./components/tooltip.js')
|
||||||
|
|
||||||
|
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const abi = require('human-standard-token-abi')
|
const abi = require('human-standard-token-abi')
|
||||||
@ -15,6 +17,7 @@ module.exports = connect(mapStateToProps)(AddTokenScreen)
|
|||||||
|
|
||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
return {
|
return {
|
||||||
|
identities: state.metamask.identities,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,15 +67,25 @@ AddTokenScreen.prototype.render = function () {
|
|||||||
}, [
|
}, [
|
||||||
|
|
||||||
h('div', [
|
h('div', [
|
||||||
h('span', {
|
h(Tooltip, {
|
||||||
|
position: 'top',
|
||||||
|
title: 'The contract of the actual token contract. Click for more info.',
|
||||||
|
}, [
|
||||||
|
h('a', {
|
||||||
style: { fontWeight: 'bold', paddingRight: '10px'},
|
style: { fontWeight: 'bold', paddingRight: '10px'},
|
||||||
}, 'Token Address'),
|
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('section.flex-row.flex-center', [
|
||||||
h('input#token-address', {
|
h('input#token-address', {
|
||||||
name: 'address',
|
name: 'address',
|
||||||
placeholder: 'Token Address',
|
placeholder: 'Token Contract Address',
|
||||||
onChange: this.tokenAddressDidChange.bind(this),
|
onChange: this.tokenAddressDidChange.bind(this),
|
||||||
style: {
|
style: {
|
||||||
width: 'inherit',
|
width: 'inherit',
|
||||||
@ -171,7 +184,9 @@ AddTokenScreen.prototype.tokenAddressDidChange = function (event) {
|
|||||||
AddTokenScreen.prototype.validateInputs = function () {
|
AddTokenScreen.prototype.validateInputs = function () {
|
||||||
let msg = ''
|
let msg = ''
|
||||||
const state = this.state
|
const state = this.state
|
||||||
|
const identitiesList = Object.keys(this.props.identities)
|
||||||
const { address, symbol, decimals } = state
|
const { address, symbol, decimals } = state
|
||||||
|
const standardAddress = ethUtil.addHexPrefix(address).toLowerCase()
|
||||||
|
|
||||||
const validAddress = ethUtil.isValidAddress(address)
|
const validAddress = ethUtil.isValidAddress(address)
|
||||||
if (!validAddress) {
|
if (!validAddress) {
|
||||||
@ -189,7 +204,12 @@ AddTokenScreen.prototype.validateInputs = function () {
|
|||||||
msg += 'Symbol must be between 0 and 10 characters.'
|
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) {
|
if (!isValid) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@ -216,4 +236,3 @@ AddTokenScreen.prototype.attemptToAutoFillTokenParams = async function (address)
|
|||||||
this.setState({ symbol: symbol[0], decimals: decimals[0].toString() })
|
this.setState({ symbol: symbol[0], decimals: decimals[0].toString() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user