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: Add 'deposited'


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: Add 'deposited' field to deposit transaction
Date: Wed, 18 Jan 2023 19:33:04 +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 598de5b0d wallet-core: Add 'deposited' field to deposit transaction
598de5b0d is described below

commit 598de5b0d576987ea317b22fd6d33cbe4a1a19ac
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Jan 18 19:30:48 2023 +0100

    wallet-core: Add 'deposited' field to deposit transaction
    
    This field indicates whether the POST requests to deposit coins went
    through with the exchange.
    
    We also don't consider a deposit transaction as having lifeness when it
    is already deposited and we're just querying for informational deposit
    tracking information.
---
 packages/taler-harness/src/integrationtests/test-deposit.ts |  3 +--
 packages/taler-util/src/transactions-types.ts               |  5 +++++
 packages/taler-wallet-core/src/operations/deposits.ts       |  3 ++-
 packages/taler-wallet-core/src/operations/pending.ts        | 11 ++++++++++-
 packages/taler-wallet-core/src/operations/transactions.ts   |  7 +++++++
 5 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-deposit.ts 
b/packages/taler-harness/src/integrationtests/test-deposit.ts
index 07382c43e..e4ca08789 100644
--- a/packages/taler-harness/src/integrationtests/test-deposit.ts
+++ b/packages/taler-harness/src/integrationtests/test-deposit.ts
@@ -54,11 +54,10 @@ export async function runDepositTest(t: GlobalTestState) {
     WalletApiOperation.GetTransactions,
     {},
   );
+
   console.log("transactions", JSON.stringify(transactions, undefined, 2));
   t.assertDeepEqual(transactions.transactions[0].type, "withdrawal");
-  t.assertTrue(!transactions.transactions[0].pending);
   t.assertDeepEqual(transactions.transactions[1].type, "deposit");
-  t.assertTrue(!transactions.transactions[1].pending);
   // The raw amount is what ends up on the bank account, which includes
   // deposit and wire fees.
   t.assertDeepEqual(transactions.transactions[1].amountRaw, "TESTKUDOS:9.79");
diff --git a/packages/taler-util/src/transactions-types.ts 
b/packages/taler-util/src/transactions-types.ts
index e81625a5a..7562b5884 100644
--- a/packages/taler-util/src/transactions-types.ts
+++ b/packages/taler-util/src/transactions-types.ts
@@ -550,6 +550,11 @@ export interface TransactionDeposit extends 
TransactionCommon {
   wireTransferDeadline: TalerProtocolTimestamp;
 
   wireTransferProgress: number;
+
+  /**
+   * Did all the deposit requests succeed?
+   */
+  deposited: boolean;
 }
 
 export interface TransactionByIdRequest {
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts 
b/packages/taler-wallet-core/src/operations/deposits.ts
index 71caae5b3..f3ec81686 100644
--- a/packages/taler-wallet-core/src/operations/deposits.ts
+++ b/packages/taler-wallet-core/src/operations/deposits.ts
@@ -21,7 +21,6 @@ import {
   AbsoluteTime,
   AmountJson,
   Amounts,
-  bytesToString,
   CancellationToken,
   canonicalJson,
   codecForDepositSuccess,
@@ -457,6 +456,8 @@ export async function prepareDepositGroup(
     effectiveDepositAmount: Amounts.stringify(effectiveDepositAmount),
   };
 }
+
+
 export async function createDepositGroup(
   ws: InternalWalletState,
   req: CreateDepositGroupRequest,
diff --git a/packages/taler-wallet-core/src/operations/pending.ts 
b/packages/taler-wallet-core/src/operations/pending.ts
index d9d62ec65..a73af528c 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -200,13 +200,22 @@ async function gatherDepositPending(
     if (dg.timestampFinished) {
       return;
     }
+    let deposited = true;
+    for (const d of dg.depositedPerCoin) {
+      if (!d) {
+        deposited = false;
+      }
+    }
     const opId = RetryTags.forDeposit(dg);
     const retryRecord = await tx.operationRetries.get(opId);
     const timestampDue = retryRecord?.retryInfo.nextRetry ?? 
AbsoluteTime.now();
     resp.pendingOperations.push({
       type: PendingTaskType.Deposit,
       ...getPendingCommon(ws, opId, timestampDue),
-      givesLifeness: true,
+      // Fully deposited operations don't give lifeness,
+      // because there is no reason to wait on the
+      // deposit tracking status.
+      givesLifeness: !deposited,
       depositGroupId: dg.depositGroupId,
       lastError: retryRecord?.lastError,
       retryInfo: retryRecord?.retryInfo,
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 58def0f34..7fa2c075c 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -557,6 +557,12 @@ function buildTransactionForDeposit(
   dg: DepositGroupRecord,
   ort?: OperationRetryRecord,
 ): Transaction {
+  let deposited = true;
+  for (const d of dg.depositedPerCoin) {
+    if (!d) {
+      deposited = false;
+    }
+  }
   return {
     type: TransactionType.Deposit,
     amountRaw: Amounts.stringify(dg.effectiveDepositAmount),
@@ -581,6 +587,7 @@ function buildTransactionForDeposit(
         )) /
       dg.transactionPerCoin.length,
     depositGroupId: dg.depositGroupId,
+    deposited,
     ...(ort?.lastError ? { error: ort.lastError } : {}),
   };
 }

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