summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/dbless.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-09-14 21:27:03 +0200
committerFlorian Dold <florian@dold.me>2022-09-14 21:27:03 +0200
commita66b636dee2ed531bb5119feced80d6569d99176 (patch)
treed19b83739531220051ab850bfe3dd9478f7fca6b /packages/taler-wallet-core/src/dbless.ts
parentc021876b41bff11ad28c3a43808795fa0d02ce99 (diff)
downloadwallet-core-a66b636dee2ed531bb5119feced80d6569d99176.tar.gz
wallet-core-a66b636dee2ed531bb5119feced80d6569d99176.tar.bz2
wallet-core-a66b636dee2ed531bb5119feced80d6569d99176.zip
wallet-core: restructure denomination record for easier querying
Diffstat (limited to 'packages/taler-wallet-core/src/dbless.ts')
-rw-r--r--packages/taler-wallet-core/src/dbless.ts28
1 files changed, 21 insertions, 7 deletions
diff --git a/packages/taler-wallet-core/src/dbless.ts b/packages/taler-wallet-core/src/dbless.ts
index 3a775c3f1..652ba8f53 100644
--- a/packages/taler-wallet-core/src/dbless.ts
+++ b/packages/taler-wallet-core/src/dbless.ts
@@ -48,6 +48,7 @@ import {
UnblindedSignature,
BankWithdrawDetails,
parseWithdrawUri,
+ AmountJson,
} from "@gnu-taler/taler-util";
import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
import { DenominationRecord } from "./db.js";
@@ -158,11 +159,15 @@ export async function withdrawCoin(args: {
const planchet = await cryptoApi.createPlanchet({
coinIndex: 0,
denomPub: denom.denomPub,
- feeWithdraw: denom.feeWithdraw,
+ feeWithdraw: denom.fees.feeWithdraw,
reservePriv: reserveKeyPair.reservePriv,
reservePub: reserveKeyPair.reservePub,
secretSeed: encodeCrock(getRandomBytes(32)),
- value: denom.value,
+ value: {
+ currency: denom.currency,
+ fraction: denom.amountFrac,
+ value: denom.amountVal,
+ },
});
const reqBody: ExchangeWithdrawRequest = {
@@ -192,8 +197,8 @@ export async function withdrawCoin(args: {
denomSig: ubSig,
denomPub: denom.denomPub,
denomPubHash: denom.denomPubHash,
- feeDeposit: Amounts.stringify(denom.feeDeposit),
- feeRefresh: Amounts.stringify(denom.feeRefresh),
+ feeDeposit: Amounts.stringify(denom.fees.feeDeposit),
+ feeRefresh: Amounts.stringify(denom.fees.feeRefresh),
exchangeBaseUrl: args.exchangeBaseUrl,
};
}
@@ -203,7 +208,12 @@ export function findDenomOrThrow(
amount: AmountString,
): DenominationRecord {
for (const d of exchangeInfo.keys.currentDenominations) {
- if (Amounts.cmp(d.value, amount) === 0 && isWithdrawableDenom(d)) {
+ const value: AmountJson = {
+ currency: d.currency,
+ fraction: d.amountFrac,
+ value: d.amountVal,
+ };
+ if (Amounts.cmp(value, amount) === 0 && isWithdrawableDenom(d)) {
return d;
}
}
@@ -281,8 +291,12 @@ export async function refreshCoin(req: {
count: 1,
denomPub: x.denomPub,
denomPubHash: x.denomPubHash,
- feeWithdraw: x.feeWithdraw,
- value: x.value,
+ feeWithdraw: x.fees.feeWithdraw,
+ value: {
+ currency: x.currency,
+ fraction: x.amountFrac,
+ value: x.amountVal,
+ },
})),
});