aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-03-22 03:53:28 +0800
committerkumavis <aaron@kumavis.me>2018-03-22 03:53:28 +0800
commit3595d71c2d01d08fe1692ef4fe2f4d6d5c3241d9 (patch)
treee9726a32e70a235df6c08a87858e051ef9fec556
parent278e1ba61eab97860be295ad938cf47ce22f11ed (diff)
parentdc92b56f184100a24aaf53c3e93619514159f938 (diff)
downloadtangerine-wallet-browser-3595d71c2d01d08fe1692ef4fe2f4d6d5c3241d9.tar
tangerine-wallet-browser-3595d71c2d01d08fe1692ef4fe2f4d6d5c3241d9.tar.gz
tangerine-wallet-browser-3595d71c2d01d08fe1692ef4fe2f4d6d5c3241d9.tar.bz2
tangerine-wallet-browser-3595d71c2d01d08fe1692ef4fe2f4d6d5c3241d9.tar.lz
tangerine-wallet-browser-3595d71c2d01d08fe1692ef4fe2f4d6d5c3241d9.tar.xz
tangerine-wallet-browser-3595d71c2d01d08fe1692ef4fe2f4d6d5c3241d9.tar.zst
tangerine-wallet-browser-3595d71c2d01d08fe1692ef4fe2f4d6d5c3241d9.zip
Merge branch 'i3554-fix-editing-dapp-token-txs' of https://github.com/danjm/metamask-extension into danjm-i3554-fix-editing-dapp-token-txs
-rw-r--r--ui/app/components/pending-tx/confirm-send-token.js1
-rw-r--r--ui/app/components/pending-tx/index.js14
-rw-r--r--ui/app/selectors.js3
3 files changed, 13 insertions, 5 deletions
diff --git a/ui/app/components/pending-tx/confirm-send-token.js b/ui/app/components/pending-tx/confirm-send-token.js
index ccd87c0a4..f9276e8a5 100644
--- a/ui/app/components/pending-tx/confirm-send-token.js
+++ b/ui/app/components/pending-tx/confirm-send-token.js
@@ -87,6 +87,7 @@ function mapDispatchToProps (dispatch, ownProps) {
amount: tokenAmountInHex,
errors: { to: null, amount: null },
editingTransactionId: id,
+ token: ownProps.token,
}))
dispatch(actions.showSendTokenPage())
},
diff --git a/ui/app/components/pending-tx/index.js b/ui/app/components/pending-tx/index.js
index f4f6afb8f..9676e9c86 100644
--- a/ui/app/components/pending-tx/index.js
+++ b/ui/app/components/pending-tx/index.js
@@ -63,14 +63,17 @@ PendingTx.prototype.componentWillMount = async function () {
isFetching: false,
})
}
+ const tokenData = txParams && abiDecoder.decodeMethod(txParams.data)
+ const { name: tokenMethodName } = tokenData || {}
+ const isTokenTransaction = ['transfer', 'approve', 'transferFrom']
+ .find(possibleName => tokenMethodName === possibleName)
- try {
+ 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]) {
@@ -83,11 +86,14 @@ PendingTx.prototype.componentWillMount = async function () {
})
} else {
this.setState({
- transactionType: TX_TYPES.SEND_ETHER,
+ transactionType: TX_TYPES.SEND_TOKEN,
+ tokenAddress: txParams.to,
+ tokenSymbol: null,
+ tokenDecimals: null,
isFetching: false,
})
}
- } catch (e) {
+ } else {
this.setState({
transactionType: TX_TYPES.SEND_ETHER,
isFetching: false,
diff --git a/ui/app/selectors.js b/ui/app/selectors.js
index d37c26f7e..2bdc39004 100644
--- a/ui/app/selectors.js
+++ b/ui/app/selectors.js
@@ -56,8 +56,9 @@ function getSelectedToken (state) {
const tokens = state.metamask.tokens || []
const selectedTokenAddress = state.metamask.selectedTokenAddress
const selectedToken = tokens.filter(({ address }) => address === selectedTokenAddress)[0]
+ const sendToken = state.metamask.send.token
- return selectedToken || null
+ return selectedToken || sendToken || null
}
function getSelectedTokenExchangeRate (state) {