2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
2020-11-03 00:41:28 +01:00
|
|
|
import {
|
|
|
|
getIsMainnet,
|
|
|
|
getNativeCurrency,
|
|
|
|
getPreferences,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../selectors';
|
|
|
|
import { getHexGasTotal } from '../../../helpers/utils/confirm-tx.util';
|
|
|
|
import { sumHexes } from '../../../helpers/utils/transactions.util';
|
|
|
|
import TransactionBreakdown from './transaction-breakdown.component';
|
2018-10-26 10:26:43 +02:00
|
|
|
|
2019-03-06 19:14:53 +01:00
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2021-03-10 21:16:44 +01:00
|
|
|
const { transaction, isTokenApprove } = ownProps;
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
txParams: { gas, gasPrice, value } = {},
|
|
|
|
txReceipt: { gasUsed } = {},
|
2021-02-04 19:15:23 +01:00
|
|
|
} = transaction;
|
|
|
|
const { showFiatInTestnets } = getPreferences(state);
|
|
|
|
const isMainnet = getIsMainnet(state);
|
2019-02-26 19:30:41 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const gasLimit = typeof gasUsed === 'string' ? gasUsed : gas;
|
2019-03-06 19:14:53 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const hexGasTotal =
|
2021-02-04 19:15:23 +01:00
|
|
|
(gasLimit && gasPrice && getHexGasTotal({ gasLimit, gasPrice })) || '0x0';
|
|
|
|
const totalInHex = sumHexes(hexGasTotal, value);
|
2019-03-06 19:14:53 +01:00
|
|
|
|
2018-10-26 10:26:43 +02:00
|
|
|
return {
|
|
|
|
nativeCurrency: getNativeCurrency(state),
|
2020-11-03 00:41:28 +01:00
|
|
|
showFiat: isMainnet || Boolean(showFiatInTestnets),
|
2019-03-06 19:14:53 +01:00
|
|
|
totalInHex,
|
|
|
|
gas,
|
|
|
|
gasPrice,
|
|
|
|
gasUsed,
|
2020-10-09 22:11:39 +02:00
|
|
|
isTokenApprove,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2018-10-26 10:26:43 +02:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
export default connect(mapStateToProps)(TransactionBreakdown);
|