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: enable STX by default with migration and notification #28854

Open
wants to merge 135 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
dba315a
Add migration and tests for enabling STX by default, update preferenc…
httpJunkie Dec 2, 2024
59b94a5
add logging to trace state and metadata change in preferences control…
httpJunkie Dec 2, 2024
606f293
add logging in setPreference in preferences controller and actions.ts
httpJunkie Dec 2, 2024
629b2a2
update `VersionedData` in the migration to have preferences:
httpJunkie Dec 2, 2024
dac7203
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 3, 2024
3010831
Add UI for legacy transaction flow, creation of STX Banner Alert for …
httpJunkie Dec 4, 2024
0987ad2
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 4, 2024
f89ab51
update `stx-migration.js` to include `extraReducers`, added test and …
httpJunkie Dec 4, 2024
73a0f19
Add logs and alet to ensure component is mounting and state is as int…
httpJunkie Dec 5, 2024
a3daae9
remove alert and update logs
httpJunkie Dec 5, 2024
85073df
registering our stxMigration reducer in ducks index
httpJunkie Dec 5, 2024
9b906cd
Remove logs from migration script; update stx-migration logs to debug…
httpJunkie Dec 5, 2024
cf23f7b
update stx-migration in ducks to dismissAndDIsable alert state once t…
httpJunkie Dec 5, 2024
a24e963
revert changes to wrong file
httpJunkie Dec 5, 2024
89fde17
update stx-migration ducks file to consider dismiss and disable alert.
httpJunkie Dec 5, 2024
3a6e424
update path to store in test file and directly tests the thunk behav…
httpJunkie Dec 5, 2024
3af6e58
add logs to check extraReducer logic and state.
httpJunkie Dec 5, 2024
ed3be1f
Add permanent alert dismissal for MetaMask Smart Transactions onboard…
httpJunkie Dec 5, 2024
724d3e6
With changes to permanent alert dismissal, we needed to update our te…
httpJunkie Dec 6, 2024
24c1d6c
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 6, 2024
1df568e
First stab at trying to implement alert for new confirmation/transact…
httpJunkie Dec 6, 2024
a6fa239
added an action to dismiss
httpJunkie Dec 6, 2024
21a45a8
feat: add STX migration toast to new confirmation flow
httpJunkie Dec 6, 2024
da793a6
move toast to top of page and try to default to darkmode
httpJunkie Dec 6, 2024
cea779c
Merge branch 'main' into feat/enable-stx-migration
danjm Dec 6, 2024
5df15e0
chore: cleanup STX migration implementation
httpJunkie Dec 9, 2024
8162b8c
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Dec 9, 2024
d2ccb44
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 9, 2024
a220f50
Add Banner Alert to the Swaps page (top)
httpJunkie Dec 9, 2024
32d4822
chore: remove 'smartTransactionsLearnMore' for use of 'learnMoreUpper…
httpJunkie Dec 9, 2024
5ec03ae
Change `smartTransactionsLearnMore` to 'learnMore' on STXBannerAlert
httpJunkie Dec 9, 2024
04f21e7
fix: Add 'transaction-alerts' style to wrap component as it's not mad…
httpJunkie Dec 9, 2024
2c74335
chore: remove 'Message" postfix
httpJunkie Dec 9, 2024
f836749
fix: This change ensures that the STX opt-in status is only affected …
httpJunkie Dec 9, 2024
1b59f9c
chore: Rename any and all use of word: 'stx or STX' for variables and…
httpJunkie Dec 9, 2024
d34a1c5
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 10, 2024
657255a
chore: address issues in PR (use constants), remove zendesk url, remo…
httpJunkie Dec 10, 2024
62ece63
fix: Update SmartTransactionsBannerAlert to encompass styling needed …
httpJunkie Dec 10, 2024
9abcd56
fix: update the index file for SmartTransactionsBannerAlert as we are…
httpJunkie Dec 10, 2024
5814520
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 10, 2024
b40018b
Update Smart Transactions Migration redux/ducks test to ensure we are…
httpJunkie Dec 10, 2024
2823d1d
fix: test needed to be updated after changing naming in `SmartTransac…
httpJunkie Dec 11, 2024
7771d5d
chore: run prettier fix on `messages.json`
httpJunkie Dec 11, 2024
77ba466
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 11, 2024
036a3a8
fix: fitness function failure, convert our JS files to TypeScript sin…
httpJunkie Dec 11, 2024
958ae8f
fix: fitness function failure, convert our JS files to TypeScript
httpJunkie Dec 11, 2024
bd9cdf0
test: update snapshots to include STX banner container
httpJunkie Dec 11, 2024
ab95ca9
fix: remove unused d.ts file no longer needed as SmartTransactionsBan…
httpJunkie Dec 11, 2024
73b4662
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 11, 2024
94f920b
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 11, 2024
398bd78
fix: These are old tests planned for disable. The quicker way to solv…
httpJunkie Dec 11, 2024
7ff3b71
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Dec 11, 2024
8388d4d
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 11, 2024
ebe57a4
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 12, 2024
796b1a2
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 12, 2024
11fe290
fix: removed console.log accidentally left in.
httpJunkie Dec 12, 2024
35123de
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 12, 2024
50be87a
This seems to be the correct way to skip these tests rather than `xde…
httpJunkie Dec 12, 2024
b87bd4c
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Dec 12, 2024
5368950
refactor: simplify smart transactions migration alert
httpJunkie Dec 12, 2024
2936c72
fix: let's make the test descriptions more accurate to what we're act…
httpJunkie Dec 12, 2024
bf6234d
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 12, 2024
8acd1ec
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 12, 2024
a7f208f
fix: update snapshot to include smartTransactionsOptInStatus
httpJunkie Dec 12, 2024
e79a067
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 12, 2024
2af5d8f
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Dec 12, 2024
e8c85fd
added snapshots for Banner Alert
httpJunkie Dec 12, 2024
b265893
chore: updates snapshots for the connect-account-modal test
georgeweiler Dec 12, 2024
941d34b
Merge branch 'main' into feat/enable-stx-migration
georgeweiler Dec 12, 2024
57125a2
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
georgeweiler Dec 12, 2024
6fab703
Revert "chore: updates snapshots for the connect-account-modal test"
georgeweiler Dec 12, 2024
7d29763
fix: revert to ^HEAD on problematic test.
httpJunkie Dec 12, 2024
ffcf811
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Dec 12, 2024
c10e55d
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 12, 2024
f6473a3
disable STX for these tests: adding the baseFixtureOptions with smar…
httpJunkie Dec 12, 2024
81631b9
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Dec 12, 2024
577cdee
match the structure where metamask should ibe nested under data in ou…
httpJunkie Dec 12, 2024
f24f686
revert changes to `swaps-notifications.spec.ts` as test results did n…
httpJunkie Dec 12, 2024
a53cb5e
Add logic to determine confirmationType in Wrapper
httpJunkie Dec 12, 2024
32ad253
chore: Move all logic for conditionally rendering the SmartTransactio…
httpJunkie Dec 12, 2024
cf244b5
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 12, 2024
0971419
chore: update SmartTransactionsBannerAlert to maintain backward compa…
httpJunkie Dec 13, 2024
fb4fe4a
fix: update smart-transaction-banner-alert test so it verifies our ne…
httpJunkie Dec 13, 2024
628563d
fix: auto-dismiss STX migration banner when user disables STX
httpJunkie Dec 13, 2024
82b40d7
fix: handle STX banner dismiss when toggling STX off
httpJunkie Dec 13, 2024
e65e33d
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 13, 2024
eb955dd
fix: linting / TS errors
httpJunkie Dec 13, 2024
688f049
fix: update snapshots for `snap-ui-address`, `connect-accounts-modal`…
httpJunkie Dec 13, 2024
cf008ed
fix: add `as string` back to satisfy linting
httpJunkie Dec 13, 2024
775fc85
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 13, 2024
e7ca076
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 16, 2024
fdb9f00
fix: update snapshot for connect-account-modal to have the same trans…
httpJunkie Dec 16, 2024
986592e
fix: update snapshot to match CI transform for `snap-ui-address`
httpJunkie Dec 16, 2024
d529b61
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 16, 2024
7c6757e
fix: update STX Banner Alert text to match new design mockups, ensure…
httpJunkie Dec 16, 2024
6e1f73e
fix: improve STX banner display logic for new installs
httpJunkie Dec 17, 2024
ccb2130
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 17, 2024
46f9ef5
fix: update preferences-controller test because we added smartTransac…
httpJunkie Dec 17, 2024
62dd4e8
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 17, 2024
8c875b0
fix: update snapshot for `confirm-send-ether.test.js`
httpJunkie Dec 17, 2024
35d12d3
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 17, 2024
0ed49c5
fix: add test for prepare-swap-page.test.js
httpJunkie Dec 17, 2024
e743a15
fix: updated snapshots from failing tests.
httpJunkie Dec 17, 2024
0f6e770
fix: snapshot update for connect-accounts-modal
httpJunkie Dec 17, 2024
b7f6313
fix: update snapshot for `snap-ui-address.test.tsx`
httpJunkie Dec 17, 2024
07680bd
fix: add `smartTransactionsMigrationApplied` to `expectedMissingState`
httpJunkie Dec 18, 2024
3c29e52
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 18, 2024
258b0a0
fix: try adding withPreferencesController with smartTransactionsMigra…
httpJunkie Dec 18, 2024
ae6d64e
fix: fix formatting on error.spec.js
httpJunkie Dec 18, 2024
c6b81f8
fix: reset `errors.spec.js` to version on main
httpJunkie Dec 18, 2024
ba8f557
fix: remove comments in preference-controller
httpJunkie Dec 18, 2024
80f264a
feat: update how we check for transaction confirmations
httpJunkie Dec 18, 2024
51b633f
fix: update `confirm.test.tsx` and snapshot.
httpJunkie Dec 18, 2024
9fd62b6
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 18, 2024
067fc9b
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 19, 2024
202e7d6
Update snapshots for E2E tests
dan437 Dec 19, 2024
4377a1b
Update a Jest snapshot
dan437 Dec 19, 2024
fd00aa9
Update an E2E test
dan437 Dec 19, 2024
b7ed2d1
fix: remove root level duplicated `smartTransactionsOptInStatus` (we …
httpJunkie Dec 19, 2024
49ab97d
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 19, 2024
b445df7
fix: cleaned up test for migration after removing `smartTransactionsO…
httpJunkie Dec 19, 2024
d9f06a1
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 19, 2024
9a51557
fix: remove root level `smartTransactionsOptInStatus` from snapshots.
httpJunkie Dec 19, 2024
7123914
Merge branch 'feat/enable-stx-migration' of github.com:MetaMask/metam…
httpJunkie Dec 19, 2024
3cda0ac
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 19, 2024
20cca27
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 19, 2024
ab5c1d7
fix: Remove redundant test for an impossible state (alert enabled bef…
httpJunkie Dec 19, 2024
105d90d
refactor: streamline SmartTransactionsBannerAlert logic
httpJunkie Dec 19, 2024
f520d7c
refactor: simplify logic in migration 135 and fix formatting in smart…
httpJunkie Dec 19, 2024
dcf814c
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 19, 2024
28d135a
fix: remove skipped tests
httpJunkie Dec 19, 2024
b58381f
fix: close SmartTransactionsMigrationNotification on `swap-eth.spec.ts`
httpJunkie Dec 19, 2024
e92d4dd
fix: Scroll "View all quotes" button into view before clicking in STX…
httpJunkie Dec 20, 2024
8385fce
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 20, 2024
f4b14dc
Merge branch 'main' into feat/enable-stx-migration
httpJunkie Dec 21, 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
9 changes: 9 additions & 0 deletions app/_locales/en/messages.json

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

2 changes: 2 additions & 0 deletions app/scripts/controllers/preferences-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ describe('preferences controller', () => {
privacyMode: false,
showFiatInTestnets: false,
showTestNetworks: false,
smartTransactionsMigrationApplied: false,
smartTransactionsOptInStatus: true,
useNativeCurrencyAsPrimaryCurrency: true,
hideZeroBalanceTokens: false,
Expand Down Expand Up @@ -762,6 +763,7 @@ describe('preferences controller', () => {
showExtensionInFullSizeView: false,
showFiatInTestnets: false,
showTestNetworks: false,
smartTransactionsMigrationApplied: false,
smartTransactionsOptInStatus: true,
useNativeCurrencyAsPrimaryCurrency: true,
hideZeroBalanceTokens: false,
Expand Down
13 changes: 13 additions & 0 deletions app/scripts/controllers/preferences-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export type Preferences = {
showFiatInTestnets: boolean;
showTestNetworks: boolean;
smartTransactionsOptInStatus: boolean;
smartTransactionsMigrationApplied: boolean;
showNativeTokenAsMainBalance: boolean;
useNativeCurrencyAsPrimaryCurrency: boolean;
hideZeroBalanceTokens: boolean;
Expand All @@ -129,6 +130,7 @@ export type PreferencesControllerState = Omit<
PreferencesState,
| 'showTestNetworks'
| 'smartTransactionsOptInStatus'
| 'smartTransactionsMigrationApplied'
| 'privacyMode'
| 'tokenSortConfig'
| 'useMultiRpcMigration'
Expand Down Expand Up @@ -217,6 +219,7 @@ export const getDefaultPreferencesControllerState =
showFiatInTestnets: false,
showTestNetworks: false,
smartTransactionsOptInStatus: true,
smartTransactionsMigrationApplied: false,
showNativeTokenAsMainBalance: false,
useNativeCurrencyAsPrimaryCurrency: true,
hideZeroBalanceTokens: false,
Expand Down Expand Up @@ -406,6 +409,16 @@ const controllerMetadata = {
preferences: {
persist: true,
anonymous: true,
properties: {
smartTransactionsOptInStatus: {
persist: true,
anonymous: true,
},
smartTransactionsMigrationApplied: {
persist: true,
anonymous: true,
},
},
},
ipfsGateway: {
persist: true,
Expand Down
187 changes: 187 additions & 0 deletions app/scripts/migrations/135.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import { SmartTransaction } from '@metamask/smart-transactions-controller/dist/types';
import { migrate, VersionedData } from './135';

const prevVersion = 134;

describe('migration #135', () => {
const mockSmartTransaction: SmartTransaction = {
uuid: 'test-uuid',
};

it('should update the version metadata', async () => {
const oldStorage: VersionedData = {
meta: { version: prevVersion },
data: {},
};

const newStorage = await migrate(oldStorage);
expect(newStorage.meta).toStrictEqual({ version: 135 });
});

it('should set stx opt-in to true and migration flag when stx opt-in status is null', async () => {
const oldStorage: VersionedData = {
meta: { version: prevVersion },
data: {
PreferencesController: {
preferences: {
smartTransactionsOptInStatus: null,
},
},
},
};

const newStorage = await migrate(oldStorage);
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsOptInStatus,
).toBe(true);
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsMigrationApplied,
).toBe(true);
});

it('should set stx opt-in to true and migration flag when stx opt-in status is undefined', async () => {
const oldStorage: VersionedData = {
meta: { version: prevVersion },
data: {
PreferencesController: {},
},
};

const newStorage = await migrate(oldStorage);
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsOptInStatus,
).toBe(true);
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsMigrationApplied,
).toBe(true);
});

it('should set stx opt-in to true and migration flag when stx opt-in is false and no existing mainnet smart transactions', async () => {
const oldStorage: VersionedData = {
meta: { version: prevVersion },
data: {
PreferencesController: {
preferences: {
smartTransactionsOptInStatus: false,
},
},
SmartTransactionsController: {
smartTransactionsState: {
smartTransactions: {
'0x1': [], // Empty mainnet transactions
'0xAA36A7': [mockSmartTransaction], // Sepolia has transactions
},
},
},
},
};

const newStorage = await migrate(oldStorage);
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsOptInStatus,
).toBe(true);
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsMigrationApplied,
).toBe(true);
});

it('should not change stx opt-in when stx opt-in is false but has existing smart transactions, but should set migration flag', async () => {
const oldStorage: VersionedData = {
meta: { version: prevVersion },
data: {
PreferencesController: {
preferences: {
smartTransactionsOptInStatus: false,
},
},
SmartTransactionsController: {
smartTransactionsState: {
smartTransactions: {
'0x1': [mockSmartTransaction],
},
},
},
},
};

const newStorage = await migrate(oldStorage);
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsOptInStatus,
).toBe(false);
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsMigrationApplied,
).toBe(true);
});

it('should not change stx opt-in when stx opt-in is already true, but should set migration flag', async () => {
const oldStorage: VersionedData = {
meta: { version: prevVersion },
data: {
PreferencesController: {
preferences: {
smartTransactionsOptInStatus: true,
},
},
},
};

const newStorage = await migrate(oldStorage);
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsOptInStatus,
).toBe(true);
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsMigrationApplied,
).toBe(true);
});

it('should initialize preferences object if it does not exist', async () => {
const oldStorage: VersionedData = {
meta: { version: prevVersion },
data: {
PreferencesController: {
preferences: {
smartTransactionsOptInStatus: true,
},
},
},
};

const newStorage = await migrate(oldStorage);
expect(newStorage.data.PreferencesController?.preferences).toBeDefined();
expect(
newStorage.data.PreferencesController?.preferences
?.smartTransactionsMigrationApplied,
).toBe(true);
});

it('should capture exception if PreferencesController state is invalid', async () => {
const sentryCaptureExceptionMock = jest.fn();
global.sentry = {
captureException: sentryCaptureExceptionMock,
};

const oldStorage = {
meta: { version: prevVersion },
data: {
PreferencesController: 'invalid',
},
} as unknown as VersionedData;

await migrate(oldStorage);

expect(sentryCaptureExceptionMock).toHaveBeenCalledTimes(1);
expect(sentryCaptureExceptionMock).toHaveBeenCalledWith(
new Error('Invalid PreferencesController state: string'),
);
});
});
84 changes: 84 additions & 0 deletions app/scripts/migrations/135.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { hasProperty, isObject } from '@metamask/utils';
import { cloneDeep } from 'lodash';
import type { SmartTransaction } from '@metamask/smart-transactions-controller/dist/types';
import { CHAIN_IDS } from '@metamask/transaction-controller';

export type VersionedData = {
meta: {
version: number;
};
data: {
PreferencesController?: {
preferences?: {
smartTransactionsOptInStatus?: boolean | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the smartTransactionsOptInStatus line here twice?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the heads up, I will most likely be removing the root level property in the controllerMetadata inside preferences-controller and that should fix this. I was initially trying to figure out the right place for it and this is a valid point.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a reminder that smartTransactionsOptInStatus is still here twice.

smartTransactionsMigrationApplied?: boolean;
};
};
SmartTransactionsController?: {
smartTransactionsState: {
smartTransactions: Record<string, SmartTransaction[]>;
};
};
};
};

export const version = 135;

function transformState(state: VersionedData['data']) {
if (
!hasProperty(state, 'PreferencesController') ||
!isObject(state.PreferencesController)
) {
global.sentry?.captureException?.(
new Error(
`Invalid PreferencesController state: ${typeof state.PreferencesController}`,
),
);
return state;
}

const { PreferencesController } = state;

const currentOptInStatus =
PreferencesController.preferences?.smartTransactionsOptInStatus;

if (
currentOptInStatus === undefined ||
currentOptInStatus === null ||
(currentOptInStatus === false && !hasExistingSmartTransactions(state))
) {
state.PreferencesController.preferences = {
...state.PreferencesController.preferences,
smartTransactionsOptInStatus: true,
smartTransactionsMigrationApplied: true,
};
} else {
state.PreferencesController.preferences = {
...state.PreferencesController.preferences,
smartTransactionsMigrationApplied: true,
};
}

return state;
}

function hasExistingSmartTransactions(state: VersionedData['data']): boolean {
const smartTransactions =
state?.SmartTransactionsController?.smartTransactionsState
?.smartTransactions;

if (!isObject(smartTransactions)) {
return false;
}

return (smartTransactions[CHAIN_IDS.MAINNET] || []).length > 0;
}

export async function migrate(
originalVersionedData: VersionedData,
): Promise<VersionedData> {
const versionedData = cloneDeep(originalVersionedData);
versionedData.meta.version = version;
transformState(versionedData.data);
return versionedData;
}
1 change: 1 addition & 0 deletions app/scripts/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const migrations = [
require('./133.1'),
require('./133.2'),
require('./134'),
require('./135'),
];

export default migrations;
1 change: 1 addition & 0 deletions privacy-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"bafkreifvhjdf6ve4jfv6qytqtux5nd4nwnelioeiqx5x2ez5yrgrzk7ypi.ipfs.dweb.link",
"bafybeidxfmwycgzcp4v2togflpqh2gnibuexjy4m4qqwxp7nh3jx5zlh4y.ipfs.dweb.link",
"bridge.api.cx.metamask.io",
"bridge.dev-api.cx.metamask.io",
"cdn.segment.com",
"cdn.segment.io",
"cdnjs.cloudflare.com",
Expand Down
2 changes: 2 additions & 0 deletions shared/constants/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export enum AlertTypes {
unconnectedAccount = 'unconnectedAccount',
web3ShimUsage = 'web3ShimUsage',
invalidCustomNetwork = 'invalidCustomNetwork',
smartTransactionsMigration = 'smartTransactionsMigration',
}

/**
Expand All @@ -10,6 +11,7 @@ export enum AlertTypes {
export const TOGGLEABLE_ALERT_TYPES = [
AlertTypes.unconnectedAccount,
AlertTypes.web3ShimUsage,
AlertTypes.smartTransactionsMigration,
];

export enum Web3ShimUsageAlertStates {
Expand Down
Loading
Loading