gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: wallet-core: fix error report


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: fix error reporting for exchange entries
Date: Mon, 08 Jan 2024 18:51:47 +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 2987f6f83 wallet-core: fix error reporting for exchange entries
2987f6f83 is described below

commit 2987f6f8365a15c6761a370bfd0ebf0952ce3f66
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Jan 8 18:51:38 2024 +0100

    wallet-core: fix error reporting for exchange entries
---
 packages/taler-harness/src/harness/harness.ts      | 15 ++++++
 .../integrationtests/test-exchange-management.ts   | 11 ++--
 .../src/integrationtests/test-peer-to-peer-push.ts |  9 +++-
 .../integrationtests/test-withdrawal-conversion.ts | 21 ++++++--
 packages/taler-util/src/errors.ts                  |  4 ++
 packages/taler-util/src/taler-error-codes.ts       | 60 +++++++++++++++++-----
 packages/taler-wallet-core/src/db.ts               | 16 +-----
 .../taler-wallet-core/src/operations/balance.ts    | 15 ++++--
 .../taler-wallet-core/src/operations/exchanges.ts  | 34 ++++++------
 .../src/operations/pay-peer-pull-credit.ts         |  8 +--
 .../taler-wallet-core/src/operations/pending.ts    | 54 +++++++++----------
 .../taler-wallet-core/src/operations/withdraw.ts   |  7 +--
 packages/taler-wallet-core/src/wallet.ts           |  6 +--
 13 files changed, 159 insertions(+), 101 deletions(-)

diff --git a/packages/taler-harness/src/harness/harness.ts 
b/packages/taler-harness/src/harness/harness.ts
index ea2406f52..a8cd1131d 100644
--- a/packages/taler-harness/src/harness/harness.ts
+++ b/packages/taler-harness/src/harness/harness.ts
@@ -1013,6 +1013,18 @@ export class ExchangeService implements 
ExchangeServiceInterface {
     );
   }
 
+  /**
+   * Run the taler-exchange-expire command once in test mode.
+   */
+  async runExpireOnce() {
+    await runCommand(
+      this.globalState,
+      `exchange-${this.name}-expire-once`,
+      "taler-exchange-expire",
+      [...this.timetravelArgArr, "-c", this.configFilename, "-t"],
+    );
+  }
+
   changeConfig(f: (config: Configuration) => void) {
     const config = Configuration.load(this.configFilename);
     f(config);
@@ -1056,6 +1068,9 @@ export class ExchangeService implements 
ExchangeServiceInterface {
     config.setString("taler-exchange-secmod-eddsa", "lookahead_sign", "20 s");
     config.setString("taler-exchange-secmod-rsa", "lookahead_sign", "20 s");
 
+    // FIXME: Remove once the exchange default config properly ships this.
+    config.setString("exchange", "EXPIRE_IDLE_SLEEP_INTERVAL", "1 s");
+
     const exchangeMasterKey = createEddsaKeyPair();
 
     config.setString(
diff --git 
a/packages/taler-harness/src/integrationtests/test-exchange-management.ts 
b/packages/taler-harness/src/integrationtests/test-exchange-management.ts
index e7ebfffc8..37b490d6b 100644
--- a/packages/taler-harness/src/integrationtests/test-exchange-management.ts
+++ b/packages/taler-harness/src/integrationtests/test-exchange-management.ts
@@ -190,11 +190,14 @@ export async function runExchangeManagementTest(
     });
   });
 
+  console.log("got error", err1);
+
   // Response is malformed, since it didn't even contain a version code
   // in a format the wallet can understand.
   t.assertTrue(
-    err1.errorDetail.code === 
TalerErrorCode.WALLET_RECEIVED_MALFORMED_RESPONSE,
+    err1.errorDetail.code === TalerErrorCode.WALLET_EXCHANGE_UNAVAILABLE,
   );
