gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-wallet-webex] 01/03: warn about incompatible version


From: gnunet
Subject: [GNUnet-SVN] [taler-wallet-webex] 01/03: warn about incompatible versions on withdraw
Date: Sun, 04 Jun 2017 20:25:38 +0200

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

dold pushed a commit to branch master
in repository wallet-webex.

commit 2cf33705c8ef95e04144b2a77cd4a79189136199
Author: Florian Dold <address@hidden>
AuthorDate: Sun Jun 4 20:16:09 2017 +0200

    warn about incompatible versions on withdraw
---
 .gitignore                                 |  2 ++
 src/i18n/de.po                             | 16 +++++++-------
 src/i18n/en-US.po                          | 16 +++++++-------
 src/i18n/fr.po                             | 16 +++++++-------
 src/i18n/it.po                             | 16 +++++++-------
 src/i18n/taler-wallet-webex.pot            | 16 +++++++-------
 src/types.ts                               | 13 ++++++++++++
 src/wallet.ts                              | 24 ++++++++++++++++++++-
 src/webex/pages/confirm-create-reserve.tsx | 34 +++++++++++++++++++++++++++++-
 src/webex/style/wallet.css                 | 19 +++++++++++++++++
 src/webex/wxBackend.ts                     |  2 +-
 11 files changed, 131 insertions(+), 43 deletions(-)

diff --git a/.gitignore b/.gitignore
index c8ef9b05..d7a865b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,5 @@ dist/
 # Even though node_modules are tracked in git,
 # per default we don't want them to show up in git status
 node_modules
+
+*.swp
diff --git a/src/i18n/de.po b/src/i18n/de.po
index 171e8b05..5bf73c8a 100644
--- a/src/i18n/de.po
+++ b/src/i18n/de.po
@@ -151,44 +151,44 @@ msgid ""
 "selected."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:424
+#: src/webex/pages/confirm-create-reserve.tsx:455
 #, c-format
 msgid "Accept fees and withdraw"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:429
+#: src/webex/pages/confirm-create-reserve.tsx:460
 #, c-format
 msgid "Change Exchange Provider"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:485
+#: src/webex/pages/confirm-create-reserve.tsx:517
 #, c-format
 msgid "You are about to withdraw %1$s from your bank account into your wallet."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:568
+#: src/webex/pages/confirm-create-reserve.tsx:600
 #, c-format
 msgid ""
 "Oops, something went wrong. The wallet responded with error status (%1$s)."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:579
+#: src/webex/pages/confirm-create-reserve.tsx:611
 #, c-format
 msgid "Checking URL, please wait ..."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:593
+#: src/webex/pages/confirm-create-reserve.tsx:625
 #, c-format
 msgid "Can't parse amount: %1$s"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:600
+#: src/webex/pages/confirm-create-reserve.tsx:632
 #, c-format
 msgid "Can't parse wire_types: %1$s"
 msgstr ""
 
 #. TODO:generic error reporting function or component.
-#: src/webex/pages/confirm-create-reserve.tsx:620
+#: src/webex/pages/confirm-create-reserve.tsx:652
 #, c-format
 msgid "Fatal error: \"%1$s\"."
 msgstr ""
diff --git a/src/i18n/en-US.po b/src/i18n/en-US.po
index 7870ff89..e548014e 100644
--- a/src/i18n/en-US.po
+++ b/src/i18n/en-US.po
@@ -151,44 +151,44 @@ msgid ""
 "selected."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:424
+#: src/webex/pages/confirm-create-reserve.tsx:455
 #, c-format
 msgid "Accept fees and withdraw"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:429
+#: src/webex/pages/confirm-create-reserve.tsx:460
 #, c-format
 msgid "Change Exchange Provider"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:485
+#: src/webex/pages/confirm-create-reserve.tsx:517
 #, c-format
 msgid "You are about to withdraw %1$s from your bank account into your wallet."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:568
+#: src/webex/pages/confirm-create-reserve.tsx:600
 #, c-format
 msgid ""
 "Oops, something went wrong. The wallet responded with error status (%1$s)."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:579
