1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

UX: Ensure block explorer link is for desired account (#20144)

This commit is contained in:
David Walsh 2023-07-25 11:59:22 -05:00 committed by GitHub
parent 25247d0300
commit 9310a95499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 3 deletions

View File

@ -138,6 +138,7 @@ export const AccountListItemMenu = ({
metricsLocation={METRICS_LOCATION} metricsLocation={METRICS_LOCATION}
closeMenu={closeMenu} closeMenu={closeMenu}
textProps={{ variant: TextVariant.bodySm }} textProps={{ variant: TextVariant.bodySm }}
address={identity.address}
/> />
{isRemovable ? ( {isRemovable ? (
<MenuItem <MenuItem

View File

@ -101,6 +101,7 @@ export const GlobalMenu = ({ closeMenu, anchorElement }) => {
<ViewExplorerMenuItem <ViewExplorerMenuItem
metricsLocation={METRICS_LOCATION} metricsLocation={METRICS_LOCATION}
closeMenu={closeMenu} closeMenu={closeMenu}
address={address}
/> />
<MenuItem <MenuItem
iconName={IconName.Connect} iconName={IconName.Connect}

View File

@ -18,7 +18,6 @@ import {
getBlockExplorerLinkText, getBlockExplorerLinkText,
getCurrentChainId, getCurrentChainId,
getRpcPrefsForCurrentProvider, getRpcPrefsForCurrentProvider,
getSelectedAddress,
} from '../../../selectors'; } from '../../../selectors';
import { getURLHostName } from '../../../helpers/utils/util'; import { getURLHostName } from '../../../helpers/utils/util';
import { NETWORKS_ROUTE } from '../../../helpers/constants/routes'; import { NETWORKS_ROUTE } from '../../../helpers/constants/routes';
@ -27,15 +26,15 @@ export const ViewExplorerMenuItem = ({
metricsLocation, metricsLocation,
closeMenu, closeMenu,
textProps, textProps,
address,
}) => { }) => {
const t = useI18nContext(); const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext); const trackEvent = useContext(MetaMetricsContext);
const history = useHistory(); const history = useHistory();
const currentAddress = useSelector(getSelectedAddress);
const chainId = useSelector(getCurrentChainId); const chainId = useSelector(getCurrentChainId);
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider); const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider);
const addressLink = getAccountLink(currentAddress, chainId, rpcPrefs); const addressLink = getAccountLink(address, chainId, rpcPrefs);
const { blockExplorerUrl } = rpcPrefs; const { blockExplorerUrl } = rpcPrefs;
const blockExplorerUrlSubTitle = getURLHostName(blockExplorerUrl); const blockExplorerUrlSubTitle = getURLHostName(blockExplorerUrl);
@ -94,4 +93,5 @@ ViewExplorerMenuItem.propTypes = {
metricsLocation: PropTypes.string.isRequired, metricsLocation: PropTypes.string.isRequired,
closeMenu: PropTypes.func, closeMenu: PropTypes.func,
textProps: PropTypes.object, textProps: PropTypes.object,
address: PropTypes.string.isRequired,
}; };

View File

@ -10,6 +10,7 @@ const render = () => {
<ViewExplorerMenuItem <ViewExplorerMenuItem
metricsLocation="Global Menu" metricsLocation="Global Menu"
closeMenu={jest.fn()} closeMenu={jest.fn()}
address="0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
/>, />,
store, store,
); );