+
   exchangesList = await wallet.client.call(
     WalletApiOperation.ListExchanges,
     {},
@@ -235,11 +238,7 @@ export async function runExchangeManagementTest(
     });
   });
 
-  t.assertTrue(
-    err2.hasErrorCode(
-      TalerErrorCode.WALLET_EXCHANGE_PROTOCOL_VERSION_INCOMPATIBLE,
-    ),
-  );
+  t.assertTrue(err2.hasErrorCode(TalerErrorCode.WALLET_EXCHANGE_UNAVAILABLE));
 
   exchangesList = await wallet.client.call(
     WalletApiOperation.ListExchanges,
diff --git 
a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts 
b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
index 583dba28d..bf0c7a78f 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-push.ts
@@ -31,7 +31,6 @@ import {
 import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
 import { GlobalTestState } from "../harness/harness.js";
 import {
-  applyTimeTravelV2,
   createSimpleTestkudosEnvironmentV2,
   createWalletDaemonWithClient,
   withdrawViaBankV2,
@@ -194,11 +193,19 @@ export async function runPeerToPeerPushTest(t: 
GlobalTestState) {
     Duration.fromSpec({ days: 5 }),
   );
 
+  console.log("stopping exchange to apply time-travel");
+
   await exchange.stop();
   exchange.setTimetravel(timetravelOffsetMs);
   await exchange.start();
   await exchange.pingUntilAvailable();
 
+  console.log("running expire");
+  await exchange.runExpireOnce();
+  console.log("done running expire");
+
+  console.log("purse should now be expired");
+
   await w1.walletClient.call(WalletApiOperation.TestingSetTimetravel, {
     offsetMs: timetravelOffsetMs,
   });
diff --git 
a/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts 
b/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts
index 781a0fe90..0209a6cbf 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-conversion.ts
@@ -22,6 +22,7 @@ import {
   AmountString,
   Duration,
   Logger,
+  TalerBankConversionApi,
   TalerCorebankApiClient,
   TransactionType,
   WireGatewayApiClient,
@@ -73,9 +74,23 @@ async function runTestfakeConversionService(): 
Promise<TestfakeConversionService
         JSON.stringify({
           version: "0:0:0",
           name: "taler-conversion-info",
-          regional_currency: {},
-          fiat_currency: {},
-        }),
+          regional_currency: "FOO",
+          fiat_currency: "BAR",
+          regional_currency_specification: {
+            alt_unit_names: {},
+            name: "FOO",
+            num_fractional_input_digits: 2,
+            num_fractional_normal_digits: 2,
+            num_fractional_trailing_zero_digits: 2,
+          },
+          fiat_currency_specification: {
+            alt_unit_names: {},
+            name: "BAR",
+            num_fractional_input_digits: 2,
+            num_fractional_normal_digits: 2,
+            num_fractional_trailing_zero_digits: 2,
+          },
+        } satisfies TalerBankConversionApi.IntegrationConfig),
       );
     } else if (path === "/cashin-rate") {
       res.writeHead(200, { "Content-Type": "application/json" });
diff --git a/packages/taler-util/src/errors.ts 
b/packages/taler-util/src/errors.ts
index 7439ba69d..69990d41f 100644
--- a/packages/taler-util/src/errors.ts
+++ b/packages/taler-util/src/errors.ts
@@ -147,6 +147,10 @@ export interface DetailsMap {
     urlWallet: string;
     urlExchange: string;
   };
+  [TalerErrorCode.WALLET_EXCHANGE_UNAVAILABLE]: {
+    exchangeBaseUrl: string;
+    innerError: TalerErrorDetail | undefined;
+  };
 }
 
 type ErrBody<Y> = Y extends keyof DetailsMap ? DetailsMap[Y] : empty;
