2022-04-25 20:28:52 +02:00
|
|
|
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 {
|
2023-02-02 21:15:26 +01:00
|
|
|
TypographyVariant,
|
2023-07-12 18:40:12 +02:00
|
|
|
FontWeight,
|
|
|
|
Display,
|
2023-02-02 21:15:26 +01:00
|
|
|
JustifyContent,
|
2023-07-12 18:40:12 +02:00
|
|
|
BlockSize,
|
2023-02-02 21:15:26 +01:00
|
|
|
AlignItems,
|
2023-07-12 18:40:12 +02:00
|
|
|
TextAlign,
|
2023-02-02 21:15:26 +01:00
|
|
|
TextColor,
|
2022-04-25 20:28:52 +02:00
|
|
|
} from '../../../../helpers/constants/design-system';
|
|
|
|
import {
|
|
|
|
CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP,
|
|
|
|
NETWORK_TO_NAME_MAP,
|
|
|
|
} from '../../../../../shared/constants/network';
|
2023-05-02 14:36:24 +02:00
|
|
|
import { getProviderConfig } from '../../../../ducks/metamask/metamask';
|
2022-04-25 20:28:52 +02:00
|
|
|
|
|
|
|
export default function ConfirmationNetworkSwitch({ newNetwork }) {
|
2023-05-02 14:36:24 +02:00
|
|
|
const { chainId, nickname, type } = useSelector(getProviderConfig);
|
2022-04-25 20:28:52 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
className="confirmation-network-switch"
|
2023-07-12 18:40:12 +02:00
|
|
|
display={Display.Flex}
|
|
|
|
height={BlockSize.Full}
|
2023-02-02 21:15:26 +01:00
|
|
|
justifyContent={JustifyContent.center}
|
2022-04-25 20:28:52 +02:00
|
|
|
marginTop={8}
|
|
|
|
>
|
|
|
|
<Box
|
|
|
|
className="confirmation-network-switch__icon"
|
2023-07-12 18:40:12 +02:00
|
|
|
display={Display.Block}
|
2022-04-25 20:28:52 +02:00
|
|
|
>
|
2023-05-02 14:36:24 +02:00
|
|
|
{chainId in CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP ? (
|
2022-04-25 20:28:52 +02:00
|
|
|
<SiteIcon
|
2023-05-02 14:36:24 +02:00
|
|
|
icon={CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP[chainId]}
|
|
|
|
name={nickname}
|
2022-04-25 20:28:52 +02:00
|
|
|
size={64}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<div className="confirmation-network-switch__unknown-icon">
|
|
|
|
<i className="fa fa-question fa-2x" />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<Typography
|
2023-02-02 21:15:26 +01:00
|
|
|
color={TextColor.textDefault}
|
|
|
|
variant={TypographyVariant.H6}
|
2023-07-12 18:40:12 +02:00
|
|
|
fontWeight={FontWeight.Normal}
|
|
|
|
align={TextAlign.Center}
|
2022-04-25 20:28:52 +02:00
|
|
|
boxProps={{
|
2023-07-12 18:40:12 +02:00
|
|
|
display: Display.Flex,
|
2023-02-02 21:15:26 +01:00
|
|
|
justifyContent: JustifyContent.center,
|
2022-04-25 20:28:52 +02:00
|
|
|
}}
|
|
|
|
>
|
2023-05-02 14:36:24 +02:00
|
|
|
{nickname || NETWORK_TO_NAME_MAP[type]}
|
2022-04-25 20:28:52 +02:00
|
|
|
</Typography>
|
|
|
|
</Box>
|
|
|
|
<Box
|
|
|
|
className="confirmation-network-switch__center-icon"
|
2023-07-12 18:40:12 +02:00
|
|
|
display={Display.Flex}
|
2023-02-02 21:15:26 +01:00
|
|
|
alignItems={AlignItems.center}
|
|
|
|
justifyContent={JustifyContent.center}
|
2022-04-25 20:28:52 +02:00
|
|
|
>
|
|
|
|
<i className="fa fa-angle-right fa-lg confirmation-network-switch__check" />
|
|
|
|
<div className="confirmation-network-switch__dashed-line" />
|
|
|
|
</Box>
|
|
|
|
<Box
|
|
|
|
className="confirmation-network-switch__icon"
|
2023-07-12 18:40:12 +02:00
|
|
|
display={Display.Block}
|
2022-04-25 20:28:52 +02:00
|
|
|
>
|
|
|
|
{newNetwork.chainId in CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP ? (
|
|
|
|
<SiteIcon
|
|
|
|
icon={CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP[newNetwork.chainId]}
|
2023-03-09 22:00:28 +01:00
|
|
|
name={newNetwork.nickname}
|
2022-04-25 20:28:52 +02:00
|
|
|
size={64}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<div className="confirmation-network-switch__unknown-icon">
|
|
|
|
<i className="fa fa-question fa-2x" />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<Typography
|
2023-02-02 21:15:26 +01:00
|
|
|
color={TextColor.textDefault}
|
|
|
|
variant={TypographyVariant.H6}
|
2023-07-12 18:40:12 +02:00
|
|
|
fontWeight={FontWeight.Normal}
|
|
|
|
align={TextAlign.Center}
|
2022-04-25 20:28:52 +02:00
|
|
|
boxProps={{
|
2023-07-12 18:40:12 +02:00
|
|
|
display: Display.Flex,
|
2023-02-02 21:15:26 +01:00
|
|
|
justifyContent: JustifyContent.center,
|
2022-04-25 20:28:52 +02:00
|
|
|
}}
|
|
|
|
>
|
2023-03-09 22:00:28 +01:00
|
|
|
{newNetwork.nickname}
|
2022-04-25 20:28:52 +02:00
|
|
|
</Typography>
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfirmationNetworkSwitch.propTypes = {
|
|
|
|
newNetwork: PropTypes.shape({
|
|
|
|
chainId: PropTypes.string.isRequired,
|
2023-03-09 22:00:28 +01:00
|
|
|
nickname: PropTypes.string.isRequired,
|
2022-04-25 20:28:52 +02:00
|
|
|
}),
|
|
|
|
};
|