diff --git a/gulpfile.js b/gulpfile.js index a95542e1b..03fe4d8a4 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 60bd44c90..7e391cd91 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 b5d7d4fb9..c3c1f508a 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(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(ws, workItem); + this.wake(ws, workItem); return; } diff --git a/src/crypto/emscInterface-test.ts b/src/crypto/emscInterface-test.ts index 789ac2509..518ed8e72 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 81c6e9a21..8c9a34132 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 805abd361..24db4de56 100644 --- a/src/query.ts +++ b/src/query.ts @@ -49,6 +49,7 @@ export class Store { } } + /** * Definition of an index. */ @@ -61,6 +62,13 @@ export class Index { constructor(s: Store, 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 implements QueryStream, PromiseLike { type FilterFn = (e: any) => boolean; type SubscribeFn = (done: boolean, value: any, tx: IDBTransaction) => void; type SubscribeOneFn = (value: any, tx: IDBTransaction) => void; -type FlatMapFn = (v: T) => T[]; class QueryStreamFilter extends QueryStreamBase { constructor(public s: QueryStreamBase, public filterFn: FilterFn) { @@ -349,7 +356,7 @@ class QueryStreamFlatMap extends QueryStreamBase { } 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 aac429c76..c4b6c466a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -899,40 +899,12 @@ 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 5564162b9..92187d82f 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 c743240a4..a7796cc8f 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; diff --git a/src/webex/pages/add-auditor.tsx b/src/webex/pages/add-auditor.tsx index 72e800192..dbe761a5f 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 7c6a3aff1..8850cdd87 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 dc7bd46af..9b4c93334 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 50a1045ef..6e1cc4a82 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

{i18n.str`Withdraw fees:`} {amountToPretty(totalCost)}

; - } - return

; -} - - interface ExchangeSelectionProps { suggestedExchangeUrl: string; amount: AmountJson; @@ -298,7 +287,7 @@ class ManualSelection extends ImplicitStateComponent { } 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 829ea0c90..75ba990b4 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 e10da7b05..4aadf5add 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 a1a3f6b2b..c62a6f8af 100644 --- a/src/webex/pages/popup.tsx +++ b/src/webex/pages/popup.tsx @@ -325,7 +325,6 @@ class WalletBalanceView extends React.Component { }); const link = chrome.extension.getURL("/src/webex/pages/auditors.html"); const linkElem = Trusted Auditors and Exchanges; - const paybackLink = chrome.extension.getURL("/src/webex/pages/payback.html"); const paybackLinkElem = Trusted Auditors and Exchanges; return (

@@ -340,7 +339,6 @@ class WalletBalanceView extends React.Component { 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 = {abbrev(d.contractHash)}; - const merchantElem = {abbrev(d.merchantName, 15)}; return ( Merchant {abbrev(d.merchantName, 15)} offered contract {abbrev(d.contractHash)}; diff --git a/src/webex/pages/tree.tsx b/src/webex/pages/tree.tsx index 850a3c46d..3eafbbeb4 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 d6f923aa1..70cd61d62 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 c7aa34a9a..eaae41b9f 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 { } 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 2f915190b..f4250a2c5 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 31ceb95a0..fbd1975b7 100644 --- a/tslint.json +++ b/tslint.json @@ -55,7 +55,8 @@ "namespaces": { "visibilities": ["exported"] } - }] + }], + "no-unused-variable": true }, "rulesDirectory": [] }