aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-wallet-core/src/operations/deposits.ts33
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts14
2 files changed, 24 insertions, 23 deletions
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts
index dc743e17f..a36091165 100644
--- a/packages/taler-wallet-core/src/operations/deposits.ts
+++ b/packages/taler-wallet-core/src/operations/deposits.ts
@@ -79,7 +79,7 @@ import {
import { InternalWalletState } from "../internal-wallet-state.js";
import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http";
import { OperationAttemptResult } from "../util/retries.js";
-import { spendCoins } from "./common.js";
+import { spendCoins, TombstoneTag } from "./common.js";
import { getExchangeDetails } from "./exchanges.js";
import {
extractContractData,
@@ -166,15 +166,15 @@ export function computeDepositTransactionStatus(
case DepositOperationStatus.Aborted:
return {
major: TransactionMajorState.Aborted,
- }
+ };
case DepositOperationStatus.Failed:
return {
major: TransactionMajorState.Failed,
- }
+ };
case DepositOperationStatus.SuspendedAborting:
return {
major: TransactionMajorState.SuspendedAborting,
- }
+ };
default:
throw Error(`unexpected deposit group state (${dg.operationStatus})`);
}
@@ -351,10 +351,21 @@ export async function cancelAbortingDepositGroup(
export async function deleteDepositGroup(
ws: InternalWalletState,
- depositGroupId: boolean,
- opts: { forced?: boolean } = {},
+ depositGroupId: string,
) {
- throw Error("not implemented");
+ // FIXME: We should check first if we are in a final state
+ // where deletion is allowed.
+ await ws.db
+ .mktx((x) => [x.depositGroups, x.tombstones])
+ .runReadWrite(async (tx) => {
+ const tipRecord = await tx.depositGroups.get(depositGroupId);
+ if (tipRecord) {
+ await tx.depositGroups.delete(depositGroupId);
+ await tx.tombstones.put({
+ id: TombstoneTag.DeleteDepositGroup + ":" + depositGroupId,
+ });
+ }
+ });
}
/**
@@ -503,7 +514,9 @@ async function refundDepositGroup(
method: "POST",
body: refundReq,
});
- logger.info(`coin ${i} refund HTTP status for coin: ${httpResp.status}`);
+ logger.info(
+ `coin ${i} refund HTTP status for coin: ${httpResp.status}`,
+ );
let newStatus: DepositElementStatus;
if (httpResp.status === 200) {
// FIXME: validate response
@@ -564,7 +577,6 @@ async function refundDepositGroup(
await tx.depositGroups.put(newDg);
});
-
return OperationAttemptResult.pendingEmpty();
}
@@ -742,8 +754,7 @@ export async function processDepositGroup(
dg.trackingState = {};
}
- dg.trackingState[newWiredCoin.id] =
- newWiredCoin.value;
+ dg.trackingState[newWiredCoin.id] = newWiredCoin.value;
}
await tx.depositGroups.put(dg);
});
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index 84f879f58..e3cfa0c25 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -77,6 +77,7 @@ import {
abortDepositGroup,
cancelAbortingDepositGroup,
computeDepositTransactionStatus,
+ deleteDepositGroup,
processDepositGroup,
resumeDepositGroup,
suspendDepositGroup,
@@ -1601,18 +1602,7 @@ export async function deleteTransaction(
case TransactionType.Deposit: {
const depositGroupId = parsedTx.depositGroupId;
- await ws.db
- .mktx((x) => [x.depositGroups, x.tombstones])
- .runReadWrite(async (tx) => {
- const tipRecord = await tx.depositGroups.get(depositGroupId);
- if (tipRecord) {
- await tx.depositGroups.delete(depositGroupId);
- await tx.tombstones.put({
- id: TombstoneTag.DeleteDepositGroup + ":" + depositGroupId,
- });
- }
- });
-
+ await deleteDepositGroup(ws, depositGroupId);
return;
}