mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
addEthereumChain bug fixes (#10520)
This commit is contained in:
parent
20b2c5f004
commit
1a2dc850a3
@ -1945,7 +1945,7 @@
|
|||||||
"message": "View in activity"
|
"message": "View in activity"
|
||||||
},
|
},
|
||||||
"switchEthereumChainConfirmationDescription": {
|
"switchEthereumChainConfirmationDescription": {
|
||||||
"message": "This will will switch the selected network within MetaMask to a previously added network:"
|
"message": "This will switch the selected network within MetaMask to a previously added network:"
|
||||||
},
|
},
|
||||||
"switchEthereumChainConfirmationTitle": {
|
"switchEthereumChainConfirmationTitle": {
|
||||||
"message": "Allow this site to switch the network?"
|
"message": "Allow this site to switch the network?"
|
||||||
|
@ -32,7 +32,9 @@ async function addEthereumChainHandler(
|
|||||||
if (!req.params?.[0] || typeof req.params[0] !== 'object') {
|
if (!req.params?.[0] || typeof req.params[0] !== 'object') {
|
||||||
return end(
|
return end(
|
||||||
ethErrors.rpc.invalidParams({
|
ethErrors.rpc.invalidParams({
|
||||||
message: `Expected single, object parameter. Received:\n${req.params}`,
|
message: `Expected single, object parameter. Received:\n${JSON.stringify(
|
||||||
|
req.params,
|
||||||
|
)}`,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,6 @@ import { useDispatch, useSelector } from 'react-redux';
|
|||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import { produce } from 'immer';
|
import { produce } from 'immer';
|
||||||
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
|
||||||
import {
|
|
||||||
ENVIRONMENT_TYPE_FULLSCREEN,
|
|
||||||
ENVIRONMENT_TYPE_POPUP,
|
|
||||||
} from '../../../../shared/constants/app';
|
|
||||||
import Box from '../../components/ui/box';
|
import Box from '../../components/ui/box';
|
||||||
import Chip from '../../components/ui/chip';
|
import Chip from '../../components/ui/chip';
|
||||||
import MetaMaskTemplateRenderer from '../../components/app/metamask-template-renderer';
|
import MetaMaskTemplateRenderer from '../../components/app/metamask-template-renderer';
|
||||||
@ -138,16 +133,11 @@ export default function ConfirmationPage() {
|
|||||||
}, [pendingConfirmation, t, dispatch]);
|
}, [pendingConfirmation, t, dispatch]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const environmentType = getEnvironmentType();
|
|
||||||
// If the number of pending confirmations reduces to zero when the user
|
// If the number of pending confirmations reduces to zero when the user
|
||||||
// is in the fullscreen or popup UI, return them to the default route.
|
// return them to the default route. Otherwise, if the number of pending
|
||||||
// Otherwise, if the number of pending confirmations reduces to a number
|
// confirmations reduces to a number that is less than the currently
|
||||||
// that is less than the currently viewed index, reset the index.
|
// viewed index, reset the index.
|
||||||
if (
|
if (pendingConfirmations.length === 0) {
|
||||||
pendingConfirmations.length === 0 &&
|
|
||||||
(environmentType === ENVIRONMENT_TYPE_FULLSCREEN ||
|
|
||||||
environmentType === ENVIRONMENT_TYPE_POPUP)
|
|
||||||
) {
|
|
||||||
history.push(DEFAULT_ROUTE);
|
history.push(DEFAULT_ROUTE);
|
||||||
} else if (pendingConfirmations.length <= currentPendingConfirmation) {
|
} else if (pendingConfirmations.length <= currentPendingConfirmation) {
|
||||||
setCurrentPendingConfirmation(pendingConfirmations.length - 1);
|
setCurrentPendingConfirmation(pendingConfirmations.length - 1);
|
||||||
|
@ -2,8 +2,6 @@ export const GO_HOME = 'GO_HOME';
|
|||||||
// modal state
|
// modal state
|
||||||
export const MODAL_OPEN = 'UI_MODAL_OPEN';
|
export const MODAL_OPEN = 'UI_MODAL_OPEN';
|
||||||
export const MODAL_CLOSE = 'UI_MODAL_CLOSE';
|
export const MODAL_CLOSE = 'UI_MODAL_CLOSE';
|
||||||
// notification state
|
|
||||||
export const CLOSE_NOTIFICATION_WINDOW = 'CLOSE_NOTIFICATION_WINDOW';
|
|
||||||
// sidebar state
|
// sidebar state
|
||||||
export const SIDEBAR_OPEN = 'UI_SIDEBAR_OPEN';
|
export const SIDEBAR_OPEN = 'UI_SIDEBAR_OPEN';
|
||||||
export const SIDEBAR_CLOSE = 'UI_SIDEBAR_CLOSE';
|
export const SIDEBAR_CLOSE = 'UI_SIDEBAR_CLOSE';
|
||||||
|
@ -1772,24 +1772,16 @@ export function hideModal(payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function closeCurrentNotificationWindow() {
|
export function closeCurrentNotificationWindow() {
|
||||||
return (dispatch, getState) => {
|
return (_, getState) => {
|
||||||
if (
|
if (
|
||||||
getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION &&
|
getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION &&
|
||||||
!hasUnconfirmedTransactions(getState())
|
!hasUnconfirmedTransactions(getState())
|
||||||
) {
|
) {
|
||||||
global.platform.closeCurrentWindow();
|
global.platform.closeCurrentWindow();
|
||||||
|
|
||||||
dispatch(closeNotificationWindow());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function closeNotificationWindow() {
|
|
||||||
return {
|
|
||||||
type: actionConstants.CLOSE_NOTIFICATION_WINDOW,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function showSidebar({ transitionName, type, props }) {
|
export function showSidebar({ transitionName, type, props }) {
|
||||||
return {
|
return {
|
||||||
type: actionConstants.SIDEBAR_OPEN,
|
type: actionConstants.SIDEBAR_OPEN,
|
||||||
@ -2476,7 +2468,7 @@ export function resolvePendingApproval(id, value) {
|
|||||||
await promisifiedBackground.resolvePendingApproval(id, value);
|
await promisifiedBackground.resolvePendingApproval(id, value);
|
||||||
// Before closing the current window, check if any additional confirmations
|
// Before closing the current window, check if any additional confirmations
|
||||||
// are added as a result of this confirmation being accepted
|
// are added as a result of this confirmation being accepted
|
||||||
const { pendingApprovals } = await promisifiedBackground.getState();
|
const { pendingApprovals } = await forceUpdateMetamaskState(dispatch);
|
||||||
if (Object.values(pendingApprovals).length === 0) {
|
if (Object.values(pendingApprovals).length === 0) {
|
||||||
dispatch(closeCurrentNotificationWindow());
|
dispatch(closeCurrentNotificationWindow());
|
||||||
}
|
}
|
||||||
@ -2494,7 +2486,7 @@ export function rejectPendingApproval(id, error) {
|
|||||||
await promisifiedBackground.rejectPendingApproval(id, error);
|
await promisifiedBackground.rejectPendingApproval(id, error);
|
||||||
// Before closing the current window, check if any additional confirmations
|
// Before closing the current window, check if any additional confirmations
|
||||||
// are added as a result of this confirmation being rejected
|
// are added as a result of this confirmation being rejected
|
||||||
const { pendingApprovals } = await promisifiedBackground.getState();
|
const { pendingApprovals } = await forceUpdateMetamaskState(dispatch);
|
||||||
if (Object.values(pendingApprovals).length === 0) {
|
if (Object.values(pendingApprovals).length === 0) {
|
||||||
dispatch(closeCurrentNotificationWindow());
|
dispatch(closeCurrentNotificationWindow());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user