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: remove dead cod


From: gnunet
Subject: [GNUnet-SVN] [taler-wallet-webex] branch master updated: remove dead code and add comments
Date: Wed, 24 May 2017 16:13:08 +0200

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

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

The following commit(s) were added to refs/heads/master by this push:
     new 1c8206f8 remove dead code and add comments
1c8206f8 is described below

commit 1c8206f8c0c8921643aa1b070fbe6648411300fe
Author: Florian Dold <address@hidden>
AuthorDate: Wed May 24 16:14:23 2017 +0200

    remove dead code and add comments
---
 src/background/background.ts   |  4 +++-
 src/checkable.ts               |  3 +++
 src/components.ts              |  6 +++++-
 src/content_scripts/notify.ts  |  7 ++++---
 src/cryptoWorker.ts            |  8 ++++++--
 src/emscriptif.ts              | 19 ++++++++++++-------
 src/helpers.ts                 | 39 ++++++++++++++++-----------------------
 src/http.ts                    | 27 ++++++++++++++++-----------
 src/pages/confirm-contract.tsx | 10 ++++------
 src/pages/popup.tsx            |  4 +---
 tooling/README                 |  7 +++++++
 11 files changed, 77 insertions(+), 57 deletions(-)

diff --git a/src/background/background.ts b/src/background/background.ts
index 9b50caf9..aca27ef4 100644
--- a/src/background/background.ts
+++ b/src/background/background.ts
@@ -20,7 +20,9 @@
  * @author Florian Dold
  */
 
