Skip to content

Commit 4da050b

Browse files
authored
Merge branch 'main' into fix/redeposits-not-shown
2 parents a43dbd9 + a37efd8 commit 4da050b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+901
-174
lines changed

app/_locales/en/messages.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/_locales/en_GB/messages.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
21.8 KB
Binary file not shown.

app/scripts/controllers/app-state-controller.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ describe('AppStateController', () => {
790790
"notificationGasPollTokens": [],
791791
"onboardingDate": null,
792792
"outdatedBrowserWarningLastShown": null,
793+
"pendingShieldCohort": null,
793794
"popupGasPollTokens": [],
794795
"productTour": "accountIcon",
795796
"recoveryPhraseReminderHasBeenShown": false,
@@ -879,6 +880,7 @@ describe('AppStateController', () => {
879880
"notificationGasPollTokens": [],
880881
"onboardingDate": null,
881882
"outdatedBrowserWarningLastShown": null,
883+
"pendingShieldCohort": null,
882884
"popupGasPollTokens": [],
883885
"productTour": "accountIcon",
884886
"recoveryPhraseReminderHasBeenShown": false,
@@ -1045,6 +1047,7 @@ describe('AppStateController', () => {
10451047
"notificationGasPollTokens": [],
10461048
"onboardingDate": null,
10471049
"outdatedBrowserWarningLastShown": null,
1050+
"pendingShieldCohort": null,
10481051
"popupGasPollTokens": [],
10491052
"productTour": "accountIcon",
10501053
"recoveryPhraseReminderHasBeenShown": false,

app/scripts/controllers/app-state-controller.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export type AppStateControllerState = {
123123
updateModalLastDismissedAt: number | null;
124124
hasShownMultichainAccountsIntroModal: boolean;
125125
showShieldEntryModalOnce: boolean | null;
126+
pendingShieldCohort: string | null;
126127

127128
/**
128129
* Whether the wallet reset is in progress.
@@ -275,6 +276,7 @@ const getDefaultAppStateControllerState = (): AppStateControllerState => ({
275276
updateModalLastDismissedAt: null,
276277
hasShownMultichainAccountsIntroModal: false,
277278
showShieldEntryModalOnce: null,
279+
pendingShieldCohort: null,
278280
isWalletResetInProgress: false,
279281

280282
...getInitialStateOverrides(),
@@ -614,6 +616,12 @@ const controllerMetadata: StateMetadata<AppStateControllerState> = {
614616
includeInDebugSnapshot: true,
615617
usedInUi: true,
616618
},
619+
pendingShieldCohort: {
620+
includeInStateLogs: true,
621+
persist: false,
622+
includeInDebugSnapshot: true,
623+
usedInUi: true,
624+
},
617625
isWalletResetInProgress: {
618626
persist: true,
619627
includeInDebugSnapshot: true,
@@ -1528,6 +1536,12 @@ export class AppStateController extends BaseController<
15281536
});
15291537
}
15301538

1539+
setPendingShieldCohort(cohort: string | null): void {
1540+
this.update((state) => {
1541+
state.pendingShieldCohort = cohort;
1542+
});
1543+
}
1544+
15311545
setCanTrackWalletFundsObtained(enabled: boolean): void {
15321546
this.update((state) => {
15331547
state.canTrackWalletFundsObtained = enabled;

app/scripts/metamask-controller.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ import {
129129
SecretType,
130130
RecoveryError,
131131
} from '@metamask/seedless-onboarding-controller';
132-
import { PRODUCT_TYPES } from '@metamask/subscription-controller';
132+
import { COHORT_NAMES, PRODUCT_TYPES } from '@metamask/subscription-controller';
133133
import { isSnapId } from '@metamask/snaps-utils';
134134
import {
135135
findAtomicBatchSupportForChain,
@@ -2529,6 +2529,9 @@ export default class MetamaskController extends EventEmitter {
25292529
this.subscriptionController.getSubscriptionsEligibilities.bind(
25302530
this.subscriptionController,
25312531
),
2532+
assignUserToCohort: this.subscriptionController.assignUserToCohort.bind(
2533+
this.subscriptionController,
2534+
),
25322535
getSubscriptions: this.subscriptionController.getSubscriptions.bind(
25332536
this.subscriptionController,
25342537
),
@@ -2911,6 +2914,8 @@ export default class MetamaskController extends EventEmitter {
29112914
),
29122915
setShowShieldEntryModalOnce:
29132916
appStateController.setShowShieldEntryModalOnce.bind(appStateController),
2917+
setPendingShieldCohort:
2918+
appStateController.setPendingShieldCohort.bind(appStateController),
29142919
setShieldPausedToastLastClickedOrClosed:
29152920
appStateController.setShieldPausedToastLastClickedOrClosed.bind(
29162921
appStateController,
@@ -8527,6 +8532,19 @@ export default class MetamaskController extends EventEmitter {
85278532
transactionMeta,
85288533
isSponsored,
85298534
);
8535+
8536+
// Mark send/transfer/swap transactions for Shield post_tx cohort evaluation
8537+
const isPostTxTransaction = [
8538+
TransactionType.simpleSend,
8539+
TransactionType.tokenMethodTransfer,
8540+
TransactionType.swap,
8541+
TransactionType.swapAndSend,
8542+
].includes(transactionMeta.type);
8543+
8544+
const { pendingShieldCohort } = this.appStateController.state;
8545+
if (isPostTxTransaction && !pendingShieldCohort) {
8546+
this.appStateController.setPendingShieldCohort(COHORT_NAMES.POST_TX);
8547+
}
85308548
}
85318549

85328550
/**

shared/constants/metametrics.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,9 @@ export enum MetaMetricsEventName {
942942
ExtensionPinned = 'Extension Pinned',
943943
// Extension Port Stream
944944
PortStreamChunked = 'Port Stream Chunked',
945+
///: BEGIN:ONLY_INCLUDE_IF(build-experimental)
946+
ViewportSwitched = 'Viewport Switched',
947+
///: END:ONLY_INCLUDE_IF
945948
}
946949

947950
export enum MetaMetricsEventAccountType {

shared/types/background.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export type ControllerStatePropertiesEnumerated = {
139139
lastUpdatedAt: AppStateControllerState['lastUpdatedAt'];
140140
lastUpdatedFromVersion: AppStateControllerState['lastUpdatedFromVersion'];
141141
showShieldEntryModalOnce: AppStateControllerState['showShieldEntryModalOnce'];
142+
pendingShieldCohort: AppStateControllerState['pendingShieldCohort'];
142143
throttledOrigins: AppStateControllerState['throttledOrigins'];
143144
enableEnforcedSimulations: AppStateControllerState['enableEnforcedSimulations'];
144145
enableEnforcedSimulationsForTransactions: AppStateControllerState['enableEnforcedSimulationsForTransactions'];

test/e2e/default-fixture.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function defaultFixture(inputChainId = CHAIN_IDS.LOCALHOST) {
123123
snapsInstallPrivacyWarningShown: true,
124124
hasShownMultichainAccountsIntroModal: true,
125125
showShieldEntryModalOnce: false,
126+
pendingShieldCohort: null,
126127
appActiveTab: {
127128
id: 1,
128129
title: 'E2E Test Dapp',

test/e2e/fixtures/onboarding-fixture.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"showNetworkBanner": true,
7373
"showPermissionsTour": true,
7474
"showShieldEntryModalOnce": null,
75+
"pendingShieldCohort": null,
7576
"showTestnetMessageInDropdown": true,
7677
"slides": [],
7778
"surveyLinkLastClickedOrClosed": null,

0 commit comments

Comments
 (0)