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"
|
||||
},
|
||||
"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": {
|
||||
"message": "Allow this site to switch the network?"
|
||||
|
@ -32,7 +32,9 @@ async function addEthereumChainHandler(
|
||||
if (!req.params?.[0] || typeof req.params[0] !== 'object') {
|
||||
return end(
|
||||
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 { isEqual } from 'lodash';
|
||||
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 Chip from '../../components/ui/chip';
|
||||
import MetaMaskTemplateRenderer from '../../components/app/metamask-template-renderer';
|
||||
@ -138,16 +133,11 @@ export default function ConfirmationPage() {
|
||||
}, [pendingConfirmation, t, dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
const environmentType = getEnvironmentType();
|
||||
// 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.
|
||||
// Otherwise, if the number of pending confirmations reduces to a number
|
||||
// that is less than the currently viewed index, reset the index.
|
||||
if (
|
||||
pendingConfirmations.length === 0 &&
|
||||
(environmentType === ENVIRONMENT_TYPE_FULLSCREEN ||
|
||||
environmentType === ENVIRONMENT_TYPE_POPUP)
|
||||
) {
|
||||
// return them to the default route. Otherwise, if the number of pending
|
||||
// confirmations reduces to a number that is less than the currently
|
||||
// viewed index, reset the index.
|
||||
if (pendingConfirmations.length === 0) {
|
||||
history.push(DEFAULT_ROUTE);
|
||||
} else if (pendingConfirmations.length <= currentPendingConfirmation) {
|
||||
setCurrentPendingConfirmation(pendingConfirmations.length - 1);
|
||||
|
@ -2,8 +2,6 @@ export const GO_HOME = 'GO_HOME';
|
||||
// modal state
|
||||
export const MODAL_OPEN = 'UI_MODAL_OPEN';
|
||||
export const MODAL_CLOSE = 'UI_MODAL_CLOSE';
|
||||
// notification state
|
||||
export const CLOSE_NOTIFICATION_WINDOW = 'CLOSE_NOTIFICATION_WINDOW';
|
||||
// sidebar state
|
||||
export const SIDEBAR_OPEN = 'UI_SIDEBAR_OPEN';
|
||||
export const SIDEBAR_CLOSE = 'UI_SIDEBAR_CLOSE';
|
||||
|
@ -1772,24 +1772,16 @@ export function hideModal(payload) {
|
||||
}
|
||||
|
||||
export function closeCurrentNotificationWindow() {
|
||||
return (dispatch, getState) => {
|
||||
return (_, getState) => {
|
||||
if (
|
||||
getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION &&
|
||||
!hasUnconfirmedTransactions(getState())
|
||||
) {
|
||||
global.platform.closeCurrentWindow();
|
||||
|
||||
dispatch(closeNotificationWindow());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function closeNotificationWindow() {
|
||||
return {
|
||||
type: actionConstants.CLOSE_NOTIFICATION_WINDOW,
|
||||
};
|
||||
}
|
||||
|
||||
export function showSidebar({ transitionName, type, props }) {
|
||||
return {
|
||||
type: actionConstants.SIDEBAR_OPEN,
|
||||
@ -2476,7 +2468,7 @@ export function resolvePendingApproval(id, value) {
|
||||
await promisifiedBackground.resolvePendingApproval(id, value);
|
||||
// Before closing the current window, check if any additional confirmations
|
||||
// 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) {
|
||||
dispatch(closeCurrentNotificationWindow());
|
||||
}
|
||||
@ -2494,7 +2486,7 @@ export function rejectPendingApproval(id, error) {
|
||||
await promisifiedBackground.rejectPendingApproval(id, error);
|
||||
// Before closing the current window, check if any additional confirmations
|
||||
// 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) {
|
||||
dispatch(closeCurrentNotificationWindow());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user