aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-06-28 06:02:15 +0800
committerDan Finlay <dan@danfinlay.com>2017-06-28 06:03:35 +0800
commit78af771c797a3a9d57970ef94be3c3e5ecf117c6 (patch)
tree78b040a8ce170f6ab831b30db9cce01da1575826 /ui
parent5440ed23d621c9ebcd24f89d54701f978e1c086e (diff)
downloadtangerine-wallet-browser-78af771c797a3a9d57970ef94be3c3e5ecf117c6.tar
tangerine-wallet-browser-78af771c797a3a9d57970ef94be3c3e5ecf117c6.tar.gz
tangerine-wallet-browser-78af771c797a3a9d57970ef94be3c3e5ecf117c6.tar.bz2
tangerine-wallet-browser-78af771c797a3a9d57970ef94be3c3e5ecf117c6.tar.lz
tangerine-wallet-browser-78af771c797a3a9d57970ef94be3c3e5ecf117c6.tar.xz
tangerine-wallet-browser-78af771c797a3a9d57970ef94be3c3e5ecf117c6.tar.zst
tangerine-wallet-browser-78af771c797a3a9d57970ef94be3c3e5ecf117c6.zip
Do not allow adding non token addresses
Diffstat (limited to 'ui')
-rw-r--r--ui/app/add-token.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/ui/app/add-token.js b/ui/app/add-token.js
index b303b5c0d..f21184270 100644
--- a/ui/app/add-token.js
+++ b/ui/app/add-token.js
@@ -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)