gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: make verbose details an optio


From: gnunet
Subject: [taler-wallet-core] branch master updated: make verbose details an option
Date: Wed, 22 Jan 2020 12:23:07 +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 14103aa0 make verbose details an option
14103aa0 is described below

commit 14103aa0750fd2874480a564b2f0be0932c13e21
Author: Florian Dold <address@hidden>
AuthorDate: Wed Jan 22 12:22:57 2020 +0100

    make verbose details an option
---
 src/headless/integrationtest.ts |   2 +-
 src/operations/history.ts       | 107 +++++++++++++++++++++-------------------
 src/types/history.ts            |  15 ++++--
 src/types/pending.ts            |   8 +++
 4 files changed, 77 insertions(+), 55 deletions(-)

diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts
index 6ec28dc4..984ef9c3 100644
--- a/src/headless/integrationtest.ts
+++ b/src/headless/integrationtest.ts
@@ -187,7 +187,7 @@ export async function runIntegrationTest(args: 
IntegrationTestArgs) {
 
   await myWallet.runUntilDone();
 
-  const history = await myWallet.getHistory();
+  const history = await myWallet.getHistory({ verboseDetails: true });
 
   console.log("history after integration test:", JSON.stringify(history, 
undefined, 2));
 }
diff --git a/src/operations/history.ts b/src/operations/history.ts
index 88dc1994..b2b78fe1 100644
--- a/src/operations/history.ts
+++ b/src/operations/history.ts
@@ -215,15 +215,16 @@ export async function getHistory(
               cs.push(x);
             }
           });
