gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (d6c545a0b -> 183c83661)


From: gnunet
Subject: [taler-wallet-core] branch master updated (d6c545a0b -> 183c83661)
Date: Fri, 16 Sep 2022 17:35:12 +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 d6c545a0b -prettier, fix type error
     new 16e781444 -move declaration
     new 183c83661 -wallet-core: merge DenominationInfo and DenomInfo

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/walletTypes.ts             | 17 +-------
 packages/taler-wallet-core/src/db.ts               | 50 +++-------------------
 .../taler-wallet-core/src/internal-wallet-state.ts | 10 +----
 .../src/operations/backup/index.ts                 |  7 +--
 .../taler-wallet-core/src/operations/deposits.ts   |  2 +-
 .../taler-wallet-core/src/operations/exchanges.ts  |  4 +-
 packages/taler-wallet-core/src/operations/pay.ts   |  4 +-
 .../taler-wallet-core/src/operations/recoup.ts     |  4 +-
 .../taler-wallet-core/src/operations/refresh.ts    | 15 +++----
 .../taler-wallet-core/src/operations/refund.ts     |  3 +-
 packages/taler-wallet-core/src/operations/tip.ts   |  3 +-
 .../taler-wallet-core/src/operations/withdraw.ts   |  3 +-
 packages/taler-wallet-core/src/util/retries.ts     | 44 ++++++++++++++++++-
 packages/taler-wallet-core/src/wallet.ts           | 21 +++++----
 14 files changed, 77 insertions(+), 110 deletions(-)

diff --git a/packages/taler-util/src/walletTypes.ts 
b/packages/taler-util/src/walletTypes.ts
index 6dcaac78d..8c6ec7431 100644
--- a/packages/taler-util/src/walletTypes.ts
+++ b/packages/taler-util/src/walletTypes.ts
@@ -682,21 +682,6 @@ const codecForWireInfo = (): Codec<WireInfo> =>
     .property("accounts", codecForList(codecForExchangeAccount()))
     .build("codecForWireInfo");
 
