diff options
author | Thomas <thomas.b.huang@gmail.com> | 2018-05-04 05:38:49 +0800 |
---|---|---|
committer | Thomas <thomas.b.huang@gmail.com> | 2018-05-04 05:38:49 +0800 |
commit | 025d8e798394fab215a3a41247d4ed2ecf865edd (patch) | |
tree | 5a245136f008d335314d772fab84c61038257d40 /ui/app/components/pending-tx/index.js | |
parent | 1d353c002ddbb636c8291f7e26cf8d8309983e86 (diff) | |
parent | 23e1290e27c165e967a4a642980abc7c18d759b1 (diff) | |
download | tangerine-wallet-browser-025d8e798394fab215a3a41247d4ed2ecf865edd.tar.gz tangerine-wallet-browser-025d8e798394fab215a3a41247d4ed2ecf865edd.tar.zst tangerine-wallet-browser-025d8e798394fab215a3a41247d4ed2ecf865edd.zip |
Merge branch 'e2e-tests' of https://github.com/tmashuang/metamask-extension into e2e-tests
Diffstat (limited to 'ui/app/components/pending-tx/index.js')
-rw-r--r-- | ui/app/components/pending-tx/index.js | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/ui/app/components/pending-tx/index.js b/ui/app/components/pending-tx/index.js index 6ee83ba7e..893538bcf 100644 --- a/ui/app/components/pending-tx/index.js +++ b/ui/app/components/pending-tx/index.js @@ -8,11 +8,11 @@ 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') -const Loading = require('../loading') +const Loading = require('../loading-screen') const TX_TYPES = { DEPLOY_CONTRACT: '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,30 +92,15 @@ 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]) { - this.setState({ - transactionType: TX_TYPES.SEND_TOKEN, - tokenAddress: txParams.to, - tokenSymbol: symbol[0], - tokenDecimals: decimals[0], - isFetching: false, - }) - } else { - this.setState({ - transactionType: TX_TYPES.SEND_TOKEN, - tokenAddress: txParams.to, - tokenSymbol: null, - tokenDecimals: null, - isFetching: false, - }) - } + const { symbol, decimals } = await getSymbolAndDecimals(txParams.to, existingTokens) + + this.setState({ + transactionType: TX_TYPES.SEND_TOKEN, + tokenAddress: txParams.to, + tokenSymbol: symbol, + tokenDecimals: decimals, + isFetching: false, + }) } else { this.setState({ transactionType: TX_TYPES.SEND_ETHER, |