gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: wallet-core: implement deleti


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: implement deletion for new refund implementation
Date: Wed, 24 May 2023 14:59:58 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 318f54418 wallet-core: implement deletion for new refund implementation
318f54418 is described below

commit 318f54418467e31c9b4b71d82d2cf00932fc167c
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed May 24 14:59:54 2023 +0200

    wallet-core: implement deletion for new refund implementation
---
 packages/taler-wallet-core/src/operations/common.ts   | 19 ++++++++++++++++++-
 .../taler-wallet-core/src/operations/transactions.ts  | 18 +++++++++++++++++-
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/common.ts 
b/packages/taler-wallet-core/src/operations/common.ts
index 95551010c..d75869043 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -362,9 +362,10 @@ export enum TombstoneTag {
   DeletePeerPushCredit = "delete-peer-push-credit",
 }
 
-
 /**
  * Create an event ID from the type and the primary key for the event.
+ * 
+ * @deprecated use constructTombstone instead
  */
 export function makeTombstoneId(type: TombstoneTag, ...args: string[]): string 
{
   return `tmb:${type}:${args.map((x) => encodeURIComponent(x)).join(":")}`;
@@ -458,3 +459,19 @@ export function runLongpollAsync(
   };
   asyncFn();
 }
+
+export type ParsedTombstone =
+  | {
+      tag: TombstoneTag.DeleteWithdrawalGroup;
+      withdrawalGroupId: string;
+    }
+  | { tag: TombstoneTag.DeleteRefund; refundGroupId: string };
+
+export function constructTombstone(p: ParsedTombstone): string {
+  switch (p.tag) {
+    case TombstoneTag.DeleteWithdrawalGroup:
+      return `tmb:${p.tag}:${p.withdrawalGroupId}`;
+    case TombstoneTag.DeleteRefund:
+      return `tmb:${p.tag}:${p.refundGroupId}`;
+  }
+}
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 41c74f4d1..647b9dd90 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -71,6 +71,7 @@ import { assertUnreachable } from 
"../util/assertUnreachable.js";
 import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
 import { constructTaskIdentifier, TaskIdentifiers } from "../util/retries.js";
 import {
+  constructTombstone,
   makeTombstoneId,
   resetOperationTimeout,
   runOperationWithErrorReporting,
@@ -1615,7 +1616,22 @@ export async function deleteTransaction(
     }
 
     case TransactionType.Refund: {
-      // FIXME: Implement!
+      const refundGroupId = parsedTx.refundGroupId;
+      await ws.db
+        .mktx((x) => [x.refundGroups, x.tombstones])
+        .runReadWrite(async (tx) => {
+          const refundRecord = await tx.refundGroups.get(refundGroupId);
+          if (!refundRecord) {
+            return;
+          }
+          await tx.refundGroups.delete(refundGroupId);
+          await tx.tombstones.put({
+            id: constructTombstone({
+              tag: TombstoneTag.DeleteRefund,
+              refundGroupId,
+            }),
+          });
+        });
       return;
     }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]