diff --git a/craco.config.js b/craco.config.js
index 935b942..3acb036 100644
--- a/craco.config.js
+++ b/craco.config.js
@@ -1,6 +1,7 @@
// Copyright (c) 2020-2021 Drew Lemmy
// This file is part of KristWeb 2 under GPL-3.0.
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
+const CracoAlias = require("craco-alias");
const CracoLessPlugin = require("craco-less");
const AntdDayjsWebpackPlugin = require("antd-dayjs-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
@@ -21,6 +22,14 @@
plugins: [
{
+ plugin: CracoAlias,
+ options: {
+ source: "tsconfig",
+ baseUrl: "./src",
+ tsConfigPath: "./tsconfig.extend.json"
+ }
+ },
+ {
plugin: CracoLessPlugin,
options: {
cssLoaderOptions: {
diff --git a/package.json b/package.json
index 820835a..cfacd76 100644
--- a/package.json
+++ b/package.json
@@ -100,6 +100,7 @@
"@typescript-eslint/parser": "4.15.3-alpha.17",
"antd-dayjs-webpack-plugin": "^1.0.6",
"babel-plugin-lodash": "^3.3.4",
+ "craco-alias": "^2.2.0",
"craco-less": "^1.17.1",
"eslint": "^7.21.0",
"eslint-plugin-react": "^7.22.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2e46f87..ef5faf0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -59,6 +59,7 @@
'@typescript-eslint/parser': 4.15.3-alpha.17_eslint@7.21.0+typescript@4.1.5
antd-dayjs-webpack-plugin: 1.0.6_dayjs@1.10.4
babel-plugin-lodash: 3.3.4
+ craco-alias: 2.2.0
craco-less: 1.17.1_077094f002a207b28261f7f7ea13418e
eslint: 7.21.0
eslint-plugin-react: 7.22.0_eslint@7.21.0
@@ -4303,6 +4304,10 @@
node: '>=10'
resolution:
integrity: sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==
+ /craco-alias/2.2.0:
+ dev: true
+ resolution:
+ integrity: sha512-FLSRaCWI/CKLUO+Cb/GH9ljSYWdrlzkYf3N373Kuof0hckJ1tj+wPN0XyToR8KPUggoIB5+IDkGs1uKUBuGUiA==
/craco-less/1.17.1_077094f002a207b28261f7f7ea13418e:
dependencies:
'@craco/craco': 6.1.1_react-scripts@4.0.3
@@ -13813,6 +13818,7 @@
base64-arraybuffer: ^0.2.0
chart.js: ^2.9.4
classnames: ^2.2.6
+ craco-alias: ^2.2.0
craco-less: ^1.17.1
csv-stringify: ^5.6.2
dayjs: ^1.10.4
diff --git a/public/locales/en.json b/public/locales/en.json
index 4fecf0d..ef2c0c9 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -580,11 +580,16 @@
"import": {
"description": "Paste the backup code (or import from a file below) and enter the corresponding master password.",
+
"masterPasswordPlaceholder": "Master password",
"masterPasswordRequired": "Master password is required.",
"masterPasswordIncorrect": "Master password is incorrect.",
+
"fromFileButton": "Import from file",
"textareaPlaceholder": "Paste backup code here",
+ "textareaRequired": "Backup code is required.",
+
+ "modalTitle": "Import backup",
"modalButton": "Import",
"detectedFormat": "<0>Detected format:0> <2 />",
diff --git a/src/__tests__/App.tsx b/src/__tests__/App.tsx
index cb0cede..fbc005b 100644
--- a/src/__tests__/App.tsx
+++ b/src/__tests__/App.tsx
@@ -3,7 +3,7 @@
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
import React from "react";
import { render, screen } from "@testing-library/react";
-import App from "../App";
+import App from "@app";
test("renders the app", async () => {
render();
diff --git a/src/components/DateTime.tsx b/src/components/DateTime.tsx
index 291604b..d5db61d 100644
--- a/src/components/DateTime.tsx
+++ b/src/components/DateTime.tsx
@@ -5,7 +5,7 @@
import classNames from "classnames";
import { Tooltip } from "antd";
-import { useBooleanSetting } from "../utils/settings";
+import { useBooleanSetting } from "@utils/settings";
import dayjs from "dayjs";
import TimeAgo from "react-timeago";
diff --git a/src/components/addresses/ContextualAddress.tsx b/src/components/addresses/ContextualAddress.tsx
index 4419d54..4f64676 100644
--- a/src/components/addresses/ContextualAddress.tsx
+++ b/src/components/addresses/ContextualAddress.tsx
@@ -6,15 +6,15 @@
import { Tooltip, Typography } from "antd";
import { useSelector } from "react-redux";
-import { RootState } from "../../store";
+import { RootState } from "@store";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
-import { KristAddress } from "../../krist/api/types";
-import { Wallet, useWallets } from "../../krist/wallets/Wallet";
-import { parseCommonMeta, CommonMeta } from "../../utils/commonmeta";
-import { stripNameSuffix } from "../../utils/currency";
-import { useBooleanSetting } from "../../utils/settings";
+import { KristAddress } from "@api/types";
+import { Wallet, useWallets } from "@wallets/Wallet";
+import { parseCommonMeta, CommonMeta } from "@utils/commonmeta";
+import { stripNameSuffix } from "@utils/currency";
+import { useBooleanSetting } from "@utils/settings";
import { KristNameLink } from "../names/KristNameLink";
diff --git a/src/components/auth/AuthMasterPasswordPopover.tsx b/src/components/auth/AuthMasterPasswordPopover.tsx
index 5f02f6a..fd64868 100644
--- a/src/components/auth/AuthMasterPasswordPopover.tsx
+++ b/src/components/auth/AuthMasterPasswordPopover.tsx
@@ -6,13 +6,14 @@
import { TooltipPlacement } from "antd/lib/tooltip";
import { useSelector, shallowEqual } from "react-redux";
-import { RootState } from "../../store";
+import { RootState } from "@store";
import { useTranslation } from "react-i18next";
+import { translateError } from "@utils/i18n";
import { FakeUsernameInput } from "./FakeUsernameInput";
import { getMasterPasswordInput } from "./MasterPasswordInput";
-import { authMasterPassword } from "../../krist/wallets/WalletManager";
+import { authMasterPassword } from "@wallets/WalletManager";
interface FormValues {
masterPassword: string;
@@ -36,12 +37,8 @@
try {
await authMasterPassword(salt, tester, values.masterPassword);
onSubmit();
- } catch (e) {
- const message = e.message // Translate the error if we can
- ? e.message.startsWith("masterPassword.") ? t(e.message) : e.message
- : t("masterPassword.errorUnknown");
-
- setPasswordError(message);
+ } catch (err) {
+ setPasswordError(translateError(t, err, "masterPassword.errorUnknown"));
}
}
diff --git a/src/components/auth/AuthorisedAction.tsx b/src/components/auth/AuthorisedAction.tsx
index bcbcb16..f73bfbf 100644
--- a/src/components/auth/AuthorisedAction.tsx
+++ b/src/components/auth/AuthorisedAction.tsx
@@ -5,7 +5,7 @@
import { TooltipPlacement } from "antd/lib/tooltip";
import { useSelector, shallowEqual } from "react-redux";
-import { RootState } from "../../store";
+import { RootState } from "@store";
import { AuthMasterPasswordPopover } from "./AuthMasterPasswordPopover";
import { SetMasterPasswordModal } from "./SetMasterPasswordModal";
diff --git a/src/components/auth/ForcedAuth.tsx b/src/components/auth/ForcedAuth.tsx
index 936e0bf..0a21e5d 100644
--- a/src/components/auth/ForcedAuth.tsx
+++ b/src/components/auth/ForcedAuth.tsx
@@ -5,11 +5,11 @@
import { useTranslation, TFunction } from "react-i18next";
import { useSelector, shallowEqual } from "react-redux";
-import { RootState } from "../../store";
+import { RootState } from "@store";
-import { authMasterPassword } from "../../krist/wallets/WalletManager";
+import { authMasterPassword } from "@wallets/WalletManager";
-import { useMountEffect } from "../../utils";
+import { useMountEffect } from "@utils";
async function forceAuth(t: TFunction, salt: string, tester: string): Promise {
try {
diff --git a/src/components/auth/SetMasterPasswordModal.tsx b/src/components/auth/SetMasterPasswordModal.tsx
index 58052c2..8b883d7 100644
--- a/src/components/auth/SetMasterPasswordModal.tsx
+++ b/src/components/auth/SetMasterPasswordModal.tsx
@@ -8,7 +8,7 @@
import { FakeUsernameInput } from "./FakeUsernameInput";
import { getMasterPasswordInput } from "./MasterPasswordInput";
-import { setMasterPassword } from "../../krist/wallets/WalletManager";
+import { setMasterPassword } from "@wallets/WalletManager";
interface Props {
visible: boolean;
diff --git a/src/components/krist/KristValue.tsx b/src/components/krist/KristValue.tsx
index 1ccdc16..b633cda 100644
--- a/src/components/krist/KristValue.tsx
+++ b/src/components/krist/KristValue.tsx
@@ -5,7 +5,7 @@
import classNames from "classnames";
import { useSelector } from "react-redux";
-import { RootState } from "../../store";
+import { RootState } from "@store";
import { KristSymbol } from "./KristSymbol";
diff --git a/src/components/names/KristNameLink.tsx b/src/components/names/KristNameLink.tsx
index 6a8e080..6e8440e 100644
--- a/src/components/names/KristNameLink.tsx
+++ b/src/components/names/KristNameLink.tsx
@@ -6,11 +6,11 @@
import { Typography } from "antd";
import { useSelector } from "react-redux";
-import { RootState } from "../../store";
+import { RootState } from "@store";
import { Link } from "react-router-dom";
-import { useBooleanSetting } from "../../utils/settings";
+import { useBooleanSetting } from "@utils/settings";
const { Text } = Typography;
diff --git a/src/components/names/NameARecordLink.tsx b/src/components/names/NameARecordLink.tsx
index 1d56d03..7abe915 100644
--- a/src/components/names/NameARecordLink.tsx
+++ b/src/components/names/NameARecordLink.tsx
@@ -5,8 +5,8 @@
import classNames from "classnames";
import { useSelector } from "react-redux";
-import { RootState } from "../../store";
-import { stripNameSuffix } from "../../utils/currency";
+import { RootState } from "@store";
+import { stripNameSuffix } from "@utils/currency";
import { KristNameLink } from "./KristNameLink";
diff --git a/src/components/results/APIErrorResult.tsx b/src/components/results/APIErrorResult.tsx
index 2545ab2..56bedf6 100644
--- a/src/components/results/APIErrorResult.tsx
+++ b/src/components/results/APIErrorResult.tsx
@@ -8,7 +8,7 @@
import { useTranslation } from "react-i18next";
import { SmallResult, ResultProps } from "./SmallResult";
-import { APIError } from "../../krist/api";
+import { APIError } from "@api";
interface Props {
error: Error;
diff --git a/src/components/transactions/TransactionConciseMetadata.tsx b/src/components/transactions/TransactionConciseMetadata.tsx
index 734b4a0..b1bc354 100644
--- a/src/components/transactions/TransactionConciseMetadata.tsx
+++ b/src/components/transactions/TransactionConciseMetadata.tsx
@@ -5,10 +5,10 @@
import classNames from "classnames";
import { useSelector } from "react-redux";
-import { RootState } from "../../store";
+import { RootState } from "@store";
-import { KristTransaction } from "../../krist/api/types";
-import { stripNameFromMetadata } from "../../utils/currency";
+import { KristTransaction } from "@api/types";
+import { stripNameFromMetadata } from "@utils/currency";
import "./TransactionConciseMetadata.less";
diff --git a/src/components/transactions/TransactionItem.tsx b/src/components/transactions/TransactionItem.tsx
index f61c01f..8c5563f 100644
--- a/src/components/transactions/TransactionItem.tsx
+++ b/src/components/transactions/TransactionItem.tsx
@@ -8,8 +8,8 @@
import { useTranslation, Trans } from "react-i18next";
import { Link } from "react-router-dom";
-import { KristTransaction } from "../../krist/api/types";
-import { Wallet } from "../../krist/wallets/Wallet";
+import { KristTransaction } from "@api/types";
+import { Wallet } from "@wallets/Wallet";
import { DateTime } from "../DateTime";
import { KristValue } from "../krist/KristValue";
import { KristNameLink } from "../names/KristNameLink";
diff --git a/src/components/transactions/TransactionSummary.tsx b/src/components/transactions/TransactionSummary.tsx
index ccb9310..846639f 100644
--- a/src/components/transactions/TransactionSummary.tsx
+++ b/src/components/transactions/TransactionSummary.tsx
@@ -7,9 +7,9 @@
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
-import { useWallets } from "../../krist/wallets/Wallet";
+import { useWallets } from "@wallets/Wallet";
-import { KristTransaction } from "../../krist/api/types";
+import { KristTransaction } from "@api/types";
import { TransactionItem } from "./TransactionItem";
import "./TransactionSummary.less";
diff --git a/src/components/transactions/TransactionType.tsx b/src/components/transactions/TransactionType.tsx
index 5a5280f..6e97299 100644
--- a/src/components/transactions/TransactionType.tsx
+++ b/src/components/transactions/TransactionType.tsx
@@ -7,8 +7,8 @@
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
-import { KristTransaction, KristTransactionType } from "../../krist/api/types";
-import { Wallet, useWallets } from "../../krist/wallets/Wallet";
+import { KristTransaction, KristTransactionType } from "@api/types";
+import { Wallet, useWallets } from "@wallets/Wallet";
import "./TransactionType.less";
diff --git a/src/components/wallets/SelectWalletCategory.tsx b/src/components/wallets/SelectWalletCategory.tsx
index 46561c9..fa06c1a 100644
--- a/src/components/wallets/SelectWalletCategory.tsx
+++ b/src/components/wallets/SelectWalletCategory.tsx
@@ -7,8 +7,8 @@
import { useTranslation } from "react-i18next";
-import { localeSort } from "../../utils";
-import { useWallets } from "../../krist/wallets/Wallet";
+import { localeSort } from "@utils";
+import { useWallets } from "@wallets/Wallet";
const { Text } = Typography;
diff --git a/src/components/wallets/SelectWalletFormat.tsx b/src/components/wallets/SelectWalletFormat.tsx
index 269fcc7..4346849 100644
--- a/src/components/wallets/SelectWalletFormat.tsx
+++ b/src/components/wallets/SelectWalletFormat.tsx
@@ -6,8 +6,8 @@
import { useTranslation } from "react-i18next";
-import { WalletFormatName, ADVANCED_FORMATS } from "../../krist/wallets/formats/WalletFormat";
-import { useBooleanSetting } from "../../utils/settings";
+import { WalletFormatName, ADVANCED_FORMATS } from "@wallets/formats/WalletFormat";
+import { useBooleanSetting } from "@utils/settings";
interface Props {
initialFormat: WalletFormatName;
diff --git a/src/components/wallets/SyncWallets.tsx b/src/components/wallets/SyncWallets.tsx
index 07f8e69..a91a12a 100644
--- a/src/components/wallets/SyncWallets.tsx
+++ b/src/components/wallets/SyncWallets.tsx
@@ -1,8 +1,8 @@
// Copyright (c) 2020-2021 Drew Lemmy
// This file is part of KristWeb 2 under GPL-3.0.
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
-import { syncWallets } from "../../krist/wallets/Wallet";
-import { useMountEffect } from "../../utils";
+import { syncWallets } from "@wallets/Wallet";
+import { useMountEffect } from "@utils";
/** Sync the wallets with the Krist node on startup. */
export function SyncWallets(): JSX.Element | null {
diff --git a/src/global/AppRouter.tsx b/src/global/AppRouter.tsx
index 0f3af54..6a1c091 100644
--- a/src/global/AppRouter.tsx
+++ b/src/global/AppRouter.tsx
@@ -4,25 +4,25 @@
import React from "react";
import { Switch, Route } from "react-router-dom";
-import { DashboardPage } from "../pages/dashboard/DashboardPage";
-import { WalletsPage } from "../pages/wallets/WalletsPage";
+import { DashboardPage } from "@pages/dashboard/DashboardPage";
+import { WalletsPage } from "@pages/wallets/WalletsPage";
-import { AddressPage } from "../pages/addresses/AddressPage";
-import { BlocksPage } from "../pages/blocks/BlocksPage";
-import { BlockPage } from "../pages/blocks/BlockPage";
-import { TransactionsPage, ListingType as TXListing } from "../pages/transactions/TransactionsPage";
-import { TransactionPage } from "../pages/transactions/TransactionPage";
-import { NamesPage, ListingType as NamesListing } from "../pages/names/NamesPage";
-import { NamePage } from "../pages/names/NamePage";
+import { AddressPage } from "@pages/addresses/AddressPage";
+import { BlocksPage } from "@pages/blocks/BlocksPage";
+import { BlockPage } from "@pages/blocks/BlockPage";
+import { TransactionsPage, ListingType as TXListing } from "@pages/transactions/TransactionsPage";
+import { TransactionPage } from "@pages/transactions/TransactionPage";
+import { NamesPage, ListingType as NamesListing } from "@pages/names/NamesPage";
+import { NamePage } from "@pages/names/NamePage";
-import { SettingsPage } from "../pages/settings/SettingsPage";
-import { SettingsTranslations } from "../pages/settings/SettingsTranslations";
+import { SettingsPage } from "@pages/settings/SettingsPage";
+import { SettingsTranslations } from "@pages/settings/SettingsTranslations";
-import { CreditsPage } from "../pages/credits/CreditsPage";
+import { CreditsPage } from "@pages/credits/CreditsPage";
-import { DevPage } from "../pages/dev/DevPage";
+import { DevPage } from "@pages/dev/DevPage";
-import { NotFoundPage } from "../pages/NotFoundPage";
+import { NotFoundPage } from "@pages/NotFoundPage";
interface AppRoute {
path: string;
diff --git a/src/global/AppServices.tsx b/src/global/AppServices.tsx
index b59c838..562e069 100644
--- a/src/global/AppServices.tsx
+++ b/src/global/AppServices.tsx
@@ -3,8 +3,8 @@
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
import React from "react";
-import { SyncWallets } from "../components/wallets/SyncWallets";
-import { ForcedAuth } from "../components/auth/ForcedAuth";
+import { SyncWallets } from "@comp/wallets/SyncWallets";
+import { ForcedAuth } from "@comp/auth/ForcedAuth";
import { WebsocketService } from "./ws/WebsocketService";
import { SyncWork } from "./ws/SyncWork";
import { SyncMOTD } from "./ws/SyncMOTD";
diff --git a/src/global/ws/SyncMOTD.tsx b/src/global/ws/SyncMOTD.tsx
index e442dcc..5ce3826 100644
--- a/src/global/ws/SyncMOTD.tsx
+++ b/src/global/ws/SyncMOTD.tsx
@@ -4,15 +4,15 @@
import { useEffect } from "react";
import { useSelector } from "react-redux";
-import { RootState } from "../../store";
-import * as nodeActions from "../../store/actions/NodeActions";
+import { RootState } from "@store";
+import * as nodeActions from "@actions/NodeActions";
-import { store } from "../../App";
+import { store } from "@app";
-import * as api from "../../krist/api";
-import { KristMOTD, KristMOTDBase } from "../../krist/api/types";
+import * as api from "@api";
+import { KristMOTD, KristMOTDBase } from "@api/types";
-import { recalculateWallets, useWallets } from "../../krist/wallets/Wallet";
+import { recalculateWallets, useWallets } from "@wallets/Wallet";
import Debug from "debug";
const debug = Debug("kristweb:sync-motd");
diff --git a/src/global/ws/SyncWork.tsx b/src/global/ws/SyncWork.tsx
index c488570..d56649f 100644
--- a/src/global/ws/SyncWork.tsx
+++ b/src/global/ws/SyncWork.tsx
@@ -4,13 +4,13 @@
import { useEffect } from "react";
import { useSelector } from "react-redux";
-import { RootState } from "../../store";
-import * as nodeActions from "../../store/actions/NodeActions";
+import { RootState } from "@store";
+import * as nodeActions from "@actions/NodeActions";
-import { store } from "../../App";
+import { store } from "@app";
-import * as api from "../../krist/api";
-import { KristWorkDetailed } from "../../krist/api/types";
+import * as api from "@api";
+import { KristWorkDetailed } from "@api/types";
import Debug from "debug";
const debug = Debug("kristweb:sync-work");
diff --git a/src/global/ws/WebsocketService.tsx b/src/global/ws/WebsocketService.tsx
index 7915477..e25cc2c 100644
--- a/src/global/ws/WebsocketService.tsx
+++ b/src/global/ws/WebsocketService.tsx
@@ -3,14 +3,14 @@
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
import { useState, useEffect } from "react";
-import { store } from "../../App";
-import { WalletMap } from "../../store/reducers/WalletsReducer";
-import * as wsActions from "../../store/actions/WebsocketActions";
-import * as nodeActions from "../../store/actions/NodeActions";
+import { store } from "@app";
+import { WalletMap } from "@reducers/WalletsReducer";
+import * as wsActions from "@actions/WebsocketActions";
+import * as nodeActions from "@actions/NodeActions";
-import * as api from "../../krist/api";
-import { KristAddress, KristBlock, KristTransaction, WSConnectionState, WSIncomingMessage, WSSubscriptionLevel } from "../../krist/api/types";
-import { useWallets, findWalletByAddress, syncWallet, syncWalletUpdate, Wallet } from "../../krist/wallets/Wallet";
+import * as api from "@api";
+import { KristAddress, KristBlock, KristTransaction, WSConnectionState, WSIncomingMessage, WSSubscriptionLevel } from "@api/types";
+import { useWallets, findWalletByAddress, syncWallet, syncWalletUpdate, Wallet } from "@wallets/Wallet";
import WebSocketAsPromised from "websocket-as-promised";
import { throttle } from "lodash-es";
diff --git a/src/krist/AddressAlgo.ts b/src/krist/AddressAlgo.ts
index db74732..19b539a 100644
--- a/src/krist/AddressAlgo.ts
+++ b/src/krist/AddressAlgo.ts
@@ -1,7 +1,7 @@
// Copyright (c) 2020-2021 Drew Lemmy
// This file is part of KristWeb 2 under GPL-3.0.
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
-import { sha256, doubleSHA256 } from "../utils/crypto";
+import { sha256, doubleSHA256 } from "@utils/crypto";
const hexToBase36 = (input: number): string => {
const byte = 48 + Math.floor(input / 7);
diff --git a/src/krist/api/index.ts b/src/krist/api/index.ts
index a5c3fd9..44d0643 100644
--- a/src/krist/api/index.ts
+++ b/src/krist/api/index.ts
@@ -2,11 +2,11 @@
// This file is part of KristWeb 2 under GPL-3.0.
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
import { notification } from "antd";
-import i18n from "../../utils/i18n";
+import i18n from "@utils/i18n";
import { useSelector } from "react-redux";
-import { RootState } from "../../store";
-import { store } from "../../App";
+import { RootState } from "@store";
+import { store } from "@app";
import { APIResponse } from "./types";
import { throttle } from "lodash-es";
diff --git a/src/krist/api/lookup.ts b/src/krist/api/lookup.ts
index 6089c9c..72c3f2a 100644
--- a/src/krist/api/lookup.ts
+++ b/src/krist/api/lookup.ts
@@ -4,7 +4,7 @@
import { KristAddress, KristTransaction, KristName, KristBlock } from "./types";
import * as api from ".";
-import { LookupFilterOptionsBase, LookupResponseBase, getFilterOptionsQuery } from "../../utils/table";
+import { LookupFilterOptionsBase, LookupResponseBase, getFilterOptionsQuery } from "@utils/table";
// =============================================================================
// Addresses
diff --git a/src/krist/wallets/Wallet.ts b/src/krist/wallets/Wallet.ts
index e285fff..d05fbc9 100644
--- a/src/krist/wallets/Wallet.ts
+++ b/src/krist/wallets/Wallet.ts
@@ -6,16 +6,16 @@
import { applyWalletFormat, WalletFormatName } from "./formats/WalletFormat";
import { makeV2Address } from "../AddressAlgo";
-import { aesGcmDecrypt, aesGcmEncrypt } from "../../utils/crypto";
+import { aesGcmDecrypt, aesGcmEncrypt } from "@utils/crypto";
import { KristAddressWithNames, lookupAddresses } from "../api/lookup";
-import { store } from "../../App";
-import * as actions from "../../store/actions/WalletsActions";
-import { WalletMap } from "../../store/reducers/WalletsReducer";
+import { store } from "@app";
+import * as actions from "@actions/WalletsActions";
+import { WalletMap } from "@reducers/WalletsReducer";
import { useSelector, shallowEqual } from "react-redux";
-import { RootState } from "../../store";
+import { RootState } from "@store";
import { Mutex } from "async-mutex";
diff --git a/src/krist/wallets/WalletManager.ts b/src/krist/wallets/WalletManager.ts
index 64d0b2d..ef54e66 100644
--- a/src/krist/wallets/WalletManager.ts
+++ b/src/krist/wallets/WalletManager.ts
@@ -1,11 +1,13 @@
// Copyright (c) 2020-2021 Drew Lemmy
// This file is part of KristWeb 2 under GPL-3.0.
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
-import { toHex } from "../../utils";
-import { aesGcmEncrypt, aesGcmDecrypt } from "../../utils/crypto";
+import { toHex } from "@utils";
+import { aesGcmEncrypt, aesGcmDecrypt } from "@utils/crypto";
-import { store } from "../../App";
-import * as actions from "../../store/actions/WalletManagerActions";
+import { store } from "@app";
+import * as actions from "@actions/WalletManagerActions";
+
+import { TranslatedError } from "@utils/i18n";
/** Verifies that the given master password is correct, and dispatches the
* auth action to the Redux store. */
@@ -14,8 +16,10 @@
tester: string | undefined,
password: string
): Promise {
- if (!password) throw new Error("masterPassword.errorPasswordRequired");
- if (!salt || !tester) throw new Error("masterPassword.errorPasswordUnset");
+ if (!password)
+ throw new TranslatedError("masterPassword.errorPasswordRequired");
+ if (!salt || !tester)
+ throw new TranslatedError("masterPassword.errorPasswordUnset");
try {
// Attempt to decrypt the tester with the given password
@@ -23,10 +27,12 @@
// Verify that the decrypted tester is equal to the salt, if not, the
// provided master password is incorrect.
- if (testerDec !== salt) throw new Error("masterPassword.errorPasswordIncorrect");
+ if (testerDec !== salt)
+ throw new TranslatedError("masterPassword.errorPasswordIncorrect");
} catch (e) {
// OperationError usually means decryption failure
- if (e.name === "OperationError") throw new Error("masterPassword.errorPasswordIncorrect");
+ if (e.name === "OperationError")
+ throw new TranslatedError("masterPassword.errorPasswordIncorrect");
else throw e;
}
@@ -37,7 +43,8 @@
/** Generates a salt and tester, sets the master password, and dispatches the
* action to the Redux store. */
export async function setMasterPassword(password: string): Promise {
- if (!password) throw new Error("masterPassword.errorPasswordRequired");
+ if (!password)
+ throw new TranslatedError("masterPassword.errorPasswordRequired");
// Generate the salt (to be encrypted with the master password)
const salt = window.crypto.getRandomValues(new Uint8Array(32));
diff --git a/src/krist/wallets/formats/WalletFormat.ts b/src/krist/wallets/formats/WalletFormat.ts
index 397c123..b754268 100644
--- a/src/krist/wallets/formats/WalletFormat.ts
+++ b/src/krist/wallets/formats/WalletFormat.ts
@@ -1,7 +1,7 @@
// Copyright (c) 2020-2021 Drew Lemmy
// This file is part of KristWeb 2 under GPL-3.0.
// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt
-import { sha256 } from "../../../utils/crypto";
+import { sha256 } from "@utils/crypto";
export interface WalletFormat {
(password: string, username?: string): Promise;
diff --git a/src/layout/nav/ConnectionIndicator.tsx b/src/layout/nav/ConnectionIndicator.tsx
index c64efee..ca96676 100644
--- a/src/layout/nav/ConnectionIndicator.tsx
+++ b/src/layout/nav/ConnectionIndicator.tsx
@@ -5,10 +5,10 @@
import { Tooltip } from "antd";
import { useSelector } from "react-redux";
-import { RootState } from "../../store";
+import { RootState } from "@store";
import { useTranslation } from "react-i18next";
-import { WSConnectionState } from "../../krist/api/types";
+import { WSConnectionState } from "@api/types";
import "./ConnectionIndicator.less";
diff --git a/src/layout/nav/CymbalIndicator.tsx b/src/layout/nav/CymbalIndicator.tsx
index 68b6761..f927889 100644
--- a/src/layout/nav/CymbalIndicator.tsx
+++ b/src/layout/nav/CymbalIndicator.tsx
@@ -5,8 +5,8 @@
import Icon from "@ant-design/icons";
import { useSelector, shallowEqual } from "react-redux";
-import { RootState } from "../../store";
-import { SettingsState } from "../../utils/settings";
+import { RootState } from "@store";
+import { SettingsState } from "@utils/settings";
export const CymbalIconSvg = (): JSX.Element => (