taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 68b90ab875e8c68619b778209b2562f58a90c150
parent d0f90d80c344602d632372cc13b1f35a2017cfa5
Author: Florian Dold <dold@taler.net>
Date:   Sat, 18 Jul 2026 20:00:12 +0200

db: rename DenominationRecord to WalletDenomination

Diffstat:
Mpackages/taler-wallet-core/src/coinSelection.ts | 4++--
Mpackages/taler-wallet-core/src/db-common.ts | 6+++---
Mpackages/taler-wallet-core/src/db-indexeddb.ts | 6+++---
Mpackages/taler-wallet-core/src/dbtx.ts | 14+++++++-------
Mpackages/taler-wallet-core/src/denomSelection.ts | 8++++----
Mpackages/taler-wallet-core/src/denominations.ts | 12++++++------
Mpackages/taler-wallet-core/src/exchanges.ts | 12++++++------
Mpackages/taler-wallet-core/src/instructedAmountConversion.ts | 4++--
Mpackages/taler-wallet-core/src/pay-merchant.ts | 6+++---
Mpackages/taler-wallet-core/src/refresh.ts | 4++--
Mpackages/taler-wallet-core/src/wallet.ts | 4++--
Mpackages/taler-wallet-core/src/withdraw.test.ts | 4++--
Mpackages/taler-wallet-core/src/withdraw.ts | 16++++++++--------
13 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/packages/taler-wallet-core/src/coinSelection.ts b/packages/taler-wallet-core/src/coinSelection.ts @@ -63,7 +63,7 @@ import { PaymentBalanceDetails, } from "./balance.js"; import { getAutoRefreshExecuteThreshold } from "./common.js"; -import { DenominationRecord } from "./db-indexeddb.js"; +import { WalletDenomination } from "./db-common.js"; import { checkExchangeInScopeTx, ExchangeDetails, @@ -1070,7 +1070,7 @@ async function selectPayCandidates( numAvailable += coinAvail.pendingRefreshOutputCount ?? 0; } denoms.push({ - ...DenominationRecord.toDenomInfo(denom), + ...WalletDenomination.toDenomInfo(denom), numAvailable, maxAge: coinAvail.maxAge, }); diff --git a/packages/taler-wallet-core/src/db-common.ts b/packages/taler-wallet-core/src/db-common.ts @@ -1089,7 +1089,7 @@ export interface WalletToken { /** * Denomination record as stored in the wallet's database. */ -export interface DenominationRecord { +export interface WalletDenomination { /** * Currency of the denomination. * @@ -1200,8 +1200,8 @@ export interface DenomFees { feeRefund: AmountString; } -export namespace DenominationRecord { - export function toDenomInfo(d: DenominationRecord): DenominationInfo { +export namespace WalletDenomination { + export function toDenomInfo(d: WalletDenomination): DenominationInfo { return { denomPub: d.denomPub, exchangeMasterPub: d.exchangeMasterPub, diff --git a/packages/taler-wallet-core/src/db-indexeddb.ts b/packages/taler-wallet-core/src/db-indexeddb.ts @@ -110,10 +110,10 @@ import { WalletBackupConfState, WithdrawalGroupStatus, timestampProtocolFromDb, - DenominationRecord, + WalletDenomination, DenomFees, } from "./db-common.js"; -export { DenominationRecord, DenomFees }; +export { DenomFees }; import { DbAccess, DbAccessImpl, @@ -2362,7 +2362,7 @@ export const WalletIndexedDbStoresV1 = { ), denominations: describeStore( "denominations", - describeContents<DenominationRecord>({ + describeContents<WalletDenomination>({ keyPath: ["exchangeBaseUrl", "denomPubHash"], }), { diff --git a/packages/taler-wallet-core/src/dbtx.ts b/packages/taler-wallet-core/src/dbtx.ts @@ -33,7 +33,7 @@ import { WalletPeerPushCredit, WalletPeerPullDebit, WalletToken, - DenominationRecord, + WalletDenomination, DenominationVerificationStatus, OPERATION_STATUS_NONFINAL_FIRST, OPERATION_STATUS_NONFINAL_LAST, @@ -217,16 +217,16 @@ export interface WalletDbTransaction { contractPriv: string, ): Promise<WalletPeerPullDebit | undefined>; - upsertDenomination(rec: DenominationRecord): Promise<void>; + upsertDenomination(rec: WalletDenomination): Promise<void>; getDenomination( exchangeBaseUrl: string, denomPubHash: string, - ): Promise<DenominationRecord | undefined>; + ): Promise<WalletDenomination | undefined>; getDenominationsByVerificationStatus( verificationStatus: DenominationVerificationStatus, - ): Promise<DenominationRecord[]>; + ): Promise<WalletDenomination[]>; getDonationSummaries(): Promise<DonationSummaryRecord[]>; @@ -742,7 +742,7 @@ export class IdbWalletTransaction implements WalletDbTransaction { return this.getPeerPullDebit(r.peerPullDebitId); } - async upsertDenomination(rec: DenominationRecord): Promise<void> { + async upsertDenomination(rec: WalletDenomination): Promise<void> { const tx = this.tx; await tx.denominations.put(rec); } @@ -750,14 +750,14 @@ export class IdbWalletTransaction implements WalletDbTransaction { async getDenomination( exchangeBaseUrl: string, denomPubHash: string, - ): Promise<DenominationRecord | undefined> { + ): Promise<WalletDenomination | undefined> { const tx = this.tx; return await tx.denominations.get([exchangeBaseUrl, denomPubHash]); } async getDenominationsByVerificationStatus( verificationStatus: DenominationVerificationStatus, - ): Promise<DenominationRecord[]> { + ): Promise<WalletDenomination[]> { const tx = this.tx; return await tx.denominations.indexes.byVerificationStatus.getAll( verificationStatus, diff --git a/packages/taler-wallet-core/src/denomSelection.ts b/packages/taler-wallet-core/src/denomSelection.ts @@ -36,7 +36,7 @@ import { DenominationVerificationStatus, timestampAbsoluteFromDb, } from "./db-common.js"; -import { DenominationRecord } from "./db-indexeddb.js"; +import { WalletDenomination } from "./db-common.js"; import { isWithdrawableDenom } from "./denominations.js"; const logger = new Logger("denomSelection.ts"); @@ -74,7 +74,7 @@ export class UnverifiedDenomError extends Error { */ export function selectWithdrawalDenominations( amountAvailable: AmountJson, - denoms: DenominationRecord[], + denoms: WalletDenomination[], opts: { limitCoins?: number } = {}, ): DenomSelectionState { if (denoms.length == 0) { @@ -101,7 +101,7 @@ export function selectWithdrawalDenominations( if (d.verificationStatus === DenominationVerificationStatus.Unverified) { throw new UnverifiedDenomError( "unverified denomination", - DenominationRecord.toDenomInfo(d), + WalletDenomination.toDenomInfo(d), ); } if (!isWithdrawableDenom(d)) { @@ -191,7 +191,7 @@ export function selectWithdrawalDenominations( export function selectForcedWithdrawalDenominations( amountAvailable: AmountJson, - denoms: DenominationRecord[], + denoms: WalletDenomination[], forcedDenomSel: ForcedDenomSel, ): DenomSelectionState { const selectedDenoms: { diff --git a/packages/taler-wallet-core/src/denominations.ts b/packages/taler-wallet-core/src/denominations.ts @@ -35,7 +35,7 @@ import { TaskRunResult } from "./common.js"; import { DenominationVerificationStatus, timestampProtocolFromDb, - DenominationRecord, + WalletDenomination, } from "./db-common.js"; import { WalletDbTransaction } from "./dbtx.js"; import { WalletExecutionContext } from "./index.js"; @@ -469,7 +469,7 @@ export function createTimeline<Type extends object>( * Denominations with an unverified signature * are not considered withdrawable. */ -export function isWithdrawableDenom(d: DenominationRecord): boolean { +export function isWithdrawableDenom(d: WalletDenomination): boolean { if (d.isLost) { logger.trace( `Skipping lost denomination ${d.denomPubHash} of ${d.exchangeBaseUrl}`, @@ -500,7 +500,7 @@ export function isWithdrawableDenom(d: DenominationRecord): boolean { * are considered candidates. */ export function isCandidateWithdrawableDenomRec( - d: DenominationRecord, + d: WalletDenomination, ): boolean { const now = AbsoluteTime.now(); const start = AbsoluteTime.fromProtocolTimestamp( @@ -548,7 +548,7 @@ export function isCandidateWithdrawableDenomInfo(d: DenominationInfo): boolean { export async function isValidDenomRecord( wex: WalletExecutionContext, exchangeMasterPub: string, - d: DenominationRecord, + d: WalletDenomination, ): Promise<boolean> { const res = await wex.cryptoApi.isValidDenom({ masterPub: exchangeMasterPub, @@ -571,7 +571,7 @@ const denomBatchSize = 70; export async function validateDenoms( wex: WalletExecutionContext, - denoms: DenominationRecord[], + denoms: WalletDenomination[], ): Promise<void> { if (denoms.length == 0) { logger.info(`no denominations need to be validated`); @@ -582,7 +582,7 @@ export async function validateDenoms( let current = 0; while (current < denoms.length) { - const updatedDenoms: DenominationRecord[] = []; + const updatedDenoms: WalletDenomination[] = []; for ( let batchIdx = 0; batchIdx < denomBatchSize && current < denoms.length; diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts @@ -148,12 +148,12 @@ import { timestampPreciseToDb, timestampProtocolFromDb, timestampProtocolToDb, + WalletDenomination, } from "./db-common.js"; import { DenomFamilyParams, DenomLossEventRecord, DenominationFamilyRecord, - DenominationRecord, ExchangeDetailsRecord, ExchangeEntryRecord, ExchangeMigrationReason, @@ -2040,7 +2040,7 @@ export async function updateExchangeFromUrlHandler( // In the future: Filter out old denominations by index const allOldDenoms = await tx.denominations.indexes.byExchangeBaseUrl.getAll(exchangeBaseUrl); - const oldDenomByDph = new Map<string, DenominationRecord>(); + const oldDenomByDph = new Map<string, WalletDenomination>(); for (const denom of allOldDenoms) { oldDenomByDph.set(denom.denomPubHash, denom); } @@ -2089,7 +2089,7 @@ export async function updateExchangeFromUrlHandler( // First, find denom family - const denomRec: DenominationRecord = { + const denomRec: WalletDenomination = { currency: keysInfo.currency, denominationFamilySerial, denomPub: currentDenom.denomPub, @@ -2665,7 +2665,7 @@ async function handleRecoup( } function getAutoRefreshExecuteThresholdForDenom( - d: DenominationRecord, + d: WalletDenomination, ): AbsoluteTime { return getAutoRefreshExecuteThreshold({ stampExpireWithdraw: timestampProtocolFromDb(d.stampExpireWithdraw), @@ -2676,7 +2676,7 @@ function getAutoRefreshExecuteThresholdForDenom( /** * Timestamp after which the wallet would do the next check for an auto-refresh. */ -function getAutoRefreshCheckThreshold(d: DenominationRecord): AbsoluteTime { +function getAutoRefreshCheckThreshold(d: WalletDenomination): AbsoluteTime { const expireWithdraw = AbsoluteTime.fromProtocolTimestamp( timestampProtocolFromDb(d.stampExpireWithdraw), ); @@ -3015,7 +3015,7 @@ export async function getExchangeDetailedInfo( } const denominations: DenominationInfo[] = denominationRecords.map((x) => - DenominationRecord.toDenomInfo(x), + WalletDenomination.toDenomInfo(x), ); return { diff --git a/packages/taler-wallet-core/src/instructedAmountConversion.ts b/packages/taler-wallet-core/src/instructedAmountConversion.ts @@ -29,7 +29,7 @@ import { strcmp, } from "@gnu-taler/taler-util"; import { timestampProtocolFromDb } from "./db-common.js"; -import { DenominationRecord } from "./db-indexeddb.js"; +import { WalletDenomination } from "./db-common.js"; import { getExchangeDetailsInTx } from "./exchanges.js"; import { WalletExecutionContext } from "./wallet.js"; @@ -289,7 +289,7 @@ async function getAvailableCoins( } function buildCoinInfoFromDenom( - denom: DenominationRecord, + denom: WalletDenomination, purseFee: AmountJson | undefined, wireFee: AmountJson | undefined, maxAge: number, diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts @@ -150,11 +150,11 @@ import { timestampPreciseToDb, timestampProtocolFromDb, timestampProtocolToDb, + WalletDenomination, } from "./db-common.js"; import { CoinRecord, DbCoinSelection, - DenominationRecord, DonationPlanchetRecord, PurchaseRecord, RefundGroupRecord, @@ -851,7 +851,7 @@ export async function getTotalPaymentCostInTx( const refreshCost = await getTotalRefreshCost( wex, tx, - DenominationRecord.toDenomInfo(denom), + WalletDenomination.toDenomInfo(denom), amountLeft, ); costs.push(Amounts.parseOrThrow(pcs[i].contribution)); @@ -2307,7 +2307,7 @@ export async function generateDepositPermissions( const depositPermissions: CoinDepositPermission[] = []; const coinWithDenom: Array<{ coin: CoinRecord; - denom: DenominationRecord; + denom: WalletDenomination; }> = []; await wex.runLegacyWalletDbTx(async (tx) => { for (let i = 0; i < payCoinSel.coinContributions.length; i++) { diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts @@ -95,13 +95,13 @@ import { RefreshOperationStatus, timestampPreciseFromDb, timestampPreciseToDb, + WalletDenomination, } from "./db-common.js"; import { CoinAvailabilityRecord, CoinHistoryRecord, CoinRecord, CoinSourceType, - DenominationRecord, RefreshGroupPerExchangeInfo, RefreshGroupRecord, RefreshSessionRecord, @@ -384,7 +384,7 @@ export async function getTotalRefreshCost( * to refresh. */ function getTotalRefreshCostInternal( - denoms: DenominationRecord[], + denoms: WalletDenomination[], refreshedDenom: DenominationInfo, amountLeft: AmountJson, ): AmountJson { diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts @@ -316,10 +316,10 @@ import { ConfigRecordKey, timestampAbsoluteFromDb, timestampProtocolToDb, + WalletDenomination, } from "./db-common.js"; import { CoinSourceType, - DenominationRecord, WalletIndexedDbStoresV1, WalletIndexedDbTransaction, applyFixups, @@ -616,7 +616,7 @@ export async function getDenomInfo( ? await tx.getDenomination(exchangeBaseUrl, denomPubHash) : await tx.denominations.get([exchangeBaseUrl, denomPubHash]); if (d != null) { - return DenominationRecord.toDenomInfo(d); + return WalletDenomination.toDenomInfo(d); } else { return undefined; } diff --git a/packages/taler-wallet-core/src/withdraw.test.ts b/packages/taler-wallet-core/src/withdraw.test.ts @@ -27,7 +27,7 @@ import { DenominationVerificationStatus, timestampProtocolToDb, } from "./db-common.js"; -import { DenominationRecord } from "./db-indexeddb.js"; +import { WalletDenomination } from "./db-common.js"; import { selectWithdrawalDenominations } from "./denomSelection.js"; test("withdrawal selection bug repro", (t) => { @@ -60,7 +60,7 @@ test("withdrawal selection bug repro", (t) => { ), ); - const denoms: DenominationRecord[] = [ + const denoms: WalletDenomination[] = [ { denominationFamilySerial: 0, denomPub: { diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts @@ -144,11 +144,11 @@ import { timestampPreciseFromDb, timestampPreciseToDb, timestampProtocolToDb, + WalletDenomination, } from "./db-common.js"; import { CoinRecord, CoinSourceType, - DenominationRecord, OperationRetryRecord, PlanchetRecord, WgInfo, @@ -1257,7 +1257,7 @@ async function getWithdrawableDenoms( wex: WalletExecutionContext, exchangeBaseUrl: string, currency: string, -): Promise<DenominationRecord[]> { +): Promise<WalletDenomination[]> { return await wex.runLegacyWalletDbTx(async (tx) => { return getWithdrawableDenomsTx(wex, tx, exchangeBaseUrl, currency); }); @@ -1276,7 +1276,7 @@ export async function getWithdrawableDenomsTx( exchangeBaseUrl: string, currency: string, maxAmount?: AmountLike, -): Promise<DenominationRecord[]> { +): Promise<WalletDenomination[]> { const dbNow = timestampProtocolToDb(TalerProtocolTimestamp.now()); const allFamilies = await tx.denominationFamilies.indexes.byExchangeBaseUrl.getAll( @@ -1289,7 +1289,7 @@ export async function getWithdrawableDenomsTx( ); logger.trace(`have ${allFamilies.length} families`); } - const relevantDenoms: DenominationRecord[] = []; + const relevantDenoms: WalletDenomination[] = []; for (const fam of allFamilies) { const famCurrency = Amounts.currencyOf(fam.familyParams.value); if (famCurrency != currency) { @@ -1308,7 +1308,7 @@ export async function getWithdrawableDenomsTx( const fpSerial = fam.denominationFamilySerial; checkDbInvariant(typeof fpSerial === "number", "denominationFamilySerial"); // Now we need to find a representative denom for the family. - let denom: DenominationRecord | undefined; + let denom: WalletDenomination | undefined; const denomCursor = tx.denominations.indexes.byDenominationFamilySerialAndStampExpireWithdraw.iter(); const dr0 = await denomCursor.current(); @@ -2015,7 +2015,7 @@ export async function updateWithdrawalDenomsForExchange( await tx.denominationFamilies.indexes.byExchangeBaseUrl.getAll( exchangeBaseUrl, ); - const denominations: DenominationRecord[] | undefined = []; + const denominations: WalletDenomination[] | undefined = []; for (const fam of allFamilies) { const fpSerial = fam.denominationFamilySerial; checkDbInvariant( @@ -2079,7 +2079,7 @@ async function getWithdrawalCandidateDenoms( wex: WalletExecutionContext, exchangeBaseUrl: string, amount: AmountString, -): Promise<DenominationRecord[]> { +): Promise<WalletDenomination[]> { await updateWithdrawalDenomsForExchange(wex, exchangeBaseUrl); return await wex.runLegacyWalletDbTx(async (tx) => { return await getWithdrawableDenomsTx( @@ -2888,7 +2888,7 @@ export async function getExchangeWithdrawalInfo( withdrawalType, }); - let candidateDenoms: DenominationRecord[]; + let candidateDenoms: WalletDenomination[]; let selectedDenoms: DenomSelectionState; if (Amounts.isNonZero(instructedAmount)) {