diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-03-22 05:12:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-22 05:12:37 +0800 |
commit | 8cf9ae3ee6517a2a9a69c2579b5b0e4ef18bca21 (patch) | |
tree | 08e2f8118e550cf151608937c3d17ee694d023b7 | |
parent | 278e1ba61eab97860be295ad938cf47ce22f11ed (diff) | |
parent | 4c2cf15d2ad9cdfee4ce67b795877c7ab60231a7 (diff) | |
download | tangerine-wallet-browser-8cf9ae3ee6517a2a9a69c2579b5b0e4ef18bca21.tar tangerine-wallet-browser-8cf9ae3ee6517a2a9a69c2579b5b0e4ef18bca21.tar.gz tangerine-wallet-browser-8cf9ae3ee6517a2a9a69c2579b5b0e4ef18bca21.tar.bz2 tangerine-wallet-browser-8cf9ae3ee6517a2a9a69c2579b5b0e4ef18bca21.tar.lz tangerine-wallet-browser-8cf9ae3ee6517a2a9a69c2579b5b0e4ef18bca21.tar.xz tangerine-wallet-browser-8cf9ae3ee6517a2a9a69c2579b5b0e4ef18bca21.tar.zst tangerine-wallet-browser-8cf9ae3ee6517a2a9a69c2579b5b0e4ef18bca21.zip |
Merge pull request #3658 from MetaMask/danjm-i3554-fix-editing-dapp-token-txs
Identify token transactions by method names
-rw-r--r-- | test/integration/lib/send-new-ui.js | 1 | ||||
-rw-r--r-- | ui/app/components/pending-tx/confirm-send-token.js | 1 | ||||
-rw-r--r-- | ui/app/components/pending-tx/index.js | 18 | ||||
-rw-r--r-- | ui/app/selectors.js | 3 |
4 files changed, 18 insertions, 5 deletions
diff --git a/test/integration/lib/send-new-ui.js b/test/integration/lib/send-new-ui.js index 3fc7c79f8..46e0ef0e4 100644 --- a/test/integration/lib/send-new-ui.js +++ b/test/integration/lib/send-new-ui.js @@ -127,6 +127,7 @@ async function runSendFlowTest(assert, done) { selectState.val('send edit') reactTriggerChange(selectState[0]) + await timeout(10000) const confirmFromName = (await queryAsync($, '.sender-to-recipient__sender-name')).first() assert.equal(confirmFromName[0].textContent, 'Send Account 2', 'confirm screen should show correct from name') 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..9c0453a3b 100644 --- a/ui/app/components/pending-tx/index.js +++ b/ui/app/components/pending-tx/index.js @@ -64,13 +64,20 @@ PendingTx.prototype.componentWillMount = async function () { }) } - try { + // inspect tx data for supported special confirmation screens + let isTokenTransaction = false + if (txParams.data) { + const tokenData = abiDecoder.decodeMethod(txParams.data) + const { name: tokenMethodName } = tokenData || {} + isTokenTransaction = (tokenMethodName === 'transfer') + } + + 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 +90,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) { |