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: derive DD37 for


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: derive DD37 for tipping
Date: Mon, 24 Apr 2023 21:39:32 +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 ce41337bd wallet-core: derive DD37 for tipping
ce41337bd is described below

commit ce41337bd1f15a82706808d02660d6550c7ab9fc
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Apr 24 21:39:28 2023 +0200

    wallet-core: derive DD37 for tipping
---
 packages/taler-util/src/transactions-types.ts      |  2 ++
 packages/taler-wallet-core/src/operations/tip.ts   | 27 ++++++++++++++++++++++
 .../src/operations/transactions.ts                 |  8 +++----
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/packages/taler-util/src/transactions-types.ts 
b/packages/taler-util/src/transactions-types.ts
index 29ddb22a3..017e54e0a 100644
--- a/packages/taler-util/src/transactions-types.ts
+++ b/packages/taler-util/src/transactions-types.ts
@@ -103,6 +103,8 @@ export enum TransactionMinorState {
   KycRequired = "kyc-required",
   Track = "track",
   Refresh = "refresh",
+  Pickup = "pickup",
+  User = "user",
 }
 
 export interface TransactionsResponse {
diff --git a/packages/taler-wallet-core/src/operations/tip.ts 
b/packages/taler-wallet-core/src/operations/tip.ts
index b37288079..5bcf609b5 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -35,6 +35,9 @@ import {
   TalerErrorCode,
   TalerProtocolTimestamp,
   TipPlanchetDetail,
+  TransactionMajorState,
+  TransactionMinorState,
+  TransactionState,
   TransactionType,
   URL,
 } from "@gnu-taler/taler-util";
@@ -67,6 +70,30 @@ import { selectWithdrawalDenominations } from 
"../util/coinSelection.js";
 
 const logger = new Logger("operations/tip.ts");
 
+/**
+ * Get the (DD37-style) transaction status based on the
+ * database record of a tip.
+ */
+export function computeTipTransactionStatus(
+  tipRecord: TipRecord,
+): TransactionState {
+  if (tipRecord.pickedUpTimestamp) {
+    return {
+      major: TransactionMajorState.Done,
+    };
+  }
+  if (tipRecord.acceptedTimestamp) {
+    return {
+      major: TransactionMajorState.Pending,
+      minor: TransactionMinorState.Pickup,
+    };  
+  }
+  return {
+    major: TransactionMajorState.Pending,
+    minor: TransactionMinorState.User,
+  };
+}
+
 export async function prepareTip(
   ws: InternalWalletState,
   talerTipUri: string,
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 1a511583a..674d4959c 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -68,7 +68,7 @@ import {
 import { InternalWalletState } from "../internal-wallet-state.js";
 import { PendingTaskType } from "../pending-types.js";
 import { assertUnreachable } from "../util/assertUnreachable.js";
-import { checkDbInvariant } from "../util/invariants.js";
+import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
 import { constructTaskIdentifier, TaskIdentifiers } from "../util/retries.js";
 import {
   makeTombstoneId,
@@ -92,7 +92,7 @@ import {
 } from "./pay-merchant.js";
 import { processPeerPullCredit } from "./pay-peer.js";
 import { processRefreshGroup } from "./refresh.js";
-import { processTip } from "./tip.js";
+import { computeTipTransactionStatus, processTip } from "./tip.js";
 import {
   augmentPaytoUrisForWithdrawal,
   processWithdrawalGroup,
@@ -823,11 +823,11 @@ function buildTransactionForTip(
   tipRecord: TipRecord,
   ort?: OperationRetryRecord,
 ): Transaction {
-  if (!tipRecord.acceptedTimestamp) throw Error("");
+  checkLogicInvariant(!!tipRecord.acceptedTimestamp);
 
   return {
     type: TransactionType.Tip,
-    txState: mkTxStateUnknown(),
+    txState: computeTipTransactionStatus(tipRecord),
     amountEffective: Amounts.stringify(tipRecord.tipAmountEffective),
     amountRaw: Amounts.stringify(tipRecord.tipAmountRaw),
     extendedStatus: tipRecord.pickedUpTimestamp

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