aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/add-token.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/add-token.js')
-rw-r--r--ui/app/add-token.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/ui/app/add-token.js b/ui/app/add-token.js
index 025cfacb5..f21184270 100644
--- a/ui/app/add-token.js
+++ b/ui/app/add-token.js
@@ -31,6 +31,7 @@ function AddTokenScreen () {
AddTokenScreen.prototype.render = function () {
const state = this.state
+ const props = this.props
const { warning, symbol, decimals } = state
return (
@@ -40,7 +41,7 @@ AddTokenScreen.prototype.render = function () {
h('.section-title.flex-row.flex-center', [
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
onClick: (event) => {
- state.dispatch(actions.goHome())
+ props.dispatch(actions.goHome())
},
}),
h('h2.page-subtitle', 'Add Token'),
@@ -141,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'),
]),
@@ -201,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)