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 import paths


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: fix import paths, remove unused code, thread through cancellation tokens
Date: Mon, 19 Feb 2024 18:20: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 e888d7f29 wallet-core: fix import paths, remove unused code, thread 
through cancellation tokens
e888d7f29 is described below

commit e888d7f292f68a58fc4b56771fb8a38219d53b86
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Feb 19 18:20:43 2024 +0100

    wallet-core: fix import paths, remove unused code, thread through 
cancellation tokens
---
 packages/taler-wallet-core/src/backup/index.ts     | 12 ++--
 packages/taler-wallet-core/src/merchants.ts        | 66 ----------------------
 packages/taler-wallet-core/src/pay-merchant.ts     | 30 +++++-----
 .../taler-wallet-core/src/pay-peer-pull-debit.ts   | 39 ++++++++-----
 packages/taler-wallet-core/src/recoup.ts           | 14 +++--
 packages/taler-wallet-core/src/shepherd.ts         | 32 +++++++----
 6 files changed, 76 insertions(+), 117 deletions(-)

diff --git a/packages/taler-wallet-core/src/backup/index.ts 
b/packages/taler-wallet-core/src/backup/index.ts
index c9ab6c5d9..13bf95026 100644
--- a/packages/taler-wallet-core/src/backup/index.ts
+++ b/packages/taler-wallet-core/src/backup/index.ts
@@ -82,19 +82,19 @@ import {
   WalletDbReadOnlyTransaction,
   timestampOptionalPreciseFromDb,
   timestampPreciseToDb,
-} from "../../db.js";
-import { InternalWalletState } from "../../internal-wallet-state.js";
+} from "../db.js";
+import { InternalWalletState } from "../internal-wallet-state.js";
 import {
   checkDbInvariant,
   checkLogicInvariant,
-} from "../../util/invariants.js";
-import { addAttentionRequest, removeAttentionRequest } from 
"../../attention.js";
+} from "../util/invariants.js";
+import { addAttentionRequest, removeAttentionRequest } from "../attention.js";
 import {
   TaskIdentifiers,
   TaskRunResult,
   TaskRunResultType,
-} from "../../common.js";
-import { preparePayForUri } from "../../pay-merchant.js";
+} from "../common.js";
+import { preparePayForUri } from "../pay-merchant.js";
 
 const logger = new Logger("operations/backup.ts");
 
