summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-01-23 23:50:36 +0100
committerFlorian Dold <florian@dold.me>2024-01-23 23:50:36 +0100
commitaab96ecf602d51fb682aa37d2182f9838cf27393 (patch)
tree3547589991185170b0c771efbc1de753bfb2755d /packages/taler-wallet-core/src/operations
parent937d9204e6c66bdc13e7b770a125d008bdfc6587 (diff)
downloadwallet-core-aab96ecf602d51fb682aa37d2182f9838cf27393.tar.gz
wallet-core-aab96ecf602d51fb682aa37d2182f9838cf27393.tar.bz2
wallet-core-aab96ecf602d51fb682aa37d2182f9838cf27393.zip
wallet-core: fix getTransactionById for refreshes, test it
Fixes bugs.taler.net/n/8234
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts38
1 files changed, 27 insertions, 11 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index 74bc20320..89f756ae9 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -280,8 +280,21 @@ export async function getTransactionById(
}
case TransactionType.Refresh: {
- // FIXME: We should return info about the refresh here!
- throw Error(`no tx for refresh`);
+ // FIXME: We should return info about the refresh here!;
+ const refreshGroupId = parsedTx.refreshGroupId;
+ return await ws.db.runReadOnlyTx(
+ ["refreshGroups", "operationRetries"],
+ async (tx) => {
+ const refreshGroupRec = await tx.refreshGroups.get(refreshGroupId);
+ if (!refreshGroupRec) {
+ throw Error("not found");
+ }
+ const retries = await tx.operationRetries.get(
+ TaskIdentifiers.forRefresh(refreshGroupRec),
+ );
+ return buildTransactionForRefresh(refreshGroupRec, retries);
+ },
+ );
}
case TransactionType.Reward: {
@@ -522,7 +535,7 @@ function buildTransactionForPeerPullCredit(
const silentWithdrawalErrorForInvoice =
wsrOrt?.lastError &&
wsrOrt.lastError.code ===
- TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE &&
+ TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE &&
Object.values(wsrOrt.lastError.errorsPerCoin ?? {}).every((e) => {
return (
e.code === TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR &&
@@ -552,10 +565,10 @@ function buildTransactionForPeerPullCredit(
kycUrl: pullCredit.kycUrl,
...(wsrOrt?.lastError
? {
- error: silentWithdrawalErrorForInvoice
- ? undefined
- : wsrOrt.lastError,
- }
+ error: silentWithdrawalErrorForInvoice
+ ? undefined
+ : wsrOrt.lastError,
+ }
: {}),
};
}
@@ -770,7 +783,9 @@ function buildTransactionForRefresh(
txState: computeRefreshTransactionState(refreshGroupRecord),
txActions: computeRefreshTransactionActions(refreshGroupRecord),
refreshReason: refreshGroupRecord.reason,
- amountEffective: Amounts.stringify(Amounts.sub(outputAmount, inputAmount).amount),
+ amountEffective: Amounts.stringify(
+ Amounts.sub(outputAmount, inputAmount).amount,
+ ),
amountRaw: Amounts.stringify(
Amounts.zeroOfCurrency(refreshGroupRecord.currency),
),
@@ -960,9 +975,10 @@ export async function getWithdrawalTransactionByUri(
x.operationRetries,
])
.runReadWrite(async (tx) => {
- const withdrawalGroupRecord = await tx.withdrawalGroups.indexes.byTalerWithdrawUri.get(
- request.talerWithdrawUri,
- );
+ const withdrawalGroupRecord =
+ await tx.withdrawalGroups.indexes.byTalerWithdrawUri.get(
+ request.talerWithdrawUri,
+ );
if (!withdrawalGroupRecord) {
return undefined;