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: lint for unused


From: gnunet
Subject: [GNUnet-SVN] [taler-wallet-webex] branch master updated: lint for unused variables, fix query bug detected by this
Date: Mon, 29 May 2017 18:27:53 +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 94d111a9 lint for unused variables, fix query bug detected by this
94d111a9 is described below

commit 94d111a94533c0c31231642e8ffe4fbd4ce30096
Author: Florian Dold <address@hidden>
AuthorDate: Mon May 29 18:27:50 2017 +0200

    lint for unused variables, fix query bug detected by this
---
 gulpfile.js                                |  1 +
 src/crypto/cryptoApi-test.ts               |  1 +
 src/crypto/cryptoApi.ts                    |  4 ++--
 src/crypto/emscInterface-test.ts           |  4 ++++
 src/crypto/emscInterface.ts                |  3 ---
 src/query.ts                               | 11 +++++++++--
 src/types.ts                               | 30 +-----------------------------
 src/wallet.ts                              |  7 ++-----
 src/webex/notify.ts                        | 10 ----------
 src/webex/pages/add-auditor.tsx            |  8 --------
 src/webex/pages/auditors.tsx               |  8 --------
 src/webex/pages/confirm-contract.tsx       |  1 -
 src/webex/pages/confirm-create-reserve.tsx | 14 +-------------
 src/webex/pages/error.tsx                  |  4 ++--
 src/webex/pages/payback.tsx                | 13 +------------
 src/webex/pages/popup.tsx                  |  4 ----
 src/webex/pages/tree.tsx                   |  1 -
 src/webex/renderHtml.tsx                   |  2 --
 src/webex/wxBackend.ts                     |  3 ---
 tsconfig.json                              |  3 ++-
 tslint.json                                |  3 ++-
 21 files changed, 28 insertions(+), 107 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js
index a95542e1..03fe4d8a 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -111,6 +111,7 @@ const tsBaseArgs = {
   noImplicitAny: true,
   allowJs: true,
   checkJs: true,
+  noUnusedLocals: true,
 };
 
 
diff --git a/src/crypto/cryptoApi-test.ts b/src/crypto/cryptoApi-test.ts
index 60bd44c9..7e391cd9 100644
--- a/src/crypto/cryptoApi-test.ts
+++ b/src/crypto/cryptoApi-test.ts
@@ -94,6 +94,7 @@ test("precoin creation", async (t) => {
   };
 
   const precoin = await crypto.createPreCoin(denomValid1, r);
+  t.truthy(precoin);
   t.pass();
 });
 
