gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (8a3ac7f0 -> bf9c2ae7)


From: gnunet
Subject: [taler-wallet-core] branch master updated (8a3ac7f0 -> bf9c2ae7)
Date: Thu, 03 Sep 2020 14:05:10 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a change to branch master
in repository wallet-core.

    from 8a3ac7f0 schedule exchange updating
     new 09b5bfe0 towards auto-refresh
     new bf9c2ae7 add proposalId in preparePay response

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 packages/taler-wallet-core/src/operations/pay.ts   |  3 +++
 .../taler-wallet-core/src/operations/pending.ts    |  3 ++-
 .../taler-wallet-core/src/operations/refresh.ts    |  5 +++++
 .../taler-wallet-core/src/operations/withdraw.ts   |  2 ++
 packages/taler-wallet-core/src/types/dbTypes.ts    |  8 ++++++++
 packages/taler-wallet-core/src/types/pending.ts    | 11 +++++++++++
 .../taler-wallet-core/src/types/walletTypes.ts     |  2 ++
 packages/taler-wallet-core/src/util/time.ts        | 23 ++++++++++++----------
 packages/taler-wallet-core/src/wallet.ts           |  5 ++++-
 9 files changed, 50 insertions(+), 12 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/pay.ts 
b/packages/taler-wallet-core/src/operations/pay.ts
index ce71737d..2c491ec6 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -1085,6 +1085,7 @@ export async function preparePayForUri(
       paid: true,
       amountRaw: Amounts.stringify(purchase.contractData.amount),
       amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost),
+      proposalId,
     };
   } else if (!purchase.timestampFirstSuccessfulPay) {
     return {
@@ -1094,6 +1095,7 @@ export async function preparePayForUri(
       paid: false,
       amountRaw: Amounts.stringify(purchase.contractData.amount),
       amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost),
+      proposalId,
     };
   } else {
     const paid = !purchase.paymentSubmitPending;
@@ -1105,6 +1107,7 @@ export async function preparePayForUri(
       amountRaw: Amounts.stringify(purchase.contractData.amount),
       amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost),
       ...(paid ? { nextUrl: purchase.contractData.orderId } : {}),
+      proposalId,
     };
   }
 }
diff --git a/packages/taler-wallet-core/src/operations/pending.ts 
b/packages/taler-wallet-core/src/operations/pending.ts
index 8cbc5e56..e24e8fc4 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -92,7 +92,8 @@ async function gatherExchangePending(
             },
           });
         }
