gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-wallet-webex] branch master updated (c1b11a66 -> 54b


From: gnunet
Subject: [GNUnet-SVN] [taler-wallet-webex] branch master updated (c1b11a66 -> 54b5a9af)
Date: Mon, 09 Apr 2018 00:43:21 +0200

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

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

    from c1b11a66 fix merchant page event handling, remove taler-pay for now
     new 3570e36b squelch ts error
     new 6533716f prevent race condition where we can accept tip before the 
background page knows about it
     new a75ef403 make linter happy
     new 54b5a9af set display version to 0.5.0

The 4 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:
 manifest.json                              |  4 ++--
 src/amounts.ts                             | 25 +++++++++++++++++++++
 src/i18n.tsx                               | 36 ++++++++++++++++++------------
 src/talerTypes.ts                          |  7 ++++++
 src/wallet.ts                              |  6 +++--
 src/webex/compat.ts                        |  6 ++---
 src/webex/pages/confirm-contract.tsx       |  3 ++-
 src/webex/pages/confirm-create-reserve.tsx |  2 +-
 src/webex/pages/redirect.js                |  8 +++++--
 src/webex/pages/tip.tsx                    |  4 ++--
 src/webex/wxApi.ts                         |  3 +++
 src/webex/wxBackend.ts                     |  7 ++++--
 tsconfig.json                              |  1 +
 13 files changed, 83 insertions(+), 29 deletions(-)

diff --git a/manifest.json b/manifest.json
index 6fb7c1a6..b2239dd8 100644
--- a/manifest.json
+++ b/manifest.json
@@ -4,8 +4,8 @@
   "name": "GNU Taler Wallet (git)",
   "description": "Privacy preserving and transparent payments",
   "author": "GNU Taler Developers",
-  "version": "0.6.59",
-  "version_name": "0.5.0-pre11",
+  "version": "0.6.60",
+  "version_name": "0.5.0",
 
   "minimum_chrome_version": "51",
   "minimum_opera_version": "36",
diff --git a/src/amounts.ts b/src/amounts.ts
index fafbcb3e..280cd636 100644
--- a/src/amounts.ts
+++ b/src/amounts.ts
@@ -19,16 +19,19 @@
  * Types and helper functions for dealing with Taler amounts.
  */
 
+
 /**
  * Imports.
  */
 import { Checkable } from "./checkable";
 
+
 /**
  * Number of fractional units that one value unit represents.
  */
 export const fractionalBase = 1e8;
 
+
 /**
  * Non-negative financial amount.  Fractional values are expressed as multiples
  * of 1e-8.
@@ -60,6 +63,7 @@ export class AmountJson {
   static checked: (obj: any) => AmountJson;
 }
 
+
 /**
  * Result of a possibly overflowing operation.
  */
@@ -74,6 +78,7 @@ export interface Result {
   saturated: boolean;
 }
 
+
 /**
  * Get the largest amount that is safely representable.
  */
@@ -85,6 +90,7 @@ export function getMaxAmount(currency: string): AmountJson {
   };
 }
 
+
 /**
  * Get an amount that represents zero units of a currency.
  */
@@ -96,6 +102,7 @@ export function getZero(currency: string): AmountJson {
   };
 }
 
+
 /**
  * Add two amounts.  Return the result and whether
  * the addition overflowed.  The overflow is always handled
@@ -124,6 +131,7 @@ export function add(first: AmountJson, ...rest: 
AmountJson[]): Result {
   return { amount: { currency, value, fraction }, saturated: false };
 }
 
+
 /**
  * Subtract two amounts.  Return the result and whether
  * the subtraction overflowed.  The overflow is always handled
@@ -158,6 +166,7 @@ export function sub(a: AmountJson, ...rest: AmountJson[]): 
Result {
   return { amount: { currency, value, fraction }, saturated: false };
 }
 
+
 /**
  * Compare two amounts.  Returns 0 when equal, -1 when a < b
  * and +1 when a > b.  Throws when currencies don't match.
@@ -186,6 +195,7 @@ export function cmp(a: AmountJson, b: AmountJson): number {
   }
 }
 
+
 /**
  * Create a copy of an amount.
  */