diff --git a/packages/taler-util/src/taler-error-codes.ts 
b/packages/taler-util/src/taler-error-codes.ts
index 5b72ae7ec..2361b6d73 100644
--- a/packages/taler-util/src/taler-error-codes.ts
+++ b/packages/taler-util/src/taler-error-codes.ts
@@ -2649,7 +2649,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The backend lacks a wire transfer method configuration option for the 
given instance. Thus, this instance is unavailable (not findable for creating 
new orders).
+   * The merchant instance has no active bank accounts configured. However, at 
least one bank account must be available to create new orders.
    * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2657,7 +2657,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The proposal had no timestamp and the backend failed to obtain the local 
time. Likely to be an internal error.
+   * The proposal had no timestamp and the merchant backend failed to obtain 
the current local time.
    * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR 
(500).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2665,7 +2665,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The order provided to the backend could not be parsed, some required 
fields were missing or ill-formed.
+   * The order provided to the backend could not be parsed; likely some 
required fields were missing or ill-formed.
    * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2673,7 +2673,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The backend encountered an error: the proposal already exists.
+   * A conflicting order (sharing the same order identifier) already exists at 
this merchant backend instance.
    * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2681,7 +2681,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The request is invalid: the wire deadline is before the refund deadline.
+   * The order creation request is invalid because the given wire deadline is 
before the refund deadline.
    * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2689,7 +2689,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The request is invalid: a delivery date was given, but it is in the past.
+   * The order creation request is invalid because the delivery date given is 
in the past.
    * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2697,7 +2697,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The request is invalid: the wire deadline for the order would be "never".
+   * The order creation request is invalid because a wire deadline of "never" 
is not allowed.
    * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2705,7 +2705,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The request is invalid: a payment deadline was given, but it is in the 
past.
+   * The order ceration request is invalid because the given payment deadline 
is in the past.
    * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2713,7 +2713,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The request is invalid: a refund deadline was given, but it is in the 
past.
+   * The order creation request is invalid because the given refund deadline 
is in the past.
    * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2721,7 +2721,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The backend does not trust any exchange that would allow funds to be 
wired to any bank account of this instance using the selected wire method. Note 
that right now, we do not support the use of exchange bank accounts with 
mandatory currency conversion.
+   * The backend does not trust any exchange that would allow funds to be 
wired to any bank account of this instance using the wire method specified with 
the order. Note that right now, we do not support the use of exchange bank 
accounts with mandatory currency conversion.
    * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2745,7 +2745,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The order provided to the backend could not be deleted, our offer is 
still valid and awaiting payment.
+   * The order provided to the backend could not be deleted, our offer is 
still valid and awaiting payment. Deletion may work later after the offer has 
expired if it remains unpaid.
    * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2761,7 +2761,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The amount to be refunded is inconsistent: either is lower than the 
previous amount being awarded, or it is too big to be paid back. In this second 
case, the fault stays on the business dept. side.
+   * The amount to be refunded is inconsistent: either is lower than the 
previous amount being awarded, or it exceeds the original price paid by the 
customer.
    * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2769,7 +2769,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The frontend gave an unpaid order id to issue the refund to.
