Skip to content

Commit 7b7e842

Browse files
fix: base wallet is now only loaded in background script (#1564)
1 parent 0d7bab0 commit 7b7e842

File tree

6 files changed

+13
-7
lines changed

6 files changed

+13
-7
lines changed

apps/browser-extension-wallet/src/features/nami-migration/Activating.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import React, { useEffect } from 'react';
22

33
import { NamiMigrationUpdatingYourWallet } from '@lace/core';
44
import { consumeRemoteApi, RemoteApiPropertyType } from '@cardano-sdk/web-extension';
5-
import { NamiMigrationAPI, NamiMigrationChannels } from '@lib/scripts/background/nami-migration';
5+
import type { NamiMigrationAPI } from '@lib/scripts/background/nami-migration';
66
import { runtime } from 'webextension-polyfill';
77
import { useHistory } from 'react-router-dom';
88
import { walletRoutePaths as routes } from '@routes/wallet-paths';
99
import { useCurrencyStore } from '@providers/currency';
1010
import { MigrationState } from './migration-tool/migrator/migration-state.data';
1111
import { useTheme } from '@providers/ThemeProvider/context';
12+
import { NamiMigrationChannels } from '@lib/scripts/types';
1213

1314
const namiMigrationRemoteApi = consumeRemoteApi<Pick<NamiMigrationAPI, 'startMigration' | 'checkMigrationStatus'>>(
1415
{

apps/browser-extension-wallet/src/features/nami-migration/NamiMigrationGuard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { consumeRemoteApi, RemoteApiPropertyType } from '@cardano-sdk/web-extension';
2-
import { NamiMigrationAPI, NamiMigrationChannels } from '@lib/scripts/background/nami-migration';
2+
import type { NamiMigrationAPI } from '@lib/scripts/background/nami-migration';
33
import { getBackgroundStorage } from '@lib/scripts/background/storage';
44
import { MigrationState } from './migration-tool/migrator/migration-state.data';
55
import React, { Fragment, useCallback, useEffect, useState } from 'react';
@@ -9,7 +9,7 @@ import { walletRoutePaths as routes } from '@routes/wallet-paths';
99
import { useWalletStore } from '@src/stores';
1010
import { APP_MODE_POPUP } from '@src/utils/constants';
1111
import { useBackgroundServiceAPIContext } from '@providers';
12-
import { BrowserViewSections } from '@lib/scripts/types';
12+
import { BrowserViewSections, NamiMigrationChannels } from '@lib/scripts/types';
1313
import { NamiMigration } from './NamiMigration';
1414

1515
const namiMigrationRemoteApi = consumeRemoteApi<Pick<NamiMigrationAPI, 'checkMigrationStatus' | 'abortMigration'>>(

apps/browser-extension-wallet/src/lib/scripts/background/nami-migration.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { currencyCode } from '@providers/currency/constants';
88
import { exposeApi, getWalletStoreId, RemoteApiPropertyType } from '@cardano-sdk/web-extension';
99
import { storage } from '@cardano-sdk/wallet';
1010
import { of } from 'rxjs';
11+
import { NamiMigrationChannels } from '@lib/scripts/types';
1112

1213
const collateralRepository: CollateralRepository = async ({ utxo, chainId, walletId, accountIndex }) => {
1314
const walletStoreId = getWalletStoreId(walletId, chainId, accountIndex);
@@ -28,10 +29,6 @@ const startMigration = async () => {
2829
};
2930
};
3031

31-
export enum NamiMigrationChannels {
32-
MIGRATION = 'migration'
33-
}
34-
3532
export interface NamiMigrationAPI {
3633
checkMigrationStatus: () => Promise<MigrationState>;
3734
startMigration: () => Promise<{

apps/browser-extension-wallet/src/lib/scripts/background/wallet.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ import { ExperimentName } from '@providers/ExperimentsProvider/types';
3939
import { requestMessage$ } from './services/utilityServices';
4040
import { MessageTypes } from '../types';
4141

42+
if (typeof window !== 'undefined') {
43+
throw new TypeError('This module should only be imported in service worker');
44+
}
45+
4246
// It is important that this file is not exported from index,
4347
// because creating wallet repository with store creates an actual pouchdb database
4448
// which results in some trash files when running the tests (leveldb directory)

apps/browser-extension-wallet/src/lib/scripts/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './dapp-service';
33
export * from './userIdService';
44
export * from './prices';
55
export * from './storage';
6+
export * from './nami-migration-channels';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export enum NamiMigrationChannels {
2+
MIGRATION = 'migration'
3+
}

0 commit comments

Comments
 (0)