+#: src/webex/pages/confirm-create-reserve.tsx:611
 #, c-format
 msgid "Checking URL, please wait ..."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:593
+#: src/webex/pages/confirm-create-reserve.tsx:625
 #, c-format
 msgid "Can't parse amount: %1$s"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:600
+#: src/webex/pages/confirm-create-reserve.tsx:632
 #, c-format
 msgid "Can't parse wire_types: %1$s"
 msgstr ""
 
 #. TODO:generic error reporting function or component.
-#: src/webex/pages/confirm-create-reserve.tsx:620
+#: src/webex/pages/confirm-create-reserve.tsx:652
 #, c-format
 msgid "Fatal error: \"%1$s\"."
 msgstr ""
diff --git a/src/i18n/fr.po b/src/i18n/fr.po
index ccd36aec..da860ad8 100644
--- a/src/i18n/fr.po
+++ b/src/i18n/fr.po
@@ -151,44 +151,44 @@ msgid ""
 "selected."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:424
+#: src/webex/pages/confirm-create-reserve.tsx:455
 #, c-format
 msgid "Accept fees and withdraw"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:429
+#: src/webex/pages/confirm-create-reserve.tsx:460
 #, c-format
 msgid "Change Exchange Provider"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:485
+#: src/webex/pages/confirm-create-reserve.tsx:517
 #, c-format
 msgid "You are about to withdraw %1$s from your bank account into your wallet."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:568
+#: src/webex/pages/confirm-create-reserve.tsx:600
 #, c-format
 msgid ""
 "Oops, something went wrong. The wallet responded with error status (%1$s)."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:579
+#: src/webex/pages/confirm-create-reserve.tsx:611
 #, c-format
 msgid "Checking URL, please wait ..."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:593
+#: src/webex/pages/confirm-create-reserve.tsx:625
 #, c-format
 msgid "Can't parse amount: %1$s"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:600
+#: src/webex/pages/confirm-create-reserve.tsx:632
 #, c-format
 msgid "Can't parse wire_types: %1$s"
 msgstr ""
 
 #. TODO:generic error reporting function or component.
-#: src/webex/pages/confirm-create-reserve.tsx:620
+#: src/webex/pages/confirm-create-reserve.tsx:652
 #, c-format
 msgid "Fatal error: \"%1$s\"."
 msgstr ""
diff --git a/src/i18n/it.po b/src/i18n/it.po
index ccd36aec..da860ad8 100644
--- a/src/i18n/it.po
+++ b/src/i18n/it.po
@@ -151,44 +151,44 @@ msgid ""
 "selected."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:424
+#: src/webex/pages/confirm-create-reserve.tsx:455
 #, c-format
 msgid "Accept fees and withdraw"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:429
+#: src/webex/pages/confirm-create-reserve.tsx:460
 #, c-format
 msgid "Change Exchange Provider"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:485
+#: src/webex/pages/confirm-create-reserve.tsx:517
 #, c-format
 msgid "You are about to withdraw %1$s from your bank account into your wallet."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:568
+#: src/webex/pages/confirm-create-reserve.tsx:600
 #, c-format
 msgid ""
 "Oops, something went wrong. The wallet responded with error status (%1$s)."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:579
+#: src/webex/pages/confirm-create-reserve.tsx:611
 #, c-format
 msgid "Checking URL, please wait ..."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:593
+#: src/webex/pages/confirm-create-reserve.tsx:625
 #, c-format
 msgid "Can't parse amount: %1$s"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:600
+#: src/webex/pages/confirm-create-reserve.tsx:632
 #, c-format
 msgid "Can't parse wire_types: %1$s"
 msgstr ""
 
 #. TODO:generic error reporting function or component.
-#: src/webex/pages/confirm-create-reserve.tsx:620
+#: src/webex/pages/confirm-create-reserve.tsx:652
 #, c-format
 msgid "Fatal error: \"%1$s\"."
 msgstr ""
