[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: sync parseTx with the new mak
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: sync parseTx with the new makeTx |
Date: |
Mon, 17 Oct 2022 18:36:47 +0200 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 995b6b4e9 sync parseTx with the new makeTx
995b6b4e9 is described below
commit 995b6b4e96e2bd750d2d42f7ff806f4e2efb2d19
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Mon Oct 17 13:36:39 2022 -0300
sync parseTx with the new makeTx
---
.../taler-wallet-core/src/operations/common.ts | 22 ++++++++++++++++++++++
.../src/operations/transactions.ts | 11 +++++++----
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/packages/taler-wallet-core/src/operations/common.ts
b/packages/taler-wallet-core/src/operations/common.ts
index 95441be2b..2bed195a1 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -306,6 +306,28 @@ export function makeTransactionId(
return `txn:${type}:${args.map((x) => encodeURIComponent(x)).join(":")}`;
}
+export function parseTransactionId(txId: string): {
+ type: TransactionType;
+ args: string[];
+} {
+ const txnParts = txId.split(":");
+ if (txnParts.length < 3) {
+ throw Error("transactionId should have al least 3 parts separated by ':'");
+ }
+ const [txn, typeStr, ...args] = txnParts;
+ const type = typeStr as TransactionType;
+
+ if (txn !== "txn") {
+ throw Error("transactionId should start with txn");
+ }
+
+ if (args.length === 0) {
+ throw Error("transactionId should have one or more arguments");
+ }
+
+ return { type, args };
+}
+
/**
* Create an event ID from the type and the primary key for the event.
*/
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts
b/packages/taler-wallet-core/src/operations/transactions.ts
index b9f8dfdc6..5c903a649 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -53,7 +53,12 @@ import {
import { InternalWalletState } from "../internal-wallet-state.js";
import { checkDbInvariant } from "../util/invariants.js";
import { RetryTags } from "../util/retries.js";
-import { makeTombstoneId, makeTransactionId, TombstoneTag } from "./common.js";
+import {
+ makeTombstoneId,
+ makeTransactionId,
+ parseTransactionId,
+ TombstoneTag,
+} from "./common.js";
import { processDepositGroup } from "./deposits.js";
import { getExchangeDetails } from "./exchanges.js";
import {
@@ -117,9 +122,7 @@ export async function getTransactionById(
ws: InternalWalletState,
req: TransactionByIdRequest,
): Promise<Transaction> {
- const [typeStr, ...rest] = req.transactionId.split(":");
- const type = typeStr as TransactionType;
-
+ const { type, args: rest } = parseTransactionId(req.transactionId);
if (
type === TransactionType.Withdrawal ||
type === TransactionType.PeerPullCredit ||
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: sync parseTx with the new makeTx,
gnunet <=