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

[MMI] Always redirect to MMI portfolio dashboard upon the user clicking on swaps (#20527)

This commit is contained in:
Albert Olivé 2023-08-18 18:44:23 +02:00 committed by GitHub
parent 23249b68b7
commit 8df77ed93d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,39 +14,44 @@ import {
getMmiPortfolioEnabled,
getMmiPortfolioUrl,
} from '../../../selectors/institutional/selectors';
///: END:ONLY_INCLUDE_IN
import { MMI_SWAPS_URL } from '../../../../shared/constants/swaps';
///: END:ONLY_INCLUDE_IN
import { I18nContext } from '../../../contexts/i18n';
import {
SEND_ROUTE,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
BUILD_QUOTE_ROUTE,
///: END:ONLY_INCLUDE_IN
} from '../../../helpers/constants/routes';
import Tooltip from '../../ui/tooltip';
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display';
import { PRIMARY, SECONDARY } from '../../../helpers/constants/common';
import {
getAccountType,
isBalanceCached,
getShouldShowFiat,
getCurrentKeyring,
getSwapsDefaultToken,
getIsSwapsChain,
getSelectedAccountCachedBalance,
getCurrentChainId,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
getSwapsDefaultToken,
getCurrentKeyring,
getIsBridgeChain,
getIsBuyableChain,
getMetaMetricsId,
///: END:ONLY_INCLUDE_IN
} from '../../../selectors';
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
import { setSwapsFromToken } from '../../../ducks/swaps/swaps';
import IconButton from '../../ui/icon-button';
import { isHardwareKeyring } from '../../../helpers/utils/hardware';
///: END:ONLY_INCLUDE_IN
import IconButton from '../../ui/icon-button';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import {
MetaMetricsEventCategory,
MetaMetricsEventName,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
MetaMetricsSwapsEventSource,
///: END:ONLY_INCLUDE_IN
} from '../../../../shared/constants/metametrics';
import Spinner from '../../ui/spinner';
import { startNewDraftTransaction } from '../../../ducks/send';
@ -69,16 +74,15 @@ const EthOverview = ({ className, showAddress }) => {
const isBridgeChain = useSelector(getIsBridgeChain);
const isBuyableChain = useSelector(getIsBuyableChain);
const metaMetricsId = useSelector(getMetaMetricsId);
///: END:ONLY_INCLUDE_IN
const keyring = useSelector(getCurrentKeyring);
const usingHardwareWallet = isHardwareKeyring(keyring?.type);
const defaultSwapsToken = useSelector(getSwapsDefaultToken);
///: END:ONLY_INCLUDE_IN
const balanceIsCached = useSelector(isBalanceCached);
const showFiat = useSelector(getShouldShowFiat);
const balance = useSelector(getSelectedAccountCachedBalance);
const isSwapsChain = useSelector(getIsSwapsChain);
const defaultSwapsToken = useSelector(getSwapsDefaultToken);
const chainId = useSelector(getCurrentChainId);
const accountType = useSelector(getAccountType);
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
const mmiPortfolioEnabled = useSelector(getMmiPortfolioEnabled);
@ -256,14 +260,13 @@ const EthOverview = ({ className, showAddress }) => {
/>
}
onClick={() => {
if (accountType === 'custody') {
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
global.platform.openTab({
url: MMI_SWAPS_URL,
});
///: END:ONLY_INCLUDE_IN
return;
}
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
if (isSwapsChain) {
trackEvent({
event: MetaMetricsEventName.NavSwapButtonClicked,
@ -282,6 +285,7 @@ const EthOverview = ({ className, showAddress }) => {
history.push(BUILD_QUOTE_ROUTE);
}
}
///: END:ONLY_INCLUDE_IN
}}
label={t('swap')}
data-testid="token-overview-button-swap"