1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/ui/components/app/transaction-breakdown/transaction-breakdown.container.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
2020-11-03 00:41:28 +01:00
import {
getIsMainnet,
getNativeCurrency,
getPreferences,
} from '../../../selectors';
import { getHexGasTotal } from '../../../helpers/utils/confirm-tx.util';
import { sumHexes } from '../../../helpers/utils/transactions.util';
import TransactionBreakdown from './transaction-breakdown.component';
const mapStateToProps = (state, ownProps) => {
const { transaction, isTokenApprove } = ownProps;
2020-11-03 00:41:28 +01:00
const {
txParams: { gas, gasPrice, value } = {},
txReceipt: { gasUsed } = {},
} = transaction;
const { showFiatInTestnets } = getPreferences(state);
const isMainnet = getIsMainnet(state);
const gasLimit = typeof gasUsed === 'string' ? gasUsed : gas;
2020-11-03 00:41:28 +01:00
const hexGasTotal =
(gasLimit && gasPrice && getHexGasTotal({ gasLimit, gasPrice })) || '0x0';
const totalInHex = sumHexes(hexGasTotal, value);
return {
nativeCurrency: getNativeCurrency(state),
2020-11-03 00:41:28 +01:00
showFiat: isMainnet || Boolean(showFiatInTestnets),
totalInHex,
gas,
gasPrice,
gasUsed,
isTokenApprove,
};
};
export default connect(mapStateToProps)(TransactionBreakdown);