diff --git a/src/i18n/taler-wallet-webex.pot b/src/i18n/taler-wallet-webex.pot
index ccd36aec..da860ad8 100644
--- a/src/i18n/taler-wallet-webex.pot
+++ b/src/i18n/taler-wallet-webex.pot
@@ -151,44 +151,44 @@ msgid ""
 "selected."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:424
+#: src/webex/pages/confirm-create-reserve.tsx:455
 #, c-format
 msgid "Accept fees and withdraw"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:429
+#: src/webex/pages/confirm-create-reserve.tsx:460
 #, c-format
 msgid "Change Exchange Provider"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:485
+#: src/webex/pages/confirm-create-reserve.tsx:517
 #, c-format
 msgid "You are about to withdraw %1$s from your bank account into your wallet."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:568
+#: src/webex/pages/confirm-create-reserve.tsx:600
 #, c-format
 msgid ""
 "Oops, something went wrong. The wallet responded with error status (%1$s)."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:579
+#: src/webex/pages/confirm-create-reserve.tsx:611
 #, c-format
 msgid "Checking URL, please wait ..."
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:593
+#: src/webex/pages/confirm-create-reserve.tsx:625
 #, c-format
 msgid "Can't parse amount: %1$s"
 msgstr ""
 
-#: src/webex/pages/confirm-create-reserve.tsx:600
+#: src/webex/pages/confirm-create-reserve.tsx:632
 #, c-format
 msgid "Can't parse wire_types: %1$s"
 msgstr ""
 
 #. TODO:generic error reporting function or component.
-#: src/webex/pages/confirm-create-reserve.tsx:620
+#: src/webex/pages/confirm-create-reserve.tsx:652
 #, c-format
 msgid "Fatal error: \"%1$s\"."
 msgstr ""
diff --git a/src/types.ts b/src/types.ts
index 7120f64c..9a7a79ac 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -27,6 +27,7 @@
  * Imports.
  */
 import { Checkable } from "./checkable";
+import * as LibtoolVersion from "./libtoolVersion";
 
 /**
  * Non-negative financial amount.  Fractional values are expressed as multiples
@@ -492,6 +493,11 @@ export interface ExchangeRecord {
    * Timestamp for last update.
    */
   lastUpdateTime: number;
+
+  /**
+   * Last observed protocol version.
+   */
+  protocolVersion?: string;
 }
 
 /**
@@ -558,6 +564,13 @@ export interface ReserveCreationInfo {
    * Public keys of trusted auditors for the currency we're withdrawing.
    */
   trustedAuditorPubs: string[];
+  /**
+   * Result of checking the wallet's version
+   * against the exchange's version.
+   *
+   * Older exchanges don't return version information.
+   */
+  versionMatch: LibtoolVersion.VersionMatchResult|undefined;
 }
 
 
diff --git a/src/wallet.ts b/src/wallet.ts
index b0029e75..2f5fa294 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -34,6 +34,7 @@ import {
   HttpRequestLibrary,
   RequestException,
 } from "./http";
