gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] 02/02: -wallet-core: merge DenominationInfo and Deno


From: gnunet
Subject: [taler-wallet-core] 02/02: -wallet-core: merge DenominationInfo and DenomInfo
Date: Fri, 16 Sep 2022 17:35:14 +0200

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

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

commit 183c83661454cfb75ee6d2969b7529619d9a6226
Author: Florian Dold <florian@dold.me>
AuthorDate: Fri Sep 16 17:35:06 2022 +0200

    -wallet-core: merge DenominationInfo and DenomInfo
---
 packages/taler-util/src/walletTypes.ts                  | 17 ++---------------
 packages/taler-wallet-core/src/db.ts                    |  6 +++---
 packages/taler-wallet-core/src/internal-wallet-state.ts | 10 +---------
 packages/taler-wallet-core/src/operations/exchanges.ts  |  4 +---
 packages/taler-wallet-core/src/operations/refresh.ts    | 13 +++++++------
 packages/taler-wallet-core/src/wallet.ts                |  8 ++++----
 6 files changed, 18 insertions(+), 40 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 fdb9b668e..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, 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,7 +1719,7 @@ export interface OperationRetryRecord {
   /**
    * Unique identifier for the operation.  Typically of
    * the format `${opType}-${opUniqueKey}`
-   * 
+   *
    * @see {@link RetryTags}
    */
   id: string;
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/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/refresh.ts 
b/packages/taler-wallet-core/src/operations/refresh.ts
index 048ab15b3..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";
@@ -64,7 +64,6 @@ import {
 } from "../db.js";
 import { TalerError } from "../errors.js";
 import {
-  DenomInfo,
   EXCHANGE_COINS_LOCK,
   InternalWalletState,
 } from "../internal-wallet-state.js";
@@ -74,9 +73,11 @@ import {
 } from "../util/http.js";
 import { checkDbInvariant } from "../util/invariants.js";
 import { GetReadWriteAccess } from "../util/query.js";
-import { OperationAttemptResult, OperationAttemptResultType, 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,
@@ -98,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/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index f89d0330c..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 {
@@ -115,7 +116,6 @@ import {
 } from "./errors.js";
 import { createDenominationTimeline } from "./index.browser.js";
 import {
-  DenomInfo,
   ExchangeOperations,
   InternalWalletState,
   MerchantInfo,
@@ -746,7 +746,7 @@ async function getExchangeDetailedInfo(
         return;
       }
 
-      const denominations: DenomInfo[] = denominationRecords.map((x) =>
+      const denominations: DenominationInfo[] = denominationRecords.map((x) =>
         DenominationRecord.toDenomInfo(x),
       );
 
@@ -1572,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.
@@ -1606,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]