gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: tipping transaction list entr


From: gnunet
Subject: [taler-wallet-core] branch master updated: tipping transaction list entry, integration test and DB simplifications
Date: Tue, 08 Sep 2020 16:24:45 +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 043a5f89 tipping transaction list entry, integration test and DB 
simplifications
043a5f89 is described below

commit 043a5f89fe020bbb55170a9fc355c3d699ad8761
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Tue Sep 8 19:54:23 2020 +0530

    tipping transaction list entry, integration test and DB simplifications
---
 .../taler-integrationtests/src/test-tipping.ts     |  9 +++++++
 .../taler-wallet-core/src/operations/pending.ts    |  2 +-
 packages/taler-wallet-core/src/operations/tip.ts   | 22 ++++++----------
 .../src/operations/transactions.ts                 | 24 ++++++++++++++++++
 packages/taler-wallet-core/src/types/dbTypes.ts    | 29 ++++++----------------
 .../taler-wallet-core/src/types/transactions.ts    | 12 ---------
 6 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/packages/taler-integrationtests/src/test-tipping.ts 
b/packages/taler-integrationtests/src/test-tipping.ts
index f7840f5d..4c080293 100644
--- a/packages/taler-integrationtests/src/test-tipping.ts
+++ b/packages/taler-integrationtests/src/test-tipping.ts
@@ -109,4 +109,13 @@ runTest(async (t: GlobalTestState) => {
   console.log(bal);
 
   t.assertAmountEquals(bal.balances[0].available, "TESTKUDOS:4.85");
+
+  const txns = await wallet.getTransactions();
+
+  console.log("Transactions:", JSON.stringify(txns, undefined, 2));
+
+  t.assertDeepEqual(txns.transactions[0].type, "tip");
+  t.assertDeepEqual(txns.transactions[0].pending, false);
+  t.assertAmountEquals(txns.transactions[0].amountEffective, "TESTKUDOS:4.85");
+  t.assertAmountEquals(txns.transactions[0].amountRaw, "TESTKUDOS:5.0");
 });