diff --git a/packages/taler-wallet-core/src/merchants.ts 
b/packages/taler-wallet-core/src/merchants.ts
deleted file mode 100644
index 6400aad7d..000000000
--- a/packages/taler-wallet-core/src/merchants.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2021 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
- 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/>
- */
-
-/**
- * Imports.
- */
-import {
-  canonicalizeBaseUrl,
-  Logger,
-  URL,
-  codecForMerchantConfigResponse,
-  LibtoolVersion,
-} from "@gnu-taler/taler-util";
-import { InternalWalletState, MerchantInfo } from "./internal-wallet-state.js";
-import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http";
-
-const logger = new Logger("taler-wallet-core:merchants.ts");
-
-export async function getMerchantInfo(
-  ws: InternalWalletState,
-  merchantBaseUrl: string,
-): Promise<MerchantInfo> {
-  const canonBaseUrl = canonicalizeBaseUrl(merchantBaseUrl);
-
-  const existingInfo = ws.merchantInfoCache[canonBaseUrl];
-  if (existingInfo) {
-    return existingInfo;
-  }
-
-  const configUrl = new URL("config", canonBaseUrl);
-  const resp = await ws.http.fetch(configUrl.href);
-
-  const configResp = await readSuccessResponseJsonOrThrow(
-    resp,
-    codecForMerchantConfigResponse(),
-  );
-
-  logger.info(
-    `merchant "${canonBaseUrl}" reports protocol ${configResp.version}"`,
-  );
-
-  const parsedVersion = LibtoolVersion.parseVersion(configResp.version);
-  if (!parsedVersion) {
-    throw Error("invalid merchant version");
-  }
-
-  const merchantInfo: MerchantInfo = {
-    protocolVersionCurrent: parsedVersion.current,
-  };
-
-  ws.merchantInfoCache[canonBaseUrl] = merchantInfo;
-  return merchantInfo;
-}
diff --git a/packages/taler-wallet-core/src/pay-merchant.ts 
b/packages/taler-wallet-core/src/pay-merchant.ts
index f294035e6..0bd851464 100644
--- a/packages/taler-wallet-core/src/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/pay-merchant.ts
@@ -32,6 +32,7 @@ import {
   Amounts,
   AmountString,
   AsyncFlag,
+  CancellationToken,
   codecForAbortResponse,
   codecForMerchantContractTerms,
   codecForMerchantOrderRefundPickupResponse,
@@ -94,6 +95,17 @@ import {
   readUnexpectedResponseDetails,
   throwUnexpectedRequestError,
 } from "@gnu-taler/taler-util/http";
+import {
+  constructTaskIdentifier,
+  DbRetryInfo,
+  spendCoins,
+  TaskIdentifiers,
+  TaskRunResult,
+  TaskRunResultType,
+  TombstoneTag,
+  TransactionContext,
+  TransitionResult,
+} from "./common.js";
 import { EddsaKeypair } from "./crypto/cryptoImplementation.js";
 import {
   CoinRecord,
@@ -121,21 +133,7 @@ import {
   EXCHANGE_COINS_LOCK,
   InternalWalletState,
 } from "./internal-wallet-state.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { PreviousPayCoins, selectPayCoinsNew } from "./util/coinSelection.js";
-import { checkDbInvariant } from "./util/invariants.js";
 import { DbReadWriteTransaction, StoreNames } from "./query.js";
-import {
-  constructTaskIdentifier,
-  DbRetryInfo,
-  spendCoins,
-  TaskIdentifiers,
-  TaskRunResult,
-  TaskRunResultType,
-  TombstoneTag,
-  TransactionContext,
-  TransitionResult,
-} from "./common.js";
 import {
   calculateRefreshOutput,
   createRefreshGroup,
@@ -146,6 +144,9 @@ 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";
 
 /**
  * Logger.
@@ -1935,6 +1936,7 @@ export async function confirmPay(
 export async function processPurchase(
   ws: InternalWalletState,
   proposalId: string,
+  cancellationToken: CancellationToken,
 ): Promise<TaskRunResult> {
   const purchase = await ws.db.runReadOnlyTx(["purchases"], async (tx) => {
     return tx.purchases.get(proposalId);
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 f71fdcee7..62472c7f8 100644
--- a/packages/taler-wallet-core/src/pay-peer-pull-debit.ts
+++ b/packages/taler-wallet-core/src/pay-peer-pull-debit.ts
@@ -26,6 +26,7 @@
 import {
   AcceptPeerPullPaymentResponse,
   Amounts,
+  CancellationToken,
   CoinRefreshRequest,
   ConfirmPeerPullDebitRequest,
   ContractTermsUtil,
@@ -62,6 +63,14 @@ import {
   readSuccessResponseJsonOrThrow,
   readTalerErrorResponse,
 } from "@gnu-taler/taler-util/http";
+import {
+  TaskRunResult,
+  TaskRunResultType,
+  TransactionContext,
+  TransitionResult,
+  constructTaskIdentifier,
+  spendCoins,
+} from "./common.js";
 import {
   DbReadWriteTransaction,
   InternalWalletState,
@@ -75,17 +84,6 @@ import {
   createRefreshGroup,
   timestampPreciseToDb,
 } from "./index.js";
-import { assertUnreachable } from "./util/assertUnreachable.js";
-import { PeerCoinRepair, selectPeerCoins } from "./util/coinSelection.js";
-import { checkLogicInvariant } from "./util/invariants.js";
-import {
-  TaskRunResult,
-  TaskRunResultType,
-  TransactionContext,
-  TransitionResult,
-  constructTaskIdentifier,
-  spendCoins,
-} from "./common.js";
 import {
   codecForExchangePurseStatus,
   getTotalPeerPaymentCost,
@@ -96,6 +94,9 @@ 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";
 
 const logger = new Logger("pay-peer-pull-debit.ts");
 
@@ -413,6 +414,7 @@ async function handlePurseCreationConflict(
 async function processPeerPullDebitPendingDeposit(
   ws: InternalWalletState,
   peerPullInc: PeerPullPaymentIncomingRecord,
+  cancellationToken: CancellationToken,
 ): Promise<TaskRunResult> {
   const pursePub = peerPullInc.pursePub;
 
@@ -445,6 +447,7 @@ async function processPeerPullDebitPendingDeposit(
   const httpResp = await ws.http.fetch(purseDepositUrl.href, {
     method: "POST",
     body: depositPayload,
+    cancellationToken,
   });
 
   const ctx = new PeerPullDebitTransactionContext(
@@ -489,6 +492,7 @@ async function processPeerPullDebitPendingDeposit(
 async function processPeerPullDebitAbortingRefresh(
   ws: InternalWalletState,
   peerPullInc: PeerPullPaymentIncomingRecord,
+  _cancellationToken: CancellationToken,
 ): Promise<TaskRunResult> {
   const peerPullDebitId = peerPullInc.peerPullDebitId;
   const abortRefreshGroupId = peerPullInc.abortRefreshGroupId;
@@ -538,6 +542,7 @@ async function processPeerPullDebitAbortingRefresh(
 export async function processPeerPullDebit(
   ws: InternalWalletState,
   peerPullDebitId: string,
+  cancellationToken: CancellationToken,
 ): Promise<TaskRunResult> {
   const peerPullInc = await ws.db.runReadOnlyTx(
     ["peerPullDebit"],
@@ -551,9 +556,17 @@ export async function processPeerPullDebit(
 
   switch (peerPullInc.status) {
     case PeerPullDebitRecordStatus.PendingDeposit:
-      return await processPeerPullDebitPendingDeposit(ws, peerPullInc);
+      return await processPeerPullDebitPendingDeposit(
+        ws,
+        peerPullInc,
+        cancellationToken,
+      );
     case PeerPullDebitRecordStatus.AbortingRefresh:
-      return await processPeerPullDebitAbortingRefresh(ws, peerPullInc);
+      return await processPeerPullDebitAbortingRefresh(
+        ws,
+        peerPullInc,
+        cancellationToken,
+      );
   }
   return TaskRunResult.finished();
 }
diff --git a/packages/taler-wallet-core/src/recoup.ts 
b/packages/taler-wallet-core/src/recoup.ts
index a2ffa4132..02aa1e167 100644
--- a/packages/taler-wallet-core/src/recoup.ts
+++ b/packages/taler-wallet-core/src/recoup.ts
@@ -26,6 +26,7 @@
  */
 import {
   Amounts,
+  CancellationToken,
   CoinStatus,
   Logger,
   RefreshReason,
@@ -39,6 +40,11 @@ import {
   j2s,
 } from "@gnu-taler/taler-util";
 import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http";
+import {
+  TaskRunResult,
+  TransactionContext,
+  constructTaskIdentifier,
+} from "./common.js";
 import {
   CoinRecord,
   CoinSourceType,
@@ -53,14 +59,9 @@ import {
 } from "./db.js";
 import { InternalWalletState } from "./internal-wallet-state.js";
 import { PendingTaskType } from "./pending-types.js";
-import { checkDbInvariant } from "./util/invariants.js";
-import {
-  TaskRunResult,
-  TransactionContext,
-  constructTaskIdentifier,
-} from "./common.js";
 import { createRefreshGroup } from "./refresh.js";
 import { constructTransactionIdentifier } from "./transactions.js";
+import { checkDbInvariant } from "./util/invariants.js";
 import { internalCreateWithdrawalGroup } from "./withdraw.js";
 
 const logger = new Logger("operations/recoup.ts");
@@ -295,6 +296,7 @@ async function recoupRefreshCoin(
 export async function processRecoupGroup(
   ws: InternalWalletState,
   recoupGroupId: string,
+  cancellationToken: CancellationToken,
 ): Promise<TaskRunResult> {
   let recoupGroup = await ws.db.runReadOnlyTx(["recoupGroups"], async (tx) => {
     return tx.recoupGroups.get(recoupGroupId);
diff --git a/packages/taler-wallet-core/src/shepherd.ts 
b/packages/taler-wallet-core/src/shepherd.ts
index 438b4cf84..462d51a0d 100644
--- a/packages/taler-wallet-core/src/shepherd.ts
+++ b/packages/taler-wallet-core/src/shepherd.ts
@@ -37,14 +37,6 @@ import {
   j2s,
   makeErrorDetail,
 } from "@gnu-taler/taler-util";
-import { CryptoApiStoppedError } from "./crypto/workers/crypto-dispatcher.js";
-import {
-  OPERATION_STATUS_ACTIVE_FIRST,
-  OPERATION_STATUS_ACTIVE_LAST,
-  WalletDbAllStoresReadOnlyTransaction,
-  timestampAbsoluteFromDb,
-} from "./index.js";
-import { InternalWalletState } from "./internal-wallet-state.js";
 import { processBackupForProvider } from "./backup/index.js";
 import {
   DbRetryInfo,
@@ -54,18 +46,26 @@ import {
   getExchangeState,
   parseTaskIdentifier,
 } from "./common.js";
+import { CryptoApiStoppedError } from "./crypto/workers/crypto-dispatcher.js";
 import { processDepositGroup } from "./deposits.js";
 import { updateExchangeFromUrlHandler } from "./exchanges.js";
+import {
+  OPERATION_STATUS_ACTIVE_FIRST,
+  OPERATION_STATUS_ACTIVE_LAST,
+  WalletDbAllStoresReadOnlyTransaction,
+  timestampAbsoluteFromDb,
+} from "./index.js";
+import { InternalWalletState } from "./internal-wallet-state.js";
 import { processPurchase } from "./pay-merchant.js";
 import { processPeerPullCredit } from "./pay-peer-pull-credit.js";
 import { processPeerPullDebit } from "./pay-peer-pull-debit.js";
 import { processPeerPushCredit } from "./pay-peer-push-credit.js";
 import { processPeerPushDebit } from "./pay-peer-push-debit.js";
+import { PendingTaskType, TaskId } from "./pending-types.js";
 import { processRecoupGroup } from "./recoup.js";
 import { processRefreshGroup } from "./refresh.js";
 import { constructTransactionIdentifier } from "./transactions.js";
 import { processWithdrawalGroup } from "./withdraw.js";
-import { PendingTaskType, TaskId } from "./pending-types.js";
 
 const logger = new Logger("shepherd.ts");
 
@@ -518,9 +518,13 @@ async function callOperationHandlerForTaskId(
         cancellationToken,
       );
     case PendingTaskType.Purchase:
-      return await processPurchase(ws, pending.proposalId);
+      return await processPurchase(ws, pending.proposalId, cancellationToken);
     case PendingTaskType.Recoup:
-      return await processRecoupGroup(ws, pending.recoupGroupId);
+      return await processRecoupGroup(
+        ws,
+        pending.recoupGroupId,
+        cancellationToken,
+      );
     case PendingTaskType.Deposit:
       return await processDepositGroup(
         ws,
@@ -542,7 +546,11 @@ async function callOperationHandlerForTaskId(
         cancellationToken,
       );
     case PendingTaskType.PeerPullDebit:
-      return await processPeerPullDebit(ws, pending.peerPullDebitId);
+      return await processPeerPullDebit(
+        ws,
+        pending.peerPullDebitId,
+        cancellationToken,
+      );
     case PendingTaskType.PeerPushCredit:
       return await processPeerPushCredit(
         ws,

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