-
+/**
+ * Imports.
+ */
 import {wxMain} from "./../wxBackend";
 
 window.addEventListener("load", () => {
diff --git a/src/checkable.ts b/src/checkable.ts
index 8eb5e152..6bfaea01 100644
--- a/src/checkable.ts
+++ b/src/checkable.ts
@@ -32,6 +32,9 @@
  *    name: string;
  *    @Checkable.Number
  *    age: number;
+ *
+ *    // Method will be implemented automatically
+ *    static checked(obj: any): Person;
  *  }
  * ```
  */
diff --git a/src/components.ts b/src/components.ts
index 569810f3..bef3cff4 100644
--- a/src/components.ts
+++ b/src/components.ts
@@ -16,11 +16,15 @@
 
 
 /**
- * General helper components
+ * General helper React components.
  * 
  * @author Florian Dold
  */
 
+
+/**
+ * Imports.
+ */
 import * as React from "react";
 
 export interface StateHolder<T> {
diff --git a/src/content_scripts/notify.ts b/src/content_scripts/notify.ts
index 49833163..64414e0b 100644
--- a/src/content_scripts/notify.ts
+++ b/src/content_scripts/notify.ts
@@ -16,13 +16,14 @@
 
 
 /**
- * Script that is injected into (all!) pages to allow them
+ * Module that is injected into (all!) pages to allow them
  * to interact with the GNU Taler wallet via DOM Events.
- *
- * @author Florian Dold
  */
 
 
+/**
+ * Imports.
+ */
 import URI = require("urijs");
 
 declare var cloneInto: any;
diff --git a/src/cryptoWorker.ts b/src/cryptoWorker.ts
index aab7d334..bf802a32 100644
--- a/src/cryptoWorker.ts
+++ b/src/cryptoWorker.ts
@@ -16,11 +16,12 @@
 
 /**
  * Web worker for crypto operations.
- * @author Florian Dold
  */
 
-"use strict";
 
+/**
+ * Imports.
+ */
 import * as native from "./emscriptif";
 import {
   PreCoinRecord,
@@ -386,6 +387,9 @@ namespace RpcFunctions {
     return refreshSession;
   }
 
+  /**
+   * Hash a string including the zero terminator.
+   */
   export function hashString(str: string): string {
     const b = native.ByteArray.fromStringWithNull(str);
     return b.hash().toCrock();
diff --git a/src/emscriptif.ts b/src/emscriptif.ts
index caa0fb8c..60653b66 100644
--- a/src/emscriptif.ts
+++ b/src/emscriptif.ts
@@ -14,21 +14,26 @@
  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
-import {AmountJson} from "./types";
-import * as emscLib from "./emscripten/taler-emscripten-lib";
 
 /**
  * Medium-level interface to emscripten-compiled modules used
- * by the wallet.
+ * by the wallet.  Handles memory management by allocating by allocating
+ * objects in arenas that then can be disposed of all at once.
  *
  * The high-level interface (using WebWorkers) is exposed in src/cryptoApi.ts.
- *
- * @author Florian Dold
  */
 
-"use strict";
+/**
+ * Imports.
+ */
+import {AmountJson} from "./types";
+import * as emscLib from "./emscripten/taler-emscripten-lib";
+
 
-// Size of a native pointer.
+/**
+ * Size of a native pointer.  Must match the size
+ * use when compiling via emscripten.
+ */
 const PTR_SIZE = 4;
 
 const GNUNET_OK = 1;
diff --git a/src/helpers.ts b/src/helpers.ts
index 7b947027..8b2b265c 100644
--- a/src/helpers.ts
+++ b/src/helpers.ts
@@ -17,20 +17,19 @@
 /**
  * Smaller helper functions that do not depend
  * on the emscripten machinery.
- *
- * @author Florian Dold
  */
 
+/**
+ * Imports.
+ */
 import {AmountJson, Amounts} from "./types";
 import URI = require("urijs");
 
-export function substituteFulfillmentUrl(url: string, vars: any) {
-  url = url.replace("${H_contract}", vars.H_contract);
-  url = url.replace("${$}", "$");
-  return url;
-}
-
-
+/**
+ * Show an amount in a form suitable for the user.
+ * FIXME:  In the future, this should consider currency-specific
+ * settings such as significant digits or currency symbols.
+ */
 export function amountToPretty(amount: AmountJson): string {
   let x = amount.value + amount.fraction / Amounts.fractionalBase;
   return `${x} ${amount.currency}`;
@@ -54,20 +53,6 @@ export function canonicalizeBaseUrl(url: string) {
 }
 
 
-export function parsePrettyAmount(pretty: string): AmountJson|undefined {
-  const res = /([0-9]+)(.[0-9]+)?\s*(\w+)/.exec(pretty);
-  if (!res) {
-    return undefined;
-  }
-  return {
-    value: parseInt(res[1], 10),
-    fraction: res[2] ? (parseFloat(`0.${res[2]}`) / Amounts.fractionalBase) : 
0,
-    currency: res[3]
-  }
-}
-
-
-
 /**
  * Convert object to JSON with canonical ordering of keys
  * and whitespace omitted.
@@ -119,6 +104,10 @@ export function flatMap<T, U>(xs: T[], f: (x: T) => U[]): 
U[] {
 }
 
 
+/**
+ * Extract a numeric timstamp (in seconds) from the Taler date format
+ * ("/Date([n])/").  Returns null if input is not in the right format.
+ */
 export function getTalerStampSec(stamp: string): number | null {
   const m = stamp.match(/\/?Date\(([0-9]*)\)\/?/);
   if (!m) {
@@ -128,6 +117,10 @@ export function getTalerStampSec(stamp: string): number | 
null {
 }
 
 
+/**
+ * Get a JavaScript Date object from a Taler date string.
+ * Returns null if input is not in the right format.
+ */
 export function getTalerStampDate(stamp: string): Date | null {
   let sec = getTalerStampSec(stamp);
   if (sec == null) {
diff --git a/src/http.ts b/src/http.ts
index 5e658001..965a44a9 100644
--- a/src/http.ts
+++ b/src/http.ts
@@ -16,23 +16,22 @@
 
 /**
  * Helpers for doing XMLHttpRequest-s that are based on ES6 promises.
- * @module Http
- * @author Florian Dold
+ * Allows for easy mocking for test cases.
  */
 
-"use strict";
-
+/**
+ * An HTTP response that is returned by all request methods of this library.
+ */
 export interface HttpResponse {
   status: number;
   responseText: string;
 }
 
 
+/**
+ * The request library is bundled into an interface to make mocking easy.
+ */
 export interface HttpRequestLibrary {
-  req(method: string,
-      url: string,
-      options?: any): Promise<HttpResponse>;
-
   get(url: string): Promise<HttpResponse>;
 
   postJson(url: string, body: any): Promise<HttpResponse>;
@@ -41,8 +40,12 @@ export interface HttpRequestLibrary {
 }
 
 
+/**
+ * An implementation of the [[HttpRequestLibrary]] using the
+ * browser's XMLHttpRequest.
+ */
 export class BrowserHttpLib {
-  req(method: string,
+  private req(method: string,
       url: string,
       options?: any): Promise<HttpResponse> {
     return new Promise<HttpResponse>((resolve, reject) => {
@@ -82,8 +85,10 @@ export class BrowserHttpLib {
 }
 
 
+/**
+ * Exception thrown on request errors.
+ */
 export class RequestException {
-  constructor(detail: any) {
-
+  constructor(public detail: any) {
   }
 }
diff --git a/src/pages/confirm-contract.tsx b/src/pages/confirm-contract.tsx
index d8f72ba0..6c2480c1 100644
--- a/src/pages/confirm-contract.tsx
+++ b/src/pages/confirm-contract.tsx
@@ -17,13 +17,12 @@
 /**
  * Page shown to the user to confirm entering
  * a contract.
- *
- * @author Florian Dold
  */
 
-"use strict";
 
-import {substituteFulfillmentUrl} from "../helpers";
+/**
+ * Imports.
+ */
 import {Contract, AmountJson, ExchangeRecord} from "../types";
 import {OfferRecord} from "../wallet";
 import {renderContract, prettyAmount} from "../renderHtml";
@@ -201,8 +200,7 @@ class ContractPrompt extends 
React.Component<ContractPromptProps, ContractPrompt
       }
       let c = d.offer!.contract;
       console.log("contract", c);
-      document.location.href = substituteFulfillmentUrl(c.fulfillment_url,
-                                                        this.state.offer);
+      document.location.href = c.fulfillment_url;
     });
   }
 
diff --git a/src/pages/popup.tsx b/src/pages/popup.tsx
index 9b375097..c0d280db 100644
--- a/src/pages/popup.tsx
+++ b/src/pages/popup.tsx
@@ -25,7 +25,6 @@
 
 "use strict";
 
-import {substituteFulfillmentUrl} from "../helpers";
 import BrowserClickedEvent = chrome.browserAction.BrowserClickedEvent;
 import {HistoryRecord, HistoryLevel} from "../wallet";
 import {
@@ -372,8 +371,7 @@ function formatHistoryItem(historyItem: HistoryRecord) {
       );
     }
     case "pay": {
-      let url = substituteFulfillmentUrl(d.fulfillmentUrl,
-                                         {H_contract: d.contractHash});
+      let url = d.fulfillmentUrl;
       let merchantElem = <em>{abbrev(d.merchantName, 15)}</em>;
       let fulfillmentLinkElem = <a href={url} onClick={openTab(url)}>view 
product</a>;
       return (
diff --git a/tooling/README b/tooling/README
new file mode 100644
index 00000000..dd14496a
--- /dev/null
+++ b/tooling/README
@@ -0,0 +1,7 @@
+This directory contains NPM packages that are used by the wallet.
+
+At some point they should be published to the registry, right now we don't
+bother and simply add them to the top-level wallet project via file URL.
+
+Due to this, the JavaScript files compiled from TypeScript are currently
+checked into git.

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



reply via email to

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