@@ -197,6 +207,7 @@ export function copy(a: AmountJson): AmountJson {
   };
 }
 
+
 /**
  * Divide an amount.  Throws on division by zero.
  */
@@ -215,6 +226,7 @@ export function divide(a: AmountJson, n: number): 
AmountJson {
   };
 }
 
+
 /**
  * Check if an amount is non-zero.
  */
@@ -222,6 +234,7 @@ export function isNonZero(a: AmountJson): boolean {
   return a.value > 0 || a.fraction > 0;
 }
 
+
 /**
  * Parse an amount like 'EUR:20.5' for 20 Euros and 50 ct.
  */
@@ -237,6 +250,11 @@ export function parse(s: string): AmountJson|undefined {
   };
 }
 
+
+/**
+ * Parse amount in standard string form (like 'EUR:20.5'),
+ * throw if the input is not a valid amount.
+ */
 export function parseOrThrow(s: string): AmountJson {
   const res = parse(s);
   if (!res) {
@@ -245,6 +263,7 @@ export function parseOrThrow(s: string): AmountJson {
   return res;
 }
 
+
 /**
  * Convert the amount to a float.
  */
@@ -252,6 +271,7 @@ export function toFloat(a: AmountJson): number {
   return a.value + (a.fraction / fractionalBase);
 }
 
+
 /**
  * Convert a float to a Taler amount.
  * Loss of precision possible.
@@ -264,6 +284,7 @@ export function fromFloat(floatVal: number, currency: 
string) {
   };
 }
 
+
 /**
  * Convert to standard human-readable string representation that's
  * also used in JSON formats.
@@ -272,6 +293,10 @@ export function toString(a: AmountJson) {
   return `${a.currency}:${a.value + (a.fraction / fractionalBase)}`;
 }
 
+
+/**
+ * Check if the argument is a valid amount in string form.
+ */
 export function check(a: any) {
   if (typeof a !== "string") {
     return false;
diff --git a/src/i18n.tsx b/src/i18n.tsx
index dfd1528e..ddf4fb76 100644
--- a/src/i18n.tsx
+++ b/src/i18n.tsx
@@ -26,23 +26,31 @@ import {strings} from "./i18n/strings";
 import * as jedLib from "jed";
 import * as React from "react";
 
-let lang: string;
-try {
-  lang = chrome.i18n.getUILanguage();
-  // Chrome gives e.g. "en-US", but Firefox gives us "en_US"
-  lang = lang.replace("_", "-");
-} catch (e) {
-  lang = "en";
-  console.warn("i18n default language not available");
-}
 
-if (!strings[lang]) {
-  lang = "en-US";
-  console.log(`language ${lang} not found, defaulting to english`);
-}
+const jed = setupJed();
 
-const jed = new jedLib.Jed(strings[lang]);
 
+/**
+ * Set up jed library for internationalization,
+ * based on browser language settings.
+ */
+function setupJed(): any {
+  let lang: string;
+  try {
+    lang = chrome.i18n.getUILanguage();
+    // Chrome gives e.g. "en-US", but Firefox gives us "en_US"
+    lang = lang.replace("_", "-");
+  } catch (e) {
+    lang = "en";
+    console.warn("i18n default language not available");
+  }
+
+  if (!strings[lang]) {
+    lang = "en-US";
+    console.log(`language ${lang} not found, defaulting to english`);
+  }
+  return new jedLib.Jed(strings[lang]);
+}
 
 
 /**
diff --git a/src/talerTypes.ts b/src/talerTypes.ts
index 15e0009f..f8fb72b9 100644
--- a/src/talerTypes.ts
+++ b/src/talerTypes.ts
@@ -896,9 +896,16 @@ export function isWireDetail(x: any): x is WireDetail {
  */
 @Checkable.Class({extra: true})
 export class Proposal {
+  /**
+   * Contract terms for the propoal.
+   */
   @Checkable.Value(() => ContractTerms)
   contract_terms: ContractTerms;
 
+  /**
+   * Signature over contract, made by the merchant.  The public key used for 
signing
+   * must be contract_terms.merchant_pub.
+   */
   @Checkable.String()
   sig: string;
 
diff --git a/src/wallet.ts b/src/wallet.ts
index 7c8aa772..8655c59c 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -2754,7 +2754,7 @@ export class Wallet {
       return this.activeTipOperations[key];
     }
     const p = this.processTipImpl(tipToken);
-    this.activeTipOperations[key] = p
+    this.activeTipOperations[key] = p;
     try {
       return await p;
     } finally {
@@ -2801,6 +2801,7 @@ export class Wallet {
     let merchantResp;
 
     tipRecord = await this.q().putOrGetExisting(Stores.tips, tipRecord, 
[tipRecord.tipId, merchantDomain]);
+    this.notifier.notify();
 
     // Planchets in the form that the merchant expects
     const planchetsDetail: TipPlanchetDetail[] = tipRecord.planchets.map((p) 
=> ({
@@ -2846,6 +2847,7 @@ export class Wallet {
     tipRecord.pickedUp = true;
 
     await this.q().put(Stores.tips, tipRecord).finish();
+    this.notifier.notify();
 
     return tipRecord;
   }
@@ -2890,7 +2892,7 @@ export class Wallet {
   async getTipStatus(tipToken: TipToken): Promise<TipStatus> {
     const tipId = tipToken.tip_id;
     const merchantDomain = new URI(tipToken.pickup_url).origin();
-    let tipRecord = await this.q().get(Stores.tips, [tipId, merchantDomain]);
+    const tipRecord = await this.q().get(Stores.tips, [tipId, merchantDomain]);
     const amount = Amounts.parseOrThrow(tipToken.amount);
     const exchangeUrl = tipToken.exchange_url;
     this.processTip(tipToken);
diff --git a/src/webex/compat.ts b/src/webex/compat.ts
index 30ffd4a8..65ddfab4 100644
--- a/src/webex/compat.ts
+++ b/src/webex/compat.ts
@@ -15,9 +15,9 @@
  */
 
 /**
-* Compatibility helpers needed for browsers that don't implement
-* WebExtension APIs consistently.
-*/
+ * Compatibility helpers needed for browsers that don't implement
+ * WebExtension APIs consistently.
+ */
 
 export function isFirefox(): boolean {
     const rt = chrome.runtime as any;
diff --git a/src/webex/pages/confirm-contract.tsx 
b/src/webex/pages/confirm-contract.tsx
index f1e98f22..41eebda8 100644
--- a/src/webex/pages/confirm-contract.tsx
+++ b/src/webex/pages/confirm-contract.tsx
@@ -379,7 +379,8 @@ class ContractPrompt extends 
React.Component<ContractPromptProps, ContractPrompt
           {products}
           {(this.state.payStatus && this.state.payStatus.coinSelection)
             ? <i18n.Translate wrap="p">
-                The total price is <span>{amount} </span> (plus 
<span>{renderAmount(this.state.payStatus.coinSelection.totalFees)}</span> fees).
+                The total price is <span>{amount} </span>
+                (plus 
<span>{renderAmount(this.state.payStatus.coinSelection.totalFees)}</span> fees).
               </i18n.Translate>
             :
             <i18n.Translate wrap="p">The total price is 
<span>{amount}</span>.</i18n.Translate>
diff --git a/src/webex/pages/confirm-create-reserve.tsx 
b/src/webex/pages/confirm-create-reserve.tsx
index 5be6fe35..cef64716 100644
--- a/src/webex/pages/confirm-create-reserve.tsx
+++ b/src/webex/pages/confirm-create-reserve.tsx
@@ -340,7 +340,7 @@ class ExchangeSelection extends 
ImplicitStateComponent<ExchangeSelectionProps> {
             <button className="pure-button button-success" onClick={() => 
this.select(this.props.suggestedExchangeUrl)}>
               <i18n.Translate wrap="span">
               Select <strong>{this.props.suggestedExchangeUrl}</strong>
-              </i18n.Translate> 
+              </i18n.Translate>
             </button>
           </div>
         )}
diff --git a/src/webex/pages/redirect.js b/src/webex/pages/redirect.js
index 5a758cce..879f5b53 100644
--- a/src/webex/pages/redirect.js
+++ b/src/webex/pages/redirect.js
@@ -7,6 +7,10 @@
  * redirect to pages inside the extension that are a web-accessible resource.
  */
 
- 
 const myUrl = new URL(window.location.href);
-window.location.replace(myUrl.searchParams.get("url"));
+const redirectUrl = myUrl.searchParams.get("url");
+if (!redirectUrl) {
+  console.error("missing redirect URL");
+} else {
+  window.location.replace(redirectUrl);
+}
diff --git a/src/webex/pages/tip.tsx b/src/webex/pages/tip.tsx
index f21bc0ea..c13120c4 100644
--- a/src/webex/pages/tip.tsx
+++ b/src/webex/pages/tip.tsx
@@ -30,8 +30,8 @@ import * as i18n from "../../i18n";
 
 import {
   acceptTip,
-  getTipStatus,
   getReserveCreationInfo,
+  getTipStatus,
 } from "../wxApi";
 
 import {
@@ -127,7 +127,7 @@ class TipDisplay extends React.Component<TipDisplayProps, 
TipDisplayState> {
         <button
             className="pure-button pure-button-primary"
             type="button"
-            disabled={!(this.state.rci && this.state.tipStatus)}
+            disabled={!(this.state.rci && this.state.tipStatus && 
this.state.tipStatus.tipRecord)}
             onClick={() => this.accept()}>
           { this.state.working
             ? <span><object className="svg-icon svg-baseline" 
data="/img/spinner-bars.svg" /> </span>
diff --git a/src/webex/wxApi.ts b/src/webex/wxApi.ts
index 32788d37..e5da642f 100644
--- a/src/webex/wxApi.ts
+++ b/src/webex/wxApi.ts
@@ -72,6 +72,9 @@ export interface UpgradeResponse {
 }
 
 
+/**
+ * Error thrown when the function from the backend (via RPC) threw an error.
+ */
 export class WalletApiError extends Error {
   constructor(message: string, public detail: any) {
     super(message);
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 0b4f0976..b1aecbbd 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -475,7 +475,10 @@ function waitMs(timeoutMs: number): Promise<void> {
 }
 
 
-function makeSyncWalletRedirect(url: string, tabId: number, oldUrl: string, 
params?: {[name: string]: string | undefined}): object {
+function makeSyncWalletRedirect(url: string,
+                                tabId: number,
+                                oldUrl: string,
+                                params?: {[name: string]: string | 
undefined}): object {
   const innerUrl = new URI(chrome.extension.getURL("/src/webex/pages/" + url));
   if (params) {
     for (const key in params) {
@@ -552,8 +555,8 @@ function handleHttpPayment(headerList: 
chrome.webRequest.HttpHeader[], url: stri
   if (fields.contract_url) {
     return makeSyncWalletRedirect("confirm-contract.html", tabId, url, {
       contractUrl: fields.contract_url,
-      sessionId: fields.session_id,
       resourceUrl: fields.resource_url,
+      sessionId: fields.session_id,
     });
   }
 
diff --git a/tsconfig.json b/tsconfig.json
index 819c5427..d085b722 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -66,6 +66,7 @@
     "src/webex/pages/logs.tsx",
     "src/webex/pages/payback.tsx",
     "src/webex/pages/popup.tsx",
+    "src/webex/pages/redirect.js",
     "src/webex/pages/refund.tsx",
     "src/webex/pages/reset-required.tsx",
     "src/webex/pages/return-coins.tsx",

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



reply via email to

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