+   * Only paid orders can be refunded, and the frontend specified an unpaid 
order to issue a refund for.
    * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -2777,7 +2777,7 @@ export enum TalerErrorCode {
 
 
   /**
-   * The refund delay was set to 0 and thus no refunds are allowed for this 
order.
+   * The refund delay was set to 0 and thus no refunds are ever allowed for 
this order.
    * Returned with an HTTP status code of #MHD_HTTP_FORBIDDEN (403).
    * (A value of 0 indicates that the error is generated client-side).
    */
@@ -3488,6 +3488,30 @@ export enum TalerErrorCode {
   BANK_NON_ADMIN_PATCH_CONTACT = 5141,
 
 
+  /**
+   * The client tried to create a transaction that credit the admin account.
+   * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
+   * (A value of 0 indicates that the error is generated client-side).
+   */
+  BANK_ADMIN_CREDITOR = 5142,
+
+
+  /**
+   * The referenced challenge was not found.
+   * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).
+   * (A value of 0 indicates that the error is generated client-side).
+   */
+  BANK_CHALLENGE_NOT_FOUND = 5143,
+
+
+  /**
+   * The referenced challenge has expired.
+   * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).
+   * (A value of 0 indicates that the error is generated client-side).
+   */
+  BANK_TAN_CHALLENGE_EXPIRED = 5144,
+
+
   /**
    * The sync service failed find the account in its database.
    * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).
@@ -3864,6 +3888,14 @@ export enum TalerErrorCode {
   WALLET_ORDER_ALREADY_PAID = 7031,
 
 
+  /**
+   * An exchange that is required for some request is currently not available.
+   * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0).
+   * (A value of 0 indicates that the error is generated client-side).
+   */
+  WALLET_EXCHANGE_UNAVAILABLE = 7032,
+
+
   /**
    * We encountered a timeout with our payment backend.
    * Returned with an HTTP status code of #MHD_HTTP_GATEWAY_TIMEOUT (504).
diff --git a/packages/taler-wallet-core/src/db.ts 
b/packages/taler-wallet-core/src/db.ts
index d13e30cc6..76bb2e393 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -19,7 +19,6 @@
  */
 import {
   Event,
-  GlobalIDB,
   IDBDatabase,
   IDBFactory,
   IDBObjectStore,
@@ -262,7 +261,7 @@ export const OPERATION_STATUS_ACTIVE_FIRST = 0x0100_0000;
 /**
  * LAST possible operation status in the active range (inclusive).
  */
-export const OPERATION_STATUS_ACTIVE_LAST = 0x0113_FFFF;
+export const OPERATION_STATUS_ACTIVE_LAST = 0x0113_ffff;
 
 /**
  * Status of a withdrawal.
@@ -337,14 +336,6 @@ export enum WithdrawalGroupStatus {
   AbortedBank = 0x0503_0002,
 }
 
-/**
- * Status range of nonfinal withdrawal groups.
- */
-export const withdrawalGroupNonfinalRange = GlobalIDB.KeyRange.bound(
-  WithdrawalGroupStatus.PendingRegisteringBank,
-  WithdrawalGroupStatus.PendingAml,
-);
-
 /**
  * Extra info about a withdrawal that is used
  * with a bank-integrated withdrawal.
@@ -1704,11 +1695,6 @@ export enum DepositOperationStatus {
   Aborted = 0x0503_0000,
 }
 
-export const depositOperationNonfinalStatusRange = GlobalIDB.KeyRange.bound(
-  DepositOperationStatus.PendingDeposit,
-  DepositOperationStatus.PendingKyc,
-);
-
 export interface DepositTrackingInfo {
   // Raw wire transfer identifier of the deposit.
   wireTransferId: string;
diff --git a/packages/taler-wallet-core/src/operations/balance.ts 
b/packages/taler-wallet-core/src/operations/balance.ts
index 1b6ff7844..fdaab0d5f 100644
--- a/packages/taler-wallet-core/src/operations/balance.ts
+++ b/packages/taler-wallet-core/src/operations/balance.ts
@@ -63,11 +63,12 @@ import {
   ScopeType,
 } from "@gnu-taler/taler-util";
 import {
-  depositOperationNonfinalStatusRange,
   DepositOperationStatus,
+  OPERATION_STATUS_ACTIVE_FIRST,
+  OPERATION_STATUS_ACTIVE_LAST,
   RefreshGroupRecord,
+  RefreshOperationStatus,
   WalletStoresV1,
-  withdrawalGroupNonfinalRange,
   WithdrawalGroupStatus,
 } from "../db.js";
 import { InternalWalletState } from "../internal-wallet-state.js";
@@ -75,6 +76,7 @@ import { assertUnreachable } from 
"../util/assertUnreachable.js";
 import { checkLogicInvariant } from "../util/invariants.js";
 import { GetReadOnlyAccess } from "../util/query.js";
 import { getExchangeDetails } from "./exchanges.js";
+import { GlobalIDB } from "@gnu-taler/idb-bridge";
 
 /**
  * Logger.
@@ -142,6 +144,11 @@ export async function getBalancesInsideTransaction(
     return balanceStore[currency];
   };
 
+  const keyRangeActive = GlobalIDB.KeyRange.bound(
+    OPERATION_STATUS_ACTIVE_FIRST,
+    OPERATION_STATUS_ACTIVE_LAST,
+  );
+
   await tx.coinAvailability.iter().forEach((ca) => {
     const b = initBalance(ca.currency);
     const count = ca.visibleCoinCount ?? 0;
@@ -159,7 +166,7 @@ export async function getBalancesInsideTransaction(
   });
 
   await tx.withdrawalGroups.indexes.byStatus
-    .iter(withdrawalGroupNonfinalRange)
+    .iter(keyRangeActive)
     .forEach((wgRecord) => {
       const b = initBalance(
         Amounts.currencyOf(wgRecord.denomsSel.totalWithdrawCost),
@@ -205,7 +212,7 @@ export async function getBalancesInsideTransaction(
 
   // FIXME: Use indexing to filter out final transactions.
   await tx.depositGroups.indexes.byStatus
-    .iter(depositOperationNonfinalStatusRange)
+    .iter(keyRangeActive)
     .forEach((dgRecord) => {
       const b = initBalance(Amounts.currencyOf(dgRecord.amount));
       switch (dgRecord.operationStatus) {
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts 
b/packages/taler-wallet-core/src/operations/exchanges.ts
index 8f878ecc0..67d598e70 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -821,12 +821,13 @@ export async function fetchFreshExchange(
     );
   }
 
-  const { exchange, exchangeDetails } = await ws.db
-    .mktx((x) => [x.exchanges, x.exchangeDetails])
+  const { exchange, exchangeDetails, retryInfo } = await ws.db
+    .mktx((x) => [x.exchanges, x.exchangeDetails, x.operationRetries])
     .runReadOnly(async (tx) => {
       const exchange = await tx.exchanges.get(canonUrl);
       const exchangeDetails = await getExchangeDetails(tx, canonUrl);
-      return { exchange, exchangeDetails };
+      const retryInfo = await tx.operationRetries.get(operationId);
+      return { exchange, exchangeDetails, retryInfo };
     });
 
   if (!exchange) {
@@ -838,7 +839,10 @@ export async function fetchFreshExchange(
     case ExchangeEntryDbUpdateStatus.ReadyUpdate:
       break;
     default:
-      throw Error("unable to update exchange");
+      throw TalerError.fromDetail(TalerErrorCode.WALLET_EXCHANGE_UNAVAILABLE, {
+        exchangeBaseUrl: canonUrl,
+        innerError: retryInfo?.lastError,
+      });
   }
 
   if (!exchangeDetails) {
@@ -1253,24 +1257,24 @@ export async function downloadExchangeInfo(
   };
 }
 
-export async function getExchanges(
+/**
+ * List all exchange entries known to the wallet.
+ */
+export async function listExchanges(
   ws: InternalWalletState,
 ): Promise<ExchangesListResponse> {
   const exchanges: ExchangeListItem[] = [];
   await ws.db
-    .mktx((x) => [
-      x.exchanges,
-      x.exchangeDetails,
-      x.denominations,
-      x.operationRetries,
-    ])
+    .mktx((x) => [x.exchanges, x.exchangeDetails, x.operationRetries])
     .runReadOnly(async (tx) => {
       const exchangeRecords = await tx.exchanges.iter().toArray();
       for (const r of exchangeRecords) {
+        const taskId = constructTaskIdentifier({
+          tag: PendingTaskType.ExchangeUpdate,
+          exchangeBaseUrl: r.baseUrl,
+        });
         const exchangeDetails = await getExchangeDetails(tx, r.baseUrl);
-        const opRetryRecord = await tx.operationRetries.get(
-          TaskIdentifiers.forExchangeUpdate(r),
-        );
+        const opRetryRecord = await tx.operationRetries.get(taskId);
         exchanges.push(
           makeExchangeListItem(r, exchangeDetails, opRetryRecord?.lastError),
         );
@@ -1283,7 +1287,7 @@ export async function getExchangeDetailedInfo(
   ws: InternalWalletState,
   exchangeBaseurl: string,
 ): Promise<ExchangeDetailedResponse> {
-  //TODO: should we use the forceUpdate parameter?
+  // TODO: should we use the forceUpdate parameter?
   const exchange = await ws.db
     .mktx((x) => [x.exchanges, x.exchangeDetails, x.denominations])
     .runReadOnly(async (tx) => {
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts 
b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts
index 292116bd5..a90eceed7 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts
@@ -48,11 +48,7 @@ import {
   stringifyTalerUri,
   talerPaytoFromExchangeReserve,
 } from "@gnu-taler/taler-util";
-import {
-  readSuccessResponseJsonOrErrorCode,
-  readSuccessResponseJsonOrThrow,
-  throwUnexpectedRequestError,
-} from "@gnu-taler/taler-util/http";
+import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http";
 import {
   KycPendingInfo,
   KycUserType,
@@ -60,10 +56,10 @@ import {
   PeerPullPaymentCreditStatus,
   WithdrawalGroupStatus,
   WithdrawalRecordType,
+  fetchFreshExchange,
   timestampOptionalPreciseFromDb,
   timestampPreciseFromDb,
   timestampPreciseToDb,
-  fetchFreshExchange,
 } from "../index.js";
 import { InternalWalletState } from "../internal-wallet-state.js";
 import { PendingTaskType } from "../pending-types.js";
diff --git a/packages/taler-wallet-core/src/operations/pending.ts 
b/packages/taler-wallet-core/src/operations/pending.ts
index 560031ad1..8f9506331 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -24,7 +24,6 @@
 import { GlobalIDB } from "@gnu-taler/idb-bridge";
 import {
   AbsoluteTime,
-  TalerErrorDetail,
   TalerPreciseTimestamp,
   TransactionRecordFilter,
 } from "@gnu-taler/taler-util";
@@ -38,11 +37,8 @@ import {
   OPERATION_STATUS_ACTIVE_LAST,
   PeerPullCreditRecord,
   PeerPullDebitRecordStatus,
-  PeerPullPaymentCreditStatus,
   PeerPullPaymentIncomingRecord,
-  PeerPushCreditStatus,
   PeerPushDebitRecord,
-  PeerPushDebitStatus,
   PeerPushPaymentIncomingRecord,
   PurchaseRecord,
   PurchaseStatus,
@@ -50,17 +46,13 @@ import {
   RefreshGroupRecord,
   RefreshOperationStatus,
   RefundGroupRecord,
-  RefundGroupStatus,
   RewardRecord,
-  RewardRecordStatus,
   WalletStoresV1,
   WithdrawalGroupRecord,
-  depositOperationNonfinalStatusRange,
   timestampAbsoluteFromDb,
   timestampOptionalAbsoluteFromDb,
   timestampPreciseFromDb,
   timestampPreciseToDb,
-  withdrawalGroupNonfinalRange,
 } from "../db.js";
 import { InternalWalletState } from "../internal-wallet-state.js";
 import {
@@ -224,9 +216,12 @@ export async function iterRecordsForWithdrawal(
 ): Promise<void> {
   let withdrawalGroupRecords: WithdrawalGroupRecord[];
   if (filter.onlyState === "nonfinal") {
-    withdrawalGroupRecords = await tx.withdrawalGroups.indexes.byStatus.getAll(
-      withdrawalGroupNonfinalRange,
+    const keyRange = GlobalIDB.KeyRange.bound(
+      OPERATION_STATUS_ACTIVE_FIRST,
+      OPERATION_STATUS_ACTIVE_LAST,
     );
+    withdrawalGroupRecords =
+      await tx.withdrawalGroups.indexes.byStatus.getAll(keyRange);
   } else {
     withdrawalGroupRecords =
       await tx.withdrawalGroups.indexes.byStatus.getAll();
@@ -290,9 +285,11 @@ export async function iterRecordsForDeposit(
 ): Promise<void> {
   let dgs: DepositGroupRecord[];
   if (filter.onlyState === "nonfinal") {
-    dgs = await tx.depositGroups.indexes.byStatus.getAll(
-      depositOperationNonfinalStatusRange,
+    const keyRange = GlobalIDB.KeyRange.bound(
+      OPERATION_STATUS_ACTIVE_FIRST,
+      OPERATION_STATUS_ACTIVE_LAST,
     );
+    dgs = await tx.depositGroups.indexes.byStatus.getAll(keyRange);
   } else {
     dgs = await tx.depositGroups.indexes.byStatus.getAll();
   }
@@ -350,11 +347,11 @@ export async function iterRecordsForReward(
   f: (r: RewardRecord) => Promise<void>,
 ): Promise<void> {
   if (filter.onlyState === "nonfinal") {
-    const range = GlobalIDB.KeyRange.bound(
-      RewardRecordStatus.PendingPickup,
-      RewardRecordStatus.PendingPickup,
+    const keyRange = GlobalIDB.KeyRange.bound(
+      OPERATION_STATUS_ACTIVE_FIRST,
+      OPERATION_STATUS_ACTIVE_LAST,
     );
-    await tx.rewards.indexes.byStatus.iter(range).forEachAsync(f);
+    await tx.rewards.indexes.byStatus.iter(keyRange).forEachAsync(f);
   } else {
     await tx.rewards.indexes.byStatus.iter().forEachAsync(f);
   }
@@ -404,7 +401,10 @@ export async function iterRecordsForRefund(
   f: (r: RefundGroupRecord) => Promise<void>,
 ): Promise<void> {
   if (filter.onlyState === "nonfinal") {
-    const keyRange = GlobalIDB.KeyRange.only(RefundGroupStatus.Pending);
+    const keyRange = GlobalIDB.KeyRange.bound(
+      OPERATION_STATUS_ACTIVE_FIRST,
+      OPERATION_STATUS_ACTIVE_LAST,
+    );
     await tx.refundGroups.indexes.byStatus.iter(keyRange).forEachAsync(f);
   } else {
     await tx.refundGroups.iter().forEachAsync(f);
@@ -534,8 +534,8 @@ export async function iterRecordsForPeerPullInitiation(
 ): Promise<void> {
   if (filter.onlyState === "nonfinal") {
     const keyRange = GlobalIDB.KeyRange.bound(
-      PeerPullPaymentCreditStatus.PendingCreatePurse,
-      PeerPullPaymentCreditStatus.AbortingDeletePurse,
+      OPERATION_STATUS_ACTIVE_FIRST,
+      OPERATION_STATUS_ACTIVE_LAST,
     );
     await tx.peerPullCredit.indexes.byStatus.iter(keyRange).forEachAsync(f);
   } else {
@@ -589,8 +589,8 @@ export async function iterRecordsForPeerPullDebit(
 ): Promise<void> {
   if (filter.onlyState === "nonfinal") {
     const keyRange = GlobalIDB.KeyRange.bound(
-      PeerPullDebitRecordStatus.PendingDeposit,
-      PeerPullDebitRecordStatus.AbortingRefresh,
+      OPERATION_STATUS_ACTIVE_FIRST,
+      OPERATION_STATUS_ACTIVE_LAST,
     );
     await tx.peerPullDebit.indexes.byStatus.iter(keyRange).forEachAsync(f);
   } else {
@@ -641,8 +641,8 @@ export async function iterRecordsForPeerPushInitiation(
 ): Promise<void> {
   if (filter.onlyState === "nonfinal") {
     const keyRange = GlobalIDB.KeyRange.bound(
-      PeerPushDebitStatus.PendingCreatePurse,
-      PeerPushDebitStatus.AbortingRefreshExpired,
+      OPERATION_STATUS_ACTIVE_FIRST,
+      OPERATION_STATUS_ACTIVE_LAST,
     );
     await tx.peerPushDebit.indexes.byStatus.iter(keyRange).forEachAsync(f);
   } else {
@@ -688,8 +688,8 @@ export async function iterRecordsForPeerPushCredit(
 ): Promise<void> {
   if (filter.onlyState === "nonfinal") {
     const keyRange = GlobalIDB.KeyRange.bound(
-      PeerPushCreditStatus.PendingMerge,
-      PeerPushCreditStatus.PendingWithdrawing,
+      OPERATION_STATUS_ACTIVE_FIRST,
+      OPERATION_STATUS_ACTIVE_LAST,
     );
     await tx.peerPushCredit.indexes.byStatus.iter(keyRange).forEachAsync(f);
   } else {
@@ -706,10 +706,6 @@ async function gatherPeerPushCreditPending(
   now: AbsoluteTime,
   resp: PendingOperationsResponse,
 ): Promise<void> {
-  const keyRange = GlobalIDB.KeyRange.bound(
-    PeerPushCreditStatus.PendingMerge,
-    PeerPushCreditStatus.PendingWithdrawing,
-  );
   await iterRecordsForPeerPushCredit(
     tx,
     { onlyState: "nonfinal" },
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index 392b3753d..cf4e9a1d5 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -62,7 +62,6 @@ import {
   addPaytoQueryParams,
   canonicalizeBaseUrl,
   codecForAny,
-  codecForBankWithdrawalOperationPostResponse,
   codecForCashinConversionResponse,
   codecForConversionBankConfig,
   codecForExchangeWithdrawBatchResponse,
@@ -100,9 +99,7 @@ import {
   WithdrawalRecordType,
 } from "../db.js";
 import {
-  ExchangeDetailsRecord,
   ExchangeEntryDbRecordStatus,
-  Wallet,
   isWithdrawableDenom,
   timestampPreciseToDb,
 } from "../index.js";
@@ -134,10 +131,10 @@ import {
   WALLET_EXCHANGE_PROTOCOL_VERSION,
 } from "../versions.js";
 import {
+  ReadyExchangeSummary,
+  fetchFreshExchange,
   getExchangeDetails,
   getExchangePaytoUri,
-  fetchFreshExchange,
-  ReadyExchangeSummary,
 } from "./exchanges.js";
 import {
   TransitionInfo,
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index 2d422e59c..154665c47 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -205,7 +205,7 @@ import {
   getExchangeDetailedInfo,
   getExchangeDetails,
   getExchangeTos,
-  getExchanges,
+  listExchanges,
   updateExchangeFromUrlHandler,
 } from "./operations/exchanges.js";
 import { getMerchantInfo } from "./operations/merchants.js";
@@ -963,7 +963,7 @@ async function dispatchRequestInternal<Op extends 
WalletApiOperation>(
       return {};
     }
     case WalletApiOperation.ListExchanges: {
-      return await getExchanges(ws);
+      return await listExchanges(ws);
     }
     case WalletApiOperation.GetExchangeEntryByUrl: {
       const req = codecForGetExchangeEntryByUrlRequest().decode(payload);
@@ -997,7 +997,7 @@ async function dispatchRequestInternal<Op extends 
WalletApiOperation>(
     case WalletApiOperation.ListExchangesForScopedCurrency: {
       const req =
         codecForListExchangesForScopedCurrencyRequest().decode(payload);
-      const exchangesResp = await getExchanges(ws);
+      const exchangesResp = await listExchanges(ws);
       const result: ExchangesShortListResponse = {
         exchanges: [],
       };

-- 
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]