aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/add-token.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-10-28 01:39:40 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-10-28 08:29:12 +0800
commitc8c918d44e26e9541beead982ef0ed79a56d6e6f (patch)
tree9763d9c455910fd9b93b987d020617f4b8f13399 /ui/app/add-token.js
parent5d8b53bcf491bfe6dd59f4986f02da70b91df5cd (diff)
downloadtangerine-wallet-browser-c8c918d44e26e9541beead982ef0ed79a56d6e6f.tar.gz
tangerine-wallet-browser-c8c918d44e26e9541beead982ef0ed79a56d6e6f.tar.zst
tangerine-wallet-browser-c8c918d44e26e9541beead982ef0ed79a56d6e6f.zip
Add utility for getting token data; get token data in tx-list even if token has been removed.
Diffstat (limited to 'ui/app/add-token.js')
-rw-r--r--ui/app/add-token.js23
1 files changed, 5 insertions, 18 deletions
diff --git a/ui/app/add-token.js b/ui/app/add-token.js
index 518701a1d..10aaae103 100644
--- a/ui/app/add-token.js
+++ b/ui/app/add-token.js
@@ -21,9 +21,7 @@ const fuse = new Fuse(contractList, {
})
const actions = require('./actions')
const ethUtil = require('ethereumjs-util')
-const abi = require('human-standard-token-abi')
-const Eth = require('ethjs-query')
-const EthContract = require('ethjs-contract')
+const { tokenInfoGetter } = require('./token-util')
const R = require('ramda')
const emptyAddr = '0x0000000000000000000000000000000000000000'
@@ -63,11 +61,7 @@ function AddTokenScreen () {
}
AddTokenScreen.prototype.componentWillMount = function () {
- if (typeof global.ethereumProvider === 'undefined') return
-
- this.eth = new Eth(global.ethereumProvider)
- this.contract = new EthContract(this.eth)
- this.TokenContract = this.contract(abi)
+ this.tokenInfoGetter = tokenInfoGetter()
}
AddTokenScreen.prototype.toggleToken = function (address, token) {
@@ -164,18 +158,11 @@ AddTokenScreen.prototype.validate = function () {
}
AddTokenScreen.prototype.attemptToAutoFillTokenParams = async function (address) {
- const contract = this.TokenContract.at(address)
-
- const results = await Promise.all([
- contract.symbol(),
- contract.decimals(),
- ])
-
- const [ symbol, decimals ] = results
+ const { symbol, decimals } = await this.tokenInfoGetter(address)
if (symbol && decimals) {
this.setState({
- customSymbol: symbol[0],
- customDecimals: decimals[0].toString(),
+ customSymbol: symbol,
+ customDecimals: decimals.toString(),
})
}
}