From cd2473e1ade13ca43d8f6fafaa2e8d3c3675bfd8 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 13 Jan 2022 12:08:31 +0100 Subject: cache denomination lookups --- packages/taler-wallet-core/src/common.ts | 77 +++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) (limited to 'packages/taler-wallet-core/src/common.ts') diff --git a/packages/taler-wallet-core/src/common.ts b/packages/taler-wallet-core/src/common.ts index 5b61ef14a..5cbfae4b9 100644 --- a/packages/taler-wallet-core/src/common.ts +++ b/packages/taler-wallet-core/src/common.ts @@ -20,7 +20,7 @@ * management, etc.). * * Some operations can be accessed via this state object. This allows mutual - * recursion between operations, without having cycling dependencies between + * recursion between operations, without having cyclic dependencies between * the respective TypeScript files. * * (You can think of this as a "header file" for the wallet implementation.) @@ -29,7 +29,13 @@ /** * Imports. */ -import { WalletNotification, BalancesResponse } from "@gnu-taler/taler-util"; +import { + WalletNotification, + BalancesResponse, + AmountJson, + DenominationPubKey, + Timestamp, +} from "@gnu-taler/taler-util"; import { CryptoApi } from "./crypto/workers/cryptoApi.js"; import { ExchangeDetailsRecord, ExchangeRecord, WalletStoresV1 } from "./db.js"; import { PendingOperationsResponse } from "./pending-types.js"; @@ -119,6 +125,64 @@ export interface RecoupOperations { ): Promise; } +export interface DenomInfo { + /** + * Value of one coin of the denomination. + */ + value: AmountJson; + + /** + * The denomination public key. + */ + denomPub: DenominationPubKey; + + /** + * Hash of the denomination public key. + * Stored in the database for faster lookups. + */ + denomPubHash: string; + + /** + * Fee for withdrawing. + */ + feeWithdraw: AmountJson; + + /** + * Fee for depositing. + */ + feeDeposit: AmountJson; + + /** + * Fee for refreshing. + */ + feeRefresh: AmountJson; + + /** + * Fee for refunding. + */ + feeRefund: AmountJson; + + /** + * Validity start date of the denomination. + */ + stampStart: Timestamp; + + /** + * Date after which the currency can't be withdrawn anymore. + */ + stampExpireWithdraw: Timestamp; + + /** + * Date after the denomination officially doesn't exist anymore. + */ + stampExpireLegal: Timestamp; + + /** + * Data after which coins of this denomination can't be deposited anymore. + */ + stampExpireDeposit: Timestamp; +} + export type NotificationListener = (n: WalletNotification) => void; /** @@ -162,6 +226,15 @@ export interface InternalWalletState { merchantOps: MerchantOperations; reserveOps: ReserveOperations; + getDenomInfo( + ws: InternalWalletState, + tx: GetReadWriteAccess<{ + denominations: typeof WalletStoresV1.denominations; + }>, + exchangeBaseUrl: string, + denomPubHash: string, + ): Promise; + db: DbAccess; http: HttpRequestLibrary; -- cgit v1.2.3