From 87bc4a6fcd3b274f25ffe9a74196aa5f4f586b7e Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 2 Nov 2022 12:50:34 +0100 Subject: wallet-core: fix recoup issue --- .../src/operations/transactions.ts | 54 ++++++++++++---------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/transactions.ts') diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index 3f1d0a224..54cb84926 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -51,6 +51,7 @@ import { WalletContractData, } from "../db.js"; import { InternalWalletState } from "../internal-wallet-state.js"; +import { assertUnreachable } from "../util/assertUnreachable.js"; import { checkDbInvariant } from "../util/invariants.js"; import { RetryTags } from "../util/retries.js"; import { @@ -803,33 +804,36 @@ export async function getTransactions( const opId = RetryTags.forWithdrawal(wsr); const ort = await tx.operationRetries.get(opId); - if (wsr.wgInfo.withdrawalType === WithdrawalRecordType.PeerPullCredit) { - transactions.push(buildTransactionForPullPaymentCredit(wsr, ort)); - return; - } else if ( - wsr.wgInfo.withdrawalType === WithdrawalRecordType.PeerPushCredit - ) { - transactions.push(buildTransactionForPushPaymentCredit(wsr, ort)); - return; - } else if ( - wsr.wgInfo.withdrawalType === WithdrawalRecordType.BankIntegrated - ) { - transactions.push( - buildTransactionForBankIntegratedWithdraw(wsr, ort), - ); - } else { - const exchangeDetails = await getExchangeDetails( - tx, - wsr.exchangeBaseUrl, - ); - if (!exchangeDetails) { - // FIXME: report somehow + switch (wsr.wgInfo.withdrawalType) { + case WithdrawalRecordType.PeerPullCredit: + transactions.push(buildTransactionForPullPaymentCredit(wsr, ort)); return; - } + case WithdrawalRecordType.PeerPushCredit: + transactions.push(buildTransactionForPushPaymentCredit(wsr, ort)); + return; + case WithdrawalRecordType.BankIntegrated: + transactions.push( + buildTransactionForBankIntegratedWithdraw(wsr, ort), + ); + return; + case WithdrawalRecordType.BankManual: { + const exchangeDetails = await getExchangeDetails( + tx, + wsr.exchangeBaseUrl, + ); + if (!exchangeDetails) { + // FIXME: report somehow + return; + } - transactions.push( - buildTransactionForManualWithdraw(wsr, exchangeDetails, ort), - ); + transactions.push( + buildTransactionForManualWithdraw(wsr, exchangeDetails, ort), + ); + return; + } + case WithdrawalRecordType.Recoup: + // FIXME: Do we also report a transaction here? + return; } }); -- cgit v1.2.3