taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 046b6c4ddc5ef02ba866564c88406a7af0402e6c
parent f0a0d3bd69d3b10bcb2b616b9f595c9d02c7fb85
Author: Antoine A <>
Date:   Wed, 30 Apr 2025 18:11:52 +0200

common: use a common assertUnreachable everywhere

Diffstat:
Mpackages/taler-wallet-cli/src/index.ts | 7++-----
Mpackages/taler-wallet-webextension/src/components/HistoryItem.tsx | 4++--
Mpackages/taler-wallet-webextension/src/components/PaymentButtons.tsx | 5++---
Mpackages/taler-wallet-webextension/src/utils/index.ts | 6+-----
Mpackages/taler-wallet-webextension/src/wallet/AddBackupProvider/state.ts | 4++--
Mpackages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts | 6+++---
Mpackages/taler-wallet-webextension/src/wallet/DestinationSelection/views.tsx | 4++--
Mpackages/taler-wallet-webextension/src/wallet/Notifications/views.tsx | 4++--
Mpackages/taler-wallet-webextension/src/wallet/Transaction.tsx | 4++--
9 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2019 Taler Systems S.A. + (C) 2019-2025 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -23,6 +23,7 @@ import { AgeRestriction, Amounts, AmountString, + assertUnreachable, codecForList, codecForString, CoreApiResponse, @@ -95,10 +96,6 @@ setUnhandledRejectionHandler((error: any) => { const defaultWalletDbPath = pathHomedir() + "/" + ".talerwalletdb.sqlite3"; const defaultWalletCoreSocket = pathHomedir() + "/" + ".wallet-core.sock"; -function assertUnreachable(x: never): never { - throw new Error("Didn't expect to get here"); -} - async function doPay( wallet: WalletCoreApiClient, payUrl: string, diff --git a/packages/taler-wallet-webextension/src/components/HistoryItem.tsx b/packages/taler-wallet-webextension/src/components/HistoryItem.tsx @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2022 Taler Systems S.A. + (C) 2022-2025 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -25,12 +25,12 @@ import { TransactionMajorState, DenomLossEventType, parsePaytoUri, + assertUnreachable, } from "@gnu-taler/taler-util"; import { Fragment, h, VNode } from "preact"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { Avatar } from "../mui/Avatar.js"; import { Pages } from "../NavigationBar.js"; -import { assertUnreachable } from "../utils/index.js"; import { Column, ExtraLargeText, diff --git a/packages/taler-wallet-webextension/src/components/PaymentButtons.tsx b/packages/taler-wallet-webextension/src/components/PaymentButtons.tsx @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2022 Taler Systems S.A. + (C) 2022-2025 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,7 +18,7 @@ import { AmountJson, Amounts, InsufficientBalanceHint, - PaymentInsufficientBalanceDetails, + assertUnreachable, PreparePayResult, PreparePayResultType, TranslatedString, @@ -31,7 +31,6 @@ import { useState } from "preact/hooks"; import { useBackendContext } from "../context/backend.js"; import { Button } from "../mui/Button.js"; import { ButtonHandler } from "../mui/handlers.js"; -import { assertUnreachable } from "../utils/index.js"; import { Amount } from "./Amount.js"; import { Part } from "./Part.js"; import { QR } from "./QR.js"; diff --git a/packages/taler-wallet-webextension/src/utils/index.ts b/packages/taler-wallet-webextension/src/utils/index.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2022 Taler Systems S.A. + (C) 2022-2025 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -114,7 +114,3 @@ export function compose<SType extends { status: string }, PType>( return h(); }; } - -export function assertUnreachable(x: never): never { - throw new Error("Didn't expect to get here"); -} diff --git a/packages/taler-wallet-webextension/src/wallet/AddBackupProvider/state.ts b/packages/taler-wallet-webextension/src/wallet/AddBackupProvider/state.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2022 Taler Systems S.A. + (C) 2022-2025 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,12 +18,12 @@ import { canonicalizeBaseUrl, Codec, codecForSyncTermsOfServiceResponse, + assertUnreachable } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { useEffect, useState } from "preact/hooks"; import { useAlertContext } from "../../context/alert.js"; import { useBackendContext } from "../../context/backend.js"; -import { assertUnreachable } from "../../utils/index.js"; import { Props, State } from "./index.js"; type UrlState<T> = UrlOk<T> | UrlError; diff --git a/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts b/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2022 Taler Systems S.A. + (C) 2022-2025 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -17,7 +17,7 @@ import { ExchangeUpdateStatus, WalletBankAccountInfo, - PaytoUri, + assertUnreachable, ScopeType, parseScopeInfoShort, stringifyScopeInfoShort, @@ -29,7 +29,7 @@ import { useState } from "preact/hooks"; import { alertFromError, useAlertContext } from "../../context/alert.js"; import { useBackendContext } from "../../context/backend.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; -import { RecursiveState, assertUnreachable } from "../../utils/index.js"; +import { RecursiveState } from "../../utils/index.js"; import { Props, State } from "./index.js"; export function useComponentState(props: Props): RecursiveState<State> { diff --git a/packages/taler-wallet-webextension/src/wallet/DestinationSelection/views.tsx b/packages/taler-wallet-webextension/src/wallet/DestinationSelection/views.tsx @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2022 Taler Systems S.A. + (C) 2022-2025 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,6 +18,7 @@ import { WalletBankAccountInfo, parsePaytoUri, stringifyPaytoUri, + assertUnreachable } from "@gnu-taler/taler-util"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { styled } from "@linaria/react"; @@ -35,7 +36,6 @@ import { Paper } from "../../mui/Paper.js"; import { Pages } from "../../NavigationBar.js"; import arrowIcon from "../../svg/chevron-down.inline.svg"; import bankIcon from "../../svg/ri-bank-line.inline.svg"; -import { assertUnreachable } from "../../utils/index.js"; import { State } from "./index.js"; export function SelectCurrencyView({ diff --git a/packages/taler-wallet-webextension/src/wallet/Notifications/views.tsx b/packages/taler-wallet-webextension/src/wallet/Notifications/views.tsx @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2022 Taler Systems S.A. + (C) 2022-2025 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,6 +18,7 @@ import { AbsoluteTime, AttentionInfo, AttentionType, + assertUnreachable } from "@gnu-taler/taler-util"; import { Fragment, h, VNode } from "preact"; import { @@ -33,7 +34,6 @@ import { Avatar } from "../../mui/Avatar.js"; import { Button } from "../../mui/Button.js"; import { Grid } from "../../mui/Grid.js"; import { Pages } from "../../NavigationBar.js"; -import { assertUnreachable } from "../../utils/index.js"; import { State } from "./index.js"; const term = 1000 * 60 * 60 * 24; diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -1,6 +1,6 @@ /* This file is part of GNU Taler - (C) 2022 Taler Systems S.A. + (C) 2022-2025 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -42,6 +42,7 @@ import { TransactionWithdrawal, TranslatedString, WithdrawalType, + assertUnreachable } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { @@ -80,7 +81,6 @@ import { Button } from "../mui/Button.js"; import { SafeHandler } from "../mui/handlers.js"; import { Pages } from "../NavigationBar.js"; import refreshIcon from "../svg/refresh_24px.inline.svg"; -import { assertUnreachable } from "../utils/index.js"; interface Props { tid: string;