From d50294f76e0aa357d690a933bb6d696a2f6aef1b Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 2 Nov 2022 17:42:14 +0100 Subject: wallet-core: DB FIXMEs (amount format) --- packages/taler-wallet-core/src/util/coinSelection.ts | 2 +- packages/taler-wallet-core/src/util/denominations.test.ts | 5 +++-- packages/taler-wallet-core/src/util/denominations.ts | 11 ++++++----- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'packages/taler-wallet-core/src/util') diff --git a/packages/taler-wallet-core/src/util/coinSelection.ts b/packages/taler-wallet-core/src/util/coinSelection.ts index 12f87a920..cadf8d829 100644 --- a/packages/taler-wallet-core/src/util/coinSelection.ts +++ b/packages/taler-wallet-core/src/util/coinSelection.ts @@ -139,7 +139,7 @@ export function tallyFees( if (!tally.wireFeeCoveredForExchange.has(exchangeBaseUrl)) { const wf = - wireFeesPerExchange[exchangeBaseUrl] ?? Amounts.getZero(currency); + wireFeesPerExchange[exchangeBaseUrl] ?? Amounts.zeroOfCurrency(currency); const wfForgiven = Amounts.min(amountWireFeeLimitRemaining, wf); amountWireFeeLimitRemaining = Amounts.sub( amountWireFeeLimitRemaining, diff --git a/packages/taler-wallet-core/src/util/denominations.test.ts b/packages/taler-wallet-core/src/util/denominations.test.ts index 9c93331a3..551e06a33 100644 --- a/packages/taler-wallet-core/src/util/denominations.test.ts +++ b/packages/taler-wallet-core/src/util/denominations.test.ts @@ -25,6 +25,7 @@ import { FeeDescriptionPair, Amounts, DenominationInfo, + AmountString, } from "@gnu-taler/taler-util"; // import { expect } from "chai"; import { @@ -37,8 +38,8 @@ import test, { ExecutionContext } from "ava"; /** * Create some constants to be used as reference in the tests */ -const VALUES = Array.from({ length: 10 }).map((undef, t) => - Amounts.parseOrThrow(`USD:${t}`), +const VALUES: AmountString[] = Array.from({ length: 10 }).map( + (undef, t) => `USD:${t}`, ); const TIMESTAMPS = Array.from({ length: 20 }).map((undef, t_s) => ({ t_s })); const ABS_TIME = TIMESTAMPS.map((m) => AbsoluteTime.fromTimestamp(m)); diff --git a/packages/taler-wallet-core/src/util/denominations.ts b/packages/taler-wallet-core/src/util/denominations.ts index 9cd931acd..c05df6c6e 100644 --- a/packages/taler-wallet-core/src/util/denominations.ts +++ b/packages/taler-wallet-core/src/util/denominations.ts @@ -18,6 +18,7 @@ import { AbsoluteTime, AmountJson, Amounts, + AmountString, DenominationInfo, FeeDescription, FeeDescriptionPair, @@ -51,7 +52,7 @@ export function selectBestForOverlappingDenominations< return minDeposit; } -export function selectMinimumFee( +export function selectMinimumFee( list: T[], ): T | undefined { let minFee: T | undefined = undefined; @@ -285,7 +286,7 @@ export function createTimeline( idProp: PropsWithReturnType, periodStartProp: PropsWithReturnType, periodEndProp: PropsWithReturnType, - feeProp: PropsWithReturnType, + feeProp: PropsWithReturnType, groupProp: PropsWithReturnType | undefined, selectBestForOverlapping: (l: Type[]) => Type | undefined, ): FeeDescription[] { @@ -312,7 +313,7 @@ export function createTimeline( } ps.push({ type: "start", - fee, + fee: Amounts.stringify(fee), group, id, moment: AbsoluteTime.fromTimestamp(stampStart), @@ -320,7 +321,7 @@ export function createTimeline( }); ps.push({ type: "end", - fee, + fee: Amounts.stringify(fee), group, id, moment: AbsoluteTime.fromTimestamp(stampEnd), @@ -416,7 +417,7 @@ export function createTimeline( group: cursor.group, from: cursor.moment, until: AbsoluteTime.never(), //not yet known - fee: currentFee, + fee: Amounts.stringify(currentFee), }); } else { prev.until = cursor.moment; -- cgit v1.2.3