Skip to content

Commit

Permalink
[MMI] Allows the mmi build to be generated using the dist command (#2…
Browse files Browse the repository at this point in the history
…0148)

* adds listeners for signatureControll and adds the handleSigningEvents method

* clean up

* updates signature request containers files

* adds necessary methods

* wip

* signing flow with core methods

* yarn lint

* updates logic to fit latest signatureCOntroller

* updates mmi extension package

* updates signature-controller and message-manager packages

* checkout develop lock file and run yarn

* checkout develop lock file and package.json to test circleci

* test fix

* adds signature-controller new version

* updates mmi extension package

* tx-list update and runs lavamoat auto

* lint fix

* runs lavamoat auto

* resets lavamoat/build-system/policy.jsono to develop

* Update LavaMoat policies

* adds back the dispatch

* lint

* changes needed to generate a mmi build

* adds metametricsId in url param

* adds necessary fence

---------

Co-authored-by: MetaMask Bot <[email protected]>
  • Loading branch information
zone-live and metamaskbot authored Jul 25, 2023
1 parent 5693d19 commit 4b9a4d3
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 50 deletions.
2 changes: 1 addition & 1 deletion development/build/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function createManifestTasks({

const buildName =
buildType === 'mmi'
? `MetaMask Institutional ${mv3Str}${lavamoatStr}${snowStr}`
? `MetaMask Institutional ${mv3Str}`
: `MetaMask ${capitalize(buildType)}${mv3Str}${lavamoatStr}${snowStr}`;

manifest.name = buildName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { Tabs, Tab } from '../../../ui/tabs';
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
import Button from '../../../ui/button';
///: END:ONLY_INCLUDE_IN
import ActionableMessage from '../../../ui/actionable-message/actionable-message';
import { PageContainerFooter } from '../../../ui/page-container';
import ErrorMessage from '../../../ui/error-message';
Expand Down Expand Up @@ -57,7 +59,9 @@ export default class ConfirmPageContainerContent extends Component {
toAddress: PropTypes.string,
transactionType: PropTypes.string,
isBuyableChain: PropTypes.bool,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
openBuyCryptoInPdapp: PropTypes.func,
///: END:ONLY_INCLUDE_IN
txData: PropTypes.object,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
noteComponent: PropTypes.node,
Expand Down Expand Up @@ -197,7 +201,9 @@ export default class ConfirmPageContainerContent extends Component {
toAddress,
transactionType,
isBuyableChain,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
openBuyCryptoInPdapp,
///: END:ONLY_INCLUDE_IN
txData,
} = this.props;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import React, { useCallback, useContext, useEffect, useState } from 'react';
import React, {
useCallback,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
useContext,
///: END:ONLY_INCLUDE_IN
useEffect,
useState,
} from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';

Expand Down Expand Up @@ -45,11 +52,13 @@ import {
getSwapsDefaultToken,
} from '../../../selectors';
import useRamps from '../../../hooks/experiences/useRamps';
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
import { MetaMetricsContext } from '../../../contexts/metametrics';
import {
MetaMetricsEventCategory,
MetaMetricsEventName,
} from '../../../../shared/constants/metametrics';
///: END:ONLY_INCLUDE_IN
import {
ConfirmPageContainerHeader,
ConfirmPageContainerContent,
Expand Down Expand Up @@ -105,8 +114,9 @@ const ConfirmPageContainer = (props) => {
} = props;

const t = useI18nContext();
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
const trackEvent = useContext(MetaMetricsContext);

///: END:ONLY_INCLUDE_IN
const [collectionBalance, setCollectionBalance] = useState('0');

const isBuyableChain = useSelector(getIsBuyableChain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ export default class SignatureRequestOriginal extends Component {
address: PropTypes.string.isRequired,
name: PropTypes.string,
}).isRequired,
clearConfirmTransaction: PropTypes.func.isRequired,
history: PropTypes.object.isRequired,
mostRecentOverviewPage: PropTypes.string.isRequired,
txData: PropTypes.object.isRequired,
subjectMetadata: PropTypes.object,
hardwareWalletRequiresConnection: PropTypes.bool,
Expand All @@ -75,6 +72,9 @@ export default class SignatureRequestOriginal extends Component {
showRejectTransactionsConfirmationModal: PropTypes.func.isRequired,
cancelAllApprovals: PropTypes.func.isRequired,
rejectPendingApproval: PropTypes.func.isRequired,
clearConfirmTransaction: PropTypes.func.isRequired,
history: PropTypes.object.isRequired,
mostRecentOverviewPage: PropTypes.string.isRequired,
resolvePendingApproval: PropTypes.func.isRequired,
completedTx: PropTypes.func.isRequired,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
Expand Down Expand Up @@ -258,11 +258,11 @@ export default class SignatureRequestOriginal extends Component {

onSubmit = async () => {
const {
resolvePendingApproval,
completedTx,
clearConfirmTransaction,
history,
mostRecentOverviewPage,
resolvePendingApproval,
completedTx,
txData,
} = this.props;
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
Expand All @@ -272,12 +272,10 @@ export default class SignatureRequestOriginal extends Component {
}
///: END:ONLY_INCLUDE_IN

///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
await resolvePendingApproval(txData.id);
completedTx(txData.id);
clearConfirmTransaction();
history.push(mostRecentOverviewPage);
///: END:ONLY_INCLUDE_IN
};

onCancel = async () => {
Expand Down Expand Up @@ -332,11 +330,9 @@ export default class SignatureRequestOriginal extends Component {
}
///: END:ONLY_INCLUDE_IN

///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
await resolvePendingApproval(txData.id);
clearConfirmTransaction();
history.push(mostRecentOverviewPage);
///: END:ONLY_INCLUDE_IN
}
}}
disabled={
Expand Down
4 changes: 3 additions & 1 deletion ui/components/app/signature-request/signature-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { ethErrors, serializeError } from 'eth-rpc-errors';
import { showCustodianDeepLink } from '@metamask-institutional/extension';
///: END:ONLY_INCLUDE_IN
import {
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
resolvePendingApproval,
rejectPendingApproval,
completedTx,
///: END:ONLY_INCLUDE_IN
rejectPendingApproval,
} from '../../../store/actions';
import {
doesAddressRequireLedgerHidConnection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export default function TransactionList({
{pendingTransactions.map((dateGroup) => {
return dateGroup.transactionGroups.map(
(transactionGroup, index) => {
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
if (
transactionGroup.initialTransaction.transactionType ===
TransactionType.smart
Expand All @@ -193,7 +192,6 @@ export default function TransactionList({
</>
);
}
///: END:ONLY_INCLUDE_IN
return (
<>
{renderDateStamp(index, dateGroup)}
Expand All @@ -218,7 +216,7 @@ export default function TransactionList({
<>
{renderDateStamp(index, dateGroup)}
{transactionGroup.initialTransaction?.transactionType ===
'smart' ? (
TransactionType.smart ? (
<SmartTransactionListItem
transactionGroup={transactionGroup}
smartTransaction={transactionGroup.initialTransaction}
Expand Down
27 changes: 20 additions & 7 deletions ui/components/app/wallet-overview/eth-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { useDispatch, useSelector } from 'react-redux';
import classnames from 'classnames';
import { useHistory, useLocation } from 'react-router-dom';
import {
useHistory,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
useLocation,
///: END:ONLY_INCLUDE_IN
} from 'react-router-dom';

///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
import {
Expand All @@ -25,11 +30,13 @@ import {
getCurrentKeyring,
getSwapsDefaultToken,
getIsSwapsChain,
getIsBridgeChain,
getIsBuyableChain,
getSelectedAccountCachedBalance,
getCurrentChainId,
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
getIsBridgeChain,
getIsBuyableChain,
getMetaMetricsId,
///: END:ONLY_INCLUDE_IN
} from '../../../selectors';
import { setSwapsFromToken } from '../../../ducks/swaps/swaps';
import IconButton from '../../ui/icon-button';
Expand All @@ -45,27 +52,31 @@ import { startNewDraftTransaction } from '../../../ducks/send';
import { AssetType } from '../../../../shared/constants/transaction';
import { Icon, IconName } from '../../component-library';
import { IconColor } from '../../../helpers/constants/design-system';
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
import useRamps from '../../../hooks/experiences/useRamps';
import { getPortfolioUrl } from '../../../helpers/utils/portfolio';
///: END:ONLY_INCLUDE_IN
import WalletOverview from './wallet-overview';

const EthOverview = ({ className, showAddress }) => {
const dispatch = useDispatch();
const t = useContext(I18nContext);
const trackEvent = useContext(MetaMetricsContext);
const history = useHistory();
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
const location = useLocation();
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 balanceIsCached = useSelector(isBalanceCached);
const showFiat = useSelector(getShouldShowFiat);
const balance = useSelector(getSelectedAccountCachedBalance);
const isSwapsChain = useSelector(getIsSwapsChain);
const isBridgeChain = useSelector(getIsBridgeChain);
const isBuyableChain = useSelector(getIsBuyableChain);
const defaultSwapsToken = useSelector(getSwapsDefaultToken);
const chainId = useSelector(getCurrentChainId);
const metaMetricsId = useSelector(getMetaMetricsId);

///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
const mmiPortfolioEnabled = useSelector(getMmiPortfolioEnabled);
Expand Down Expand Up @@ -95,7 +106,7 @@ const EthOverview = ({ className, showAddress }) => {
onClick={() => {
stakingEvent();
global.platform.openTab({
url: 'https://metamask-institutional.io/staking',
url: 'https://metamask-institutional.io/stake',
});
}}
/>
Expand All @@ -117,7 +128,9 @@ const EthOverview = ({ className, showAddress }) => {
};
///: END:ONLY_INCLUDE_IN

///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
const { openBuyCryptoInPdapp } = useRamps();
///: END:ONLY_INCLUDE_IN

return (
<WalletOverview
Expand Down
7 changes: 6 additions & 1 deletion ui/components/multichain/global-menu/global-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import {
MetaMetricsEventCategory,
MetaMetricsContextProp,
} from '../../../../shared/constants/metametrics';
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
import { getPortfolioUrl } from '../../../helpers/utils/portfolio';
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
import {
getMmiPortfolioEnabled,
Expand Down Expand Up @@ -129,7 +131,10 @@ export const GlobalMenu = ({ closeMenu, anchorElement }) => {
category: MetaMetricsEventCategory.Navigation,
event: MetaMetricsEventName.MMIPortfolioButtonClicked,
});
window.open(mmiPortfolioUrl, '_blank');
window.open(
`${mmiPortfolioUrl}?metametricsId=${metaMetricsId}`,
'_blank',
);
closeMenu();
}}
data-testid="global-menu-mmi-portfolio"
Expand Down
Loading

0 comments on commit 4b9a4d3

Please sign in to comment.