-        if (e.details && e.details.nextUpdateTime.t_ms < now.t_ms) {
+        const keysUpdateRequired = e.details && e.details.nextUpdateTime.t_ms 
< now.t_ms;
+        if (keysUpdateRequired) {
           resp.pendingOperations.push({
             type: PendingOperationType.ExchangeUpdate,
             givesLifeness: false,
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts 
b/packages/taler-wallet-core/src/operations/refresh.ts
index 770c67da..6c1e643a 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -634,3 +634,8 @@ export async function createRefreshGroup(
     refreshGroupId,
   };
 }
+
+export async function autoRefresh(
+  ws: InternalWalletState,
+  exchangeBaseUrl: string,
+): Promise<void> {}
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index c719f7ab..4070e39f 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -620,6 +620,8 @@ async function processWithdrawGroupImpl(
     return;
   }
 
+  await updateExchangeFromUrl(ws, withdrawalGroup.exchangeBaseUrl);
+
   const numTotalCoins = withdrawalGroup.denomsSel.selectedDenoms
     .map((x) => x.count)
     .reduce((a, b) => a + b);
diff --git a/packages/taler-wallet-core/src/types/dbTypes.ts 
b/packages/taler-wallet-core/src/types/dbTypes.ts
index 801bb449..30a56282 100644
--- a/packages/taler-wallet-core/src/types/dbTypes.ts
+++ b/packages/taler-wallet-core/src/types/dbTypes.ts
@@ -648,6 +648,14 @@ export interface ExchangeRecord {
    * Retry status for fetching updated information about the exchange.
    */
   retryInfo: RetryInfo;
+
+  /**
+   * Next time that we should check if coins need to be refreshed.
+   * 
+   * Updated whenever the exchange's denominations are updated or when
+   * the refresh check has been done.
+   */
+  nextRefreshCheck?: Timestamp;
 }
 
 
diff --git a/packages/taler-wallet-core/src/types/pending.ts 
b/packages/taler-wallet-core/src/types/pending.ts
index 69613bec..d07754fe 100644
--- a/packages/taler-wallet-core/src/types/pending.ts
+++ b/packages/taler-wallet-core/src/types/pending.ts
@@ -28,6 +28,7 @@ import { Timestamp, Duration } from "../util/time";
 export enum PendingOperationType {
   Bug = "bug",
   ExchangeUpdate = "exchange-update",
+  ExchangeCheckRefresh = "exchange-check-refresh",
   Pay = "pay",
   ProposalChoice = "proposal-choice",
   ProposalDownload = "proposal-download",
@@ -47,6 +48,7 @@ export type PendingOperationInfo = PendingOperationInfoCommon 
&
   (
     | PendingBugOperation
     | PendingExchangeUpdateOperation
+    | PendingExchangeCheckRefreshOperation
     | PendingPayOperation
     | PendingProposalChoiceOperation
     | PendingProposalDownloadOperation
@@ -70,6 +72,15 @@ export interface PendingExchangeUpdateOperation {
   lastError: TalerErrorDetails | undefined;
 }
 
+/**
+ * The wallet should check whether coins from this exchange
+ * need to be auto-refreshed.
+ */
+export interface PendingExchangeCheckRefreshOperation {
+  type: PendingOperationType.ExchangeCheckRefresh;
+  exchangeBaseUrl: string;
+}
+
 /**
  * Some interal error happened in the wallet.  This pending operation
  * should *only* be reported for problems in the wallet, not when
diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts 
b/packages/taler-wallet-core/src/types/walletTypes.ts
index 01fd95e0..bde4fee6 100644
--- a/packages/taler-wallet-core/src/types/walletTypes.ts
+++ b/packages/taler-wallet-core/src/types/walletTypes.ts
@@ -416,6 +416,7 @@ export const codecForPreparePayResultAlreadyConfirmed = (): 
Codec<
     .property("paid", codecForBoolean())
     .property("contractTerms", codecForAny())
     .property("contractTermsHash", codecForString())
+    .property("proposalId", codecForString())
     .build("PreparePayResultAlreadyConfirmed");
 
 export const codecForPreparePayResult = (): Codec<PreparePayResult> =>
@@ -462,6 +463,7 @@ export interface PreparePayResultAlreadyConfirmed {
   amountRaw: string;
   amountEffective: string;
   contractTermsHash: string;
+  proposalId: string;
 }
 
 export interface BankWithdrawDetails {
diff --git a/packages/taler-wallet-core/src/util/time.ts 
b/packages/taler-wallet-core/src/util/time.ts
index 1641924a..512d5e90 100644
--- a/packages/taler-wallet-core/src/util/time.ts
+++ b/packages/taler-wallet-core/src/util/time.ts
@@ -89,22 +89,25 @@ export function timestampMax(t1: Timestamp, t2: Timestamp): 
Timestamp {
 const SECONDS = 1000
 const MINUTES = SECONDS * 60;
 const HOURS = MINUTES * 60;
+const DAYS = HOURS * 24;
+const MONTHS = DAYS * 30;
+const YEARS = DAYS * 365;
 
 export function durationFromSpec(spec: {
   seconds?: number,
-  hours?: number,
   minutes?: number,
+  hours?: number,
+  days?: number,
+  months?: number,
+  years?: number,
 }): Duration {
   let d_ms = 0;
-  if (spec.seconds) {
-    d_ms += spec.seconds * SECONDS;
-  }
-  if (spec.minutes) {
-    d_ms += spec.minutes * MINUTES;
-  }
-  if (spec.hours) {
-    d_ms += spec.hours * HOURS;
-  }
+  d_ms += (spec.seconds ?? 0) * SECONDS;
+  d_ms += (spec.minutes ?? 0) * MINUTES;
+  d_ms += (spec.hours ?? 0) * HOURS;
+  d_ms += (spec.days ?? 0) * DAYS;
+  d_ms += (spec.months ?? 0) * MONTHS;
+  d_ms += (spec.years ?? 0) * YEARS;
   return { d_ms };
 }
 
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index b448df64..5ca3581a 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -110,7 +110,7 @@ import {
 
 import { InternalWalletState } from "./operations/state";
 import { createReserve } from "./operations/reserves";
-import { processRefreshGroup, createRefreshGroup } from "./operations/refresh";
+import { processRefreshGroup, createRefreshGroup, autoRefresh } from 
"./operations/refresh";
 import { processWithdrawGroup } from "./operations/withdraw";
 import { getPendingOperations } from "./operations/pending";
 import { getBalances } from "./operations/balance";
@@ -267,6 +267,9 @@ export class Wallet {
       case PendingOperationType.Recoup:
         await processRecoupGroup(this.ws, pending.recoupGroupId, forceNow);
         break;
+      case PendingOperationType.ExchangeCheckRefresh:
+        await autoRefresh(this.ws, pending.exchangeBaseUrl)
+        break;
       default:
         assertUnreachable(pending);
     }

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