Skip to content

Commit

Permalink
refactor(extension): expose integration via window object
Browse files Browse the repository at this point in the history
  • Loading branch information
renanvalentin committed Apr 29, 2024
1 parent 2154c74 commit 0877108
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 48 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { SettingsLayout } from '../features/settings';
import { Lock } from '../components/Lock';
import { NftsLayout } from '../features/nfts';
import { getValueFromLocalStorage, onStorageChangeEvent } from '@src/utils/local-storage';
import { tabs } from 'webextension-polyfill';
import { runtime, tabs } from 'webextension-polyfill';
import { useEnterKeyPress } from '@hooks/useEnterKeyPress';
import { useAppSettingsContext } from '@providers/AppSettings';
import { useBackgroundPage } from '@providers/BackgroundPageProvider';
Expand All @@ -28,7 +28,22 @@ import { MainLoader } from '@components/MainLoader';
import { useAppInit } from '@hooks';
import { SharedWallet } from '@views/browser/features/shared-wallet';
import { MultiAddressBalanceVisibleModal } from '@views/browser/features/multi-address';
import { Nami } from '../features/nami';
import { consumeRemoteApi, RemoteApiPropertyType } from '@cardano-sdk/web-extension';
import { NamiMigrationAPI, NamiMigrationChannels } from '@lib/scripts/background/nami-migration';

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Remove during full implementation
window.namiMigration = consumeRemoteApi<NamiMigrationAPI>(
{
baseChannel: NamiMigrationChannels.MIGRATION,
properties: {
checkMigrationStatus: RemoteApiPropertyType.MethodReturningPromise,
startMigration: RemoteApiPropertyType.MethodReturningPromise,
abortMigration: RemoteApiPropertyType.MethodReturningPromise
}
},
{ logger: console, runtime }
);

export const defaultRoutes: RouteMap = [
{
Expand Down Expand Up @@ -58,10 +73,6 @@ export const defaultRoutes: RouteMap = [
{
path: routes.nfts,
component: NftsLayout
},
{
path: routes.nami.root,
component: Nami
}
];

Expand Down Expand Up @@ -171,7 +182,6 @@ export const BrowserViewRoutes = ({ routesMap = defaultRoutes }: { routesMap?: R
if (!isLoadingWalletInfo && !deletingWallet && (cardanoWallet === null || stayOnAllDonePage)) {
return (
<Switch>
<Route path={routes.nami.root} component={Nami} />
<Route path={'/setup'} component={WalletSetup} />
<Route path="*" render={() => <Redirect to={'/setup'} />} />
</Switch>
Expand All @@ -198,10 +208,5 @@ export const BrowserViewRoutes = ({ routesMap = defaultRoutes }: { routesMap?: R
</>
);
}

if (location.pathname.startsWith(routes.nami.root)) {
return <Nami />;
}

return <MainLoader />;
};

0 comments on commit 0877108

Please sign in to comment.