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

feat: unified confirmation navigation #28761

Merged
merged 34 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e700000
Add template confirmations to transaction and signature navigation
matthewwalsh0 Nov 23, 2024
a4a3ec9
Remove unused state
matthewwalsh0 Nov 25, 2024
9a083e9
Merge branch 'develop' into feat/shared-confirmation-navigation
matthewwalsh0 Nov 28, 2024
8144d6e
Fix unit tests
matthewwalsh0 Nov 28, 2024
52a0e95
Fix unit tests
matthewwalsh0 Nov 28, 2024
07b0dcb
Fix template navigation
matthewwalsh0 Nov 29, 2024
6872a10
Fix linting
matthewwalsh0 Dec 3, 2024
f956560
Fix E2E tests
matthewwalsh0 Dec 3, 2024
2afac9d
Update story
matthewwalsh0 Dec 3, 2024
a2023cd
Merge branch 'main' into feat/shared-confirmation-navigation
matthewwalsh0 Dec 4, 2024
39f0c5b
Revert "Fix E2E tests"
matthewwalsh0 Dec 4, 2024
71bea94
Fix E2E and integration tests
matthewwalsh0 Dec 4, 2024
5e3c824
Add E2E test
matthewwalsh0 Dec 6, 2024
fe253fc
Add unit tests for use confirmation navigation
matthewwalsh0 Dec 6, 2024
7c83ce2
Merge branch 'main' into feat/shared-confirmation-navigation
matthewwalsh0 Dec 6, 2024
10b83ef
Fix linting
matthewwalsh0 Dec 6, 2024
2ceb912
Fix unit tests
matthewwalsh0 Dec 6, 2024
97a70a9
Fix legacy navigation
matthewwalsh0 Dec 6, 2024
7f77b64
Support all confirmations
matthewwalsh0 Dec 6, 2024
a8e9de5
Update unit tests
matthewwalsh0 Dec 6, 2024
e98c8e2
Fix snap install
matthewwalsh0 Dec 7, 2024
7374a5e
Support encrypt and decrypt
matthewwalsh0 Dec 7, 2024
b89fbef
Support approval flows
matthewwalsh0 Dec 7, 2024
22c793b
Fix E2E test
matthewwalsh0 Dec 7, 2024
f3a0eb5
Remove unnecessary code
matthewwalsh0 Dec 7, 2024
18570c2
Reject all using type specific logic
matthewwalsh0 Dec 9, 2024
db5cdf9
Fix MMI build
matthewwalsh0 Dec 9, 2024
3d66d7f
Fix E2E tests
matthewwalsh0 Dec 9, 2024
c3ce905
Fix drop shadow
matthewwalsh0 Dec 10, 2024
ec62382
Fix unit tests
matthewwalsh0 Dec 10, 2024
1f03058
Merge branch 'main' into feat/shared-confirmation-navigation
matthewwalsh0 Dec 10, 2024
ac44d44
Delete interface when rejecting snap confirmations
matthewwalsh0 Dec 10, 2024
4da340f
Merge branch 'feat/shared-confirmation-navigation' of github.com:Meta…
matthewwalsh0 Dec 10, 2024
1bc93b0
Fix linting and unit tests
matthewwalsh0 Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .storybook/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Fixes for any styles that are not compatible with Storybook */

.create-snap-account-page, .remove-snap-account-page, .snap-ui-renderer {
width: 100% !important;
}

.snap-ui-renderer__footer-centered {
position: initial !important;
margin-top: auto !important;
}

.snap-ui-renderer__container {
padding-bottom: 0 !important;
}

.snap-ui-renderer__panel {
overflow-y: auto !important;
}
1 change: 1 addition & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { metamaskStorybookTheme } from './metamask-storybook-theme';
import { DocsContainer } from '@storybook/addon-docs';
import { themes } from '@storybook/theming';
import { AlertMetricsProvider } from '../ui/components/app/alert-system/contexts/alertMetricsContext';
import './index.css';

