gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] 01/02: new exchange-added notifiaction and including


From: gnunet
Subject: [taler-wallet-core] 01/02: new exchange-added notifiaction and including tos information in the wxApi.listExchange api
Date: Wed, 24 Nov 2021 12:58:59 +0100

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

sebasjm pushed a commit to branch master
in repository wallet-core.

commit f07436aa4910114a514235fb17879411dae0a555
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Wed Nov 24 08:55:37 2021 -0300

    new exchange-added notifiaction and including tos information in the 
wxApi.listExchange api
---
 packages/taler-util/src/notifications.ts               |  6 ++++++
 packages/taler-util/src/walletTypes.ts                 | 15 +++++++++++++++
 packages/taler-wallet-core/src/operations/exchanges.ts | 13 ++++++++-----
 packages/taler-wallet-core/src/operations/withdraw.ts  | 13 +++++++++----
 packages/taler-wallet-core/src/wallet.ts               |  9 ++++++++-
 5 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/packages/taler-util/src/notifications.ts 
b/packages/taler-util/src/notifications.ts
index 289dcb68..e8f27062 100644
--- a/packages/taler-util/src/notifications.ts
+++ b/packages/taler-util/src/notifications.ts
@@ -45,6 +45,7 @@ export enum NotificationType {
   RefundQueried = "refund-queried",
   RefundFinished = "refund-finished",
   ExchangeOperationError = "exchange-operation-error",
+  ExchangeAdded = "exchange-added",
   RefreshOperationError = "refresh-operation-error",
   RecoupOperationError = "recoup-operation-error",
   RefundApplyOperationError = "refund-apply-error",
@@ -150,6 +151,10 @@ export interface RefundFinishedNotification {
   type: NotificationType.RefundFinished;
 }
 
+export interface ExchangeAddedNotification {
+  type: NotificationType.ExchangeAdded;
+}
+
 export interface ExchangeOperationErrorNotification {
   type: NotificationType.ExchangeOperationError;
   error: TalerErrorDetails;
@@ -243,6 +248,7 @@ export type WalletNotification =
   | BackupOperationErrorNotification
   | WithdrawOperationErrorNotification
   | ReserveOperationErrorNotification
+  | ExchangeAddedNotification
   | ExchangeOperationErrorNotification
   | RefreshOperationErrorNotification
   | RefundStatusOperationErrorNotification
diff --git a/packages/taler-util/src/walletTypes.ts 
b/packages/taler-util/src/walletTypes.ts
index 879640e8..f00e2907 100644
--- a/packages/taler-util/src/walletTypes.ts
+++ b/packages/taler-util/src/walletTypes.ts
@@ -523,17 +523,32 @@ export interface ExchangesListRespose {
   exchanges: ExchangeListItem[];
 }
 
+export interface ExchangeTos {
+  acceptedVersion?: string;
+  currentVersion?: string;
+  contentType?: string;
+  content?: string;
+}
 export interface ExchangeListItem {
   exchangeBaseUrl: string;
   currency: string;
   paytoUris: string[];
+  tos: ExchangeTos;
 }
 
+const codecForExchangeTos = (): Codec<ExchangeTos> => 
buildCodecForObject<ExchangeTos>()
+  .property("acceptedVersion", codecOptional(codecForString()))
+  .property("currentVersion", codecOptional(codecForString()))
+  .property("contentType", codecOptional(codecForString()))
+  .property("content", codecOptional(codecForString()))
+  .build("ExchangeTos")
+
 export const codecForExchangeListItem = (): Codec<ExchangeListItem> =>
   buildCodecForObject<ExchangeListItem>()
     .property("currency", codecForString())
     .property("exchangeBaseUrl", codecForString())
     .property("paytoUris", codecForList(codecForString()))
+    .property("tos", codecForExchangeTos())
     .build("ExchangeListItem");
 
 export const codecForExchangesListResponse = (): Codec<ExchangesListRespose> =>
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts 
b/packages/taler-wallet-core/src/operations/exchanges.ts
index 638af813..a10378a8 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -494,11 +494,11 @@ async function updateExchangeFromUrlImpl(
     tosFound !== undefined
       ? tosFound
       : await downloadExchangeWithTermsOfService(
-          baseUrl,
-          ws.http,
-          timeout,
-          "text/plain",
-        );
+        baseUrl,
+        ws.http,
+        timeout,
+        "text/plain",
+      );
 
   let recoupGroupId: string | undefined = undefined;
 
@@ -657,6 +657,9 @@ async function updateExchangeFromUrlImpl(
 
   logger.trace("done updating exchange info in database");
 
+  ws.notify({
+    type: NotificationType.ExchangeAdded,
+  });
   return {
     exchange: updated.exchange,
     exchangeDetails: updated.exchangeDetails,
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index a5a8653c..979bd0e5 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -218,7 +218,7 @@ export function selectWithdrawalDenominations(
   for (const d of denoms) {
     let count = 0;
     const cost = Amounts.add(d.value, d.feeWithdraw).amount;
-    for (;;) {
+    for (; ;) {
       if (Amounts.cmp(remaining, cost) < 0) {
         break;
       }
@@ -746,8 +746,7 @@ export async function updateWithdrawalDenoms(
         denom.verificationStatus === DenominationVerificationStatus.Unverified
       ) {
         logger.trace(
-          `Validating denomination (${current + 1}/${
-            denominations.length
+          `Validating denomination (${current + 1}/${denominations.length
           }) signature of ${denom.denomPubHash}`,
         );
         const valid = await ws.cryptoApi.isValidDenom(
@@ -997,7 +996,7 @@ export async function getExchangeWithdrawalInfo(
     ) {
       console.warn(
         `wallet's support for exchange protocol version 
${WALLET_EXCHANGE_PROTOCOL_VERSION} might be outdated ` +
-          `(exchange has ${exchangeDetails.protocolVersion}), checking for 
updates`,
+        `(exchange has ${exchangeDetails.protocolVersion}), checking for 
updates`,
       );
     }
   }
@@ -1075,6 +1074,12 @@ export async function getWithdrawalDetailsForUri(
           exchanges.push({
             exchangeBaseUrl: details.exchangeBaseUrl,
             currency: details.currency,
+            tos: {
+              acceptedVersion: details.termsOfServiceAcceptedEtag,
+              currentVersion: details.termsOfServiceLastEtag,
+              contentType: details.termsOfServiceContentType,
+              content: details.termsOfServiceText,
+            },
             paytoUris: details.wireInfo.accounts.map((x) => x.payto_uri),
           });
         }
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index 44591a26..576a4459 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -513,9 +513,16 @@ async function getExchanges(
         if (!exchangeDetails) {
           continue;
         }
+
         exchanges.push({
           exchangeBaseUrl: r.baseUrl,
           currency,
+          tos: {
+            acceptedVersion: exchangeDetails.termsOfServiceAcceptedEtag,
+            currentVersion: exchangeDetails.termsOfServiceLastEtag,
+            contentType: exchangeDetails.termsOfServiceContentType,
+            content: exchangeDetails.termsOfServiceText,
+          },
           paytoUris: exchangeDetails.wireInfo.accounts.map((x) => x.payto_uri),
         });
       }
@@ -988,7 +995,7 @@ export async function handleCoreApiRequest(
       try {
         logger.error("Caught unexpected exception:");
         logger.error(e.stack);
-      } catch (e) {}
+      } catch (e) { }
       return {
         type: "error",
         operation,

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