summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-02-21 13:01:23 +0100
committerFlorian Dold <florian@dold.me>2024-02-21 13:01:23 +0100
commit612b85c18fc17af412d08e075e1fddaa67aa7bf0 (patch)
tree2209cb052c94f70145d33271b7711e39728ad72b
parent06635c195816121ed7d90cf7bd3834850b674564 (diff)
downloadwallet-core-612b85c18fc17af412d08e075e1fddaa67aa7bf0.tar.gz
wallet-core-612b85c18fc17af412d08e075e1fddaa67aa7bf0.tar.bz2
wallet-core-612b85c18fc17af412d08e075e1fddaa67aa7bf0.zip
move helpers to util
-rw-r--r--packages/taler-util/src/index.ts1
-rw-r--r--packages/taler-util/src/invariants.ts (renamed from packages/taler-wallet-core/src/util/invariants.ts)19
-rw-r--r--packages/taler-wallet-core/src/backup/index.ts3
-rw-r--r--packages/taler-wallet-core/src/balance.ts4
-rw-r--r--packages/taler-wallet-core/src/coinSelection.test.ts (renamed from packages/taler-wallet-core/src/util/coinSelection.test.ts)1
-rw-r--r--packages/taler-wallet-core/src/coinSelection.ts (renamed from packages/taler-wallet-core/src/util/coinSelection.ts)13
-rw-r--r--packages/taler-wallet-core/src/common.ts5
-rw-r--r--packages/taler-wallet-core/src/dbless.ts2
-rw-r--r--packages/taler-wallet-core/src/denominations.test.ts (renamed from packages/taler-wallet-core/src/util/denominations.test.ts)0
-rw-r--r--packages/taler-wallet-core/src/denominations.ts (renamed from packages/taler-wallet-core/src/util/denominations.ts)2
-rw-r--r--packages/taler-wallet-core/src/deposits.ts7
-rw-r--r--packages/taler-wallet-core/src/exchanges.ts10
-rw-r--r--packages/taler-wallet-core/src/index.ts2
-rw-r--r--packages/taler-wallet-core/src/instructedAmountConversion.test.ts (renamed from packages/taler-wallet-core/src/util/instructedAmountConversion.test.ts)0
-rw-r--r--packages/taler-wallet-core/src/instructedAmountConversion.ts (renamed from packages/taler-wallet-core/src/util/instructedAmountConversion.ts)8
-rw-r--r--packages/taler-wallet-core/src/pay-merchant.ts7
-rw-r--r--packages/taler-wallet-core/src/pay-peer-common.ts7
-rw-r--r--packages/taler-wallet-core/src/pay-peer-pull-credit.ts4
-rw-r--r--packages/taler-wallet-core/src/pay-peer-pull-debit.ts6
-rw-r--r--packages/taler-wallet-core/src/pay-peer-push-credit.ts4
-rw-r--r--packages/taler-wallet-core/src/pay-peer-push-debit.ts6
-rw-r--r--packages/taler-wallet-core/src/recoup.ts2
-rw-r--r--packages/taler-wallet-core/src/refresh.ts6
-rw-r--r--packages/taler-wallet-core/src/reward.ts2
-rw-r--r--packages/taler-wallet-core/src/testing.ts2
-rw-r--r--packages/taler-wallet-core/src/transactions.ts5
-rw-r--r--packages/taler-wallet-core/src/util/assertUnreachable.ts19
-rw-r--r--packages/taler-wallet-core/src/wallet.ts6
-rw-r--r--packages/taler-wallet-core/src/withdraw.test.ts2
-rw-r--r--packages/taler-wallet-core/src/withdraw.ts15
30 files changed, 83 insertions, 87 deletions
diff --git a/packages/taler-util/src/index.ts b/packages/taler-util/src/index.ts
index ec5b85d29..d9ab60910 100644
--- a/packages/taler-util/src/index.ts
+++ b/packages/taler-util/src/index.ts
@@ -29,6 +29,7 @@ export * from "./http-client/types.js";
export * from "./http-status-codes.js";
export * from "./i18n.js";
export * from "./iban.js";
+export * from "./invariants.js";
export * from "./kdf.js";
export * from "./libeufin-api-types.js";
export * from "./libtool-version.js";
diff --git a/packages/taler-wallet-core/src/util/invariants.ts b/packages/taler-util/src/invariants.ts
index 3598d857c..c6e9b8113 100644
--- a/packages/taler-wallet-core/src/util/invariants.ts
+++ b/packages/taler-util/src/invariants.ts
@@ -1,6 +1,6 @@
/*
This file is part of GNU Taler
- (C) 2020 Taler Systems S.A.
+ (C) 2019-2024 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
@@ -14,6 +14,13 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+/**
+ * Helpers for invariants.
+ */
+
+/**
+ * An invariant has been violated.
+ */
export class InvariantViolatedError extends Error {
constructor(message?: string) {
super(message);
@@ -22,9 +29,10 @@ export class InvariantViolatedError extends Error {
}
/**
- * Helpers for invariants.
+ * Check a database invariant.
+ *
+ * A violation of this invariant means that the database is inconsistent.
*/
-
export function checkDbInvariant(b: boolean, m?: string): asserts b {
if (!b) {
if (m) {
@@ -35,6 +43,11 @@ export function checkDbInvariant(b: boolean, m?: string): asserts b {
}
}
+/**
+ * Check a logic invariant.
+ *
+ * A violation of this invariant means that there is a logic bug in the program.
+ */
export function checkLogicInvariant(b: boolean, m?: string): asserts b {
if (!b) {
if (m) {
diff --git a/packages/taler-wallet-core/src/backup/index.ts b/packages/taler-wallet-core/src/backup/index.ts
index 415af6fd6..a5d7eee80 100644
--- a/packages/taler-wallet-core/src/backup/index.ts
+++ b/packages/taler-wallet-core/src/backup/index.ts
@@ -46,6 +46,8 @@ import {
bytesToString,
canonicalJson,
canonicalizeBaseUrl,
+ checkDbInvariant,
+ checkLogicInvariant,
codecForBoolean,
codecForConstString,
codecForList,
@@ -88,7 +90,6 @@ import {
timestampPreciseToDb,
} from "../db.js";
import { preparePayForUri } from "../pay-merchant.js";
-import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
import { InternalWalletState } from "../wallet.js";
const logger = new Logger("operations/backup.ts");
diff --git a/packages/taler-wallet-core/src/balance.ts b/packages/taler-wallet-core/src/balance.ts
index 34f719ad3..a287748f1 100644
--- a/packages/taler-wallet-core/src/balance.ts
+++ b/packages/taler-wallet-core/src/balance.ts
@@ -56,9 +56,11 @@ import {
AmountJson,
AmountLike,
Amounts,
+ assertUnreachable,
BalanceFlag,
BalancesResponse,
canonicalizeBaseUrl,
+ checkLogicInvariant,
GetBalanceDetailRequest,
Logger,
parsePaytoUri,
@@ -78,8 +80,6 @@ import {
getExchangeScopeInfo,
getExchangeWireDetailsInTx,
} from "./exchanges.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { checkLogicInvariant } from "./util/invariants.js";
import { InternalWalletState } from "./wallet.js";
/**
diff --git a/packages/taler-wallet-core/src/util/coinSelection.test.ts b/packages/taler-wallet-core/src/coinSelection.test.ts
index 0715c999f..839cd22fb 100644
--- a/packages/taler-wallet-core/src/util/coinSelection.test.ts
+++ b/packages/taler-wallet-core/src/coinSelection.test.ts
@@ -19,7 +19,6 @@ import {
Amounts,
DenomKeyType,
Duration,
- TalerProtocolTimestamp,
j2s,
} from "@gnu-taler/taler-util";
import test from "ava";
diff --git a/packages/taler-wallet-core/src/util/coinSelection.ts b/packages/taler-wallet-core/src/coinSelection.ts
index 02eb3ae32..f0b435b54 100644
--- a/packages/taler-wallet-core/src/util/coinSelection.ts
+++ b/packages/taler-wallet-core/src/coinSelection.ts
@@ -35,6 +35,8 @@ import {
AmountLike,
Amounts,
AmountString,
+ checkDbInvariant,
+ checkLogicInvariant,
CoinPublicKeyString,
CoinStatus,
DenominationInfo,
@@ -57,13 +59,12 @@ import {
import {
getMerchantPaymentBalanceDetails,
getPeerPaymentBalanceDetailsInTx,
-} from "../balance.js";
-import { getAutoRefreshExecuteThreshold } from "../common.js";
-import { DenominationRecord, WalletDbReadOnlyTransaction } from "../db.js";
-import { getExchangeWireDetailsInTx } from "../exchanges.js";
-import { InternalWalletState } from "../wallet.js";
+} from "./balance.js";
+import { getAutoRefreshExecuteThreshold } from "./common.js";
+import { DenominationRecord, WalletDbReadOnlyTransaction } from "./db.js";
import { isWithdrawableDenom } from "./denominations.js";
-import { checkDbInvariant, checkLogicInvariant } from "./invariants.js";
+import { getExchangeWireDetailsInTx } from "./exchanges.js";
+import { InternalWalletState } from "./wallet.js";
const logger = new Logger("coinSelection.ts");
diff --git a/packages/taler-wallet-core/src/common.ts b/packages/taler-wallet-core/src/common.ts
index 942a36c7e..9b69ad6c4 100644
--- a/packages/taler-wallet-core/src/common.ts
+++ b/packages/taler-wallet-core/src/common.ts
@@ -35,6 +35,9 @@ import {
TalerProtocolTimestamp,
TombstoneIdStr,
TransactionIdStr,
+ assertUnreachable,
+ checkDbInvariant,
+ checkLogicInvariant,
durationMul,
} from "@gnu-taler/taler-util";
import {
@@ -58,8 +61,6 @@ import {
timestampPreciseToDb,
} from "./db.js";
import { createRefreshGroup } from "./refresh.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { checkDbInvariant, checkLogicInvariant } from "./util/invariants.js";
import { InternalWalletState } from "./wallet.js";
const logger = new Logger("operations/common.ts");
diff --git a/packages/taler-wallet-core/src/dbless.ts b/packages/taler-wallet-core/src/dbless.ts
index 1d2ebe9db..c230a0504 100644
--- a/packages/taler-wallet-core/src/dbless.ts
+++ b/packages/taler-wallet-core/src/dbless.ts
@@ -58,7 +58,7 @@ import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
import { DenominationRecord } from "./db.js";
import { ExchangeInfo, downloadExchangeInfo } from "./exchanges.js";
import { assembleRefreshRevealRequest } from "./refresh.js";
-import { isWithdrawableDenom } from "./util/denominations.js";
+import { isWithdrawableDenom } from "./denominations.js";
import { getBankStatusUrl, getBankWithdrawalInfo } from "./withdraw.js";
export { downloadExchangeInfo };
diff --git a/packages/taler-wallet-core/src/util/denominations.test.ts b/packages/taler-wallet-core/src/denominations.test.ts
index 98af5d1a4..98af5d1a4 100644
--- a/packages/taler-wallet-core/src/util/denominations.test.ts
+++ b/packages/taler-wallet-core/src/denominations.test.ts
diff --git a/packages/taler-wallet-core/src/util/denominations.ts b/packages/taler-wallet-core/src/denominations.ts
index 9557c078a..177070622 100644
--- a/packages/taler-wallet-core/src/util/denominations.ts
+++ b/packages/taler-wallet-core/src/denominations.ts
@@ -27,7 +27,7 @@ import {
TalerProtocolTimestamp,
TimePoint,
} from "@gnu-taler/taler-util";
-import { DenominationRecord, timestampProtocolFromDb } from "../db.js";
+import { DenominationRecord, timestampProtocolFromDb } from "./db.js";
/**
* Given a list of denominations with the same value and same period of time:
diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts
index 6c2c53996..617f32887 100644
--- a/packages/taler-wallet-core/src/deposits.ts
+++ b/packages/taler-wallet-core/src/deposits.ts
@@ -55,7 +55,10 @@ import {
TransactionType,
URL,
WireFee,
+ assertUnreachable,
canonicalJson,
+ checkDbInvariant,
+ checkLogicInvariant,
codecForBatchDepositSuccess,
codecForTackTransactionAccepted,
codecForTackTransactionWired,
@@ -69,6 +72,7 @@ import {
stringToBytes,
} from "@gnu-taler/taler-util";
import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http";
+import { selectPayCoinsNew } from "./coinSelection.js";
import {
PendingTaskType,
TaskId,
@@ -105,9 +109,6 @@ import {
notifyTransition,
parseTransactionIdentifier,
} from "./transactions.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { selectPayCoinsNew } from "./util/coinSelection.js";
-import { checkDbInvariant, checkLogicInvariant } from "./util/invariants.js";
import { InternalWalletState } from "./wallet.js";
import { getCandidateWithdrawalDenomsTx } from "./withdraw.js";
diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts
index 610536619..a4732e474 100644
--- a/packages/taler-wallet-core/src/exchanges.ts
+++ b/packages/taler-wallet-core/src/exchanges.ts
@@ -73,6 +73,7 @@ import {
WireInfo,
assertUnreachable,
canonicalizeBaseUrl,
+ checkDbInvariant,
codecForExchangeKeysJson,
durationFromSpec,
durationMul,
@@ -117,16 +118,15 @@ import {
timestampProtocolFromDb,
timestampProtocolToDb,
} from "./db.js";
-import { DbReadOnlyTransaction } from "./query.js";
-import { createRecoupGroup } from "./recoup.js";
-import { createRefreshGroup } from "./refresh.js";
import {
createTimeline,
isWithdrawableDenom,
selectBestForOverlappingDenominations,
selectMinimumFee,
-} from "./util/denominations.js";
-import { checkDbInvariant } from "./util/invariants.js";
+} from "./denominations.js";
+import { DbReadOnlyTransaction } from "./query.js";
+import { createRecoupGroup } from "./recoup.js";
+import { createRefreshGroup } from "./refresh.js";
import { WALLET_EXCHANGE_PROTOCOL_VERSION } from "./versions.js";
import { InternalWalletState } from "./wallet.js";
diff --git a/packages/taler-wallet-core/src/index.ts b/packages/taler-wallet-core/src/index.ts
index d0de16ccd..fa984fc8f 100644
--- a/packages/taler-wallet-core/src/index.ts
+++ b/packages/taler-wallet-core/src/index.ts
@@ -32,7 +32,7 @@ export * from "./versions.js";
export * from "./wallet-api-types.js";
export * from "./wallet.js";
-export { createPairTimeline } from "./util/denominations.js";
+export { createPairTimeline } from "./denominations.js";
// FIXME: Should these really be exported?!
export {
diff --git a/packages/taler-wallet-core/src/util/instructedAmountConversion.test.ts b/packages/taler-wallet-core/src/instructedAmountConversion.test.ts
index 3b618f797..3b618f797 100644
--- a/packages/taler-wallet-core/src/util/instructedAmountConversion.test.ts
+++ b/packages/taler-wallet-core/src/instructedAmountConversion.test.ts
diff --git a/packages/taler-wallet-core/src/util/instructedAmountConversion.ts b/packages/taler-wallet-core/src/instructedAmountConversion.ts
index 1cd30fece..2250188b7 100644
--- a/packages/taler-wallet-core/src/util/instructedAmountConversion.ts
+++ b/packages/taler-wallet-core/src/instructedAmountConversion.ts
@@ -27,14 +27,14 @@ import {
GetPlanForOperationRequest,
TransactionAmountMode,
TransactionType,
+ checkDbInvariant,
parsePaytoUri,
strcmp,
} from "@gnu-taler/taler-util";
-import { DenominationRecord, timestampProtocolFromDb } from "../db.js";
-import { getExchangeWireDetailsInTx } from "../exchanges.js";
import { CoinInfo } from "./coinSelection.js";
-import { checkDbInvariant } from "./invariants.js";
-import { InternalWalletState } from "../wallet.js";
+import { DenominationRecord, timestampProtocolFromDb } from "./db.js";
+import { getExchangeWireDetailsInTx } from "./exchanges.js";
+import { InternalWalletState } from "./wallet.js";
/**
* If the operation going to be plan subtracts
diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts
index 13580464b..5e01ae716 100644
--- a/packages/taler-wallet-core/src/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/pay-merchant.ts
@@ -31,8 +31,10 @@ import {
AmountJson,
Amounts,
AmountString,
+ assertUnreachable,
AsyncFlag,
CancellationToken,
+ checkDbInvariant,
codecForAbortResponse,
codecForMerchantContractTerms,
codecForMerchantOrderRefundPickupResponse,
@@ -95,6 +97,7 @@ import {
readUnexpectedResponseDetails,
throwUnexpectedRequestError,
} from "@gnu-taler/taler-util/http";
+import { PreviousPayCoins, selectPayCoinsNew } from "./coinSelection.js";
import {
constructTaskIdentifier,
DbRetryInfo,
@@ -137,9 +140,6 @@ import {
notifyTransition,
parseTransactionIdentifier,
} from "./transactions.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { PreviousPayCoins, selectPayCoinsNew } from "./util/coinSelection.js";
-import { checkDbInvariant } from "./util/invariants.js";
import { EXCHANGE_COINS_LOCK, InternalWalletState } from "./wallet.js";
import { getCandidateWithdrawalDenomsTx } from "./withdraw.js";
@@ -1984,7 +1984,6 @@ export async function processPurchase(
return TaskRunResult.finished();
default:
assertUnreachable(purchase.purchaseStatus);
- // throw Error(`unexpected purchase status (${purchase.purchaseStatus})`);
}
}
diff --git a/packages/taler-wallet-core/src/pay-peer-common.ts b/packages/taler-wallet-core/src/pay-peer-common.ts
index abcffc83a..efb5bdb7e 100644
--- a/packages/taler-wallet-core/src/pay-peer-common.ts
+++ b/packages/taler-wallet-core/src/pay-peer-common.ts
@@ -22,23 +22,20 @@ import {
AmountString,
Amounts,
Codec,
- Logger,
TalerProtocolTimestamp,
buildCodecForObject,
+ checkDbInvariant,
codecForAmountString,
codecForTimestamp,
codecOptional,
} from "@gnu-taler/taler-util";
+import type { SelectedPeerCoin } from "./coinSelection.js";
import { SpendCoinDetails } from "./crypto/cryptoImplementation.js";
import { PeerPushPaymentCoinSelection, ReserveRecord } from "./db.js";
import { getTotalRefreshCost } from "./refresh.js";
-import type { SelectedPeerCoin } from "./util/coinSelection.js";
-import { checkDbInvariant } from "./util/invariants.js";
import { InternalWalletState } from "./wallet.js";
import { getCandidateWithdrawalDenomsTx } from "./withdraw.js";
-const logger = new Logger("operations/peer-to-peer.ts");
-
/**
* Get information about the coin selected for signatures.
*/
diff --git a/packages/taler-wallet-core/src/pay-peer-pull-credit.ts b/packages/taler-wallet-core/src/pay-peer-pull-credit.ts
index e37a948ee..e764d2169 100644
--- a/packages/taler-wallet-core/src/pay-peer-pull-credit.ts
+++ b/packages/taler-wallet-core/src/pay-peer-pull-credit.ts
@@ -40,6 +40,8 @@ import {
TransactionType,
WalletAccountMergeFlags,
WalletKycUuid,
+ assertUnreachable,
+ checkDbInvariant,
codecForAny,
codecForWalletKycUuid,
encodeCrock,
@@ -79,8 +81,6 @@ import {
constructTransactionIdentifier,
notifyTransition,
} from "./transactions.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { checkDbInvariant } from "./util/invariants.js";
import { InternalWalletState } from "./wallet.js";
import {
getExchangeWithdrawalInfo,
diff --git a/packages/taler-wallet-core/src/pay-peer-pull-debit.ts b/packages/taler-wallet-core/src/pay-peer-pull-debit.ts
index b227e941a..9fa7eb575 100644
--- a/packages/taler-wallet-core/src/pay-peer-pull-debit.ts
+++ b/packages/taler-wallet-core/src/pay-peer-pull-debit.ts
@@ -48,6 +48,8 @@ import {
TransactionMinorState,
TransactionState,
TransactionType,
+ assertUnreachable,
+ checkLogicInvariant,
codecForAny,
codecForExchangeGetContractResponse,
codecForPeerContractTerms,
@@ -63,6 +65,7 @@ import {
readSuccessResponseJsonOrThrow,
readTalerErrorResponse,
} from "@gnu-taler/taler-util/http";
+import { PeerCoinRepair, selectPeerCoins } from "./coinSelection.js";
import {
PendingTaskType,
TaskId,
@@ -92,9 +95,6 @@ import {
notifyTransition,
parseTransactionIdentifier,
} from "./transactions.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { PeerCoinRepair, selectPeerCoins } from "./util/coinSelection.js";
-import { checkLogicInvariant } from "./util/invariants.js";
import { InternalWalletState } from "./wallet.js";
const logger = new Logger("pay-peer-pull-debit.ts");
diff --git a/packages/taler-wallet-core/src/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/pay-peer-push-credit.ts
index 6dcf59be9..42a5b19df 100644
--- a/packages/taler-wallet-core/src/pay-peer-push-credit.ts
+++ b/packages/taler-wallet-core/src/pay-peer-push-credit.ts
@@ -37,6 +37,8 @@ import {
TransactionType,
WalletAccountMergeFlags,
WalletKycUuid,
+ assertUnreachable,
+ checkDbInvariant,
codecForAny,
codecForExchangeGetContractResponse,
codecForPeerContractTerms,
@@ -80,8 +82,6 @@ import {
notifyTransition,
parseTransactionIdentifier,
} from "./transactions.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { checkDbInvariant } from "./util/invariants.js";
import { InternalWalletState } from "./wallet.js";
import {
PerformCreateWithdrawalGroupResult,
diff --git a/packages/taler-wallet-core/src/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/pay-peer-push-debit.ts
index 098602ee0..1bb3b8772 100644
--- a/packages/taler-wallet-core/src/pay-peer-push-debit.ts
+++ b/packages/taler-wallet-core/src/pay-peer-push-debit.ts
@@ -38,6 +38,8 @@ import {
TransactionMinorState,
TransactionState,
TransactionType,
+ assertUnreachable,
+ checkLogicInvariant,
encodeCrock,
getRandomBytes,
j2s,
@@ -47,6 +49,7 @@ import {
readSuccessResponseJsonOrThrow,
readTalerErrorResponse,
} from "@gnu-taler/taler-util/http";
+import { PeerCoinRepair, selectPeerCoins } from "./coinSelection.js";
import {
PendingTaskType,
TaskId,
@@ -75,9 +78,6 @@ import {
constructTransactionIdentifier,
notifyTransition,
} from "./transactions.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { PeerCoinRepair, selectPeerCoins } from "./util/coinSelection.js";
-import { checkLogicInvariant } from "./util/invariants.js";
import { InternalWalletState } from "./wallet.js";
const logger = new Logger("pay-peer-push-debit.ts");
diff --git a/packages/taler-wallet-core/src/recoup.ts b/packages/taler-wallet-core/src/recoup.ts
index 99c8aabc3..6f1546d57 100644
--- a/packages/taler-wallet-core/src/recoup.ts
+++ b/packages/taler-wallet-core/src/recoup.ts
@@ -33,6 +33,7 @@ import {
TalerPreciseTimestamp,
TransactionType,
URL,
+ checkDbInvariant,
codecForRecoupConfirmation,
codecForReserveStatus,
encodeCrock,
@@ -60,7 +61,6 @@ import {
} from "./db.js";
import { createRefreshGroup } from "./refresh.js";
import { constructTransactionIdentifier } from "./transactions.js";
-import { checkDbInvariant } from "./util/invariants.js";
import type { InternalWalletState } from "./wallet.js";
import { internalCreateWithdrawalGroup } from "./withdraw.js";
diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts
index 8f3a5cab5..3b75ae2f3 100644
--- a/packages/taler-wallet-core/src/refresh.ts
+++ b/packages/taler-wallet-core/src/refresh.ts
@@ -20,7 +20,9 @@ import {
AmountJson,
Amounts,
amountToPretty,
+ assertUnreachable,
CancellationToken,
+ checkDbInvariant,
codecForExchangeMeltResponse,
codecForExchangeRevealResponse,
CoinPublicKeyString,
@@ -60,6 +62,7 @@ import {
readSuccessResponseJsonOrThrow,
readUnexpectedResponseDetails,
} from "@gnu-taler/taler-util/http";
+import { selectWithdrawalDenominations } from "./coinSelection.js";
import {
constructTaskIdentifier,
makeCoinAvailable,
@@ -95,9 +98,6 @@ import {
constructTransactionIdentifier,
notifyTransition,
} from "./transactions.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { selectWithdrawalDenominations } from "./util/coinSelection.js";
-import { checkDbInvariant } from "./util/invariants.js";
import { EXCHANGE_COINS_LOCK, InternalWalletState } from "./wallet.js";
import { getCandidateWithdrawalDenomsTx } from "./withdraw.js";
diff --git a/packages/taler-wallet-core/src/reward.ts b/packages/taler-wallet-core/src/reward.ts
index 6e7d3425c..6bfd3b324 100644
--- a/packages/taler-wallet-core/src/reward.ts
+++ b/packages/taler-wallet-core/src/reward.ts
@@ -27,6 +27,7 @@ import {
TransactionMinorState,
TransactionState,
TransactionType,
+ assertUnreachable,
} from "@gnu-taler/taler-util";
import {
PendingTaskType,
@@ -40,7 +41,6 @@ import {
constructTransactionIdentifier,
notifyTransition,
} from "./transactions.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
import { InternalWalletState } from "./wallet.js";
const logger = new Logger("operations/tip.ts");
diff --git a/packages/taler-wallet-core/src/testing.ts b/packages/taler-wallet-core/src/testing.ts
index 4dcb59868..bcb6abca0 100644
--- a/packages/taler-wallet-core/src/testing.ts
+++ b/packages/taler-wallet-core/src/testing.ts
@@ -28,6 +28,7 @@ import {
addPaytoQueryParams,
Amounts,
AmountString,
+ checkLogicInvariant,
CheckPaymentResponse,
codecForAny,
codecForCheckPaymentResponse,
@@ -76,7 +77,6 @@ import {
import { initiatePeerPushDebit } from "./pay-peer-push-debit.js";
import { getRefreshesForTransaction } from "./refresh.js";
import { getTransactionById, getTransactions } from "./transactions.js";
-import { checkLogicInvariant } from "./util/invariants.js";
import type { InternalWalletState } from "./wallet.js";
import { acceptWithdrawalFromUri } from "./withdraw.js";
diff --git a/packages/taler-wallet-core/src/transactions.ts b/packages/taler-wallet-core/src/transactions.ts
index 828c4dec3..7d54ca980 100644
--- a/packages/taler-wallet-core/src/transactions.ts
+++ b/packages/taler-wallet-core/src/transactions.ts
@@ -21,6 +21,9 @@ import { GlobalIDB } from "@gnu-taler/idb-bridge";
import {
AbsoluteTime,
Amounts,
+ assertUnreachable,
+ checkDbInvariant,
+ checkLogicInvariant,
DepositTransactionTrackingState,
j2s,
Logger,
@@ -129,8 +132,6 @@ import {
computeTipTransactionActions,
RewardTransactionContext,
} from "./reward.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { checkDbInvariant, checkLogicInvariant } from "./util/invariants.js";
import type { InternalWalletState } from "./wallet.js";
import {
augmentPaytoUrisForWithdrawal,
diff --git a/packages/taler-wallet-core/src/util/assertUnreachable.ts b/packages/taler-wallet-core/src/util/assertUnreachable.ts
deleted file mode 100644
index 1819fd09e..000000000
--- a/packages/taler-wallet-core/src/util/assertUnreachable.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2019 GNUnet e.V.
-
- 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
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-
-export function assertUnreachable(x: never): never {
- throw new Error(`Didn't expect to get here ${x}`);
-}
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index dfe7b2395..17fd74178 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -60,6 +60,8 @@ import {
WalletCoreVersion,
WalletNotification,
WithdrawalDetailsForAmount,
+ assertUnreachable,
+ checkDbInvariant,
codecForAbortTransaction,
codecForAcceptBankIntegratedWithdrawalRequest,
codecForAcceptExchangeTosRequest,
@@ -246,15 +248,13 @@ import {
retryTransaction,
suspendTransaction,
} from "./transactions.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
import {
convertDepositAmount,
convertPeerPushAmount,
convertWithdrawalAmount,
getMaxDepositAmount,
getMaxPeerPushAmount,
-} from "./util/instructedAmountConversion.js";
-import { checkDbInvariant } from "./util/invariants.js";
+} from "./instructedAmountConversion.js";
import {
WALLET_BANK_CONVERSION_API_PROTOCOL_VERSION,
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
diff --git a/packages/taler-wallet-core/src/withdraw.test.ts b/packages/taler-wallet-core/src/withdraw.test.ts
index 3eb6413e4..3e92b1717 100644
--- a/packages/taler-wallet-core/src/withdraw.test.ts
+++ b/packages/taler-wallet-core/src/withdraw.test.ts
@@ -21,7 +21,7 @@ import {
DenominationVerificationStatus,
timestampProtocolToDb,
} from "./db.js";
-import { selectWithdrawalDenominations } from "./util/coinSelection.js";
+import { selectWithdrawalDenominations } from "./coinSelection.js";
test("withdrawal selection bug repro", (t) => {
const amount = {
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
index 391fbc9e2..2d9f5c35c 100644
--- a/packages/taler-wallet-core/src/withdraw.ts
+++ b/packages/taler-wallet-core/src/withdraw.ts
@@ -69,7 +69,10 @@ import {
WithdrawUriInfoResponse,
WithdrawalExchangeAccountDetails,
addPaytoQueryParams,
+ assertUnreachable,
canonicalizeBaseUrl,
+ checkDbInvariant,
+ checkLogicInvariant,
codeForBankWithdrawalOperationPostResponse,
codecForCashinConversionResponse,
codecForConversionBankConfig,
@@ -92,6 +95,10 @@ import {
throwUnexpectedRequestError,
} from "@gnu-taler/taler-util/http";
import {
+ selectForcedWithdrawalDenominations,
+ selectWithdrawalDenominations,
+} from "./coinSelection.js";
+import {
PendingTaskType,
TaskId,
TaskRunResult,
@@ -120,6 +127,7 @@ import {
WithdrawalRecordType,
timestampPreciseToDb,
} from "./db.js";
+import { isWithdrawableDenom } from "./denominations.js";
import {
ReadyExchangeSummary,
fetchFreshExchange,
@@ -134,13 +142,6 @@ import {
constructTransactionIdentifier,
notifyTransition,
} from "./transactions.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import {
- selectForcedWithdrawalDenominations,
- selectWithdrawalDenominations,
-} from "./util/coinSelection.js";
-import { isWithdrawableDenom } from "./util/denominations.js";
-import { checkDbInvariant, checkLogicInvariant } from "./util/invariants.js";
import {
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
WALLET_EXCHANGE_PROTOCOL_VERSION,