gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: -implement getTransaction for


From: gnunet
Subject: [taler-wallet-core] branch master updated: -implement getTransaction for p2p credit txns
Date: Mon, 20 Feb 2023 03:36:52 +0100

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 bd9904f6a -implement getTransaction for p2p credit txns
bd9904f6a is described below

commit bd9904f6a057a6722f5ede036879a118bf0520a0
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Feb 20 03:36:46 2023 +0100

    -implement getTransaction for p2p credit txns
---
 .../src/operations/transactions.ts                 | 81 +++++++++++++++++++---
 1 file changed, 72 insertions(+), 9 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index c988e1e84..faac808b1 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -136,10 +136,7 @@ export async function getTransactionById(
   req: TransactionByIdRequest,
 ): Promise<Transaction> {
   const { type, args: rest } = parseId("txn", req.transactionId);
-  if (
-    type === TransactionType.Withdrawal ||
-    type === TransactionType.PeerPullCredit
-  ) {
+  if (type === TransactionType.Withdrawal) {
     const withdrawalGroupId = rest[0];
     return await ws.db
       .mktx((x) => [
@@ -341,11 +338,77 @@ export async function getTransactionById(
         return buildTransactionForPushPaymentDebit(debit, ct.contractTermsRaw);
       });
   } else if (type === TransactionType.PeerPushCredit) {
-    // FIXME: Implement!
-    throw Error("getTransaction not yet implemented for PeerPushCredit");
-  } else if (type === TransactionType.PeerPushCredit) {
-    // FIXME: Implement!
-    throw Error("getTransaction not yet implemented for PeerPullCredit");
+    const peerPushPaymentIncomingId = rest[0];
+    return await ws.db
+      .mktx((x) => [
+        x.peerPushPaymentIncoming,
+        x.contractTerms,
+        x.withdrawalGroups,
+        x.operationRetries,
+      ])
+      .runReadWrite(async (tx) => {
+        const pushInc = await tx.peerPushPaymentIncoming.get(
+          peerPushPaymentIncomingId,
+        );
+        if (!pushInc) throw Error("not found");
+        const ct = await tx.contractTerms.get(pushInc.contractTermsHash);
+        checkDbInvariant(!!ct);
+
+        let wg: WithdrawalGroupRecord | undefined = undefined;
+        let wgOrt: OperationRetryRecord | undefined = undefined;
+        if (pushInc.withdrawalGroupId) {
+          wg = await tx.withdrawalGroups.get(pushInc.withdrawalGroupId);
+          if (wg) {
+            const withdrawalOpId = RetryTags.forWithdrawal(wg);
+            wgOrt = await tx.operationRetries.get(withdrawalOpId);
+          }
+        }
+        const pushIncOpId = RetryTags.forPeerPushCredit(pushInc);
+        let pushIncOrt = await tx.operationRetries.get(pushIncOpId);
+
+        return buildTransactionForPeerPushCredit(
+          pushInc,
+          pushIncOrt,
+          ct.contractTermsRaw,
+          wg,
+          wgOrt,
+        );
+      });
+  } else if (type === TransactionType.PeerPullCredit) {
+    const pursePub = rest[0];
+    return await ws.db
+      .mktx((x) => [
+        x.peerPullPaymentInitiations,
+        x.contractTerms,
+        x.withdrawalGroups,
+        x.operationRetries,
+      ])
+      .runReadWrite(async (tx) => {
+        const pushInc = await tx.peerPullPaymentInitiations.get(pursePub);
+        if (!pushInc) throw Error("not found");
+        const ct = await tx.contractTerms.get(pushInc.contractTermsHash);
+        checkDbInvariant(!!ct);
+
+        let wg: WithdrawalGroupRecord | undefined = undefined;
+        let wgOrt: OperationRetryRecord | undefined = undefined;
+        if (pushInc.withdrawalGroupId) {
+          wg = await tx.withdrawalGroups.get(pushInc.withdrawalGroupId);
+          if (wg) {
+            const withdrawalOpId = RetryTags.forWithdrawal(wg);
+            wgOrt = await tx.operationRetries.get(withdrawalOpId);
+          }
+        }
+        const pushIncOpId = RetryTags.forPeerPullPaymentInitiation(pushInc);
+        let pushIncOrt = await tx.operationRetries.get(pushIncOpId);
+
+        return buildTransactionForPeerPullCredit(
+          pushInc,
+          pushIncOrt,
+          ct.contractTermsRaw,
+          wg,
+          wgOrt,
+        );
+      });
   } else {
     const unknownTxType: never = type;
     throw Error(`can't retrieve a '${unknownTxType}' transaction`);

-- 
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]