1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 03:20:23 +01:00
metamask-extension/ui/pages/confirmation/templates/switch-ethereum-chain.js
Erik Marks a861cc6dae
[FLASK] Add snap alerts and prompts via snap_dialog RPC method (#16048)
Co-authored-by: Guillaume Roux <guillaumeroux123@gmail.com>
Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2022-12-01 16:46:06 +01:00

98 lines
2.2 KiB
JavaScript

import { ethErrors } from 'eth-rpc-errors';
import {
COLORS,
JUSTIFY_CONTENT,
SEVERITIES,
TYPOGRAPHY,
} from '../../../helpers/constants/design-system';
const PENDING_TX_DROP_NOTICE = {
id: 'PENDING_TX_DROP_NOTICE',
severity: SEVERITIES.WARNING,
content: {
element: 'span',
children: {
element: 'MetaMaskTranslation',
props: {
translationKey: 'switchingNetworksCancelsPendingConfirmations',
},
},
},
};
async function getAlerts() {
return [PENDING_TX_DROP_NOTICE];
}
function getValues(pendingApproval, t, actions) {
return {
content: [
{
element: 'Typography',
key: 'title',
children: t('switchEthereumChainConfirmationTitle'),
props: {
variant: TYPOGRAPHY.H3,
align: 'center',
fontWeight: 'normal',
boxProps: {
margin: [0, 0, 2],
padding: [0, 4, 0, 4],
},
},
},
{
element: 'Typography',
key: 'description',
children: t('switchEthereumChainConfirmationDescription'),
props: {
variant: TYPOGRAPHY.H7,
color: COLORS.TEXT_ALTERNATIVE,
align: 'center',
boxProps: {
padding: [0, 4, 0, 4],
},
},
},
{
element: 'Box',
key: 'status-box',
props: {
justifyContent: JUSTIFY_CONTENT.CENTER,
},
children: {
element: 'ConfirmationNetworkSwitch',
key: 'network-being-switched',
props: {
newNetwork: {
chainId: pendingApproval.requestData.chainId,
name: pendingApproval.requestData.nickname,
},
},
},
},
],
cancelText: t('cancel'),
submitText: t('switchNetwork'),
onSubmit: () =>
actions.resolvePendingApproval(
pendingApproval.id,
pendingApproval.requestData,
),
onCancel: () =>
actions.rejectPendingApproval(
pendingApproval.id,
ethErrors.provider.userRejectedRequest().serialize(),
),
networkDisplay: true,
};
}
const switchEthereumChain = {
getAlerts,
getValues,
};
export default switchEthereumChain;