+import * as LibtoolVersion from "./libtoolVersion";
 import {
   AbortTransaction,
   Index,
@@ -152,6 +153,12 @@ export class KeysJson {
   signkeys: any;
 
   /**
+   * Protocol version.
+   */
+  @Checkable.Optional(Checkable.String)
+  version?: string;
+
+  /**
    * Verify that a value matches the schema of this class and convert it into a
    * member.
    */
@@ -1500,6 +1507,19 @@ export class Wallet {
       trustedAuditorPubs.push(...currencyRecord.auditors.map((a) => 
a.auditorPub));
     }
 
+    let versionMatch;
+    if (exchangeInfo.protocolVersion) {
+      versionMatch = LibtoolVersion.compare(WALLET_PROTOCOL_VERSION, 
exchangeInfo.protocolVersion);
+
+      if (versionMatch && !versionMatch.compatible && versionMatch.currentCmp 
== -1) {
+        console.log("wallet version might be outdated, checking for updates");
+        chrome.runtime.requestUpdateCheck((status, details) => {
+          console.log("update check status:", status);
+        });
+      }
+    }
+
+
     const ret: ReserveCreationInfo = {
       earliestDepositExpiration,
       exchangeInfo,
@@ -1512,6 +1532,7 @@ export class Wallet {
       wireFees,
       wireInfo,
       withdrawFee: acc,
+      versionMatch,
     };
     return ret;
   }
@@ -1610,8 +1631,9 @@ export class Wallet {
     }
 
     const updatedExchangeInfo = await this.updateExchangeInfo(exchangeInfo,
-                                                            exchangeKeysJson);
+                                                              
exchangeKeysJson);
     await this.suspendCoins(updatedExchangeInfo);
+    updatedExchangeInfo.protocolVersion = exchangeKeysJson.version;
 
     await this.q()
               .put(Stores.exchanges, updatedExchangeInfo)
diff --git a/src/webex/pages/confirm-create-reserve.tsx 
b/src/webex/pages/confirm-create-reserve.tsx
index ca8517a2..f8f53510 100644
--- a/src/webex/pages/confirm-create-reserve.tsx
+++ b/src/webex/pages/confirm-create-reserve.tsx
@@ -414,10 +414,41 @@ class ExchangeSelection extends 
ImplicitStateComponent<ExchangeSelectionProps> {
     );
   }
 
+  renderUpdateStatus() {
+    const rci = this.reserveCreationInfo();
+    if (!rci) {
+      return null;
+    }
+    if (!rci.versionMatch) {
+      return null;
+    }
+    if (rci.versionMatch.compatible) {
+      return null;
+    }
+    if (rci.versionMatch.currentCmp == -1) {
+      return (
+        <p className="errorbox">
+          Your wallet might be outdated.  The exchange has a higher, 
incompatible
+          protocol version.
+        </p>
+      );
+    }
+    if (rci.versionMatch.currentCmp == 1) {
+      return (
+        <p className="errorbox">
+          The chosen exchange might be outdated.  The exchange has a lower, 
incompatible
+          protocol version.
+        </p>
+      );
+    }
+    throw Error("not reached");
+  }
+
   renderConfirm() {
     return (
       <div>
         {this.renderFeeStatus()}
+        <p>
         <button className="pure-button button-success"
                 disabled={this.reserveCreationInfo() === null}
                 onClick={() => this.confirmReserve()}>
@@ -428,7 +459,8 @@ class ExchangeSelection extends 
ImplicitStateComponent<ExchangeSelectionProps> {
                 onClick={() => this.selectingExchange(true)}>
           {i18n.str`Change Exchange Provider`}
         </button>
-        <br/>
+        </p>
+        {this.renderUpdateStatus()}
         <Collapsible initiallyCollapsed={true} title="Fee and Spending 
Details">
           {renderReserveCreationDetails(this.reserveCreationInfo())}
         </Collapsible>
diff --git a/src/webex/style/wallet.css b/src/webex/style/wallet.css
index 752fc6d7..7bfb99e6 100644
--- a/src/webex/style/wallet.css
+++ b/src/webex/style/wallet.css
@@ -220,3 +220,22 @@ span.spacer {
 a.actionLink {
   color: black;
 }
+
+
+.errorbox {
+  border: 1px solid;
+  display: inline-block;
+  margin: 1em;
+  padding: 1em;
+  font-weight: bold;
+  background: #FF8A8A;
+}
+
+.okaybox {
+  border: 1px solid;
+  display: inline-block;
+  margin: 1em;
+  padding: 1em;
+  font-weight: bold;
+  background: #00FA9A;
+}
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 6ea9a3cf..b4e24e09 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -58,7 +58,7 @@ const DB_NAME = "taler";
  * In the future we might consider adding migration functions for
  * each version increment.
  */
-const DB_VERSION = 17;
+const DB_VERSION = 18;
 
 function handleMessage(db: IDBDatabase,
                        wallet: Wallet,

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



reply via email to

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