gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: move helpers to util


From: gnunet
Subject: [taler-wallet-core] branch master updated: move helpers to util
Date: Wed, 21 Feb 2024 13:01:23 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 612b85c18 move helpers to util
612b85c18 is described below

commit 612b85c18fc17af412d08e075e1fddaa67aa7bf0
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Feb 21 13:01:23 2024 +0100

    move helpers to util
---
 packages/taler-util/src/index.ts                      |  1 +
 .../src/util => taler-util/src}/invariants.ts         | 19 ++++++++++++++++---
 packages/taler-wallet-core/src/backup/index.ts        |  3 ++-
 packages/taler-wallet-core/src/balance.ts             |  4 ++--
 .../src/{util => }/coinSelection.test.ts              |  1 -
 .../taler-wallet-core/src/{util => }/coinSelection.ts | 13 +++++++------
 packages/taler-wallet-core/src/common.ts              |  5 +++--
 packages/taler-wallet-core/src/dbless.ts              |  2 +-
 .../src/{util => }/denominations.test.ts              |  0
 .../taler-wallet-core/src/{util => }/denominations.ts |  2 +-
 packages/taler-wallet-core/src/deposits.ts            |  7 ++++---
 packages/taler-wallet-core/src/exchanges.ts           | 10 +++++-----
 packages/taler-wallet-core/src/index.ts               |  2 +-
 .../src/{util => }/instructedAmountConversion.test.ts |  0
 .../src/{util => }/instructedAmountConversion.ts      |  8 ++++----
 packages/taler-wallet-core/src/pay-merchant.ts        |  7 +++----
 packages/taler-wallet-core/src/pay-peer-common.ts     |  7 ++-----
 .../taler-wallet-core/src/pay-peer-pull-credit.ts     |  4 ++--
 packages/taler-wallet-core/src/pay-peer-pull-debit.ts |  6 +++---
 .../taler-wallet-core/src/pay-peer-push-credit.ts     |  4 ++--
 packages/taler-wallet-core/src/pay-peer-push-debit.ts |  6 +++---
 packages/taler-wallet-core/src/recoup.ts              |  2 +-
 packages/taler-wallet-core/src/refresh.ts             |  6 +++---
 packages/taler-wallet-core/src/reward.ts              |  2 +-
 packages/taler-wallet-core/src/testing.ts             |  2 +-
 packages/taler-wallet-core/src/transactions.ts        |  5 +++--
 .../taler-wallet-core/src/util/assertUnreachable.ts   | 19 -------------------
 packages/taler-wallet-core/src/wallet.ts              |  6 +++---
 packages/taler-wallet-core/src/withdraw.test.ts       |  2 +-
 packages/taler-wallet-core/src/withdraw.ts            | 15 ++++++++-------
 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
similarity index 81%
rename from packages/taler-wallet-core/src/util/invariants.ts
rename to 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
similarity index 99%
rename from packages/taler-wallet-core/src/util/coinSelection.test.ts
rename to 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
similarity index 99%
rename from packages/taler-wallet-core/src/util/coinSelection.ts
rename to 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
similarity index 100%
rename from packages/taler-wallet-core/src/util/denominations.test.ts
rename to 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
similarity index 99%
rename from packages/taler-wallet-core/src/util/denominations.ts
rename to 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
similarity index 100%
rename from 
packages/taler-wallet-core/src/util/instructedAmountConversion.test.ts
rename to 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
similarity index 99%
rename from packages/taler-wallet-core/src/util/instructedAmountConversion.ts
rename to 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,
@@ -91,6 +94,10 @@ import {
   readSuccessResponseJsonOrThrow,
   throwUnexpectedRequestError,
 } from "@gnu-taler/taler-util/http";
+import {
+  selectForcedWithdrawalDenominations,
+  selectWithdrawalDenominations,
+} from "./coinSelection.js";
 import {
   PendingTaskType,
   TaskId,
@@ -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,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]