Skip to content

Commit ba4c1cf

Browse files
committed
feat: add mitigation on nami namespace injection
1 parent 5daf916 commit ba4c1cf

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

src/api/migration-tool/migrator/migration-state.data.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ export enum MigrationState {
88

99
export const MIGRATION_KEY = 'laceMigration' as const;
1010
export const DISMISS_MIGRATION_UNTIL = 'dismissMigrationUntil' as const;
11-
export const IS_HAVING_ISSUES = 'isHavingIssues' as const;

src/pages/Content/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ const injectScript = () => {
1616
};
1717

1818
async function shouldInject() {
19-
const { laceMigration } = (await storage.local.get(MIGRATION_KEY)) || {
19+
const { laceMigration } = (await storage.local.get([MIGRATION_KEY])) || {
2020
laceMigration: undefined,
2121
};
22+
2223
// Prevent injection into window.cardano namespace if migration has been completed
24+
// or if the user has dismissed because they are having issues migrating (setting migration state back to 'none')
2325
if (laceMigration === MigrationState.Completed) return false;
2426
const documentElement = document.documentElement.nodeName;
2527
const docElemCheck = documentElement

src/ui/lace-migration/components/migration-view/migration-view.component.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect } from 'react';
22
import {
33
MigrationState,
4-
IS_HAVING_ISSUES,
4+
MIGRATION_KEY,
55
} from '../../../../api/migration-tool/migrator/migration-state.data';
66
import { Carousel } from '../carousel/carousel.component';
77
import { Slide1 } from '../carousel/slides/Slide1.component';
@@ -50,7 +50,9 @@ export const MigrationView = ({
5050
featureFlags?.['show-having-issues-button'] || false;
5151

5252
const handleHavingIssuesClick = () => {
53-
storage.local.set({ [IS_HAVING_ISSUES]: true });
53+
storage.local.set({
54+
[MIGRATION_KEY]: MigrationState.None,
55+
});
5456
captureEvent(Events.NamiMigrationHavingIssuesClick);
5557
};
5658

src/ui/lace-migration/components/migration.component.jsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
MIGRATION_KEY,
55
MigrationState,
66
DISMISS_MIGRATION_UNTIL,
7-
IS_HAVING_ISSUES,
87
} from '../../../api/migration-tool/migrator/migration-state.data';
98
import { MigrationView } from './migration-view/migration-view.component';
109
import {
@@ -39,7 +38,6 @@ export const AppWithMigration = () => {
3938

4039
useEffect(() => {
4140
storage.local.get().then((store) => {
42-
console.log(store[IS_HAVING_ISSUES]);
4341
// Wait for Lace installation check before declaring UI to be ready
4442
checkLaceInstallation().then((laceInstalled) => {
4543
// Check if the wallet exists
@@ -51,7 +49,6 @@ export const AppWithMigration = () => {
5149
migrationState: store[MIGRATION_KEY] ?? MigrationState.None,
5250
hasWallet: typeof accounts !== 'undefined',
5351
dismissedUntil: store[DISMISS_MIGRATION_UNTIL] ?? undefined,
54-
isHavingIssues: store[IS_HAVING_ISSUES] ?? false,
5552
}));
5653
// Capture events for initial migration state when Nami is opened
5754
switch (store[MIGRATION_KEY]) {
@@ -79,7 +76,6 @@ export const AppWithMigration = () => {
7976
migrationState: changes[MIGRATION_KEY]?.newValue ?? s.migrationState,
8077
dismissedUntil:
8178
changes[DISMISS_MIGRATION_UNTIL]?.newValue ?? s.dismissedUntil,
82-
isHavingIssues: changes[IS_HAVING_ISSUES] ?? false,
8379
}));
8480
};
8581

@@ -102,16 +98,7 @@ export const AppWithMigration = () => {
10298
isBetaProgramIsActive &&
10399
featureFlags?.['is-migration-active'] !== undefined;
104100

105-
const hasShowIssuesButton =
106-
featureFlags?.['show-having-issues-button'] || false;
107-
108-
if (
109-
state.migrationState === MigrationState.Completed &&
110-
hasShowIssuesButton &&
111-
state.isHavingIssues
112-
) {
113-
showApp = true;
114-
} else if (state.migrationState === MigrationState.Completed) {
101+
if (state.migrationState === MigrationState.Completed) {
115102
showApp = false;
116103
} else if (isBetaProgramActiveAndUserEnrolled) {
117104
// Canary phase entry

0 commit comments

Comments
 (0)