Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: MMI adds back the current Tx confirmation view to MMI #26539

Merged
merged 12 commits into from
Aug 27, 2024
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() {
Copy link
Contributor Author

@zone-live zone-live Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthewwalsh0 This seems to be the logical place for what you suggested, already does it for the beta build type. I'm not adding a code fence for this since it would mean that an other one would have to exist on the useCurrentConfirmation hook (otherwise things break), also it would add unnecessary complexity imo and this can be useful down the road for similar cases.

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 @@ -309,4 +309,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 =
zone-live marked this conversation as resolved.
Show resolved Hide resolved
(isRedesignedTransactionsUserSettingEnabled && isCorrectTransactionType) ||
(!isMMI() &&
isRedesignedTransactionsUserSettingEnabled &&
isCorrectTransactionType) ||
(isRedesignedConfirmationsDeveloperSettingEnabled &&
isCorrectTransactionType);

Expand Down
Loading