aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/util
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-11-02 17:42:14 +0100
committerFlorian Dold <florian@dold.me>2022-11-02 18:23:17 +0100
commitd50294f76e0aa357d690a933bb6d696a2f6aef1b (patch)
treeabe961337c5df1614b5095bce6c5b09e761cda2c /packages/taler-wallet-core/src/util
parent6c3ef31d9a7ba44829e779afed0af9be3ab23723 (diff)
downloadwallet-core-d50294f76e0aa357d690a933bb6d696a2f6aef1b.tar.xz
wallet-core: DB FIXMEs (amount format)
Diffstat (limited to 'packages/taler-wallet-core/src/util')
-rw-r--r--packages/taler-wallet-core/src/util/coinSelection.ts2
-rw-r--r--packages/taler-wallet-core/src/util/denominations.test.ts5
-rw-r--r--packages/taler-wallet-core/src/util/denominations.ts11
3 files changed, 10 insertions, 8 deletions
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<T extends { fee: AmountJson }>(
+export function selectMinimumFee<T extends { fee: AmountString }>(
list: T[],
): T | undefined {
let minFee: T | undefined = undefined;
@@ -285,7 +286,7 @@ export function createTimeline<Type extends object>(
idProp: PropsWithReturnType<Type, string>,
periodStartProp: PropsWithReturnType<Type, TalerProtocolTimestamp>,
periodEndProp: PropsWithReturnType<Type, TalerProtocolTimestamp>,
- feeProp: PropsWithReturnType<Type, AmountJson>,
+ feeProp: PropsWithReturnType<Type, AmountString>,
groupProp: PropsWithReturnType<Type, string> | undefined,
selectBestForOverlapping: (l: Type[]) => Type | undefined,
): FeeDescription[] {
@@ -312,7 +313,7 @@ export function createTimeline<Type extends object>(
}
ps.push({
type: "start",
- fee,
+ fee: Amounts.stringify(fee),
group,
id,
moment: AbsoluteTime.fromTimestamp(stampStart),
@@ -320,7 +321,7 @@ export function createTimeline<Type extends object>(
});
ps.push({
type: "end",
- fee,
+ fee: Amounts.stringify(fee),
group,
id,
moment: AbsoluteTime.fromTimestamp(stampEnd),
@@ -416,7 +417,7 @@ export function createTimeline<Type extends object>(
group: cursor.group,
from: cursor.moment,
until: AbsoluteTime.never(), //not yet known
- fee: currentFee,
+ fee: Amounts.stringify(currentFee),
});
} else {
prev.until = cursor.moment;