mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-30 08:09:15 +01:00
05e2120814
* Introduce delay for eth_estimateGas calls with in test * Add test that fails when gas estimates of contract method calls without gas are too high. * Get transaction gas data from unApprovedTxs instead of confirmTransaction * Fix selection of gas data in gas-modal-page-container.container * Lint changes related to Version-6.7.2-gasLimitFix * Fix e2e tests on Version-6.7.2-gasLimitFix * Fix unit and integration tests for changes from Version-6.7.2-gasLimitFix * more e2e fixes * Add assertions for transaction values on confirm screen * Fix display of transaction amount on confirm screen.
62 lines
1.9 KiB
JavaScript
62 lines
1.9 KiB
JavaScript
import { connect } from 'react-redux'
|
|
import { compose } from 'recompose'
|
|
import { withRouter } from 'react-router-dom'
|
|
import ConfirmTokenTransactionBase from './confirm-token-transaction-base.component'
|
|
import {
|
|
contractExchangeRateSelector,
|
|
transactionFeeSelector,
|
|
} from '../../selectors/confirm-transaction'
|
|
import { tokenSelector } from '../../selectors/tokens'
|
|
import {
|
|
getTokenData,
|
|
} from '../../helpers/utils/transactions.util'
|
|
import {
|
|
calcTokenAmount,
|
|
getTokenToAddress,
|
|
getTokenValue,
|
|
} from '../../helpers/utils/token-util'
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
const { match: { params = {} } } = ownProps
|
|
const { id: paramsTransactionId } = params
|
|
const { confirmTransaction, metamask: { currentCurrency, conversionRate, selectedAddressTxList } } = state
|
|
|
|
const {
|
|
txData: { id: transactionId, txParams: { to: tokenAddress, data } = {} } = {},
|
|
} = confirmTransaction
|
|
|
|
const transaction = selectedAddressTxList.find(({ id }) => id === (Number(paramsTransactionId) || transactionId)) || {}
|
|
|
|
const {
|
|
ethTransactionTotal,
|
|
fiatTransactionTotal,
|
|
} = transactionFeeSelector(state, transaction)
|
|
const tokens = tokenSelector(state)
|
|
const currentToken = tokens && tokens.find(({ address }) => tokenAddress === address)
|
|
const { decimals, symbol: tokenSymbol } = currentToken || {}
|
|
|
|
const tokenData = getTokenData(data)
|
|
const tokenValue = tokenData && getTokenValue(tokenData.params)
|
|
const toAddress = tokenData && getTokenToAddress(tokenData.params)
|
|
const tokenAmount = tokenData && calcTokenAmount(tokenValue, decimals).toString()
|
|
const contractExchangeRate = contractExchangeRateSelector(state)
|
|
|
|
return {
|
|
toAddress,
|
|
tokenAddress,
|
|
tokenAmount,
|
|
tokenSymbol,
|
|
currentCurrency,
|
|
conversionRate,
|
|
contractExchangeRate,
|
|
fiatTransactionTotal,
|
|
ethTransactionTotal,
|
|
}
|
|
}
|
|
|
|
export default compose(
|
|
withRouter,
|
|
connect(mapStateToProps)
|
|
)(ConfirmTokenTransactionBase)
|