diff --git a/packages/taler-wallet-core/src/operations/pending.ts 
b/packages/taler-wallet-core/src/operations/pending.ts
index 7dda1214..7338ac77 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -351,7 +351,7 @@ async function gatherTipPending(
   onlyDue = false,
 ): Promise<void> {
   await tx.iter(Stores.tips).forEach((tip) => {
-    if (tip.pickedUp) {
+    if (tip.pickedUpTimestamp) {
       return;
     }
     resp.nextRetryDelay = updateRetryDelay(
diff --git a/packages/taler-wallet-core/src/operations/tip.ts 
b/packages/taler-wallet-core/src/operations/tip.ts
index 6ccd262b..248ea2cd 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -25,11 +25,8 @@ import {
 import * as Amounts from "../util/amounts";
 import {
   Stores,
-  PlanchetRecord,
-  WithdrawalGroupRecord,
   initRetryInfo,
   updateRetryInfoTimeout,
-  WithdrawalSourceType,
   TipPlanchet,
   CoinRecord,
   CoinSourceType,
@@ -38,7 +35,6 @@ import {
 import {
   getExchangeWithdrawalInfo,
   selectWithdrawalDenoms,
-  processWithdrawGroup,
   denomSelectionInfoToState,
 } from "./withdraw";
 import { updateExchangeFromUrl } from "./exchanges";
@@ -102,15 +98,11 @@ export async function prepareTip(
     tipRecord = {
       walletTipId: walletTipId,
       acceptedTimestamp: undefined,
-      rejectedTimestamp: undefined,
       tipAmountRaw: amount,
-      deadline: tipPickupStatus.expiration,
-      exchangeUrl: tipPickupStatus.exchange_url,
+      tipExpiration: tipPickupStatus.expiration,
+      exchangeBaseUrl: tipPickupStatus.exchange_url,
       merchantBaseUrl: res.merchantBaseUrl,
-      nextUrl: undefined,
-      pickedUp: false,
       planchets: undefined,
-      response: undefined,
       createdTimestamp: getTimestampNow(),
       merchantTipId: res.merchantTipId,
       tipAmountEffective: Amounts.sub(amount, Amounts.add(
@@ -120,6 +112,7 @@ export async function prepareTip(
       retryInfo: initRetryInfo(),
       lastError: undefined,
       denomsSel: denomSelectionInfoToState(selectedDenoms),
+      pickedUpTimestamp: undefined,
     };
     await ws.db.put(Stores.tips, tipRecord);
   }
@@ -197,7 +190,7 @@ async function processTipImpl(
     return;
   }
 
-  if (tipRecord.pickedUp) {
+  if (tipRecord.pickedUpTimestamp) {
     logger.warn("tip already picked up");
     return;
   }
@@ -302,7 +295,7 @@ async function processTipImpl(
       denomPub: planchet.denomPub,
       denomPubHash: planchet.denomPubHash,
       denomSig: denomSig,
-      exchangeBaseUrl: tipRecord.exchangeUrl,
+      exchangeBaseUrl: tipRecord.exchangeBaseUrl,
       status: CoinStatus.Fresh,
       suspended: false,
     });
@@ -315,10 +308,11 @@ async function processTipImpl(
       if (!tr) {
         return;
       }
-      if (tr.pickedUp) {
+      if (tr.pickedUpTimestamp) {
         return;
       }
-      tr.pickedUp = true;
+      tr.pickedUpTimestamp = getTimestampNow();
+      tr.lastError = undefined;
       tr.retryInfo = initRetryInfo(false);
       await tx.put(Stores.tips, tr);
       for (const cr of newCoinRecords) {
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index b5f77a19..026a91ef 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -38,6 +38,7 @@ import {
   OrderShortInfo,
 } from "../types/transactions";
 import { getFundingPaytoUris } from "./reserves";
+import { TipResponse } from "../types/talerTypes";
 
 /**
  * Create an event ID from the type and the primary key for the event.
@@ -308,6 +309,29 @@ export async function getTransactions(
           });
         });
       });
+
+      tx.iter(Stores.tips).forEachAsync(async (tipRecord) => {
+        if (
+          shouldSkipCurrency(
+            transactionsRequest,
+            tipRecord.tipAmountRaw.currency,
+          )
+        ) {
+          return;
+        }
+        if (!tipRecord.acceptedTimestamp) {
+          return;
+        }
+        transactions.push({
+          type: TransactionType.Tip,
+          amountEffective: Amounts.stringify(tipRecord.tipAmountEffective),
+          amountRaw: Amounts.stringify(tipRecord.tipAmountRaw),
+          pending: !tipRecord.pickedUpTimestamp,
+          timestamp: tipRecord.acceptedTimestamp,
+          transactionId: makeEventId(TransactionType.Tip, 
tipRecord.walletTipId),
+          error: tipRecord.lastError,
+        });
+      });
     },
   );
 
diff --git a/packages/taler-wallet-core/src/types/dbTypes.ts 
b/packages/taler-wallet-core/src/types/dbTypes.ts
index 3e24f787..60a427ef 100644
--- a/packages/taler-wallet-core/src/types/dbTypes.ts
+++ b/packages/taler-wallet-core/src/types/dbTypes.ts
@@ -950,16 +950,6 @@ export interface TipRecord {
    */
   acceptedTimestamp: Timestamp | undefined;
 
-  /**
-   * Has the user rejected the tip?
-   */
-  rejectedTimestamp: Timestamp | undefined;
-
-  /**
-   * Have we picked up the tip record from the merchant already?
-   */
-  pickedUp: boolean;
-
   /**
    * The tipped amount.
    */
@@ -970,12 +960,12 @@ export interface TipRecord {
   /**
    * Timestamp, the tip can't be picked up anymore after this deadline.
    */
-  deadline: Timestamp;
+  tipExpiration: Timestamp;
 
   /**
    * The exchange that will sign our coins, chosen by the merchant.
    */
-  exchangeUrl: string;
+  exchangeBaseUrl: string;
 
   /**
    * Base URL of the merchant that is giving us the tip.
@@ -990,12 +980,6 @@ export interface TipRecord {
 
   denomsSel: DenomSelectionState;
 
-  /**
-   * Response if the merchant responded,
-   * undefined otherwise.
-   */
-  response?: TipResponse[];
-
   /**
    * Tip ID chosen by the wallet.
    */
@@ -1006,12 +990,13 @@ export interface TipRecord {
    */
   merchantTipId: string;
 
+  createdTimestamp: Timestamp;
+
   /**
-   * URL to go to once the tip has been accepted.
+   * Timestamp for when the wallet finished picking up the tip
+   * from the merchant.
    */
-  nextUrl?: string;
-
-  createdTimestamp: Timestamp;
+  pickedUpTimestamp: Timestamp | undefined;
 
   /**
    * Retry info, even present when the operation isn't active to allow indexing
diff --git a/packages/taler-wallet-core/src/types/transactions.ts 
b/packages/taler-wallet-core/src/types/transactions.ts
index 1d1eb649..21d7ee18 100644
--- a/packages/taler-wallet-core/src/types/transactions.ts
+++ b/packages/taler-wallet-core/src/types/transactions.ts
@@ -278,18 +278,6 @@ interface TransactionRefund extends TransactionCommon {
 interface TransactionTip extends TransactionCommon {
   type: TransactionType.Tip;
 
-  // true if the user still needs to accept/decline this tip
-  waiting: boolean;
-
-  // true if the user has accepted this top, false otherwise
-  accepted: boolean;
-
-  // Exchange that the tip will be (or was) withdrawn from
-  exchangeBaseUrl: string;
-
-  // More information about the merchant that sent the tip
-  merchant: any;
-
   // Raw amount of the tip, without extra fees that apply
   amountRaw: AmountString;
 

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