From 53120dfc3ec05d49fc6f94bb498c66238225dd6b Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 7 Mar 2024 11:46:31 +0100 Subject: rename insufficient balance fields to work for both merchant and p2p payments --- packages/taler-wallet-core/src/balance.ts | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'packages/taler-wallet-core/src/balance.ts') diff --git a/packages/taler-wallet-core/src/balance.ts b/packages/taler-wallet-core/src/balance.ts index 26d348b39..5e3562ba2 100644 --- a/packages/taler-wallet-core/src/balance.ts +++ b/packages/taler-wallet-core/src/balance.ts @@ -51,8 +51,6 @@ */ import { GlobalIDB } from "@gnu-taler/idb-bridge"; import { - AllowedAuditorInfo, - AllowedExchangeInfo, AmountJson, AmountLike, Amounts, @@ -60,12 +58,13 @@ import { BalanceFlag, BalancesResponse, GetBalanceDetailRequest, + j2s, Logger, parsePaytoUri, ScopeInfo, ScopeType, } from "@gnu-taler/taler-util"; -import { findMatchingWire } from "./coinSelection.js"; +import { ExchangeRestrictionSpec, findMatchingWire } from "./coinSelection.js"; import { DepositOperationStatus, OPERATION_STATUS_ACTIVE_FIRST, @@ -462,12 +461,7 @@ export async function getBalances( export interface PaymentRestrictionsForBalance { currency: string; minAge: number; - restrictExchanges: - | { - exchanges: AllowedExchangeInfo[]; - auditors: AllowedAuditorInfo[]; - } - | undefined; + restrictExchanges: ExchangeRestrictionSpec | undefined; restrictWireMethods: string[] | undefined; depositPaytoUri: string | undefined; } @@ -504,12 +498,12 @@ export interface PaymentBalanceDetails { /** * Balance of type "merchant-acceptable" (see balance.ts for definition). */ - balanceMerchantAcceptable: AmountJson; + balanceReceiverAcceptable: AmountJson; /** * Balance of type "merchant-depositable" (see balance.ts for definition). */ - balanceMerchantDepositable: AmountJson; + balanceReceiverDepositable: AmountJson; /** * Balance that's depositable with the exchange. @@ -556,12 +550,14 @@ export async function getPaymentBalanceDetailsInTx( balanceAvailable: Amounts.zeroOfCurrency(req.currency), balanceMaterial: Amounts.zeroOfCurrency(req.currency), balanceAgeAcceptable: Amounts.zeroOfCurrency(req.currency), - balanceMerchantAcceptable: Amounts.zeroOfCurrency(req.currency), - balanceMerchantDepositable: Amounts.zeroOfCurrency(req.currency), + balanceReceiverAcceptable: Amounts.zeroOfCurrency(req.currency), + balanceReceiverDepositable: Amounts.zeroOfCurrency(req.currency), maxEffectiveSpendAmount: Amounts.zeroOfCurrency(req.currency), balanceExchangeDepositable: Amounts.zeroOfCurrency(req.currency), }; + logger.info(`computing balance details for ${j2s(req)}`); + const availableCoins = await tx.coinAvailability.getAll(); for (const ca of availableCoins) { @@ -646,13 +642,13 @@ export async function getPaymentBalanceDetailsInTx( coinAmount, ).amount; if (merchantExchangeAcceptable) { - d.balanceMerchantAcceptable = Amounts.add( - d.balanceMerchantAcceptable, + d.balanceReceiverAcceptable = Amounts.add( + d.balanceReceiverAcceptable, coinAmount, ).amount; if (merchantExchangeDepositable) { - d.balanceMerchantDepositable = Amounts.add( - d.balanceMerchantDepositable, + d.balanceReceiverDepositable = Amounts.add( + d.balanceReceiverDepositable, coinAmount, ).amount; } -- cgit v1.2.3