// eslint-disable-next-line
/* @ts-expect-error: Avoids error from window property not existing */
Expand Down
4 changes: 0 additions & 4 deletions app/_locales/de/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/el/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/en_GB/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/es/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/es_419/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/fr/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/hi/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/id/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/ja/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/ko/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/ph/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/pt/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/pt_BR/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/ru/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/tl/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/tr/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/vi/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/zh_CN/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions app/_locales/zh_TW/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 2 additions & 35 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ import log from 'loglevel';
import browser from 'webextension-polyfill';
import { storeAsStream } from '@metamask/obs-store';
import { isObject } from '@metamask/utils';
import { ApprovalType } from '@metamask/controller-utils';
import PortStream from 'extension-port-stream';

import { providerErrors } from '@metamask/rpc-errors';
import { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';
import { NotificationServicesController } from '@metamask/notification-services-controller';

import {
Expand All @@ -29,9 +25,6 @@ import {
EXTENSION_MESSAGES,
PLATFORM_FIREFOX,
MESSAGE_TYPE,
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES,
///: END:ONLY_INCLUDE_IF
} from '../../shared/constants/app';
import {
REJECT_NOTIFICATION_CLOSE,
Expand All @@ -56,6 +49,7 @@ import {
import { getCurrentChainId } from '../../shared/modules/selectors/networks';
import { addNonceToCsp } from '../../shared/modules/add-nonce-to-csp';
import { checkURLForProviderInjection } from '../../shared/modules/provider-injection';
import { rejectAllApprovals } from '../../shared/lib/approval';
import migrations from './migrations';
import Migrator from './lib/migrator';
import ExtensionPlatform from './platforms/extension';
Expand Down Expand Up @@ -1201,34 +1195,7 @@ export function setupController(
REJECT_NOTIFICATION_CLOSE,
);

// Finally, resolve snap dialog approvals on Flask and reject all the others managed by the ApprovalController.
Object.values(controller.approvalController.state.pendingApprovals).forEach(
({ id, type }) => {
switch (type) {
case ApprovalType.SnapDialogAlert:
case ApprovalType.SnapDialogPrompt:
case DIALOG_APPROVAL_TYPES.default:
controller.approvalController.accept(id, null);
break;
case ApprovalType.SnapDialogConfirmation:
controller.approvalController.accept(id, false);
break;
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
case SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.confirmAccountCreation:
case SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.confirmAccountRemoval:
case SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.showSnapAccountRedirect:
controller.approvalController.accept(id, false);
break;
///: END:ONLY_INCLUDE_IF
default:
controller.approvalController.reject(
id,
providerErrors.userRejectedRequest(),
);
break;
}
},
);
rejectAllApprovals(controller.approvalController);
}

// Updates the snaps registry and check for newly blocked snaps to block if the user has at least one snap installed that isn't preinstalled.
Expand Down
12 changes: 6 additions & 6 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ import { isSnapId } from '../../ui/helpers/utils/snaps';
import { BridgeStatusAction } from '../../shared/types/bridge-status';
import { ENVIRONMENT } from '../../development/build/constants';
import fetchWithCache from '../../shared/lib/fetch-with-cache';
import { rejectAllApprovals } from '../../shared/lib/approval';
import { BalancesController as MultichainBalancesController } from './lib/accounts/BalancesController';
import {
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
Expand Down Expand Up @@ -3553,10 +3554,6 @@ export default class MetamaskController extends EventEmitter {
markNotificationPopupAsAutomaticallyClosed: () =>
this.notificationManager.markAsAutomaticallyClosed(),

// approval
requestUserApproval:
approvalController.addAndShowApprovalRequest.bind(approvalController),

// primary keyring management
addNewAccount: this.addNewAccount.bind(this),
getSeedPhrase: this.getSeedPhrase.bind(this),
Expand Down Expand Up @@ -4180,9 +4177,12 @@ export default class MetamaskController extends EventEmitter {
),
trackInsightSnapView: this.trackInsightSnapView.bind(this),

// approval controller
resolvePendingApproval: this.resolvePendingApproval,
// ApprovalController
rejectPendingApproval: this.rejectPendingApproval,
rejectAllApprovals: rejectAllApprovals.bind(null, approvalController),
requestUserApproval:
approvalController.addAndShowApprovalRequest.bind(approvalController),
resolvePendingApproval: this.resolvePendingApproval,

// Notifications
resetViewedNotifications: announcementController.resetViewed.bind(
Expand Down
Loading
Loading