Skip to content

Commit

Permalink
Merge branch 'Version-v12.2.0' into v12.2.0-sync-v12.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Gudahtt authored Sep 2, 2024
2 parents 7da24fb + 0792ec1 commit dd646de
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 14 deletions.
9 changes: 6 additions & 3 deletions test/e2e/playwright/mmi/pageObjects/mmi-dummyApp-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ export class DummyAppPage {
if (isSign) {
await popup.click('button:has-text("Confirm")');
} else {
// Confirm
await popup.getByTestId('page-container-footer-next').click();
// Approve

if (buttonId === 'approveTokens') {
await popup.getByTestId('page-container-footer-next').click();
}

await popup
.getByTestId('custody-confirm-link__btn')
.click({ timeout: 10000 });
// }
}

await popup.close();
}

Expand Down
12 changes: 1 addition & 11 deletions ui/pages/confirmations/confirm-approve/confirm-approve.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,7 @@ export default function ConfirmApprove({
return <ConfirmContractInteraction />;
}

let tokenAllowanceImprovements = true;

///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
tokenAllowanceImprovements = false;
///: END:ONLY_INCLUDE_IF

if (
tokenAllowanceImprovements &&
assetStandard === TokenStandard.ERC20 &&
!isSetApproveForAll
) {
if (assetStandard === TokenStandard.ERC20 && !isSetApproveForAll) {
return (
<GasFeeContextProvider transaction={transaction}>
<TransactionModalContextProvider>
Expand Down
58 changes: 58 additions & 0 deletions ui/pages/confirmations/token-allowance/token-allowance.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { useDispatch, useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import PropTypes from 'prop-types';
import BigNumber from 'bignumber.js';
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
import { showCustodianDeepLink } from '@metamask-institutional/extension';
///: END:ONLY_INCLUDE_IF
import Box from '../../../components/ui/box/box';
import NetworkAccountBalanceHeader from '../../../components/app/network-account-balance-header/network-account-balance-header';
import UrlIcon from '../../../components/ui/url-icon/url-icon';
Expand Down Expand Up @@ -73,6 +76,12 @@ import CustomNonce from '../components/custom-nonce';
import FeeDetailsComponent from '../components/fee-details-component/fee-details-component';
import { BlockaidResultType } from '../../../../shared/constants/security-provider';

///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
import { getAccountType } from '../../../selectors/selectors';
import { mmiActionsFactory } from '../../../store/institutional/institution-background';
import { showCustodyConfirmLink } from '../../../store/institutional/institution-actions';
///: END:ONLY_INCLUDE_IF

const ALLOWED_HOSTS = ['portfolio.metamask.io'];

export default function TokenAllowance({
Expand Down Expand Up @@ -135,6 +144,12 @@ export default function TokenAllowance({
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
const nextNonce = useSelector(getNextSuggestedNonce);
const customNonceValue = useSelector(getCustomNonceValue);
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
const accountType = useSelector((state) =>
getAccountType(state, fromAccount.address),
);
const mmiActions = mmiActionsFactory();
///: END:ONLY_INCLUDE_IF

/**
* We set the customSpendingCap to the dappProposedTokenAmount, if provided, rather than setting customTokenAmount
Expand Down Expand Up @@ -222,6 +237,43 @@ export default function TokenAllowance({
});
};

///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
const mmiApprovalFlow = () => {
if (accountType === 'custody') {
fullTxData.custodyStatus = 'created';
fullTxData.metadata = fullTxData.metadata || {};

dispatch(mmiActions.setWaitForConfirmDeepLinkDialog(true));

const txId = fullTxData.id;
const fromAddress = fullTxData.txParams.from;
const closeNotification = false;
dispatch(updateAndApproveTx(customNonceMerge(fullTxData))).then(() => {
showCustodianDeepLink({
dispatch,
mmiActions,
txId,
fromAddress,
closeNotification,
onDeepLinkFetched: () => undefined,
onDeepLinkShown: () => {
dispatch(clearConfirmTransaction());
history.push(mostRecentOverviewPage);
},
showCustodyConfirmLink,
});
history.push(mostRecentOverviewPage);
});
} else {
// Non Custody accounts follow normal flow
dispatch(updateAndApproveTx(customNonceMerge(fullTxData))).then(() => {
dispatch(clearConfirmTransaction());
history.push(mostRecentOverviewPage);
});
}
};
///: END:ONLY_INCLUDE_IF

const handleApprove = () => {
const { name } = methodData;

Expand Down Expand Up @@ -251,10 +303,16 @@ export default function TokenAllowance({

dispatch(updateCustomNonce(''));

///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
mmiApprovalFlow();
///: END:ONLY_INCLUDE_IF

///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
dispatch(updateAndApproveTx(customNonceMerge(fullTxData))).then(() => {
dispatch(clearConfirmTransaction());
history.push(mostRecentOverviewPage);
});
///: END:ONLY_INCLUDE_IF
};

const handleNextClick = () => {
Expand Down

0 comments on commit dd646de

Please sign in to comment.