Skip to content

Commit

Permalink
chore: MMI adds back the current Tx confirmation view to MMI (#26539)
Browse files Browse the repository at this point in the history
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

While we don't support the new confirmation UI for Txs (MMI flow got
broken with the upgrade), we need to show the current one to MMI.

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
zone-live authored Aug 27, 2024
1 parent aea494d commit 5b6e7ef
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/e2e/playwright/mmi/pageObjects/mmi-auth0-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class Auth0Page {
.locator('#password')
.fill(process.env.MMI_E2E_E2E_AUTH0_PASSWORD as string);
await this.page.getByRole('button', { name: /continue/iu }).click();
await this.page.getByRole('button', { name: /E2E Organization/iu }).click();
await expect(this.page).toHaveURL(portfolio);
}
}
2 changes: 2 additions & 0 deletions test/e2e/playwright/mmi/specs/extension.visual.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ test.describe('MMI extension', () => {
'Custody Account R',
'Custody Account S',
'Custody Account T',
'TR',
'TR2',
];

// Getting extension id of MMI
Expand Down
4 changes: 4 additions & 0 deletions ui/helpers/utils/build-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export function isBeta() {
return process.env.METAMASK_BUILD_TYPE === 'beta';
}

export function isMMI() {
return process.env.METAMASK_BUILD_TYPE === 'mmi';
}

// Returns a specific version of an asset based on
// the current metamask version (i.e. main, beta, etc.)
export function getBuildSpecificAsset(assetName) {
Expand Down
27 changes: 27 additions & 0 deletions ui/pages/confirmations/hooks/useCurrentConfirmation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,31 @@ describe('useCurrentConfirmation', () => {
expect(currentConfirmation).toBeUndefined();
});
});

describe('useCurrentConfirmation with MM build type env var (MMI)', () => {
beforeAll(() => {
jest.resetModules();
process.env.METAMASK_BUILD_TYPE = 'mmi';
});

afterAll(() => {
process.env.METAMASK_BUILD_TYPE = 'main';
});

it('returns undefined if build type is MMI, user setting is enabled and transaction has correct type', () => {
const currentConfirmation = runHook({
pendingApprovals: [
{ ...APPROVAL_MOCK, type: ApprovalType.Transaction },
],
redesignedConfirmationsEnabled: true,
transaction: {
...TRANSACTION_MOCK,
type: TransactionType.contractInteraction,
},
isRedesignedConfirmationsDeveloperEnabled: false,
});

expect(currentConfirmation).toBeUndefined();
});
});
});
5 changes: 4 additions & 1 deletion ui/pages/confirmations/hooks/useCurrentConfirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '../../../selectors';
import { REDESIGN_APPROVAL_TYPES, REDESIGN_TRANSACTION_TYPES } from '../utils';
import { selectUnapprovedMessage } from '../../../selectors/signatures';
import { isMMI } from '../../../helpers/utils/build-types';

/**
* Determine the current confirmation based on the pending approvals and controller state.
Expand Down Expand Up @@ -73,7 +74,9 @@ const useCurrentConfirmation = () => {
(isRedesignedConfirmationsDeveloperSettingEnabled && isCorrectApprovalType);

const shouldUseRedesignForTransactions =
(isRedesignedTransactionsUserSettingEnabled && isCorrectTransactionType) ||
(!isMMI() &&
isRedesignedTransactionsUserSettingEnabled &&
isCorrectTransactionType) ||
(isRedesignedConfirmationsDeveloperSettingEnabled &&
isCorrectTransactionType);

Expand Down

0 comments on commit 5b6e7ef

Please sign in to comment.