mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
b5ece42ca1
* Sending showCustodyConfirmLink as a prop and fixing other issues * Upgraded MMI extension monrepo and trying to fix the issue * prevents deeplink from closing * Fixed styles of Custody view and changed the place of it * Fixed CI issues * fixing eslint issues * Update LavaMoat policies * fixing tests * Fixed test * updated snapshots * reorder, otherwise it won't make sense * adds necessary methods * removes duplicated key value * updated snapshot --------- Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net> Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com> Co-authored-by: António Regadas <apregadas@gmail.com>
240 lines
8.7 KiB
JavaScript
240 lines
8.7 KiB
JavaScript
import { compose } from 'redux';
|
|
import { connect } from 'react-redux';
|
|
import { withRouter } from 'react-router-dom';
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
import {
|
|
getMmiPortfolioEnabled,
|
|
getMmiPortfolioUrl,
|
|
} from '@metamask-institutional/portfolio-dashboard';
|
|
import { mmiActionsFactory } from '../../store/institutional/institution-background';
|
|
import { getWaitForConfirmDeepLinkDialog } from '../../selectors/institutional/selectors';
|
|
import { getInstitutionalConnectRequests } from '../../ducks/institutional/institutional';
|
|
///: END:ONLY_INCLUDE_IN
|
|
import {
|
|
activeTabHasPermissions,
|
|
getFirstPermissionRequest,
|
|
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
|
getFirstSnapInstallOrUpdateRequest,
|
|
///: END:ONLY_INCLUDE_IN
|
|
getIsMainnet,
|
|
getOriginOfCurrentTab,
|
|
getTotalUnapprovedCount,
|
|
getUnapprovedTemplatedConfirmations,
|
|
getWeb3ShimUsageStateForOrigin,
|
|
getInfuraBlocked,
|
|
getShowWhatsNewPopup,
|
|
getSortedAnnouncementsToShow,
|
|
getShowRecoveryPhraseReminder,
|
|
getShowTermsOfUse,
|
|
getShowOutdatedBrowserWarning,
|
|
getNewNetworkAdded,
|
|
hasUnsignedQRHardwareTransaction,
|
|
hasUnsignedQRHardwareMessage,
|
|
getNewNftAddedMessage,
|
|
getNewTokensImported,
|
|
getShouldShowSeedPhraseReminder,
|
|
getRemoveNftMessage,
|
|
getSuggestedTokens,
|
|
getSuggestedNfts,
|
|
getApprovalFlows,
|
|
} from '../../selectors';
|
|
|
|
import {
|
|
closeNotificationPopup,
|
|
setConnectedStatusPopoverHasBeenShown,
|
|
setDefaultHomeActiveTabName,
|
|
setWeb3ShimUsageAlertDismissed,
|
|
setAlertEnabledness,
|
|
setRecoveryPhraseReminderHasBeenShown,
|
|
setRecoveryPhraseReminderLastShown,
|
|
setTermsOfUseLastAgreed,
|
|
setOutdatedBrowserWarningLastShown,
|
|
setNewNetworkAdded,
|
|
setNewNftAddedMessage,
|
|
setRemoveNftMessage,
|
|
setNewTokensImported,
|
|
setActiveNetwork,
|
|
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
|
removeSnapError,
|
|
///: END:ONLY_INCLUDE_IN
|
|
} from '../../store/actions';
|
|
import { hideWhatsNewPopup } from '../../ducks/app/app';
|
|
import { getWeb3ShimUsageAlertEnabledness } from '../../ducks/metamask/metamask';
|
|
import { getSwapsFeatureIsLive } from '../../ducks/swaps/swaps';
|
|
import { getEnvironmentType } from '../../../app/scripts/lib/util';
|
|
import { getIsBrowserDeprecated } from '../../helpers/utils/util';
|
|
import {
|
|
ENVIRONMENT_TYPE_NOTIFICATION,
|
|
ENVIRONMENT_TYPE_POPUP,
|
|
} from '../../../shared/constants/app';
|
|
import {
|
|
AlertTypes,
|
|
Web3ShimUsageAlertStates,
|
|
} from '../../../shared/constants/alerts';
|
|
import { hasTransactionPendingApprovals } from '../../selectors/transactions';
|
|
import Home from './home.component';
|
|
|
|
const mapStateToProps = (state) => {
|
|
const { metamask, appState } = state;
|
|
const {
|
|
seedPhraseBackedUp,
|
|
selectedAddress,
|
|
connectedStatusPopoverHasBeenShown,
|
|
defaultHomeActiveTabName,
|
|
swapsState,
|
|
firstTimeFlowType,
|
|
completedOnboarding,
|
|
} = metamask;
|
|
const { forgottenPassword } = metamask;
|
|
const totalUnapprovedCount = getTotalUnapprovedCount(state);
|
|
const swapsEnabled = getSwapsFeatureIsLive(state);
|
|
const pendingConfirmations = getUnapprovedTemplatedConfirmations(state);
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
const institutionalConnectRequests = getInstitutionalConnectRequests(state);
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
const envType = getEnvironmentType();
|
|
const isPopup = envType === ENVIRONMENT_TYPE_POPUP;
|
|
const isNotification = envType === ENVIRONMENT_TYPE_NOTIFICATION;
|
|
|
|
let firstPermissionsRequest, firstPermissionsRequestId;
|
|
firstPermissionsRequest = getFirstPermissionRequest(state);
|
|
firstPermissionsRequestId = firstPermissionsRequest?.metadata.id || null;
|
|
|
|
// getFirstPermissionRequest should be updated with snap update logic once we hit main extension release
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
|
if (!firstPermissionsRequest) {
|
|
firstPermissionsRequest = getFirstSnapInstallOrUpdateRequest(state);
|
|
firstPermissionsRequestId = firstPermissionsRequest?.metadata.id || null;
|
|
}
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
const originOfCurrentTab = getOriginOfCurrentTab(state);
|
|
const shouldShowWeb3ShimUsageNotification =
|
|
isPopup &&
|
|
getWeb3ShimUsageAlertEnabledness(state) &&
|
|
activeTabHasPermissions(state) &&
|
|
getWeb3ShimUsageStateForOrigin(state, originOfCurrentTab) ===
|
|
Web3ShimUsageAlertStates.recorded;
|
|
|
|
const isSigningQRHardwareTransaction =
|
|
hasUnsignedQRHardwareTransaction(state) ||
|
|
hasUnsignedQRHardwareMessage(state);
|
|
|
|
const hasWatchTokenPendingApprovals = getSuggestedTokens(state).length > 0;
|
|
|
|
const hasWatchNftPendingApprovals = getSuggestedNfts(state).length > 0;
|
|
|
|
return {
|
|
forgottenPassword,
|
|
hasWatchTokenPendingApprovals,
|
|
hasWatchNftPendingApprovals,
|
|
swapsEnabled,
|
|
hasTransactionPendingApprovals: hasTransactionPendingApprovals(state),
|
|
shouldShowSeedPhraseReminder: getShouldShowSeedPhraseReminder(state),
|
|
isPopup,
|
|
isNotification,
|
|
selectedAddress,
|
|
firstPermissionsRequestId,
|
|
totalUnapprovedCount,
|
|
hasApprovalFlows:
|
|
Array.isArray(getApprovalFlows) && getApprovalFlows(state).length > 0,
|
|
connectedStatusPopoverHasBeenShown,
|
|
defaultHomeActiveTabName,
|
|
firstTimeFlowType,
|
|
completedOnboarding,
|
|
haveSwapsQuotes: Boolean(Object.values(swapsState.quotes || {}).length),
|
|
swapsFetchParams: swapsState.fetchParams,
|
|
showAwaitingSwapScreen: swapsState.routeState === 'awaiting',
|
|
isMainnet: getIsMainnet(state),
|
|
originOfCurrentTab,
|
|
shouldShowWeb3ShimUsageNotification,
|
|
pendingConfirmations,
|
|
infuraBlocked: getInfuraBlocked(state),
|
|
announcementsToShow: getSortedAnnouncementsToShow(state).length > 0,
|
|
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
|
errorsToShow: metamask.snapErrors,
|
|
shouldShowErrors: Object.entries(metamask.snapErrors || []).length > 0,
|
|
///: END:ONLY_INCLUDE_IN
|
|
showWhatsNewPopup: getShowWhatsNewPopup(state),
|
|
showRecoveryPhraseReminder: getShowRecoveryPhraseReminder(state),
|
|
showTermsOfUsePopup: getShowTermsOfUse(state),
|
|
showOutdatedBrowserWarning:
|
|
getIsBrowserDeprecated() && getShowOutdatedBrowserWarning(state),
|
|
seedPhraseBackedUp,
|
|
newNetworkAddedName: getNewNetworkAdded(state),
|
|
isSigningQRHardwareTransaction,
|
|
newNftAddedMessage: getNewNftAddedMessage(state),
|
|
removeNftMessage: getRemoveNftMessage(state),
|
|
newTokensImported: getNewTokensImported(state),
|
|
newNetworkAddedConfigurationId: appState.newNetworkAddedConfigurationId,
|
|
onboardedInThisUISession: appState.onboardedInThisUISession,
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
waitForConfirmDeepLinkDialog: getWaitForConfirmDeepLinkDialog(state),
|
|
institutionalConnectRequests,
|
|
modalOpen: state.appState.modal.open,
|
|
mmiPortfolioUrl: getMmiPortfolioUrl(state),
|
|
mmiPortfolioEnabled: getMmiPortfolioEnabled(state),
|
|
notificationsToShow: getSortedAnnouncementsToShow(state).length > 0,
|
|
///: END:ONLY_INCLUDE_IN
|
|
};
|
|
};
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
const mmiActions = mmiActionsFactory();
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
return {
|
|
closeNotificationPopup: () => closeNotificationPopup(),
|
|
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
|
removeSnapError: async (id) => await removeSnapError(id),
|
|
///: END:ONLY_INCLUDE_IN
|
|
setConnectedStatusPopoverHasBeenShown: () =>
|
|
dispatch(setConnectedStatusPopoverHasBeenShown()),
|
|
onTabClick: (name) => dispatch(setDefaultHomeActiveTabName(name)),
|
|
setWeb3ShimUsageAlertDismissed: (origin) =>
|
|
setWeb3ShimUsageAlertDismissed(origin),
|
|
disableWeb3ShimUsageAlert: () =>
|
|
setAlertEnabledness(AlertTypes.web3ShimUsage, false),
|
|
hideWhatsNewPopup: () => dispatch(hideWhatsNewPopup()),
|
|
setRecoveryPhraseReminderHasBeenShown: () =>
|
|
dispatch(setRecoveryPhraseReminderHasBeenShown()),
|
|
setRecoveryPhraseReminderLastShown: (lastShown) =>
|
|
dispatch(setRecoveryPhraseReminderLastShown(lastShown)),
|
|
setTermsOfUseLastAgreed: (lastAgreed) => {
|
|
dispatch(setTermsOfUseLastAgreed(lastAgreed));
|
|
},
|
|
setOutdatedBrowserWarningLastShown: (lastShown) => {
|
|
dispatch(setOutdatedBrowserWarningLastShown(lastShown));
|
|
},
|
|
setNewNftAddedMessage: (message) => {
|
|
dispatch(setRemoveNftMessage(''));
|
|
dispatch(setNewNftAddedMessage(message));
|
|
},
|
|
setRemoveNftMessage: (message) => {
|
|
dispatch(setNewNftAddedMessage(''));
|
|
dispatch(setRemoveNftMessage(message));
|
|
},
|
|
setNewTokensImported: (newTokens) => {
|
|
dispatch(setNewTokensImported(newTokens));
|
|
},
|
|
clearNewNetworkAdded: () => {
|
|
dispatch(setNewNetworkAdded({}));
|
|
},
|
|
setActiveNetwork: (networkConfigurationId) => {
|
|
dispatch(setActiveNetwork(networkConfigurationId));
|
|
},
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
setWaitForConfirmDeepLinkDialog: (wait) =>
|
|
dispatch(mmiActions.setWaitForConfirmDeepLinkDialog(wait)),
|
|
///: END:ONLY_INCLUDE_IN
|
|
};
|
|
};
|
|
|
|
export default compose(
|
|
withRouter,
|
|
connect(mapStateToProps, mapDispatchToProps),
|
|
)(Home);
|