gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: only query tip status on firs


From: gnunet
Subject: [taler-wallet-core] branch master updated: only query tip status on first call to prepare
Date: Mon, 16 Nov 2020 16:17:38 +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 af5a35de only query tip status on first call to prepare
af5a35de is described below

commit af5a35def0c7e914bd733e652e2c3c759a4b7384
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Nov 16 16:17:26 2020 +0100

    only query tip status on first call to prepare
---
 packages/taler-wallet-core/src/operations/tip.ts | 34 ++++++++++++------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/tip.ts 
b/packages/taler-wallet-core/src/operations/tip.ts
index 1d7386b8..1d19a72e 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -59,26 +59,26 @@ export async function prepareTip(
     throw Error("invalid taler://tip URI");
   }
 
-  const tipStatusUrl = new URL(
-    `tips/${res.merchantTipId}`,
-    res.merchantBaseUrl,
-  );
-  logger.trace("checking tip status from", tipStatusUrl.href);
-  const merchantResp = await ws.http.get(tipStatusUrl.href);
-  const tipPickupStatus = await readSuccessResponseJsonOrThrow(
-    merchantResp,
-    codecForTipPickupGetResponse(),
-  );
-  logger.trace(`status ${j2s(tipPickupStatus)}`);
-
-  const amount = Amounts.parseOrThrow(tipPickupStatus.tip_amount);
-
   let tipRecord = await ws.db.getIndexed(
     Stores.tips.byMerchantTipIdAndBaseUrl,
     [res.merchantTipId, res.merchantBaseUrl],
   );
 
   if (!tipRecord) {
+    const tipStatusUrl = new URL(
+      `tips/${res.merchantTipId}`,
+      res.merchantBaseUrl,
+    );
+    logger.trace("checking tip status from", tipStatusUrl.href);
+    const merchantResp = await ws.http.get(tipStatusUrl.href);
+    const tipPickupStatus = await readSuccessResponseJsonOrThrow(
+      merchantResp,
+      codecForTipPickupGetResponse(),
+    );
+    logger.trace(`status ${j2s(tipPickupStatus)}`);
+
+    const amount = Amounts.parseOrThrow(tipPickupStatus.tip_amount);
+
     logger.trace("new tip, creating tip record");
     await updateExchangeFromUrl(ws, tipPickupStatus.exchange_url);
     const withdrawDetails = await getExchangeWithdrawalInfo(
@@ -119,9 +119,9 @@ export async function prepareTip(
 
   const tipStatus: PrepareTipResult = {
     accepted: !!tipRecord && !!tipRecord.acceptedTimestamp,
-    tipAmountRaw: Amounts.stringify(tipPickupStatus.tip_amount),
-    exchangeBaseUrl: tipPickupStatus.exchange_url,
-    expirationTimestamp: tipPickupStatus.expiration,
+    tipAmountRaw: Amounts.stringify(tipRecord.tipAmountRaw),
+    exchangeBaseUrl: tipRecord.exchangeBaseUrl,
+    expirationTimestamp: tipRecord.tipExpiration,
     tipAmountEffective: Amounts.stringify(tipRecord.tipAmountEffective),
     walletTipId: tipRecord.walletTipId,
   };

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