-const codecForDenominationInfo = (): Codec<DenominationInfo> =>
-  buildCodecForObject<DenominationInfo>()
-    .property("denomPubHash", codecForString())
-    .property("value", codecForAmountJson())
-    .property("feeWithdraw", codecForAmountJson())
-    .property("feeDeposit", codecForAmountJson())
-    .property("feeRefresh", codecForAmountJson())
-    .property("feeRefund", codecForAmountJson())
-    .property("stampStart", codecForTimestamp)
-    .property("stampExpireWithdraw", codecForTimestamp)
-    .property("stampExpireLegal", codecForTimestamp)
-    .property("stampExpireDeposit", codecForTimestamp)
-    .property("exchangeBaseUrl", codecForString())
-    .build("codecForDenominationInfo");
-
 export interface DenominationInfo {
   /**
    * Value of one coin of the denomination.
@@ -709,6 +694,8 @@ export interface DenominationInfo {
    */
   denomPubHash: string;
 
+  denomPub: DenominationPubKey;
+
   /**
    * Fee for withdrawing.
    */
diff --git a/packages/taler-wallet-core/src/db.ts 
b/packages/taler-wallet-core/src/db.ts
index 6466edf5a..4fac0f9aa 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -44,10 +44,10 @@ import {
   PeerContractTerms,
   Location,
   WireInfo,
+  DenominationInfo,
 } from "@gnu-taler/taler-util";
-import { RetryInfo } from "./util/retries.js";
+import { RetryInfo, RetryTags } from "./util/retries.js";
 import { Event, IDBDatabase } from "@gnu-taler/idb-bridge";
-import { DenomInfo } from "./internal-wallet-state.js";
 
 /**
  * Name of the Taler database.  This is effectively the major
@@ -330,7 +330,7 @@ export namespace DenominationRecord {
     };
   }
 
-  export function toDenomInfo(d: DenominationRecord): DenomInfo {
+  export function toDenomInfo(d: DenominationRecord): DenominationInfo {
     return {
       denomPub: d.denomPub,
       denomPubHash: d.denomPubHash,
@@ -1719,6 +1719,8 @@ export interface OperationRetryRecord {
   /**
    * Unique identifier for the operation.  Typically of
    * the format `${opType}-${opUniqueKey}`
+   *
+   * @see {@link RetryTags}
    */
   id: string;
 
@@ -1727,48 +1729,6 @@ export interface OperationRetryRecord {
   retryInfo: RetryInfo;
 }
 
-export enum OperationAttemptResultType {
-  Finished = "finished",
-  Pending = "pending",
-  Error = "error",
-  Longpoll = "longpoll",
-}
-
-// FIXME: not part of DB!
-export type OperationAttemptResult<TSuccess = unknown, TPending = unknown> =
-  | OperationAttemptFinishedResult<TSuccess>
-  | OperationAttemptErrorResult
-  | OperationAttemptLongpollResult
-  | OperationAttemptPendingResult<TPending>;
-
-export namespace OperationAttemptResult {
-  export function finishedEmpty(): OperationAttemptResult<unknown, unknown> {
-    return {
-      type: OperationAttemptResultType.Finished,
-      result: undefined,
-    };
-  }
-}
-
-export interface OperationAttemptFinishedResult<T> {
-  type: OperationAttemptResultType.Finished;
-  result: T;
-}
-
-export interface OperationAttemptPendingResult<T> {
-  type: OperationAttemptResultType.Pending;
-  result: T;
-}
-
-export interface OperationAttemptErrorResult {
-  type: OperationAttemptResultType.Error;
-  errorDetail: TalerErrorDetail;
-}
-
-export interface OperationAttemptLongpollResult {
-  type: OperationAttemptResultType.Longpoll;
-}
-
 /**
  * Availability of coins of a given denomination (and age restriction!).
  *
diff --git a/packages/taler-wallet-core/src/internal-wallet-state.ts 
b/packages/taler-wallet-core/src/internal-wallet-state.ts
index 575e7553c..ad6afe3c3 100644
--- a/packages/taler-wallet-core/src/internal-wallet-state.ts
+++ b/packages/taler-wallet-core/src/internal-wallet-state.ts
@@ -125,14 +125,6 @@ export interface RecoupOperations {
   ): Promise<void>;
 }
 
-export type DenomInfo = DenominationInfo & {
-  /**
-   * The denomination public key.
-   */
-  denomPub: DenominationPubKey;
-}
-
-
 export type NotificationListener = (n: WalletNotification) => void;
 
 /**
@@ -184,7 +176,7 @@ export interface InternalWalletState {
     }>,
     exchangeBaseUrl: string,
     denomPubHash: string,
-  ): Promise<DenomInfo | undefined>;
+  ): Promise<DenominationInfo | undefined>;
 
   db: DbAccess<typeof WalletStoresV1>;
   http: HttpRequestLibrary;
diff --git a/packages/taler-wallet-core/src/operations/backup/index.ts 
b/packages/taler-wallet-core/src/operations/backup/index.ts
index db003af81..d4dfe2916 100644
--- a/packages/taler-wallet-core/src/operations/backup/index.ts
+++ b/packages/taler-wallet-core/src/operations/backup/index.ts
@@ -74,10 +74,7 @@ import {
   BackupProviderStateTag,
   BackupProviderTerms,
   ConfigRecord,
-  OperationAttemptResult,
-  OperationAttemptResultType,
   WalletBackupConfState,
-  WalletStoresV1,
   WALLET_BACKUP_STATE_KEY,
 } from "../../db.js";
 import { InternalWalletState } from "../../internal-wallet-state.js";
@@ -89,9 +86,7 @@ import {
   checkDbInvariant,
   checkLogicInvariant,
 } from "../../util/invariants.js";
-import { GetReadWriteAccess } from "../../util/query.js";
-import { RetryInfo, RetryTags, scheduleRetryInTx } from 
"../../util/retries.js";
-import { guardOperationException } from "../common.js";
+import { OperationAttemptResult, OperationAttemptResultType, RetryTags, 
scheduleRetryInTx } from "../../util/retries.js";
 import {
   checkPaymentByProposalId,
   confirmPay,
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts 
b/packages/taler-wallet-core/src/operations/deposits.ts
index 22ec5f0a5..c16b2376d 100644
--- a/packages/taler-wallet-core/src/operations/deposits.ts
+++ b/packages/taler-wallet-core/src/operations/deposits.ts
@@ -47,11 +47,11 @@ import {
 import {
   DenominationRecord,
   DepositGroupRecord,
-  OperationAttemptResult,
   OperationStatus,
 } from "../db.js";
 import { InternalWalletState } from "../internal-wallet-state.js";
 import { readSuccessResponseJsonOrThrow } from "../util/http.js";
+import { OperationAttemptResult } from "../util/retries.js";
 import { spendCoins } from "../wallet.js";
 import { getExchangeDetails } from "./exchanges.js";
 import {
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts 
b/packages/taler-wallet-core/src/operations/exchanges.ts
index ca85ff465..9165ed050 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -53,8 +53,6 @@ import {
   DenominationVerificationStatus,
   ExchangeDetailsRecord,
   ExchangeRecord,
-  OperationAttemptResult,
-  OperationAttemptResultType,
   WalletStoresV1,
 } from "../db.js";
 import { TalerError } from "../errors.js";
@@ -66,7 +64,7 @@ import {
   readSuccessResponseTextOrThrow,
 } from "../util/http.js";
 import { DbAccess, GetReadOnlyAccess } from "../util/query.js";
-import { RetryInfo, runOperationHandlerForResult } from "../util/retries.js";
+import { OperationAttemptResult, OperationAttemptResultType, RetryInfo, 
runOperationHandlerForResult } from "../util/retries.js";
 import { WALLET_EXCHANGE_PROTOCOL_VERSION } from "../versions.js";
 import { guardOperationException } from "./common.js";
 
diff --git a/packages/taler-wallet-core/src/operations/pay.ts 
b/packages/taler-wallet-core/src/operations/pay.ts
index 6b366f50d..468f9ca31 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -68,8 +68,6 @@ import {
   CoinRecord,
   CoinStatus,
   DenominationRecord,
-  OperationAttemptResult,
-  OperationAttemptResultType,
   ProposalRecord,
   ProposalStatus,
   PurchaseRecord,
@@ -99,7 +97,7 @@ import {
   throwUnexpectedRequestError,
 } from "../util/http.js";
 import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
-import { RetryInfo, RetryTags, scheduleRetry } from "../util/retries.js";
+import { OperationAttemptResult, OperationAttemptResultType, RetryInfo, 
RetryTags, scheduleRetry } from "../util/retries.js";
 import { spendCoins } from "../wallet.js";
 import { getExchangeDetails } from "./exchanges.js";
 import { getTotalRefreshCost } from "./refresh.js";
diff --git a/packages/taler-wallet-core/src/operations/recoup.ts 
b/packages/taler-wallet-core/src/operations/recoup.ts
index bd598511a..4424b9b40 100644
--- a/packages/taler-wallet-core/src/operations/recoup.ts
+++ b/packages/taler-wallet-core/src/operations/recoup.ts
@@ -42,8 +42,6 @@ import {
   CoinRecord,
   CoinSourceType,
   CoinStatus,
-  OperationAttemptResult,
-  OperationAttemptResultType,
   RecoupGroupRecord,
   RefreshCoinSource,
   ReserveRecordStatus,
@@ -54,7 +52,7 @@ import {
 import { InternalWalletState } from "../internal-wallet-state.js";
 import { readSuccessResponseJsonOrThrow } from "../util/http.js";
 import { GetReadWriteAccess } from "../util/query.js";
-import { RetryInfo, runOperationHandlerForResult } from "../util/retries.js";
+import { OperationAttemptResult, RetryInfo, runOperationHandlerForResult } 
from "../util/retries.js";
 import { guardOperationException } from "./common.js";
 import { createRefreshGroup, processRefreshGroup } from "./refresh.js";
 import { internalCreateWithdrawalGroup } from "./withdraw.js";
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts 
b/packages/taler-wallet-core/src/operations/refresh.ts
index e968ec020..eeb492499 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -25,6 +25,7 @@ import {
   codecForExchangeRevealResponse,
   CoinPublicKey,
   CoinPublicKeyString,
+  DenominationInfo,
   DenomKeyType,
   Duration,
   durationFromSpec,
@@ -42,7 +43,6 @@ import {
   NotificationType,
   RefreshGroupId,
   RefreshReason,
-  TalerErrorDetail,
   TalerProtocolTimestamp,
   URL,
 } from "@gnu-taler/taler-util";
@@ -57,8 +57,6 @@ import {
   CoinSourceType,
   CoinStatus,
   DenominationRecord,
-  OperationAttemptResult,
-  OperationAttemptResultType,
   OperationStatus,
   RefreshCoinStatus,
   RefreshGroupRecord,
@@ -66,7 +64,6 @@ import {
 } from "../db.js";
 import { TalerError } from "../errors.js";
 import {
-  DenomInfo,
   EXCHANGE_COINS_LOCK,
   InternalWalletState,
 } from "../internal-wallet-state.js";
@@ -76,9 +73,11 @@ import {
 } from "../util/http.js";
 import { checkDbInvariant } from "../util/invariants.js";
 import { GetReadWriteAccess } from "../util/query.js";
-import { RetryInfo, runOperationHandlerForResult } from "../util/retries.js";
-import { makeCoinAvailable, Wallet } from "../wallet.js";
-import { guardOperationException } from "./common.js";
+import {
+  OperationAttemptResult,
+  OperationAttemptResultType,
+} from "../util/retries.js";
+import { makeCoinAvailable } from "../wallet.js";
 import { updateExchangeFromUrl } from "./exchanges.js";
 import {
   isWithdrawableDenom,
@@ -100,7 +99,7 @@ const logger = new Logger("refresh.ts");
  */
 export function getTotalRefreshCost(
   denoms: DenominationRecord[],
-  refreshedDenom: DenomInfo,
+  refreshedDenom: DenominationInfo,
   amountLeft: AmountJson,
 ): AmountJson {
   const withdrawAmount = Amounts.sub(
diff --git a/packages/taler-wallet-core/src/operations/refund.ts 
b/packages/taler-wallet-core/src/operations/refund.ts
index bdcdac943..0d86b92ab 100644
--- a/packages/taler-wallet-core/src/operations/refund.ts
+++ b/packages/taler-wallet-core/src/operations/refund.ts
@@ -44,7 +44,6 @@ import {
   PrepareRefundResult,
   RefreshReason,
   TalerErrorCode,
-  TalerErrorDetail,
   TalerProtocolTimestamp,
   TransactionType,
   URL,
@@ -53,7 +52,6 @@ import {
   AbortStatus,
   CoinStatus,
   DenominationRecord,
-  OperationAttemptResult,
   PurchaseRecord,
   RefundReason,
   RefundState,
@@ -63,6 +61,7 @@ import { InternalWalletState } from 
"../internal-wallet-state.js";
 import { readSuccessResponseJsonOrThrow } from "../util/http.js";
 import { checkDbInvariant } from "../util/invariants.js";
 import { GetReadWriteAccess } from "../util/query.js";
+import { OperationAttemptResult } from "../util/retries.js";
 import { createRefreshGroup, getTotalRefreshCost } from "./refresh.js";
 import { makeEventId } from "./transactions.js";
 
diff --git a/packages/taler-wallet-core/src/operations/tip.ts 
b/packages/taler-wallet-core/src/operations/tip.ts
index 9f96b7a7d..f79851be8 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -43,8 +43,6 @@ import {
   CoinSourceType,
   CoinStatus,
   DenominationRecord,
-  OperationAttemptResult,
-  OperationAttemptResultType,
   TipRecord,
 } from "../db.js";
 import { makeErrorDetail } from "../errors.js";
@@ -54,6 +52,7 @@ import {
   readSuccessResponseJsonOrThrow,
 } from "../util/http.js";
 import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
+import { OperationAttemptResult, OperationAttemptResultType } from 
"../util/retries.js";
 import { makeCoinAvailable } from "../wallet.js";
 import { updateExchangeFromUrl } from "./exchanges.js";
 import { makeEventId } from "./transactions.js";
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index cb0b55faf..6b31842b3 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -69,8 +69,6 @@ import {
   DenomSelectionState,
   ExchangeDetailsRecord,
   ExchangeRecord,
-  OperationAttemptResult,
-  OperationAttemptResultType,
   OperationStatus,
   PlanchetRecord,
   ReserveRecordStatus,
@@ -95,6 +93,7 @@ import {
 } from "../util/http.js";
 import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
 import { DbAccess, GetReadOnlyAccess } from "../util/query.js";
+import { OperationAttemptResult, OperationAttemptResultType } from 
"../util/retries.js";
 import {
   WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
   WALLET_EXCHANGE_PROTOCOL_VERSION,
diff --git a/packages/taler-wallet-core/src/util/retries.ts 
b/packages/taler-wallet-core/src/util/retries.ts
index 4763bbc42..70b385c4a 100644
--- a/packages/taler-wallet-core/src/util/retries.ts
+++ b/packages/taler-wallet-core/src/util/retries.ts
@@ -30,8 +30,6 @@ import {
   BackupProviderRecord,
   DepositGroupRecord,
   ExchangeRecord,
-  OperationAttemptResult,
-  OperationAttemptResultType,
   ProposalRecord,
   PurchaseRecord,
   RecoupGroupRecord,
@@ -45,6 +43,48 @@ import { InternalWalletState } from 
"../internal-wallet-state.js";
 import { PendingTaskType } from "../pending-types.js";
 import { GetReadWriteAccess } from "./query.js";
 
+export enum OperationAttemptResultType {
+  Finished = "finished",
+  Pending = "pending",
+  Error = "error",
+  Longpoll = "longpoll",
+}
+
+// FIXME: not part of DB!
+export type OperationAttemptResult<TSuccess = unknown, TPending = unknown> =
+  | OperationAttemptFinishedResult<TSuccess>
+  | OperationAttemptErrorResult
+  | OperationAttemptLongpollResult
+  | OperationAttemptPendingResult<TPending>;
+
+export namespace OperationAttemptResult {
+  export function finishedEmpty(): OperationAttemptResult<unknown, unknown> {
+    return {
+      type: OperationAttemptResultType.Finished,
+      result: undefined,
+    };
+  }
+}
+
+export interface OperationAttemptFinishedResult<T> {
+  type: OperationAttemptResultType.Finished;
+  result: T;
+}
+
+export interface OperationAttemptPendingResult<T> {
+  type: OperationAttemptResultType.Pending;
+  result: T;
+}
+
+export interface OperationAttemptErrorResult {
+  type: OperationAttemptResultType.Error;
+  errorDetail: TalerErrorDetail;
+}
+
+export interface OperationAttemptLongpollResult {
+  type: OperationAttemptResultType.Longpoll;
+}
+
 export interface RetryInfo {
   firstTry: AbsoluteTime;
   nextRetry: AbsoluteTime;
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index 812106c7a..c993155d8 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -92,6 +92,7 @@ import {
   FeeDescription,
   TalerErrorDetail,
   codecForTransactionByIdRequest,
+  DenominationInfo,
 } from "@gnu-taler/taler-util";
 import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
 import {
@@ -106,8 +107,6 @@ import {
   DenominationRecord,
   exportDb,
   importDb,
-  OperationAttemptResult,
-  OperationAttemptResultType,
   WalletStoresV1,
 } from "./db.js";
 import {
@@ -117,7 +116,6 @@ import {
 } from "./errors.js";
 import { createDenominationTimeline } from "./index.browser.js";
 import {
-  DenomInfo,
   ExchangeOperations,
   InternalWalletState,
   MerchantInfo,
@@ -228,7 +226,12 @@ import {
   openPromise,
 } from "./util/promiseUtils.js";
 import { DbAccess, GetReadWriteAccess } from "./util/query.js";
-import { RetryInfo, runOperationHandlerForResult } from "./util/retries.js";
+import {
+  OperationAttemptResult,
+  OperationAttemptResultType,
+  RetryInfo,
+  runOperationHandlerForResult,
+} from "./util/retries.js";
 import { TimerAPI, TimerGroup } from "./util/timer.js";
 import {
   WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
@@ -284,7 +287,7 @@ async function callOperationHandler(
   ws: InternalWalletState,
   pending: PendingTaskInfo,
   forceNow = false,
-): Promise<OperationAttemptResult<unknown, unknown>> {
+): Promise<OperationAttemptResult> {
   switch (pending.type) {
     case PendingTaskType.ExchangeUpdate:
       return await updateExchangeFromUrlHandler(ws, pending.exchangeBaseUrl, {
@@ -743,7 +746,7 @@ async function getExchangeDetailedInfo(
         return;
       }
 
-      const denominations: DenomInfo[] = denominationRecords.map((x) =>
+      const denominations: DenominationInfo[] = denominationRecords.map((x) =>
         DenominationRecord.toDenomInfo(x),
       );
 
@@ -1099,7 +1102,7 @@ async function dispatchRequestInternal(
     }
     case "getTransactionById": {
       const req = codecForTransactionByIdRequest().decode(payload);
-      return await getTransactionById(ws, req)
+      return await getTransactionById(ws, req);
     }
     case "addExchange": {
       const req = codecForAddExchangeRequest().decode(payload);
@@ -1569,7 +1572,7 @@ class InternalWalletStateImpl implements 
InternalWalletState {
   };
 
   // FIXME: Use an LRU cache here.
-  private denomCache: Record<string, DenomInfo> = {};
+  private denomCache: Record<string, DenominationInfo> = {};
 
   /**
    * Promises that are waiting for a particular resource.
@@ -1603,7 +1606,7 @@ class InternalWalletStateImpl implements 
InternalWalletState {
     }>,
     exchangeBaseUrl: string,
     denomPubHash: string,
-  ): Promise<DenomInfo | undefined> {
+  ): Promise<DenominationInfo | undefined> {
     const key = `${exchangeBaseUrl}:${denomPubHash}`;
     const cached = this.denomCache[key];
     if (cached) {

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