diff --git a/packages/taler-wallet-cli/src/harness/harness.ts b/packages/taler-wallet-cli/src/harness/harness.ts index b0b4a137a..b53047e5d 100644 --- a/packages/taler-wallet-cli/src/harness/harness.ts +++ b/packages/taler-wallet-cli/src/harness/harness.ts @@ -856,6 +856,9 @@ class PybankService extends BankServiceBase implements BankServiceHandle { } } +// Use libeufin bank instead of pybank. +const useLibeufinBank = process.env.WALLET_HARNESS_WITH_EUFIN; + /** * Return a euFin or a pyBank implementation of * the exported BankService class. This allows @@ -866,7 +869,7 @@ function getBankServiceImpl(): { prototype: typeof PybankService.prototype; create: typeof PybankService.create; } { - if (process.env.WALLET_HARNESS_WITH_EUFIN) + if (useLibeufinBank) return { prototype: EufinBankService.prototype, create: EufinBankService.create, @@ -1003,7 +1006,7 @@ export class ExchangeService implements ExchangeServiceInterface { } async runWirewatchOnce() { - if (process.env.WALLET_HARNESS_WITH_EUFIN) { + if (useLibeufinBank) { // Not even 2 secods showed to be enough! await waitMs(4000); } @@ -2016,7 +2019,7 @@ export function getRandomIban(salt: string | null = null): string { // Only used in one tipping test. export function getWireMethod(): string { - if (process.env.WALLET_HARNESS_WITH_EUFIN) return "iban"; + if (useLibeufinBank) return "iban"; return "x-taler-bank"; } @@ -2025,7 +2028,7 @@ export function getWireMethod(): string { * on whether the banking is served by euFin or Pybank. */ export function getPayto(label: string): string { - if (process.env.WALLET_HARNESS_WITH_EUFIN) + if (useLibeufinBank) return `payto://iban/SANDBOXX/${getRandomIban( label, )}?receiver-name=${label}`; diff --git a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts index dcbf84497..db66aa7d7 100644 --- a/packages/taler-wallet-cli/src/integrationtests/testrunner.ts +++ b/packages/taler-wallet-cli/src/integrationtests/testrunner.ts @@ -222,7 +222,7 @@ export async function runTests(spec: TestRunSpec) { path.join(os.tmpdir(), "taler-integrationtests-"), ); updateCurrentSymlink(testRootDir); - console.log("testsuite root directory: ", testRootDir); + console.log(`testsuite root directory: ${testRootDir}`); const testResults: TestRunResult[] = []; diff --git a/packages/taler-wallet-core/src/bank-api-client.ts b/packages/taler-wallet-core/src/bank-api-client.ts index fb859ece3..a38896983 100644 --- a/packages/taler-wallet-core/src/bank-api-client.ts +++ b/packages/taler-wallet-core/src/bank-api-client.ts @@ -121,8 +121,7 @@ export namespace BankApi { paytoUri = respJson.paytoUri; } } catch (e) { - logger.error("error trying to parse json from response", e); - throw TalerError.fromException(e); + // Do nothing } return { password, diff --git a/packages/taler-wallet-core/src/operations/refund.ts b/packages/taler-wallet-core/src/operations/refund.ts index 28a92286b..4110b4759 100644 --- a/packages/taler-wallet-core/src/operations/refund.ts +++ b/packages/taler-wallet-core/src/operations/refund.ts @@ -25,18 +25,28 @@ */ import { AbortingCoin, - AbortRequest, AbsoluteTime, AmountJson, + AbortRequest, + AbsoluteTime, + AmountJson, Amounts, ApplyRefundResponse, codecForAbortResponse, - codecForMerchantOrderRefundPickupResponse, codecForMerchantOrderStatusPaid, CoinPublicKey, Duration, Logger, + codecForMerchantOrderRefundPickupResponse, + codecForMerchantOrderStatusPaid, + CoinPublicKey, + Duration, + Logger, MerchantCoinRefundFailureStatus, MerchantCoinRefundStatus, MerchantCoinRefundSuccessStatus, NotificationType, - parseRefundUri, PrepareRefundResult, RefreshReason, + parseRefundUri, + PrepareRefundResult, + RefreshReason, TalerErrorCode, - TalerErrorDetail, TalerProtocolTimestamp, URL + TalerErrorDetail, + TalerProtocolTimestamp, + URL, } from "@gnu-taler/taler-util"; import { AbortStatus, @@ -44,21 +54,18 @@ import { PurchaseRecord, RefundReason, RefundState, - WalletStoresV1 + WalletStoresV1, } from "../db.js"; import { InternalWalletState } from "../internal-wallet-state.js"; import { readSuccessResponseJsonOrThrow } from "../util/http.js"; import { checkDbInvariant } from "../util/invariants.js"; import { GetReadWriteAccess } from "../util/query.js"; -import { - RetryInfo -} from "../util/retries.js"; +import { RetryInfo } from "../util/retries.js"; import { guardOperationException } from "./common.js"; import { createRefreshGroup, getTotalRefreshCost } from "./refresh.js"; const logger = new Logger("refund.ts"); - export async function prepareRefund( ws: InternalWalletState, talerRefundUri: string, @@ -88,11 +95,11 @@ export async function prepareRefund( ); } - const awaiting = await queryAndSaveAwaitingRefund(ws, purchase) - const summary = calculateRefundSummary(purchase) + const awaiting = await queryAndSaveAwaitingRefund(ws, purchase); + const summary = calculateRefundSummary(purchase); const proposalId = purchase.proposalId; - const { contractData: c } = purchase.download + const { contractData: c } = purchase.download; return { proposalId, @@ -109,10 +116,9 @@ export async function prepareRefund( summary: c.summary, fulfillmentMessage: c.fulfillmentMessage, summary_i18n: c.summaryI18n, - fulfillmentMessage_i18n: - c.fulfillmentMessageI18n, + fulfillmentMessage_i18n: c.fulfillmentMessageI18n, }, - } + }; } /** * Retry querying and applying refunds for an order later. @@ -496,7 +502,7 @@ async function acceptRefunds( } else { // No error, but we need to try again! p.timestampLastRefundStatus = now; - p.refundStatusRetryInfo = RetryInfo.increment(p.refundStatusRetryInfo) + p.refundStatusRetryInfo = RetryInfo.increment(p.refundStatusRetryInfo); p.lastRefundStatusError = undefined; logger.trace("refund query not done"); } @@ -509,7 +515,6 @@ async function acceptRefunds( }); } - function calculateRefundSummary(p: PurchaseRecord): RefundSummary { let amountRefundGranted = Amounts.getZero( p.download.contractData.amount.currency, @@ -544,7 +549,12 @@ function calculateRefundSummary(p: PurchaseRecord): RefundSummary { ).amount; } }); - return { amountEffectivePaid: p.totalPayCost, amountRefundGone, amountRefundGranted, pendingAtExchange } + return { + amountEffectivePaid: p.totalPayCost, + amountRefundGone, + amountRefundGranted, + pendingAtExchange, + }; } /** @@ -590,14 +600,13 @@ export async function applyRefund( ); } - return applyRefundFromPurchaseId(ws, purchase.proposalId) + return applyRefundFromPurchaseId(ws, purchase.proposalId); } export async function applyRefundFromPurchaseId( ws: InternalWalletState, proposalId: string, ): Promise { - logger.trace("applying refund for purchase", proposalId); logger.info("processing purchase for refund"); @@ -640,7 +649,7 @@ export async function applyRefundFromPurchaseId( throw Error("purchase no longer exists"); } - const summary = calculateRefundSummary(purchase) + const summary = calculateRefundSummary(purchase); return { contractTermsHash: purchase.download.contractData.contractTermsHash, @@ -682,7 +691,8 @@ export async function processPurchaseQueryRefund( async function queryAndSaveAwaitingRefund( ws: InternalWalletState, purchase: PurchaseRecord, - waitForAutoRefund?: boolean): Promise { + waitForAutoRefund?: boolean, +): Promise { const requestUrl = new URL( `orders/${purchase.download.contractData.orderId}`, purchase.download.contractData.merchantBaseUrl, @@ -709,12 +719,22 @@ async function queryAndSaveAwaitingRefund( const refundAwaiting = Amounts.sub( Amounts.parseOrThrow(orderStatus.refund_amount), - Amounts.parseOrThrow(orderStatus.refund_taken) - ).amount + Amounts.parseOrThrow(orderStatus.refund_taken), + ).amount; - console.log("refund waiting found, ", refundAwaiting, orderStatus, purchase.refundAwaiting, purchase.refundAwaiting && Amounts.cmp(refundAwaiting, purchase.refundAwaiting)) + logger.info( + "refund waiting found, ", + refundAwaiting, + orderStatus, + purchase.refundAwaiting, + purchase.refundAwaiting && + Amounts.cmp(refundAwaiting, purchase.refundAwaiting), + ); - if (purchase.refundAwaiting === undefined || Amounts.cmp(refundAwaiting, purchase.refundAwaiting) !== 0) { + if ( + purchase.refundAwaiting === undefined || + Amounts.cmp(refundAwaiting, purchase.refundAwaiting) !== 0 + ) { await ws.db .mktx((x) => ({ purchases: x.purchases })) .runReadWrite(async (tx) => { @@ -723,7 +743,7 @@ async function queryAndSaveAwaitingRefund( logger.warn("purchase does not exist anymore"); return; } - p.refundAwaiting = refundAwaiting + p.refundAwaiting = refundAwaiting; await tx.purchases.put(p); }); } @@ -731,7 +751,6 @@ async function queryAndSaveAwaitingRefund( return refundAwaiting; } - async function processPurchaseQueryRefundImpl( ws: InternalWalletState, proposalId: string, @@ -765,7 +784,11 @@ async function processPurchaseQueryRefundImpl( AbsoluteTime.fromTimestamp(purchase.autoRefundDeadline), ) ) { - const awaitingAmount = await queryAndSaveAwaitingRefund(ws, purchase, waitForAutoRefund) + const awaitingAmount = await queryAndSaveAwaitingRefund( + ws, + purchase, + waitForAutoRefund, + ); if (Amounts.isZero(awaitingAmount)) return; }