From 0c8e56c32457ea9b9229a8a3607fcf8e7618bc17 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 14 Oct 2022 22:47:11 +0200 Subject: wallet-core: properly separate different types of IDs --- packages/taler-wallet-core/src/operations/common.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/common.ts') diff --git a/packages/taler-wallet-core/src/operations/common.ts b/packages/taler-wallet-core/src/operations/common.ts index d69bc09f8..d17530c7f 100644 --- a/packages/taler-wallet-core/src/operations/common.ts +++ b/packages/taler-wallet-core/src/operations/common.ts @@ -25,6 +25,7 @@ import { RefreshReason, TalerErrorCode, TalerErrorDetail, + TombstoneIdStr, TransactionIdStr, TransactionType, } from "@gnu-taler/taler-util"; @@ -280,9 +281,19 @@ export enum TombstoneTag { /** * Create an event ID from the type and the primary key for the event. */ -export function makeEventId( - type: TransactionType | TombstoneTag, +export function makeTransactionId( + type: TransactionType, ...args: string[] -): string { - return type + ":" + args.map((x) => encodeURIComponent(x)).join(":"); +): TransactionIdStr { + return `txn:${type}:${args.map((x) => encodeURIComponent(x)).join(":")}`; +} + +/** + * Create an event ID from the type and the primary key for the event. + */ +export function makeTombstoneId( + type: TombstoneTag, + ...args: string[] +): TombstoneIdStr { + return `tmb:${type}:${args.map((x) => encodeURIComponent(x)).join(":")}`; } -- cgit v1.2.3