gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: DB tweaks


From: gnunet
Subject: [taler-wallet-core] branch master updated: DB tweaks
Date: Tue, 08 Sep 2020 17:18:21 +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 ddbb09b1 DB tweaks
ddbb09b1 is described below

commit ddbb09b1403214cff3e5a598dc51bdf37df72971
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Tue Sep 8 20:45:33 2020 +0530

    DB tweaks
---
 packages/taler-wallet-core/src/operations/pay.ts   | 55 ++++------------------
 .../taler-wallet-core/src/operations/refund.ts     |  2 +-
 .../src/operations/transactions.ts                 |  2 +-
 packages/taler-wallet-core/src/types/dbTypes.ts    | 37 +++++++++++++--
 .../taler-wallet-core/src/types/walletTypes.ts     |  1 +
 5 files changed, 46 insertions(+), 51 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/pay.ts 
b/packages/taler-wallet-core/src/operations/pay.ts
index c655aa7d..a6f941ff 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -34,6 +34,7 @@ import {
   WalletContractData,
   CoinRecord,
   DenominationRecord,
+  PayCoinSelection,
 } from "../types/dbTypes";
 import { NotificationType } from "../types/notifications";
 import {
@@ -83,37 +84,6 @@ import { initRetryInfo, updateRetryInfoTimeout, 
getRetryDuration } from "../util
  */
 const logger = new Logger("pay.ts");
 
-/**
- * Result of selecting coins, contains the exchange, and selected
- * coins with their denomination.
- */
-export interface PayCoinSelection {
-  /**
-   * Amount requested by the merchant.
-   */
-  paymentAmount: AmountJson;
-
-  /**
-   * Public keys of the coins that were selected.
-   */
-  coinPubs: string[];
-
-  /**
-   * Amount that each coin contributes.
-   */
-  coinContributions: AmountJson[];
-
-  /**
-   * How much of the wire fees is the customer paying?
-   */
-  customerWireFees: AmountJson;
-
-  /**
-   * How much of the deposit fees is the customer paying?
-   */
-  customerDepositFees: AmountJson;
-}
-
 /**
  * Structure to describe a coin that is available to be
  * used in a payment.
@@ -141,9 +111,6 @@ export interface AvailableCoinInfo {
   feeDeposit: AmountJson;
 }
 
-export interface PayCostInfo {
-  totalCost: AmountJson;
-}
 
 /**
  * Compute the total cost of a payment to the customer.
@@ -155,7 +122,7 @@ export interface PayCostInfo {
 export async function getTotalPaymentCost(
   ws: InternalWalletState,
   pcs: PayCoinSelection,
-): Promise<PayCostInfo> {
+): Promise<AmountJson> {
   const costs = [];
   for (let i = 0; i < pcs.coinPubs.length; i++) {
     const coin = await ws.db.get(Stores.coins, pcs.coinPubs[i]);
@@ -183,9 +150,7 @@ export async function getTotalPaymentCost(
     costs.push(pcs.coinContributions[i]);
     costs.push(refreshCost);
   }
-  return {
-    totalCost: Amounts.sum(costs).amount,
-  };
+  return Amounts.sum(costs).amount;
 }
 
 /**
@@ -470,7 +435,7 @@ async function recordConfirmPay(
     contractData: d.contractData,
     lastSessionId: sessionId,
     payCoinSelection: coinSelection,
-    payCostInfo,
+    totalPayCost: payCostInfo,
     coinDepositPermissions,
     timestampAccept: getTimestampNow(),
     timestampLastRefundStatus: undefined,
@@ -1057,15 +1022,15 @@ export async function preparePayForUri(
       };
     }
 
-    const costInfo = await getTotalPaymentCost(ws, res);
-    logger.trace("costInfo", costInfo);
+    const totalCost = await getTotalPaymentCost(ws, res);
+    logger.trace("costInfo", totalCost);
     logger.trace("coinsForPayment", res);
 
     return {
       status: PreparePayResultType.PaymentPossible,
       contractTerms: JSON.parse(d.contractTermsRaw),
       proposalId: proposal.proposalId,
-      amountEffective: Amounts.stringify(costInfo.totalCost),
+      amountEffective: Amounts.stringify(totalCost),
       amountRaw: Amounts.stringify(res.paymentAmount),
     };
   }
@@ -1092,7 +1057,7 @@ export async function preparePayForUri(
       contractTermsHash: purchase.contractData.contractTermsHash,
       paid: true,
       amountRaw: Amounts.stringify(purchase.contractData.amount),
-      amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost),
+      amountEffective: Amounts.stringify(purchase.totalPayCost),
       proposalId,
     };
   } else if (!purchase.timestampFirstSuccessfulPay) {
@@ -1102,7 +1067,7 @@ export async function preparePayForUri(
       contractTermsHash: purchase.contractData.contractTermsHash,
       paid: false,
       amountRaw: Amounts.stringify(purchase.contractData.amount),
-      amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost),
+      amountEffective: Amounts.stringify(purchase.totalPayCost),
       proposalId,
     };
   } else {
@@ -1113,7 +1078,7 @@ export async function preparePayForUri(
       contractTermsHash: purchase.contractData.contractTermsHash,
       paid,
       amountRaw: Amounts.stringify(purchase.contractData.amount),
-      amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost),
+      amountEffective: Amounts.stringify(purchase.totalPayCost),
       ...(paid ? { nextUrl: purchase.contractData.orderId } : {}),
       proposalId,
     };
diff --git a/packages/taler-wallet-core/src/operations/refund.ts 
b/packages/taler-wallet-core/src/operations/refund.ts
index d49675c0..097e2086 100644
--- a/packages/taler-wallet-core/src/operations/refund.ts
+++ b/packages/taler-wallet-core/src/operations/refund.ts
@@ -470,7 +470,7 @@ export async function applyRefund(
   return {
     contractTermsHash: purchase.contractData.contractTermsHash,
     proposalId: purchase.proposalId,
-    amountEffectivePaid: Amounts.stringify(purchase.payCostInfo.totalCost),
+    amountEffectivePaid: Amounts.stringify(purchase.totalPayCost),
     amountRefundGone: Amounts.stringify(amountRefundGone),
     amountRefundGranted: Amounts.stringify(amountRefundGranted),
     pendingAtExchange,
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 54d4d557..5bc4ebac 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -238,7 +238,7 @@ export async function getTransactions(
         transactions.push({
           type: TransactionType.Payment,
           amountRaw: Amounts.stringify(pr.contractData.amount),
-          amountEffective: Amounts.stringify(pr.payCostInfo.totalCost),
+          amountEffective: Amounts.stringify(pr.totalPayCost),
           status: pr.timestampFirstSuccessfulPay
             ? PaymentStatus.Paid
             : PaymentStatus.Accepted,
diff --git a/packages/taler-wallet-core/src/types/dbTypes.ts 
b/packages/taler-wallet-core/src/types/dbTypes.ts
index 0074409e..62eadc78 100644
--- a/packages/taler-wallet-core/src/types/dbTypes.ts
+++ b/packages/taler-wallet-core/src/types/dbTypes.ts
@@ -27,7 +27,6 @@ import { AmountJson } from "../util/amounts";
 import {
   Auditor,
   CoinDepositPermission,
-  TipResponse,
   ExchangeSignKeyJson,
   MerchantInfo,
   Product,
@@ -43,8 +42,7 @@ import {
   ReserveClosingTransaction,
   ReserveRecoupTransaction,
 } from "./ReserveTransaction";
-import { Timestamp, Duration, getTimestampNow } from "../util/time";
-import { PayCoinSelection, PayCostInfo } from "../operations/pay";
+import { Timestamp, Duration } from "../util/time";
 import { IDBKeyPath } from "idb-bridge";
 import { RetryInfo } from "../util/retries";
 
@@ -1255,6 +1253,37 @@ export interface WalletContractData {
   maxDepositFee: AmountJson;
 }
 
+/**
+ * Result of selecting coins, contains the exchange, and selected
+ * coins with their denomination.
+ */
+export interface PayCoinSelection {
+  /**
+   * Amount requested by the merchant.
+   */
+  paymentAmount: AmountJson;
+
+  /**
+   * Public keys of the coins that were selected.
+   */
+  coinPubs: string[];
+
+  /**
+   * Amount that each coin contributes.
+   */
+  coinContributions: AmountJson[];
+
+  /**
+   * How much of the wire fees is the customer paying?
+   */
+  customerWireFees: AmountJson;
+
+  /**
+   * How much of the deposit fees is the customer paying?
+   */
+  customerDepositFees: AmountJson;
+}
+
 /**
  * Record that stores status information about one purchase, starting from when
  * the customer accepts a proposal.  Includes refund status if applicable.
@@ -1280,7 +1309,7 @@ export interface PurchaseRecord {
 
   payCoinSelection: PayCoinSelection;
 
-  payCostInfo: PayCostInfo;
+  totalPayCost: AmountJson;
 
   /**
    * Timestamp of the first time that sending a payment to the merchant
diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts 
b/packages/taler-wallet-core/src/types/walletTypes.ts
index c9014830..5507822f 100644
--- a/packages/taler-wallet-core/src/types/walletTypes.ts
+++ b/packages/taler-wallet-core/src/types/walletTypes.ts
@@ -931,3 +931,4 @@ export const codecForAcceptTipRequest = (): 
Codec<AcceptTipRequest> =>
   buildCodecForObject<AcceptTipRequest>()
     .property("walletTipId", codecForString())
     .build("AcceptTipRequest");
+

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