From eecd9448052fb88547697bf7e437ba47ba8b78be Mon Sep 17 00:00:00 2001 From: Tuditi <45079109+Tuditi@users.noreply.github.com> Date: Wed, 20 Mar 2024 15:25:14 +0100 Subject: [PATCH] chore: improve typings from desktop folder (#2182) * chore: update moduleResolution * fix: type issues in desktop --- .../desktop/lib/electron/apis/wallet.api.ts | 47 ++++--- .../listeners/power-monitor.listener.ts | 4 +- .../lib/electron/managers/transak.manager.ts | 44 +++--- packages/desktop/lib/electron/menus/menu.ts | 6 +- .../lib/electron/preloads/transak.preload.ts | 7 +- .../lib/electron/processes/ledger.process.ts | 2 +- .../lib/electron/processes/main.process.ts | 53 ++++---- .../lib/electron/utils/deep-link.utils.ts | 4 + .../lib/electron/utils/ledger.utils.ts | 125 ++++++++++-------- .../routers/helpers/getAppRouteForContext.ts | 2 +- packages/desktop/tsconfig.json | 1 + .../network-setup/network-setup-router.ts | 4 +- .../app/utils/isLatestStrongholdVersion.ts | 2 +- 13 files changed, 170 insertions(+), 131 deletions(-) diff --git a/packages/desktop/lib/electron/apis/wallet.api.ts b/packages/desktop/lib/electron/apis/wallet.api.ts index ce49a977ed..ab20b39c8a 100644 --- a/packages/desktop/lib/electron/apis/wallet.api.ts +++ b/packages/desktop/lib/electron/apis/wallet.api.ts @@ -1,5 +1,14 @@ -import * as IotaSdk from '@iota/sdk' -import type { CreateAccountPayload, IAuth, SyncOptions } from '@iota/sdk' +import { + Wallet, + WalletOptions, + Account, + Client, + migrateStrongholdSnapshotV2ToV3, + SecretManager, + SyncOptions, + CreateAccountPayload, + IAuth, +} from '@iota/sdk' import { bindMethodsAcrossContextBridge, bindSdkUtilsMethods } from '../utils/context-bridge.utils' import { STRONGHOLD_V2_HASHING_ROUNDS, STRONGHOLD_V2_SALT } from '../constants/stronghold-v2-migration.constants' @@ -12,7 +21,7 @@ interface PayloadType { syncOptions: SyncOptions } -const profileManagers: { [id: string]: IotaSdk.Wallet } = {} +const profileManagers: { [id: string]: Wallet } = {} const sdkUtilsMethods = bindSdkUtilsMethods() @@ -30,38 +39,38 @@ export default { nodeInfo, } }, - createWallet(id: string, options: unknown): IotaSdk.Wallet { - const manager = new IotaSdk.Wallet(options) + createWallet(id: string, options: WalletOptions): Wallet { + const manager = new Wallet(options) manager['id'] = id profileManagers[id] = manager - return bindMethodsAcrossContextBridge(IotaSdk.Wallet, manager) + return bindMethodsAcrossContextBridge(Wallet, manager) }, - async createAccount(managerId: string, payload: CreateAccountPayload): Promise { + async createAccount(managerId: string, payload: CreateAccountPayload): Promise { const manager = profileManagers[managerId] const account = await manager.createAccount(payload) - return bindMethodsAcrossContextBridge(IotaSdk.Account, account) + return bindMethodsAcrossContextBridge(Account, account) }, deleteWallet(id: string): void { if (id && id in profileManagers) { delete profileManagers[id] } }, - async getAccount(managerId: string, index: number): Promise { + async getAccount(managerId: string, index: number): Promise { const manager = profileManagers[managerId] const account = await manager.getAccount(index) - return bindMethodsAcrossContextBridge(IotaSdk.Account, account) + return bindMethodsAcrossContextBridge(Account, account) }, - async getAccounts(managerId: string): Promise { + async getAccounts(managerId: string): Promise { const manager = profileManagers[managerId] const accounts = await manager.getAccounts() - return accounts.map((account) => bindMethodsAcrossContextBridge(IotaSdk.Account, account)) + return accounts.map((account) => bindMethodsAcrossContextBridge(Account, account)) }, - async getClient(managerId: string): Promise { + async getClient(managerId: string): Promise { const manager = profileManagers[managerId] const client = await manager.getClient() - return bindMethodsAcrossContextBridge(IotaSdk.Client, client) + return bindMethodsAcrossContextBridge(Client, client) }, - async recoverAccounts(managerId: string, payload: PayloadType): Promise { + async recoverAccounts(managerId: string, payload: PayloadType): Promise { const manager = profileManagers[managerId] const accounts = await manager.recoverAccounts( payload.accountStartIndex, @@ -69,12 +78,12 @@ export default { payload.addressGapLimit, payload.syncOptions ) - return accounts.map((account) => bindMethodsAcrossContextBridge(IotaSdk.Account, account)) + return accounts.map((account) => bindMethodsAcrossContextBridge(Account, account)) }, - async getSecretManager(managerId: string): Promise { + async getSecretManager(managerId: string): Promise { const manager = profileManagers[managerId] const secretManager = await manager.getSecretManager() - return bindMethodsAcrossContextBridge(IotaSdk.SecretManager, secretManager) + return bindMethodsAcrossContextBridge(SecretManager, secretManager) }, migrateStrongholdSnapshotV2ToV3( currentPath: string, @@ -82,7 +91,7 @@ export default { currentPassword: string, newPassword: string ): unknown { - return IotaSdk.migrateStrongholdSnapshotV2ToV3( + return migrateStrongholdSnapshotV2ToV3( currentPath, newPath, STRONGHOLD_V2_SALT, diff --git a/packages/desktop/lib/electron/listeners/power-monitor.listener.ts b/packages/desktop/lib/electron/listeners/power-monitor.listener.ts index 51fa20e5a5..0decd328e1 100644 --- a/packages/desktop/lib/electron/listeners/power-monitor.listener.ts +++ b/packages/desktop/lib/electron/listeners/power-monitor.listener.ts @@ -4,10 +4,10 @@ import { windows } from '../constants/windows.constant' export function registerPowerMonitorListeners(): void { powerMonitor.on('suspend', () => { // MacOS, Windows and Linux - windows?.main?.webContents?.send('lock-screen') + windows.main?.webContents?.send('lock-screen') }) powerMonitor.on('lock-screen', () => { // MacOS and Windows - windows?.main?.webContents?.send('lock-screen') + windows.main?.webContents?.send('lock-screen') }) } diff --git a/packages/desktop/lib/electron/managers/transak.manager.ts b/packages/desktop/lib/electron/managers/transak.manager.ts index b4e66007d6..c459c0c5ce 100644 --- a/packages/desktop/lib/electron/managers/transak.manager.ts +++ b/packages/desktop/lib/electron/managers/transak.manager.ts @@ -7,9 +7,11 @@ import { TRANSAK_WIDGET_URL } from '@auxiliary/transak/constants' import { buildUrl } from '@core/utils/url' import { MarketCurrency } from '@core/market/enums/market-currency.enum' import fs from 'fs' +import { IError } from '@core/error' +import { QueryParameters } from '@core/utils' export default class TransakManager implements ITransakManager { - private rect: Electron.Rectangle + private rect: Electron.Rectangle | undefined private getPreloadPath(): string { const preloadPath = app.isPackaged @@ -54,13 +56,13 @@ export default class TransakManager implements ITransakManager { windows.transak?.show() } - public openWindow(data: ITransakWindowData): BrowserWindow { + public openWindow(data: ITransakWindowData): BrowserWindow | undefined { let preloadPath: string try { preloadPath = this.getPreloadPath() } catch (err) { - windows.main.webContents.send('transak-not-loaded') - console.error(err.message) + windows.main?.webContents?.send?.('transak-not-loaded') + console.error((err as IError).message) return } @@ -71,7 +73,7 @@ export default class TransakManager implements ITransakManager { this.rect = { x: 0, y: 0, width: 480, height: 613 } windows.transak = new BrowserWindow({ - parent: windows.main, + ...(windows.main && { parent: windows.main }), width: 480, height: 613, useContentSize: true, @@ -104,7 +106,7 @@ export default class TransakManager implements ITransakManager { windows.transak.setWindowButtonVisibility(false) } - windows.main.on('move', () => this.positionWindow()) + windows.main?.on?.('move', () => this.positionWindow()) windows.transak.once('closed', () => { windows.transak = null @@ -121,10 +123,10 @@ export default class TransakManager implements ITransakManager { let initialUrl: string try { initialUrl = this.getUrl(data) + void windows.transak.loadURL(initialUrl) } catch (err) { console.error(err) } - void windows.transak.loadURL(initialUrl) windows.transak.webContents.setWindowOpenHandler(({ url }) => { void shell.openExternal(url) @@ -135,20 +137,20 @@ export default class TransakManager implements ITransakManager { windows.transak.webContents.addListener('did-navigate', (_, url) => { const _url = new URL(url) - windows.main.webContents.send('transak-url', _url.origin) + windows.main?.webContents?.send?.('transak-url', _url.origin) }) windows.transak.webContents.addListener('did-navigate-in-page', (_, url) => { const urlToBeMatched = TRANSAK_WIDGET_URL + '/googlepay' if (url.startsWith(urlToBeMatched)) { - windows.main.webContents.send('try-open-url-in-browser', url) - void windows.transak.loadURL(initialUrl) + windows.main?.webContents?.send?.('try-open-url-in-browser', url) + void windows.transak?.loadURL?.(initialUrl) } }) windows.transak.webContents.addListener('will-navigate', (event) => { event.preventDefault() - windows.main.webContents.send('try-open-url-in-browser', event.url) + windows.main?.webContents.send('try-open-url-in-browser', event.url) }) return windows.transak @@ -162,20 +164,20 @@ export default class TransakManager implements ITransakManager { public positionWindow(): void { try { if (windows.transak) { - const [mainWindowX, mainWindowY] = windows.main.getPosition() - const [, mainWindowHeight] = windows.main.getSize() - const [, bodyHeight] = windows.main.getContentSize() + const [mainWindowX, mainWindowY] = windows.main?.getPosition() ?? [] + const [, mainWindowHeight] = windows.main?.getSize() ?? [] + const [, bodyHeight] = windows.main?.getContentSize() ?? [] const menuHeight = mainWindowHeight - bodyHeight - const newX = Math.floor(mainWindowX + this.rect.x) - const newY = Math.floor(mainWindowY + menuHeight + this.rect.y) + const newX = Math.floor(mainWindowX + (this.rect?.x ?? 0)) + const newY = Math.floor(mainWindowY + menuHeight + (this.rect?.y ?? 0)) windows.transak.setBounds({ x: newX, y: newY, - height: this.rect.height, - width: this.rect.width, + height: this.rect?.height, + width: this.rect?.width, }) if (process.platform === 'linux') { @@ -205,6 +207,10 @@ export default class TransakManager implements ITransakManager { const { address, currency, service, amount } = data const apiKey = process.env.TRANSAK_API_KEY + if (typeof apiKey !== 'string') { + throw new Error('Undefined Transak API key') + } + if (!Object.values(MarketCurrency).includes(currency as MarketCurrency)) { throw new Error('Invalid Transak currency') } @@ -220,7 +226,7 @@ export default class TransakManager implements ITransakManager { : 'LIGHT' : nativeTheme.themeSource.toUpperCase() - const queryParams = { + const queryParams: QueryParameters = { apiKey, defaultFiatCurrency: currency, defaultFiatAmount: amount, diff --git a/packages/desktop/lib/electron/menus/menu.ts b/packages/desktop/lib/electron/menus/menu.ts index 9ec3417841..04c8ec86f3 100644 --- a/packages/desktop/lib/electron/menus/menu.ts +++ b/packages/desktop/lib/electron/menus/menu.ts @@ -41,7 +41,7 @@ function toggleMaximize(): boolean { } export function initMenu(): void { - let mainMenu = null + let mainMenu: Electron.Menu app.once('ready', () => { ipcMain.handle('menu-update', (e, args) => { @@ -50,7 +50,7 @@ export function initMenu(): void { }) ipcMain.handle('menu-popup', () => { - mainMenu.popup(getOrInitWindow('main')) + mainMenu.popup({ window: getOrInitWindow('main') }) }) ipcMain.handle('menu-data', () => state) handleWindowControls() @@ -142,7 +142,7 @@ function getFirstSubmenuItems(): Electron.MenuItemConstructorOptions[] { function getDarwinSubmenuItems(): Electron.MenuItemConstructorOptions[] { return [ roleMenuItem(`${state.strings.hide} ${app.name}`, 'hide'), - roleMenuItem(state.strings.hideOthers, 'hideothers' as Electron.MenuItemConstructorOptions['role']), + roleMenuItem(state.strings.hideOthers, 'hideOthers'), roleMenuItem(state.strings.showAll, 'unhide'), ] } diff --git a/packages/desktop/lib/electron/preloads/transak.preload.ts b/packages/desktop/lib/electron/preloads/transak.preload.ts index 288ccfa3dc..3ed62797a4 100644 --- a/packages/desktop/lib/electron/preloads/transak.preload.ts +++ b/packages/desktop/lib/electron/preloads/transak.preload.ts @@ -1,4 +1,7 @@ window.addEventListener('DOMContentLoaded', () => { - window.document.getElementById('appRoot').style.borderRadius = '16px' - window.document.getElementById('appRoot').style.overflow = 'hidden' + const appRoot = window.document.getElementById('appRoot') + if (appRoot) { + appRoot.style.borderRadius = '16px' + appRoot.style.overflow = 'hidden' + } }) diff --git a/packages/desktop/lib/electron/processes/ledger.process.ts b/packages/desktop/lib/electron/processes/ledger.process.ts index 5c18a1dc4a..2211e11910 100644 --- a/packages/desktop/lib/electron/processes/ledger.process.ts +++ b/packages/desktop/lib/electron/processes/ledger.process.ts @@ -31,7 +31,7 @@ async function messageHandler(message: ILedgerProcessMessage): Promise { try { await openTransport() - let data: LedgerApiRequestResponse + let data: LedgerApiRequestResponse | undefined const { method, payload } = message switch (method) { case LedgerApiMethod.GenerateEvmAddress: { diff --git a/packages/desktop/lib/electron/processes/main.process.ts b/packages/desktop/lib/electron/processes/main.process.ts index 2e91fdaee1..6c5dcc12a2 100644 --- a/packages/desktop/lib/electron/processes/main.process.ts +++ b/packages/desktop/lib/electron/processes/main.process.ts @@ -35,6 +35,7 @@ import { ensureDirectoryExistence } from '../utils/file-system.utils' import { getMachineId } from '../utils/os.utils' import { registerPowerMonitorListeners } from '../listeners' import { ITransakWindowData } from '@core/app/interfaces' +import { IError } from '@core/error' export let appIsReady = false @@ -252,7 +253,7 @@ export function createMainWindow(): BrowserWindow { }) windows.main.webContents.on('did-finish-load', () => { - windows.main.webContents.send('version-details', versionDetails) + windows.main?.webContents?.send?.('version-details', versionDetails) }) /** @@ -268,7 +269,7 @@ export function createMainWindow(): BrowserWindow { windows.main.webContents.setWindowOpenHandler((details) => { try { - windows.main.webContents.send('try-open-url-in-browser', details.url) + windows.main?.webContents?.send?.('try-open-url-in-browser', details.url) } catch (err) { console.error(err) } @@ -310,23 +311,23 @@ ipcMain.on('start-ledger-process', () => { const { method, payload, error } = message if (error) { - windows.main.webContents.send('ledger-error', error) + windows.main?.webContents?.send?.('ledger-error', error) } else { switch (method) { case LedgerApiMethod.GenerateEvmAddress: - windows.main.webContents.send('evm-address', payload) + windows.main?.webContents?.send?.('evm-address', payload) break case LedgerApiMethod.GetEthereumAppSettings: - windows.main.webContents.send('ethereum-app-settings', payload) + windows.main?.webContents?.send?.('ethereum-app-settings', payload) break case LedgerApiMethod.SignEvmTransaction: - windows.main.webContents.send('evm-signed-transaction', payload) + windows.main?.webContents?.send?.('evm-signed-transaction', payload) break case LedgerApiMethod.SignMessage: - windows.main.webContents.send('signed-message', payload) + windows.main?.webContents?.send?.('signed-message', payload) break case LedgerApiMethod.SignEIP712: - windows.main.webContents.send('signed-eip712', payload) + windows.main?.webContents?.send?.('signed-eip712', payload) break default: /* eslint-disable-next-line no-console */ @@ -374,8 +375,13 @@ export function getOrInitWindow(windowName: string, ...args: unknown[]): Browser return openAboutWindow() case 'error': return openErrorWindow() - case 'transak': - return transakManager?.openWindow(args[0] as ITransakWindowData) + case 'transak': { + const transakWindow = transakManager?.openWindow(args[0] as ITransakWindowData) + if (transakWindow) { + return transakWindow + } + break + } default: throw Error(`Window ${windowName} not found`) } @@ -482,14 +488,14 @@ ipcMain.handle('update-app-settings', (_e, settings) => updateSettings(settings) // Theme nativeTheme.on('updated', () => { - windows.main.webContents.send('native-theme-updated') + windows.main?.webContents?.send?.('native-theme-updated') }) ipcMain.handle('get-theme', () => nativeTheme.themeSource) ipcMain.handle('update-theme', (_e, theme) => { nativeTheme.themeSource = theme if (features?.buySell?.enabled) { - windows.main.webContents.send('reset-transak') + windows.main?.webContents?.send?.('reset-transak') } }) ipcMain.handle('should-be-dark-mode', () => nativeTheme.shouldUseDarkColors) @@ -517,8 +523,8 @@ if (!isFirstInstance) { * Proxy notification activated to the wallet application */ ipcMain.on('notification-activated', (ev, contextData) => { - windows.main.focus() - windows.main.webContents.send('notification-activated', contextData) + windows.main?.focus?.() + windows.main?.webContents?.send?.('notification-activated', contextData) }) // Transak @@ -632,7 +638,12 @@ export function closeErrorWindow(): void { function windowStateKeeper(windowName: string, settingsFilename: string): IAppState { let window: BrowserWindow - let windowState: IAppState + let windowState = { + x: 0, + y: 0, + width: 1280, + height: process.platform === 'win32' ? 720 + 28 : 720, + } function setBounds(): void { const settings = loadJsonConfig(settingsFilename) @@ -641,14 +652,6 @@ function windowStateKeeper(windowName: string, settingsFilename: string): IAppSt windowState = settings.windowState[windowName] return } - - // Default - windowState = { - x: undefined, - y: undefined, - width: 1280, - height: process.platform === 'win32' ? 720 + 28 : 720, - } } function saveState(): void { @@ -721,11 +724,11 @@ function saveJsonConfig(filename: string, data: object): void { } } -function loadJsonConfig(filename: string): object { +function loadJsonConfig(filename: string): object | undefined { try { return JSON.parse(fs.readFileSync(getJsonConfig(filename)).toString()) } catch (err) { - if (!err.message.includes('ENOENT')) { + if (!(err as IError).message?.includes('ENOENT')) { console.error(err) } } diff --git a/packages/desktop/lib/electron/utils/deep-link.utils.ts b/packages/desktop/lib/electron/utils/deep-link.utils.ts index b3acc1905b..86e4007b19 100644 --- a/packages/desktop/lib/electron/utils/deep-link.utils.ts +++ b/packages/desktop/lib/electron/utils/deep-link.utils.ts @@ -38,6 +38,10 @@ function setAppAsDefaultProtocolClient(): void { * Register bloom:// protocol for deep links * https://www.electronjs.org/docs/latest/api/protocol#protocolregisterschemesasprivilegedcustomschemes */ + if (!process.env.APP_PROTOCOL) { + return + } + protocol.registerSchemesAsPrivileged([ { scheme: process.env.APP_PROTOCOL, privileges: { secure: true, standard: true } }, ]) diff --git a/packages/desktop/lib/electron/utils/ledger.utils.ts b/packages/desktop/lib/electron/utils/ledger.utils.ts index b24be494d6..09af6ffda3 100644 --- a/packages/desktop/lib/electron/utils/ledger.utils.ts +++ b/packages/desktop/lib/electron/utils/ledger.utils.ts @@ -7,7 +7,7 @@ import type { ILedgerEthereumAppSettings } from '@core/ledger/interfaces' import { IEvmAddress, IEvmSignature } from '@core/layer-2/interfaces' import { HEX_PREFIX } from '@core/utils/constants' -let transport: TransportNodeHid +let transport: TransportNodeHid | undefined export async function openTransport(): Promise { if (!transport) { @@ -25,39 +25,48 @@ export async function closeTransport(): Promise { } } -export async function getEthereumAppSettings(): Promise { - const appEth = new AppEth(transport) - const settings = await appEth.getAppConfiguration() - return { - version: settings.version, - blindSigningEnabled: Boolean(settings.arbitraryDataEnabled), - erc20ProvisioningNecessary: Boolean(settings.erc20ProvisioningNecessary), - starkEnabled: Boolean(settings.starkEnabled), - starkv2Supported: Boolean(settings.starkv2Supported), +export async function getEthereumAppSettings(): Promise { + if (transport) { + const appEth = new AppEth(transport) + const settings = await appEth.getAppConfiguration() + return { + version: settings.version, + blindSigningEnabled: Boolean(settings.arbitraryDataEnabled), + erc20ProvisioningNecessary: Boolean(settings.erc20ProvisioningNecessary), + starkEnabled: Boolean(settings.starkEnabled), + starkv2Supported: Boolean(settings.starkv2Supported), + } } } -export async function getEvmAddress(bip32Path: string): Promise { - const appEth = new AppEth(transport) - const data = await appEth.getAddress(bip32Path) +export async function getEvmAddress(bip32Path: string): Promise { + if (transport) { + const appEth = new AppEth(transport) + const data = await appEth.getAddress(bip32Path) - return { evmAddress: data.address, bip32Path } + return { evmAddress: data.address, bip32Path } + } } -export async function signTransactionData(transactionHex: string, bip32Path: string): Promise { - try { - const appEth = new AppEth(transport) - const signature = await appEth.signTransaction(bip32Path, transactionHex, null) - return { - r: HEX_PREFIX + signature.r, - v: HEX_PREFIX + signature.v, - s: HEX_PREFIX + signature.s, - } - } catch (error) { - return { - r: undefined, - v: undefined, - s: undefined, +export async function signTransactionData( + transactionHex: string, + bip32Path: string +): Promise { + if (transport) { + try { + const appEth = new AppEth(transport) + const signature = await appEth.signTransaction(bip32Path, transactionHex, null) + return { + r: HEX_PREFIX + signature.r, + v: HEX_PREFIX + signature.v, + s: HEX_PREFIX + signature.s, + } + } catch (error) { + return { + r: '', + v: '', + s: '', + } } } } @@ -66,38 +75,42 @@ export async function signEIP712Message( hashedDomain: string, hashedMessage: string, bip32Path: string -): Promise { - try { - const appEth = new AppEth(transport) - const signature = await appEth.signEIP712HashedMessage(bip32Path, hashedDomain, hashedMessage) - return { - r: signature.r, - s: signature.s, - v: signature.v.toString(), - } - } catch (error) { - return { - r: undefined, - s: undefined, - v: undefined, +): Promise { + if (transport) { + try { + const appEth = new AppEth(transport) + const signature = await appEth.signEIP712HashedMessage(bip32Path, hashedDomain, hashedMessage) + return { + r: signature.r, + s: signature.s, + v: signature.v.toString(), + } + } catch (error) { + return { + r: '', + s: '', + v: '', + } } } } -export async function signMessage(messageHex: string, bip32Path: string): Promise { - try { - const appEth = new AppEth(transport) - const signature = await appEth.signPersonalMessage(bip32Path, messageHex) - return { - r: signature.r, - s: signature.s, - v: signature.v.toString(), - } - } catch (error) { - return { - r: undefined, - s: undefined, - v: undefined, +export async function signMessage(messageHex: string, bip32Path: string): Promise { + if (transport) { + try { + const appEth = new AppEth(transport) + const signature = await appEth.signPersonalMessage(bip32Path, messageHex) + return { + r: signature.r, + s: signature.s, + v: signature.v.toString(), + } + } catch (error) { + return { + r: '', + s: '', + v: '', + } } } } diff --git a/packages/desktop/lib/routers/helpers/getAppRouteForContext.ts b/packages/desktop/lib/routers/helpers/getAppRouteForContext.ts index d3a9b0a552..702e505706 100644 --- a/packages/desktop/lib/routers/helpers/getAppRouteForContext.ts +++ b/packages/desktop/lib/routers/helpers/getAppRouteForContext.ts @@ -1,7 +1,7 @@ import { AppContext } from '@core/app' import { AppRoute } from '@core/router' -export function getAppRouteForContext(context: AppContext): AppRoute { +export function getAppRouteForContext(context: AppContext): AppRoute | undefined { switch (context) { case AppContext.Dashboard: return AppRoute.Dashboard diff --git a/packages/desktop/tsconfig.json b/packages/desktop/tsconfig.json index 1bc7230740..779e7099e7 100644 --- a/packages/desktop/tsconfig.json +++ b/packages/desktop/tsconfig.json @@ -4,6 +4,7 @@ "allowJs": true, "baseUrl": ".", "isolatedModules": false, + "moduleResolution": "node", "resolveJsonModule": true, "importsNotUsedAsValues": "remove", "lib": ["DOM", "ESNext"], diff --git a/packages/desktop/views/onboarding/views/network-setup/network-setup-router.ts b/packages/desktop/views/onboarding/views/network-setup/network-setup-router.ts index 74be9eaa3c..c248e9414f 100644 --- a/packages/desktop/views/onboarding/views/network-setup/network-setup-router.ts +++ b/packages/desktop/views/onboarding/views/network-setup/network-setup-router.ts @@ -3,8 +3,8 @@ import { Router, Subrouter } from '@core/router' import { get, writable } from 'svelte/store' import { NetworkSetupRoute } from './network-setup-route.enum' -export const networkSetupRoute = writable(null) -export const networkSetupRouter = writable(null) +export const networkSetupRoute = writable(undefined) +export const networkSetupRouter = writable(undefined) export class NetworkSetupRouter extends Subrouter { constructor(parentRouter: Router) { diff --git a/packages/shared/src/lib/core/app/utils/isLatestStrongholdVersion.ts b/packages/shared/src/lib/core/app/utils/isLatestStrongholdVersion.ts index bfbdd06467..4c806cdc6e 100644 --- a/packages/shared/src/lib/core/app/utils/isLatestStrongholdVersion.ts +++ b/packages/shared/src/lib/core/app/utils/isLatestStrongholdVersion.ts @@ -1,6 +1,6 @@ import { STRONGHOLD_VERSION } from '@core/stronghold/constants' import { StrongholdVersion } from '@core/stronghold/enums' -export function isLatestStrongholdVersion(strongholdVersion: StrongholdVersion): boolean { +export function isLatestStrongholdVersion(strongholdVersion: StrongholdVersion | undefined): boolean { return strongholdVersion === STRONGHOLD_VERSION }