aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/common.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-05-24 14:59:54 +0200
committerFlorian Dold <florian@dold.me>2023-05-24 14:59:54 +0200
commit318f54418467e31c9b4b71d82d2cf00932fc167c (patch)
tree1153a9c89e6acfcf4ca06652e00b6705ba970076 /packages/taler-wallet-core/src/operations/common.ts
parenta2ef2e391a8f030857d0f9cd56c6157cffb33659 (diff)
downloadwallet-core-318f54418467e31c9b4b71d82d2cf00932fc167c.tar.xz
wallet-core: implement deletion for new refund implementation
Diffstat (limited to 'packages/taler-wallet-core/src/operations/common.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/common.ts19
1 files changed, 18 insertions, 1 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}`;
+ }
+}