1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #3658 from MetaMask/danjm-i3554-fix-editing-dapp-token-txs

Identify token transactions by method names
This commit is contained in:
kumavis 2018-03-21 14:12:37 -07:00 committed by GitHub
commit 8cf9ae3ee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 5 deletions

View File

@ -127,6 +127,7 @@ async function runSendFlowTest(assert, done) {
selectState.val('send edit') selectState.val('send edit')
reactTriggerChange(selectState[0]) reactTriggerChange(selectState[0])
await timeout(10000)
const confirmFromName = (await queryAsync($, '.sender-to-recipient__sender-name')).first() 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') assert.equal(confirmFromName[0].textContent, 'Send Account 2', 'confirm screen should show correct from name')

View File

@ -87,6 +87,7 @@ function mapDispatchToProps (dispatch, ownProps) {
amount: tokenAmountInHex, amount: tokenAmountInHex,
errors: { to: null, amount: null }, errors: { to: null, amount: null },
editingTransactionId: id, editingTransactionId: id,
token: ownProps.token,
})) }))
dispatch(actions.showSendTokenPage()) dispatch(actions.showSendTokenPage())
}, },

View File

@ -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 token = util.getContractAtAddress(txParams.to)
const results = await Promise.all([ const results = await Promise.all([
token.symbol(), token.symbol(),
token.decimals(), token.decimals(),
]) ])
const [ symbol, decimals ] = results const [ symbol, decimals ] = results
if (symbol[0] && decimals[0]) { if (symbol[0] && decimals[0]) {
@ -83,11 +90,14 @@ PendingTx.prototype.componentWillMount = async function () {
}) })
} else { } else {
this.setState({ this.setState({
transactionType: TX_TYPES.SEND_ETHER, transactionType: TX_TYPES.SEND_TOKEN,
tokenAddress: txParams.to,
tokenSymbol: null,
tokenDecimals: null,
isFetching: false, isFetching: false,
}) })
} }
} catch (e) { } else {
this.setState({ this.setState({
transactionType: TX_TYPES.SEND_ETHER, transactionType: TX_TYPES.SEND_ETHER,
isFetching: false, isFetching: false,

View File

@ -56,8 +56,9 @@ function getSelectedToken (state) {
const tokens = state.metamask.tokens || [] const tokens = state.metamask.tokens || []
const selectedTokenAddress = state.metamask.selectedTokenAddress const selectedTokenAddress = state.metamask.selectedTokenAddress
const selectedToken = tokens.filter(({ address }) => address === selectedTokenAddress)[0] const selectedToken = tokens.filter(({ address }) => address === selectedTokenAddress)[0]
const sendToken = state.metamask.send.token
return selectedToken || null return selectedToken || sendToken || null
} }
function getSelectedTokenExchangeRate (state) { function getSelectedTokenExchangeRate (state) {