import React from 'react'; import PropTypes from 'prop-types'; import { useSelector } from 'react-redux'; import Box from '../../../../components/ui/box'; import SiteIcon from '../../../../components/ui/site-icon'; import Typography from '../../../../components/ui/typography/typography'; import { TypographyVariant, FONT_WEIGHT, DISPLAY, JustifyContent, BLOCK_SIZES, AlignItems, TEXT_ALIGN, TextColor, } from '../../../../helpers/constants/design-system'; import { CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP, NETWORK_TO_NAME_MAP, } from '../../../../../shared/constants/network'; export default function ConfirmationNetworkSwitch({ newNetwork }) { const currentNetwork = useSelector((state) => ({ nickname: state.metamask.provider.nickname, type: state.metamask.provider.type, chainId: state.metamask.provider.chainId, })); return ( {currentNetwork.chainId in CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP ? ( ) : (
)} {currentNetwork.nickname || NETWORK_TO_NAME_MAP[currentNetwork.type]}
{newNetwork.chainId in CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP ? ( ) : (
)} {newNetwork.name}
); } ConfirmationNetworkSwitch.propTypes = { newNetwork: PropTypes.shape({ chainId: PropTypes.string.isRequired, name: PropTypes.string.isRequired, }), };