diff --git a/src/krist/AddressAlgo.ts b/src/krist/AddressAlgo.ts index 942b655..9d84e30 100644 --- a/src/krist/AddressAlgo.ts +++ b/src/krist/AddressAlgo.ts @@ -3,7 +3,7 @@ const hexToBase36 = (input: number): string => { const byte = 48 + Math.floor(input / 7); return String.fromCharCode(byte + 39 > 122 ? 101 : byte > 57 ? byte + 39 : byte); -} +}; export const makeV2Address = async (key: string): Promise => { const chars = ["", "", "", "", "", "", "", "", ""]; @@ -28,4 +28,4 @@ } return chain; -} +}; diff --git a/src/krist/wallets/Wallet.ts b/src/krist/wallets/Wallet.ts index 533ab4b..44fbc1f 100644 --- a/src/krist/wallets/Wallet.ts +++ b/src/krist/wallets/Wallet.ts @@ -7,9 +7,6 @@ import * as actions from "@actions/WalletsActions"; import { WalletMap } from "@reducers/WalletsReducer"; -import Debug from "debug"; -const debug = Debug("kristweb:wallet"); - export interface Wallet { // UUID for this wallet id: string; @@ -38,7 +35,10 @@ export type WalletSyncableKeys = "balance" | "names" | "firstSeen"; export type WalletSyncable = Pick; -export async function decryptWallet(id: string, data: AESEncryptedString, masterPassword: string): Promise { +export async function decryptWallet(id: string, data: AESEncryptedString | null, masterPassword: string): Promise { + if (data === null) // localStorage key was missing + throw new Error("masterPassword.walletStorageCorrupt"); + try { // Attempt to decrypt and deserialize the wallet data const dec = await aesGcmDecrypt(data, masterPassword); @@ -85,14 +85,14 @@ /** Loads all available wallets from local storage and dispatches them to the * Redux store. */ -export async function loadWallets(dispatch: AppDispatch, masterPassword: string) { +export async function loadWallets(dispatch: AppDispatch, masterPassword: string): Promise { // Find all `wallet2` keys from local storage. const keysToLoad = Object.keys(localStorage) .map(extractWalletKey) .filter(k => k !== undefined); const wallets = await Promise.all(keysToLoad - .map(([key, id]) => decryptWallet(id, localStorage.getItem(key)!, masterPassword))); + .map(([key, id]) => decryptWallet(id, localStorage.getItem(key), masterPassword))); // Convert to map with wallet IDs const walletMap: WalletMap = wallets.reduce((obj, w) => ({ ...obj, [w.id]: w }), {}); @@ -103,7 +103,7 @@ // TODO: temporary exposure of methods for testing declare global { interface Window { - encryptWallet: typeof encryptWallet + encryptWallet: typeof encryptWallet; } } window.encryptWallet = encryptWallet; diff --git a/src/layouts/my-transactions/MyTransactionsMobileItem.tsx b/src/layouts/my-transactions/MyTransactionsMobileItem.tsx index 24e4ff3..2d0994b 100644 --- a/src/layouts/my-transactions/MyTransactionsMobileItem.tsx +++ b/src/layouts/my-transactions/MyTransactionsMobileItem.tsx @@ -4,11 +4,11 @@ import { Transaction } from "./MyTransactionsPage"; interface Props { - item: Transaction + item: Transaction; }; export const MyTransactionsMobileItem: React.FC = ({ item }: Props) => { return <> {/* TODO */} - -} + ; +}; diff --git a/src/layouts/my-transactions/MyTransactionsPage.tsx b/src/layouts/my-transactions/MyTransactionsPage.tsx index 8ef929c..2e8b43e 100644 --- a/src/layouts/my-transactions/MyTransactionsPage.tsx +++ b/src/layouts/my-transactions/MyTransactionsPage.tsx @@ -13,13 +13,13 @@ // TODO: Temporary export interface Transaction { - id: number, - from?: string, - to?: string, - value: number, - time: DateString, - name?: string, - metadata?: string + id: number; + from?: string; + to?: string; + value: number; + time: DateString; + name?: string; + metadata?: string; } const COLUMNS = new Map, ColumnSpec>() diff --git a/src/layouts/my-wallets/MyWalletsMobileItem.tsx b/src/layouts/my-wallets/MyWalletsMobileItem.tsx index 822ce83..812d4f7 100644 --- a/src/layouts/my-wallets/MyWalletsMobileItem.tsx +++ b/src/layouts/my-wallets/MyWalletsMobileItem.tsx @@ -7,11 +7,11 @@ import { Wallet } from "@krist/wallets/Wallet"; interface Props { - item: Wallet + item: Wallet; }; export const Separator: React.FC = () => - + ; export const MyWalletsMobileItem: React.FC = ({ item }: Props) => { const { t } = useTranslation(); @@ -54,5 +54,5 @@ }

- -} + ; +}; diff --git a/src/layouts/my-wallets/MyWalletsPage.tsx b/src/layouts/my-wallets/MyWalletsPage.tsx index 96a27a0..f15bcb3 100644 --- a/src/layouts/my-wallets/MyWalletsPage.tsx +++ b/src/layouts/my-wallets/MyWalletsPage.tsx @@ -7,7 +7,6 @@ import { ListView } from "@components/list-view/ListView"; import { IconButton } from "@components/icon-button/IconButton"; -import Button from "react-bootstrap/Button"; import { AddWalletButton, CreateWalletButton } from "@layouts/dialogs/AddWalletDialog"; import { SearchTextbox } from "@components/list-view/SearchTextbox"; diff --git a/src/shared-components/list-view/ListMobile.tsx b/src/shared-components/list-view/ListMobile.tsx index f3536f0..23329ab 100644 --- a/src/shared-components/list-view/ListMobile.tsx +++ b/src/shared-components/list-view/ListMobile.tsx @@ -1,9 +1,8 @@ -import { KristValue } from "@components/krist-value/KristValue"; import React, { Component, ReactNode } from "react"; import { ListGroup } from "react-bootstrap"; -import { Columns, QueryStateBase, DataStateBase } from "./DataProvider"; +import { QueryStateBase, DataStateBase } from "./DataProvider"; import "./ListMobile.scss"; @@ -29,6 +28,6 @@ {renderListItem(item)} )} - + ; } } diff --git a/src/store/actions/WalletsActions.ts b/src/store/actions/WalletsActions.ts index dd9cc6b..7407cfe 100644 --- a/src/store/actions/WalletsActions.ts +++ b/src/store/actions/WalletsActions.ts @@ -18,10 +18,10 @@ export const removeWallet = createAction(constants.REMOVE_WALLET, (id): RemoveWalletPayload => ({ id }))(); -export interface UpdateWalletPayload { id: string, wallet: WalletUpdatable }; +export interface UpdateWalletPayload { id: string; wallet: WalletUpdatable }; export const updateWallet = createAction(constants.UPDATE_WALLET, (id, wallet): UpdateWalletPayload => ({ id, wallet }))(); -export interface SyncWalletPayload { id: string, wallet: WalletSyncable }; +export interface SyncWalletPayload { id: string; wallet: WalletSyncable }; export const syncWallet = createAction(constants.SYNC_WALLET, (id, wallet): SyncWalletPayload => ({ id, wallet }))(); diff --git a/src/store/reducers/WalletsReducer.ts b/src/store/reducers/WalletsReducer.ts index b0eb763..7dbfeca 100644 --- a/src/store/reducers/WalletsReducer.ts +++ b/src/store/reducers/WalletsReducer.ts @@ -3,7 +3,7 @@ import { Wallet } from "../../krist/wallets/Wallet"; -export type WalletMap = { [key: string]: Wallet }; +export interface WalletMap { [key: string]: Wallet } export interface State { readonly wallets: WalletMap; } @@ -45,6 +45,7 @@ // Remove wallet .handleAction(removeWallet, (state: State, { payload }: ActionType) => { // Get the wallets without the one we want to remove + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { [payload.id]: removed, ...wallets } = state.wallets; return { ...state, wallets }; }) diff --git a/src/utils/CryptoJS.ts b/src/utils/CryptoJS.ts index 93c7132..1530f99 100644 --- a/src/utils/CryptoJS.ts +++ b/src/utils/CryptoJS.ts @@ -5,9 +5,9 @@ import base64 from "base64-arraybuffer"; interface EvpKey { - key: Uint8Array, - iv: Uint8Array, - cryptoKey: CryptoKey + key: Uint8Array; + iv: Uint8Array; + cryptoKey: CryptoKey; } /**