gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (97a9e92d8 -> 4e3e17edd)


From: gnunet
Subject: [taler-wallet-core] branch master updated (97a9e92d8 -> 4e3e17edd)
Date: Wed, 28 Jun 2023 10:57:27 +0200

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

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

    from 97a9e92d8 set amount for manual withdraw when the qr does not have it
     new 35ae9f2c2 wallet-core: emit balance-change notifications, do less 
implicit background work
     new 4e3e17edd wallet-core: dead code elimination

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 packages/taler-util/src/wallet-types.ts            |  2 +
 .../taler-wallet-core/src/operations/deposits.ts   |  1 -
 .../src/operations/pay-merchant.ts                 |  3 +
 .../src/operations/pay-peer-pull-credit.ts         | 17 +----
 .../src/operations/pay-peer-pull-debit.ts          | 14 ++--
 .../src/operations/pay-peer-push-credit.ts         | 18 +++--
 .../src/operations/pay-peer-push-debit.ts          |  2 +
 .../taler-wallet-core/src/operations/refresh.ts    |  2 +
 packages/taler-wallet-core/src/operations/tip.ts   | 10 ++-
 .../taler-wallet-core/src/operations/withdraw.ts   |  9 +--
 packages/taler-wallet-core/src/util/asyncMemo.ts   | 87 ----------------------
 packages/taler-wallet-core/src/util/retries.ts     | 52 -------------
 12 files changed, 42 insertions(+), 175 deletions(-)
 delete mode 100644 packages/taler-wallet-core/src/util/asyncMemo.ts
 delete mode 100644 packages/taler-wallet-core/src/util/retries.ts

diff --git a/packages/taler-util/src/wallet-types.ts 
b/packages/taler-util/src/wallet-types.ts
index 1b55591b1..237c1c39d 100644
--- a/packages/taler-util/src/wallet-types.ts
+++ b/packages/taler-util/src/wallet-types.ts
@@ -2499,6 +2499,8 @@ export interface InitiatePeerPullCreditResponse {
   /**
    * Taler URI for the other party to make the payment
    * that was requested.
+   *
+   * @deprecated since it's not necessarily valid yet until the tx is in the 
right state
    */
   talerUri: string;
 
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts 
b/packages/taler-wallet-core/src/operations/deposits.ts
index 601df4151..236fa6b59 100644
--- a/packages/taler-wallet-core/src/operations/deposits.ts
+++ b/packages/taler-wallet-core/src/operations/deposits.ts
@@ -26,7 +26,6 @@ import {
   codecForDepositSuccess,
   codecForTackTransactionAccepted,
   codecForTackTransactionWired,
-  CoinDepositPermission,
   CoinRefreshRequest,
   CreateDepositGroupRequest,
   CreateDepositGroupResponse,
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts 
b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index d7463134a..f2df08247 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -907,6 +907,8 @@ async function handleInsufficientFunds(
         refreshReason: RefreshReason.PayMerchant,
       });
     });
+
+  ws.notify({ type: NotificationType.BalanceChange });
 }
 
 async function unblockBackup(
@@ -1446,6 +1448,7 @@ export async function confirmPay(
     });
 
   notifyTransition(ws, transactionId, transitionInfo);
+  ws.notify({ type: NotificationType.BalanceChange });
 
   return runPayForConfirmPay(ws, proposalId);
 }
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 c0b728567..725e3f3d9 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
@@ -26,6 +26,7 @@ import {
   InitiatePeerPullCreditRequest,
   InitiatePeerPullCreditResponse,
   Logger,
+  NotificationType,
   TalerErrorCode,
   TalerPreciseTimestamp,
   TalerUriAction,
@@ -785,24 +786,14 @@ export async function initiatePeerPullPayment(
       });
     });
 