diff --git a/src/crypto/cryptoApi.ts b/src/crypto/cryptoApi.ts
index b5d7d4fb..c3c1f508 100644
--- a/src/crypto/cryptoApi.ts
+++ b/src/crypto/cryptoApi.ts
@@ -100,7 +100,7 @@ export class CryptoApi {
   /**
    * Start a worker (if not started) and set as busy.
    */
-  wake<T>(ws: WorkerState, work: WorkItem): void {
+  wake(ws: WorkerState, work: WorkItem): void {
     if (ws.currentWorkItem !== null) {
       throw Error("assertion failed");
     }
@@ -238,7 +238,7 @@ export class CryptoApi {
           continue;
         }
 
-        this.wake<T>(ws, workItem);
+        this.wake(ws, workItem);
         return;
       }
 
diff --git a/src/crypto/emscInterface-test.ts b/src/crypto/emscInterface-test.ts
index 789ac250..518ed8e7 100644
--- a/src/crypto/emscInterface-test.ts
+++ b/src/crypto/emscInterface-test.ts
@@ -114,6 +114,8 @@ test("withdraw-request", (t) => {
 test("ecdsa", (t) => {
   const priv = native.EcdsaPrivateKey.create();
   const pub1 = priv.getPublicKey();
+  t.truthy(priv);
+  t.truthy(pub1);
   t.pass();
 });
 
@@ -121,5 +123,7 @@ test("ecdsa", (t) => {
 test("ecdhe", (t) => {
   const priv = native.EcdhePrivateKey.create();
   const pub = priv.getPublicKey();
+  t.truthy(priv);
+  t.truthy(pub);
   t.pass();
 });
diff --git a/src/crypto/emscInterface.ts b/src/crypto/emscInterface.ts
index 81c6e9a2..8c9a3413 100644
--- a/src/crypto/emscInterface.ts
+++ b/src/crypto/emscInterface.ts
@@ -40,9 +40,6 @@ const emscLib = getLib();
 const PTR_SIZE = 4;
 
 const GNUNET_OK = 1;
-const GNUNET_YES = 1;
-const GNUNET_NO = 0;
-const GNUNET_SYSERR = -1;
 
 
 /**
diff --git a/src/query.ts b/src/query.ts
index 805abd36..24db4de5 100644
--- a/src/query.ts
+++ b/src/query.ts
@@ -49,6 +49,7 @@ export class Store<T> {
   }
 }
 
+
 /**
  * Definition of an index.
  */
@@ -61,6 +62,13 @@ export class Index<S extends IDBValidKey, T> {
   constructor(s: Store<T>, public indexName: string, public keyPath: string | 
string[]) {
     this.storeName = s.name;
   }
+
+  /**
+   * We want to have the key type parameter in use somewhere,
+   * because otherwise the compiler complains.  In iterIndex the
+   * key type is pretty useful.
+   */
+  protected _dummyKey: S|undefined;
 }
 
 /**
@@ -315,7 +323,6 @@ abstract class QueryStreamBase<T> implements 
QueryStream<T>, PromiseLike<void> {
 type FilterFn = (e: any) => boolean;
 type SubscribeFn = (done: boolean, value: any, tx: IDBTransaction) => void;
 type SubscribeOneFn = (value: any, tx: IDBTransaction) => void;
-type FlatMapFn<T> = (v: T) => T[];
 
 class QueryStreamFilter<T> extends QueryStreamBase<T> {
   constructor(public s: QueryStreamBase<T>, public filterFn: FilterFn) {
@@ -349,7 +356,7 @@ class QueryStreamFlatMap<T, S> extends QueryStreamBase<S> {
       }
       const values = this.flatMapFn(value);
       for (const v in values) {
-        f(false, value, tx);
+        f(false, v, tx);
       }
     });
   }
diff --git a/src/types.ts b/src/types.ts
index aac429c7..c4b6c466 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -900,39 +900,11 @@ export interface WalletBalanceEntry {
 
 
 /**
- * Information about a merchant.
- */
-interface Merchant {
-  /**
-   * label for a location with the business address of the merchant
-   */
-  address: string;
-
-  /**
-   * the merchant's legal name of business
-   */
-  name: string;
-
-  /**
-   * label for a location that denotes the jurisdiction for disputes.
-   * Some of the typical fields for a location (such as a street address) may 
be absent.
-   */
-  jurisdiction: string;
-
-  /**
-   * Instance of the merchant, in case one merchant
-   * represents multiple receivers.
-   */
-  instance?: string;
-}
-
-
-/**
  * Contract terms from a merchant.
  */
 @Checkable.Class({validate: true})
 export class Contract {
-  private validate() {
+  validate() {
     if (this.exchanges.length === 0) {
       throw Error("no exchanges in contract");
     }
diff --git a/src/wallet.ts b/src/wallet.ts
index 5564162b..92187d82 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -28,13 +28,10 @@ import {
   amountToPretty,
   canonicalJson,
   canonicalizeBaseUrl,
-  deepEquals,
-  flatMap,
   getTalerStampSec,
 } from "./helpers";
 import {
   HttpRequestLibrary,
-  HttpResponse,
   RequestException,
 } from "./http";
 import {
@@ -49,7 +46,6 @@ import {
   AmountJson,
   Amounts,
   Auditor,
-  AuditorRecord,
   CheckPayResult,
   CoinPaySig,
   CoinRecord,
@@ -1045,7 +1041,6 @@ export class Wallet {
     this.startOperation(opId);
 
     try {
-      const exchange = await 
this.updateExchangeFromUrl(reserveRecord.exchange_base_url);
       const reserve = await this.updateReserve(reserveRecord.reserve_pub);
       const n = await this.depleteReserve(reserve);
 
@@ -1381,12 +1376,14 @@ export class Wallet {
         requestedAmount: reserve.requested_amount,
         reservePub,
       },
+      level: HistoryLevel.Developer,
       subjectId: `reserve-progress-${reserve.reserve_pub}`,
       timestamp: (new Date()).getTime(),
       type: "reserve-update",
     };
     await this.q()
               .put(Stores.reserves, reserve)
+              .put(Stores.history, historyEntry)
               .finish();
     this.notifier.notify();
     return reserve;
diff --git a/src/webex/notify.ts b/src/webex/notify.ts
index c743240a..a7796cc8 100644
--- a/src/webex/notify.ts
+++ b/src/webex/notify.ts
@@ -27,12 +27,8 @@
  */
 import URI = require("urijs");
 
-import * as wxApi from "./wxApi";
-
 declare var cloneInto: any;
 
-const PROTOCOL_VERSION = 1;
-
 let logVerbose: boolean = false;
 try {
   logVerbose = !!localStorage.getItem("taler-log-verbose");
@@ -45,12 +41,6 @@ if 
(document.documentElement.getAttribute("data-taler-nojs")) {
 }
 
 
-function subst(url: string, H_contract: string) {
-  url = url.replace("${H_contract}", H_contract);
-  url = url.replace("${$}", "$");
-  return url;
-}
-
 interface Handler {
   type: string;
   listener: (e: CustomEvent) => void|Promise<void>;
diff --git a/src/webex/pages/add-auditor.tsx b/src/webex/pages/add-auditor.tsx
index 72e80019..dbe761a5 100644
--- a/src/webex/pages/add-auditor.tsx
+++ b/src/webex/pages/add-auditor.tsx
@@ -21,16 +21,8 @@
  */
 
 
-import { getTalerStampDate } from "../../helpers";
 import {
-  AuditorRecord,
-  CoinRecord,
   CurrencyRecord,
-  Denomination,
-  DenominationRecord,
-  ExchangeRecord,
-  PreCoinRecord,
-  ReserveRecord,
 } from "../../types";
 
 import { ImplicitStateComponent, StateHolder } from "../components";
diff --git a/src/webex/pages/auditors.tsx b/src/webex/pages/auditors.tsx
index 7c6a3aff..8850cdd8 100644
--- a/src/webex/pages/auditors.tsx
+++ b/src/webex/pages/auditors.tsx
@@ -21,20 +21,12 @@
  */
 
 
-import { getTalerStampDate } from "../../helpers";
 import {
   AuditorRecord,
-  CoinRecord,
   CurrencyRecord,
-  Denomination,
-  DenominationRecord,
   ExchangeForCurrencyRecord,
-  ExchangeRecord,
-  PreCoinRecord,
-  ReserveRecord,
 } from "../../types";
 
-import { ImplicitStateComponent, StateHolder } from "../components";
 import {
   getCurrencies,
   updateCurrency,
diff --git a/src/webex/pages/confirm-contract.tsx 
b/src/webex/pages/confirm-contract.tsx
index dc7bd46a..9b4c9333 100644
--- a/src/webex/pages/confirm-contract.tsx
+++ b/src/webex/pages/confirm-contract.tsx
@@ -25,7 +25,6 @@
  */
 import * as i18n from "../../i18n";
 import {
-  AmountJson,
   Contract,
   ExchangeRecord,
   OfferRecord,
diff --git a/src/webex/pages/confirm-create-reserve.tsx 
b/src/webex/pages/confirm-create-reserve.tsx
index 50a1045e..6e1cc4a8 100644
--- a/src/webex/pages/confirm-create-reserve.tsx
+++ b/src/webex/pages/confirm-create-reserve.tsx
@@ -29,7 +29,6 @@ import {
   Amounts,
   CreateReserveResponse,
   CurrencyRecord,
-  Denomination,
   DenominationRecord,
   ReserveCreationInfo,
 } from "../../types";
@@ -229,16 +228,6 @@ function renderReserveCreationDetails(rci: 
ReserveCreationInfo|null) {
 }
 
 
-function WithdrawFee(props: {reserveCreationInfo: ReserveCreationInfo|null}): 
JSX.Element {
-  if (props.reserveCreationInfo) {
-    const {overhead, withdrawFee} = props.reserveCreationInfo;
-    const totalCost = Amounts.add(overhead, withdrawFee).amount;
-    return <p>{i18n.str`Withdraw fees:`} {amountToPretty(totalCost)}</p>;
-  }
-  return <p />;
-}
-
-
 interface ExchangeSelectionProps {
   suggestedExchangeUrl: string;
   amount: AmountJson;
@@ -298,7 +287,7 @@ class ManualSelection extends 
ImplicitStateComponent<ManualSelectionProps> {
     }
     try {
       const url = canonicalizeBaseUrl(this.url()!);
-      const r = await getExchangeInfo(url);
+      await getExchangeInfo(url);
       console.log("getExchangeInfo returned");
       this.isOkay(true);
     } catch (e) {
@@ -596,7 +585,6 @@ async function main() {
       throw Error(i18n.str`Can't parse amount: ${e.message}`);
     }
     const callback_url = query.callback_url;
-    const bank_url = query.bank_url;
     let wt_types;
     try {
       wt_types = JSON.parse(query.wt_types);
diff --git a/src/webex/pages/error.tsx b/src/webex/pages/error.tsx
index 829ea0c9..75ba990b 100644
--- a/src/webex/pages/error.tsx
+++ b/src/webex/pages/error.tsx
@@ -22,8 +22,6 @@
  * @author Florian Dold
  */
 
-import {ImplicitStateComponent, StateHolder} from "../components";
-
 import * as React from "react";
 import * as ReactDOM from "react-dom";
 import URI = require("urijs");
@@ -59,3 +57,5 @@ async function main() {
     console.error(`got error "${e.message}"`, e);
   }
 }
+
+document.addEventListener("DOMContentLoaded", () => main());
diff --git a/src/webex/pages/payback.tsx b/src/webex/pages/payback.tsx
index e10da7b0..4aadf5ad 100644
--- a/src/webex/pages/payback.tsx
+++ b/src/webex/pages/payback.tsx
@@ -24,25 +24,14 @@
 /**
  * Imports.
  */
-import { amountToPretty, getTalerStampDate } from "../../helpers";
+import { amountToPretty } from "../../helpers";
 import {
-  AuditorRecord,
-  CoinRecord,
-  CurrencyRecord,
-  Denomination,
-  DenominationRecord,
-  ExchangeForCurrencyRecord,
-  ExchangeRecord,
-  PreCoinRecord,
   ReserveRecord,
-  WalletBalance,
 } from "../../types";
 
 import { ImplicitStateComponent, StateHolder } from "../components";
 import {
-  getCurrencies,
   getPaybackReserves,
-  updateCurrency,
   withdrawPaybackReserve,
 } from "../wxApi";
 
diff --git a/src/webex/pages/popup.tsx b/src/webex/pages/popup.tsx
index a1a3f6b2..c62a6f8a 100644
--- a/src/webex/pages/popup.tsx
+++ b/src/webex/pages/popup.tsx
@@ -325,7 +325,6 @@ class WalletBalanceView extends React.Component<any, any> {
     });
     const link = chrome.extension.getURL("/src/webex/pages/auditors.html");
     const linkElem = <a className="actionLink" href={link} 
target="_blank">Trusted Auditors and Exchanges</a>;
-    const paybackLink = 
chrome.extension.getURL("/src/webex/pages/payback.html");
     const paybackLinkElem = <a className="actionLink" href={link} 
target="_blank">Trusted Auditors and Exchanges</a>;
     return (
       <div>
@@ -340,7 +339,6 @@ class WalletBalanceView extends React.Component<any, any> {
 
 function formatHistoryItem(historyItem: HistoryRecord) {
   const d = historyItem.detail;
-  const t = historyItem.timestamp;
   console.log("hist item", historyItem);
   switch (historyItem.type) {
     case "create-reserve":
@@ -365,8 +363,6 @@ function formatHistoryItem(historyItem: HistoryRecord) {
     }
     case "offer-contract": {
       const link = chrome.extension.getURL("view-contract.html");
-      const linkElem = <a href={link}>{abbrev(d.contractHash)}</a>;
-      const merchantElem = <em>{abbrev(d.merchantName, 15)}</em>;
       return (
         <i18n.Translate wrap="p">
           Merchant <em>{abbrev(d.merchantName, 15)}</em> offered contract <a 
href={link}>{abbrev(d.contractHash)}</a>;
diff --git a/src/webex/pages/tree.tsx b/src/webex/pages/tree.tsx
index 850a3c46..3eafbbeb 100644
--- a/src/webex/pages/tree.tsx
+++ b/src/webex/pages/tree.tsx
@@ -25,7 +25,6 @@ import { amountToPretty, getTalerStampDate } from 
"../../helpers";
 import {
   CoinRecord,
   CoinStatus,
-  Denomination,
   DenominationRecord,
   ExchangeRecord,
   PreCoinRecord,
diff --git a/src/webex/renderHtml.tsx b/src/webex/renderHtml.tsx
index d6f923aa..70cd61d6 100644
--- a/src/webex/renderHtml.tsx
+++ b/src/webex/renderHtml.tsx
@@ -27,8 +27,6 @@
 import { amountToPretty } from "../helpers";
 import * as i18n from "../i18n";
 import {
-  AmountJson,
-  Amounts,
   Contract,
 } from "../types";
 
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index c7aa34a9..eaae41b9 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -33,12 +33,10 @@ import {
 } from "../query";
 import {
   AmountJson,
-  Contract,
   Notifier,
   OfferRecord,
 } from "../types";
 import {
-  Badge,
   ConfirmReserveRequest,
   CreateReserveRequest,
   Stores,
@@ -701,7 +699,6 @@ function importDb(db: IDBDatabase, dump: any): 
Promise<void> {
         }
         console.log(`importing ${objects.length} records into ${storeName}`);
         const store = tx.objectStore(storeName);
-        const clearReq = store.clear();
         for (const obj of objects) {
           store.put(obj);
         }
diff --git a/tsconfig.json b/tsconfig.json
index 2f915190..f4250a2c 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -16,7 +16,8 @@
     "outDir": "build/src/",
     "noImplicitAny": true,
     "allowJs": true,
-    "checkJs": true
+    "checkJs": true,
+    "noUnusedLocals": true
   },
   "files": [
     "decl/chrome/chrome.d.ts",
diff --git a/tslint.json b/tslint.json
index 31ceb95a..fbd1975b 100644
--- a/tslint.json
+++ b/tslint.json
@@ -55,7 +55,8 @@
         "namespaces": {
           "visibilities": ["exported"]
         }
-      }]
+      }],
+      "no-unused-variable": true
     },
     "rulesDirectory": []
 }

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



reply via email to

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