aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/pending-tx
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-04-28 07:15:36 +0800
committerDan <danjm.com@gmail.com>2018-04-28 07:15:36 +0800
commit6de450488b8303e01d4be60c571e99f995711e51 (patch)
tree587dadd3a6dc50441b2163666e3fd44e10529474 /ui/app/components/pending-tx
parent4e7b0ff15c5a57cd58497aa292c884a97e8a5d23 (diff)
downloadtangerine-wallet-browser-6de450488b8303e01d4be60c571e99f995711e51.tar.gz
tangerine-wallet-browser-6de450488b8303e01d4be60c571e99f995711e51.tar.zst
tangerine-wallet-browser-6de450488b8303e01d4be60c571e99f995711e51.zip
Wraps calls to symbol() and decimals() in try catch
Diffstat (limited to 'ui/app/components/pending-tx')
-rw-r--r--ui/app/components/pending-tx/index.js20
1 files changed, 9 insertions, 11 deletions
diff --git a/ui/app/components/pending-tx/index.js b/ui/app/components/pending-tx/index.js
index 6ee83ba7e..392650e01 100644
--- a/ui/app/components/pending-tx/index.js
+++ b/ui/app/components/pending-tx/index.js
@@ -8,7 +8,7 @@ const abiDecoder = require('abi-decoder')
abiDecoder.addABI(abi)
const inherits = require('util').inherits
const actions = require('../../actions')
-const util = require('../../util')
+const { getSymbolAndDecimals } = require('../../token-util')
const ConfirmSendEther = require('./confirm-send-ether')
const ConfirmSendToken = require('./confirm-send-token')
const ConfirmDeployContract = require('./confirm-deploy-contract')
@@ -26,6 +26,7 @@ function mapStateToProps (state) {
const {
conversionRate,
identities,
+ tokens: existingTokens,
} = state.metamask
const accounts = state.metamask.accounts
const selectedAddress = state.metamask.selectedAddress || Object.keys(accounts)[0]
@@ -33,6 +34,7 @@ function mapStateToProps (state) {
conversionRate,
identities,
selectedAddress,
+ existingTokens,
}
}
@@ -66,6 +68,7 @@ PendingTx.prototype.componentDidUpdate = function (prevProps, prevState) {
}
PendingTx.prototype.setTokenData = async function () {
+ const { existingTokens } = this.props
const txMeta = this.gatherTxMeta()
const txParams = txMeta.txParams || {}
@@ -89,19 +92,14 @@ PendingTx.prototype.setTokenData = async function () {
}
if (isTokenTransaction) {
- const token = util.getContractAtAddress(txParams.to)
- const results = await Promise.all([
- token.symbol(),
- token.decimals(),
- ])
- const [ symbol, decimals ] = results
-
- if (symbol[0] && decimals[0]) {
+ const { symbol, decimals } = await getSymbolAndDecimals(txParams.to, existingTokens)
+
+ if (symbol && decimals) {
this.setState({
transactionType: TX_TYPES.SEND_TOKEN,
tokenAddress: txParams.to,
- tokenSymbol: symbol[0],
- tokenDecimals: decimals[0],
+ tokenSymbol: symbol,
+ tokenDecimals: decimals,
isFetching: false,
})
} else {