-  // FIXME: Should we somehow signal to the client
-  // whether purse creation has failed, or does the client/
-  // check this asynchronously from the transaction status?
-
-  const taskId = constructTaskIdentifier({
-    tag: PendingTaskType.PeerPullCredit,
-    pursePub: pursePair.pub,
-  });
-
-  await runTaskWithErrorReporting(ws, taskId, async () => {
-    return processPeerPullCredit(ws, pursePair.pub);
-  });
-
   const transactionId = constructTransactionIdentifier({
     tag: TransactionType.PeerPullCredit,
     pursePub: pursePair.pub,
   });
 
+  // The pending-incoming balance has changed.
+  ws.notify({ type: NotificationType.BalanceChange });
+
   return {
     talerUri: stringifyTalerUri({
       type: TalerUriAction.PayPull,
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts 
b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts
index c7b59e6db..9d8fabfb2 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts
@@ -22,6 +22,7 @@ import {
   ExchangePurseDeposits,
   HttpStatusCode,
   Logger,
+  NotificationType,
   PeerContractTerms,
   PreparePeerPullDebitRequest,
   PreparePeerPullDebitResponse,
@@ -388,7 +389,6 @@ export async function confirmPeerPullDebit(
   ws: InternalWalletState,
   req: ConfirmPeerPullDebitRequest,
 ): Promise<AcceptPeerPullPaymentResponse> {
-
   let peerPullPaymentIncomingId: string;
 
   if (req.transactionId) {
@@ -400,7 +400,9 @@ export async function confirmPeerPullDebit(
   } else if (req.peerPullPaymentIncomingId) {
     peerPullPaymentIncomingId = req.peerPullPaymentIncomingId;
   } else {
-    throw Error("invalid request, transactionId or peerPullPaymentIncomingId 
required");
+    throw Error(
+      "invalid request, transactionId or peerPullPaymentIncomingId required",
+    );
   }
 
   const peerPullInc = await ws.db
@@ -479,13 +481,7 @@ export async function confirmPeerPullDebit(
       return pi;
     });
 
-  await runTaskWithErrorReporting(
-    ws,
-    TaskIdentifiers.forPeerPullPaymentDebit(ppi),
-    async () => {
-      return processPeerPullDebit(ws, ppi.peerPullPaymentIncomingId);
-    },
-  );
+  ws.notify({ type: NotificationType.BalanceChange });
 
   const transactionId = constructTransactionIdentifier({
     tag: TransactionType.PeerPullDebit,
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts 
b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts
index 58a1c2b3c..3e5750af7 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts
@@ -22,6 +22,7 @@ import {
   ExchangePurseMergeRequest,
   HttpStatusCode,
   Logger,
+  NotificationType,
   PeerContractTerms,
   PreparePeerPushCreditRequest,
   PreparePeerPushCreditResponse,
@@ -60,7 +61,12 @@ import {
 } from "../index.js";
 import { assertUnreachable } from "../util/assertUnreachable.js";
 import { checkDbInvariant } from "../util/invariants.js";
-import { OperationAttemptResult, OperationAttemptResultType, 
constructTaskIdentifier, runLongpollAsync } from "./common.js";
+import {
+  OperationAttemptResult,
+  OperationAttemptResultType,
+  constructTaskIdentifier,
+  runLongpollAsync,
+} from "./common.js";
 import { updateExchangeFromUrl } from "./exchanges.js";
 import {
   codecForExchangePurseStatus,
@@ -206,6 +212,8 @@ export async function preparePeerPushCredit(
       });
     });
 
+  ws.notify({ type: NotificationType.BalanceChange });
+
   return {
     amount: purseStatus.balance,
     amountEffective: wi.withdrawalAmountEffective,
@@ -631,15 +639,15 @@ export async function confirmPeerPushCredit(
     }
     peerPushPaymentIncomingId = parsedTx.peerPushPaymentIncomingId;
   } else {
-    throw Error("no transaction ID (or deprecated peerPushPaymentIncomingId) 
provided");
+    throw Error(
+      "no transaction ID (or deprecated peerPushPaymentIncomingId) provided",
+    );
   }
 
   await ws.db
     .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming])
     .runReadWrite(async (tx) => {
-      peerInc = await tx.peerPushPaymentIncoming.get(
-        peerPushPaymentIncomingId,
-      );
+      peerInc = await 
tx.peerPushPaymentIncoming.get(peerPushPaymentIncomingId);
       if (!peerInc) {
         return;
       }
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts 
b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
index c4209eb51..a070eea50 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts
@@ -24,6 +24,7 @@ import {
   InitiatePeerPushDebitRequest,
   InitiatePeerPushDebitResponse,
   Logger,
+  NotificationType,
   RefreshReason,
   TalerError,
   TalerErrorCode,
@@ -678,6 +679,7 @@ export async function initiatePeerPushDebit(
       };
     });
   notifyTransition(ws, transactionId, transitionInfo);
+  ws.notify({ type: NotificationType.BalanceChange });
 
   return {
     contractPriv: contractKeyPair.priv,
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts 
b/packages/taler-wallet-core/src/operations/refresh.ts
index b91872735..c1a16badf 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -278,6 +278,7 @@ async function refreshCreateSession(
         }
         await tx.refreshGroups.put(rg);
       });
+    ws.notify({ type: NotificationType.BalanceChange });
     return;
   }
 
@@ -458,6 +459,7 @@ async function refreshMelt(
         }
         await tx.refreshGroups.put(rg);
       });
+    ws.notify({ type: NotificationType.BalanceChange });
     return;
   }
 
diff --git a/packages/taler-wallet-core/src/operations/tip.ts 
b/packages/taler-wallet-core/src/operations/tip.ts
index 1b40e36f1..18ef03c51 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -30,6 +30,7 @@ import {
   getRandomBytes,
   j2s,
   Logger,
+  NotificationType,
   parseTipUri,
   PrepareTipResult,
   TalerErrorCode,
@@ -57,7 +58,13 @@ import {
   readSuccessResponseJsonOrThrow,
 } from "@gnu-taler/taler-util/http";
 import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
-import { constructTaskIdentifier, makeCoinAvailable, makeCoinsVisible, 
OperationAttemptResult, OperationAttemptResultType } from "./common.js";
+import {
+  constructTaskIdentifier,
+  makeCoinAvailable,
+  makeCoinsVisible,
+  OperationAttemptResult,
+  OperationAttemptResultType,
+} from "./common.js";
 import { updateExchangeFromUrl } from "./exchanges.js";
 import {
   getCandidateWithdrawalDenoms,
@@ -421,6 +428,7 @@ export async function processTip(
       return { oldTxState, newTxState };
     });
   notifyTransition(ws, transactionId, transitionInfo);
+  ws.notify({ type: NotificationType.BalanceChange });
 
   return {
     type: OperationAttemptResultType.Finished,
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index d606e23dd..111a52882 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -62,7 +62,6 @@ import {
   ExchangeWithdrawResponse,
   WithdrawUriInfoResponse,
   ExchangeBatchWithdrawRequest,
-  WalletNotification,
   TransactionState,
   TransactionMajorState,
   TransactionMinorState,
@@ -76,7 +75,6 @@ import {
   DenominationRecord,
   DenominationVerificationStatus,
   KycPendingInfo,
-  KycUserType,
   PlanchetRecord,
   PlanchetStatus,
   WalletStoresV1,
@@ -108,11 +106,7 @@ import {
   readSuccessResponseJsonOrThrow,
   throwUnexpectedRequestError,
 } from "@gnu-taler/taler-util/http";
-import {
-  checkDbInvariant,
-  checkLogicInvariant,
-  InvariantViolatedError,
-} from "../util/invariants.js";
+import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
 import {
   DbAccess,
   GetReadOnlyAccess,
@@ -1614,6 +1608,7 @@ async function processWithdrawalGroupPendingReady(
   }
 
   notifyTransition(ws, transactionId, res.transitionInfo);
+  ws.notify({ type: NotificationType.BalanceChange });
 
   if (numPlanchetErrors > 0) {
     return {
diff --git a/packages/taler-wallet-core/src/util/asyncMemo.ts 
b/packages/taler-wallet-core/src/util/asyncMemo.ts
deleted file mode 100644
index 6e88081b6..000000000
--- a/packages/taler-wallet-core/src/util/asyncMemo.ts
+++ /dev/null
@@ -1,87 +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/>
- */
-
-interface MemoEntry<T> {
-  p: Promise<T>;
-  t: number;
-  n: number;
-}
-
-export class AsyncOpMemoMap<T> {
-  private n = 0;
-  private memoMap: { [k: string]: MemoEntry<T> } = {};
-
-  private cleanUp(key: string, n: number): void {
-    const r = this.memoMap[key];
-    if (r && r.n === n) {
-      delete this.memoMap[key];
-    }
-  }
-
-  memo(key: string, pg: () => Promise<T>): Promise<T> {
-    const res = this.memoMap[key];
-    if (res) {
-      return res.p;
-    }
-    const n = this.n++;
-    // Wrap the operation in case it immediately throws
-    const p = Promise.resolve().then(() => pg());
-    this.memoMap[key] = {
-      p,
-      n,
-      t: new Date().getTime(),
-    };
-    return p.finally(() => {
-      this.cleanUp(key, n);
-    });
-  }
-  clear(): void {
-    this.memoMap = {};
-  }
-}
-
-export class AsyncOpMemoSingle<T> {
-  private n = 0;
-  private memoEntry: MemoEntry<T> | undefined;
-
-  private cleanUp(n: number): void {
-    if (this.memoEntry && this.memoEntry.n === n) {
-      this.memoEntry = undefined;
-    }
-  }
-
-  memo(pg: () => Promise<T>): Promise<T> {
-    const res = this.memoEntry;
-    if (res) {
-      return res.p;
-    }
-    const n = this.n++;
-    // Wrap the operation in case it immediately throws
-    const p = Promise.resolve().then(() => pg());
-    p.finally(() => {
-      this.cleanUp(n);
-    });
-    this.memoEntry = {
-      p,
-      n,
-      t: new Date().getTime(),
-    };
-    return p;
-  }
-  clear(): void {
-    this.memoEntry = undefined;
-  }
-}
diff --git a/packages/taler-wallet-core/src/util/retries.ts 
b/packages/taler-wallet-core/src/util/retries.ts
deleted file mode 100644
index e602d4702..000000000
--- a/packages/taler-wallet-core/src/util/retries.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2020 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/>
- */
-
-/**
- * Helpers for dealing with retry timeouts.
- */
-
-/**
- * Imports.
- */
-import {
-  AbsoluteTime,
-  Duration,
-  Logger,
-  TalerErrorDetail,
-} from "@gnu-taler/taler-util";
-import {
-  BackupProviderRecord,
-  DepositGroupRecord,
-  ExchangeRecord,
-  PeerPullPaymentIncomingRecord,
-  PeerPullPaymentInitiationRecord,
-  PeerPushPaymentIncomingRecord,
-  PeerPushPaymentInitiationRecord,
-  PurchaseRecord,
-  RecoupGroupRecord,
-  RefreshGroupRecord,
-  TipRecord,
-  WalletStoresV1,
-  WithdrawalGroupRecord,
-} from "../db.js";
-import { TalerError } from "@gnu-taler/taler-util";
-import { InternalWalletState } from "../internal-wallet-state.js";
-import { PendingTaskType, TaskId } from "../pending-types.js";
-import { GetReadWriteAccess } from "./query.js";
-import { assertUnreachable } from "./assertUnreachable.js";
-
-const logger = new Logger("util/retries.ts");
-

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