From a66b636dee2ed531bb5119feced80d6569d99176 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 14 Sep 2022 21:27:03 +0200 Subject: wallet-core: restructure denomination record for easier querying --- packages/taler-wallet-core/src/dbless.ts | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'packages/taler-wallet-core/src/dbless.ts') 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, + }, })), }); -- cgit v1.2.3