-          const verboseDetails: VerboseWithdrawDetails = {
-            coins: cs.map((x) => ({
-              value: Amounts.toString(x.coinValue),
-              denomPub: x.denomPub,
-            })),
-          };
-          const coins = cs.map((x) => ({
-            value: x.coinValue
-          }));
+
+          let verboseDetails: VerboseWithdrawDetails | undefined = undefined;
+          if (historyQuery?.verboseDetails) {
+            verboseDetails = {
+              coins: cs.map((x) => ({
+                value: Amounts.toString(x.coinValue),
+                denomPub: x.denomPub,
+              })),
+            };
+          }
           
           history.push({
             type: HistoryEventType.Withdrawn,
@@ -257,29 +258,32 @@ export async function getHistory(
         if (!orderShortInfo) {
           return;
         }
-        const coins: {
-          value: string,
-          contribution: string;
-          denomPub: string;
-        }[] = [];
-        for (const x of purchase.payReq.coins) {
-          const c = await tx.get(Stores.coins, x.coin_pub);
-          if (!c) {
-            // FIXME: what to do here??
-            continue;
-          }
-          const d = await tx.get(Stores.denominations, [c.exchangeBaseUrl, 
c.denomPub]);
-          if (!d) {
-            // FIXME: what to do here??
-            continue;
+        let verboseDetails: VerbosePayCoinDetails | undefined = undefined;
+        if (historyQuery?.verboseDetails) {
+          const coins: {
+            value: string,
+            contribution: string;
+            denomPub: string;
+          }[] = [];
+          for (const x of purchase.payReq.coins) {
+            const c = await tx.get(Stores.coins, x.coin_pub);
+            if (!c) {
+              // FIXME: what to do here??
+              continue;
+            }
+            const d = await tx.get(Stores.denominations, [c.exchangeBaseUrl, 
c.denomPub]);
+            if (!d) {
+              // FIXME: what to do here??
+              continue;
+            }
+            coins.push({
+              contribution: x.contribution,
+              denomPub: c.denomPub,
+              value: Amounts.toString(d.value),
+            });
           }
-          coins.push({
-            contribution: x.contribution,
-            denomPub: c.denomPub,
-            value: Amounts.toString(d.value),
-          });
+          verboseDetails = { coins }; 
         }
-        const verboseDetails: VerbosePayCoinDetails = { coins };
         const amountPaidWithFees = Amounts.sum(
           purchase.payReq.coins.map(x => Amounts.parseOrThrow(x.contribution)),
         ).amount;
@@ -331,30 +335,33 @@ export async function getHistory(
         } else {
           amountRefreshedEffective = Amounts.sum(amountsEffective).amount;
         }
-        const outputCoins: {
-          value: string;
-          denomPub: string,
-        }[] = [];
-        for (const rs of rg.refreshSessionPerCoin) {
-          if (!rs) {
-            continue;
-          }
-          for (const nd of rs.newDenoms) {
-            if (!nd) {
+        let verboseDetails: VerboseRefreshDetails | undefined = undefined;
+        if (historyQuery?.verboseDetails) {
+          const outputCoins: {
+            value: string;
+            denomPub: string,
+          }[] = [];
+          for (const rs of rg.refreshSessionPerCoin) {
+            if (!rs) {
               continue;
             }
-            const d = await tx.get(Stores.denominations, [rs.exchangeBaseUrl, 
nd]);
-            if (!d) {
-              continue;
+            for (const nd of rs.newDenoms) {
+              if (!nd) {
+                continue;
+              }
+              const d = await tx.get(Stores.denominations, 
[rs.exchangeBaseUrl, nd]);
+              if (!d) {
+                continue;
+              }
+              outputCoins.push({
+                denomPub: d.denomPub,
+                value: Amounts.toString(d.value),
+              });
             }
-            outputCoins.push({
-              denomPub: d.denomPub,
-              value: Amounts.toString(d.value),
-            });
           }
-        }
-        const verboseDetails: VerboseRefreshDetails = {
-          outputCoins: outputCoins,
+          verboseDetails = {
+            outputCoins: outputCoins,
+          }
         }
         history.push({
           type: HistoryEventType.Refreshed,
diff --git a/src/types/history.ts b/src/types/history.ts
index ad7d98df..52148cb0 100644
--- a/src/types/history.ts
+++ b/src/types/history.ts
@@ -509,7 +509,7 @@ export interface HistoryPaymentSent {
    */
   sessionId: string | undefined;
 
-  verboseDetails: VerbosePayCoinDetails;
+  verboseDetails?: VerbosePayCoinDetails;
 }
 
 /**
@@ -590,7 +590,7 @@ export interface HistoryRefreshedEvent {
    */
   refreshGroupId: string;
 
-  verboseDetails: VerboseRefreshDetails;
+  verboseDetails?: VerboseRefreshDetails;
 }
 
 export interface VerboseWithdrawDetails {
@@ -630,7 +630,10 @@ export interface HistoryWithdrawnEvent {
    */
   amountWithdrawnEffective: string;
 
-  verboseDetails: VerboseWithdrawDetails;
+  /**
+   * Verbose details of the operations, only generated when requested.
+   */
+  verboseDetails?: VerboseWithdrawDetails;
 }
 
 /**
@@ -684,5 +687,9 @@ export type HistoryEvent = HistoryEventBase &
   );
 
 export interface HistoryQuery {
-  // TBD
+  /**
+   * Output extra verbose details, intended for debugging
+   * and not for end users.
+   */
+  verboseDetails?: boolean;
 }
diff --git a/src/types/pending.ts b/src/types/pending.ts
index 15299dec..b6b0849a 100644
--- a/src/types/pending.ts
+++ b/src/types/pending.ts
@@ -60,6 +60,9 @@ export type PendingOperationInfo = PendingOperationInfoCommon 
&
     | PendingWithdrawOperation
   );
 
+/**
+ * The wallet is currently updating information about an exchange.
+ */
 export interface PendingExchangeUpdateOperation {
   type: PendingOperationType.ExchangeUpdate;
   stage: string;
@@ -68,6 +71,11 @@ export interface PendingExchangeUpdateOperation {
   lastError: OperationError | undefined;
 }
 
+/**
+ * Some interal error happened in the wallet.  This pending operation
+ * should *only* be reported for problems in the wallet, not when
+ * a problem with a merchant/exchange/etc. occurs.
+ */
 export interface PendingBugOperation {
   type: PendingOperationType.Bug;
   message: string;

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]