lint for unused variables, fix query bug detected by this
This commit is contained in:
parent
b5c90d1221
commit
94d111a945
@ -111,6 +111,7 @@ const tsBaseArgs = {
|
||||
noImplicitAny: true,
|
||||
allowJs: true,
|
||||
checkJs: true,
|
||||
noUnusedLocals: true,
|
||||
};
|
||||
|
||||
|
||||
|
@ -94,6 +94,7 @@ test("precoin creation", async (t) => {
|
||||
};
|
||||
|
||||
const precoin = await crypto.createPreCoin(denomValid1, r);
|
||||
t.truthy(precoin);
|
||||
t.pass();
|
||||
});
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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;
|
||||
|
||||
|
||||
/**
|
||||
|
11
src/query.ts
11
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
30
src/types.ts
30
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");
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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>;
|
||||
|
@ -21,16 +21,8 @@
|
||||
*/
|
||||
|
||||
|
||||
import { getTalerStampDate } from "../../helpers";
|
||||
import {
|
||||
AuditorRecord,
|
||||
CoinRecord,
|
||||
CurrencyRecord,
|
||||
Denomination,
|
||||
DenominationRecord,
|
||||
ExchangeRecord,
|
||||
PreCoinRecord,
|
||||
ReserveRecord,
|
||||
} from "../../types";
|
||||
|
||||
import { ImplicitStateComponent, StateHolder } from "../components";
|
||||
|
@ -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,
|
||||
|
@ -25,7 +25,6 @@
|
||||
*/
|
||||
import * as i18n from "../../i18n";
|
||||
import {
|
||||
AmountJson,
|
||||
Contract,
|
||||
ExchangeRecord,
|
||||
OfferRecord,
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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>;
|
||||
|
@ -25,7 +25,6 @@ import { amountToPretty, getTalerStampDate } from "../../helpers";
|
||||
import {
|
||||
CoinRecord,
|
||||
CoinStatus,
|
||||
Denomination,
|
||||
DenominationRecord,
|
||||
ExchangeRecord,
|
||||
PreCoinRecord,
|
||||
|
@ -27,8 +27,6 @@
|
||||
import { amountToPretty } from "../helpers";
|
||||
import * as i18n from "../i18n";
|
||||
import {
|
||||
AmountJson,
|
||||
Amounts,
|
||||
Contract,
|
||||
} from "../types";
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -16,7 +16,8 @@
|
||||
"outDir": "build/src/",
|
||||
"noImplicitAny": true,
|
||||
"allowJs": true,
|
||||
"checkJs": true
|
||||
"checkJs": true,
|
||||
"noUnusedLocals": true
|
||||
},
|
||||
"files": [
|
||||
"decl/chrome/chrome.d.ts",
|
||||
|
@ -55,7 +55,8 @@
|
||||
"namespaces": {
|
||||
"visibilities": ["exported"]
|
||||
}
|
||||
}]
|
||||
}],
|
||||
"no-unused-variable": true
|
||||
},
|
||||
"rulesDirectory": []
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user