summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-29 16:58:03 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-29 16:58:03 +0200
commitb5c90d12219ca3a0df173ddf085d2353831a8ef6 (patch)
treefd26569ccacbed57cb47c24cce7863fb060f42cf
parent1c3346cd534143f4dd56a625b963a1a3acfa83d1 (diff)
downloadwallet-core-b5c90d12219ca3a0df173ddf085d2353831a8ef6.tar.gz
wallet-core-b5c90d12219ca3a0df173ddf085d2353831a8ef6.tar.bz2
wallet-core-b5c90d12219ca3a0df173ddf085d2353831a8ef6.zip
fix remaining lint warnings
-rw-r--r--src/i18n.tsx41
-rw-r--r--src/memidb.ts3
-rw-r--r--src/types.ts7
-rw-r--r--src/webex/pages/add-auditor.tsx58
-rw-r--r--src/webex/pages/auditors.tsx51
-rw-r--r--src/webex/pages/confirm-contract.tsx39
-rw-r--r--src/webex/wxApi.ts2
7 files changed, 114 insertions, 87 deletions
diff --git a/src/i18n.tsx b/src/i18n.tsx
index 8c3d54192..8f2c15443 100644
--- a/src/i18n.tsx
+++ b/src/i18n.tsx
@@ -21,8 +21,9 @@
/**
* Imports.
*/
-import * as jedLib from "jed";
import {strings} from "./i18n/strings";
+
+import * as jedLib from "jed";
import * as React from "react";
let lang: string;
@@ -111,15 +112,15 @@ interface TranslateProps {
* </Translate>
* ```
*/
-export class Translate extends React.Component<TranslateProps,void> {
+export class Translate extends React.Component<TranslateProps, void> {
render(): JSX.Element {
const s = stringifyChildren(this.props.children);
- const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 == 0);
+ const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 === 0);
const childArray = React.Children.toArray(this.props.children!);
for (let i = 0; i < childArray.length - 1; ++i) {
- if ((typeof childArray[i]) == "string" && (typeof childArray[i+1]) == "string") {
- childArray[i+1] = (childArray[i] as string).concat(childArray[i+1] as string);
- childArray.splice(i,1);
+ if ((typeof childArray[i]) === "string" && (typeof childArray[i + 1]) === "string") {
+ childArray[i + 1] = (childArray[i] as string).concat(childArray[i + 1] as string);
+ childArray.splice(i, 1);
}
}
const result = [];
@@ -155,20 +156,20 @@ export class Translate extends React.Component<TranslateProps,void> {
* </TranslateSwitch>
* ```
*/
-export class TranslateSwitch extends React.Component<TranslateSwitchProps,void>{
+export class TranslateSwitch extends React.Component<TranslateSwitchProps, void> {
render(): JSX.Element {
let singular: React.ReactElement<TranslationPluralProps> | undefined;
let plural: React.ReactElement<TranslationPluralProps> | undefined;
const children = this.props.children;
if (children) {
React.Children.forEach(children, (child: any) => {
- if (child.type == TranslatePlural) {
+ if (child.type === TranslatePlural) {
plural = child;
}
- if (child.type == TranslateSingular) {
+ if (child.type === TranslateSingular) {
singular = child;
}
- });
+ });
}
if ((!singular) || (!plural)) {
console.error("translation not found");
@@ -190,15 +191,15 @@ interface TranslationPluralProps {
/**
* See [[TranslateSwitch]].
*/
-export class TranslatePlural extends React.Component<TranslationPluralProps,void> {
+export class TranslatePlural extends React.Component<TranslationPluralProps, void> {
render(): JSX.Element {
const s = stringifyChildren(this.props.children);
- const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 == 0);
+ const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 === 0);
const childArray = React.Children.toArray(this.props.children!);
for (let i = 0; i < childArray.length - 1; ++i) {
- if ((typeof childArray[i]) == "string" && (typeof childArray[i + 1]) == "string") {
- childArray[i+i] = childArray[i] as string + childArray[i + 1] as string;
- childArray.splice(i,1);
+ if ((typeof childArray[i]) === "string" && (typeof childArray[i + 1]) === "string") {
+ childArray[i + i] = childArray[i] as string + childArray[i + 1] as string;
+ childArray.splice(i, 1);
}
}
const result = [];
@@ -222,15 +223,15 @@ export class TranslatePlural extends React.Component<TranslationPluralProps,void
/**
* See [[TranslateSwitch]].
*/
-export class TranslateSingular extends React.Component<TranslationPluralProps,void> {
+export class TranslateSingular extends React.Component<TranslationPluralProps, void> {
render(): JSX.Element {
const s = stringifyChildren(this.props.children);
- const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 == 0);
+ const tr = jed.ngettext(s, s, 1).split(/%(\d+)\$s/).filter((e: any, i: number) => i % 2 === 0);
const childArray = React.Children.toArray(this.props.children!);
for (let i = 0; i < childArray.length - 1; ++i) {
- if ((typeof childArray[i]) == "string" && (typeof childArray[i + 1]) == "string") {
- childArray[i+i] = childArray[i] as string + childArray[i + 1] as string;
- childArray.splice(i,1);
+ if ((typeof childArray[i]) === "string" && (typeof childArray[i + 1]) === "string") {
+ childArray[i + i] = childArray[i] as string + childArray[i + 1] as string;
+ childArray.splice(i, 1);
}
}
const result = [];
diff --git a/src/memidb.ts b/src/memidb.ts
index e36183ffb..fe1d986f1 100644
--- a/src/memidb.ts
+++ b/src/memidb.ts
@@ -18,6 +18,9 @@
* In-memory implementation of the IndexedDB interface.
*/
+/* work in progres ... */
+/* tslint:disable */
+
interface StoredObject {
key: any;
diff --git a/src/types.ts b/src/types.ts
index 8b5f4063b..aac429c76 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -1117,8 +1117,6 @@ export class OfferRecord {
}
-
-
/**
* Wire fee for one wire method as stored in the
* wallet's database.
@@ -1380,8 +1378,11 @@ export function mkAmount(value: number, fraction: number, currency: string): Amo
}
/**
- * Possible responses for checkPay.
+ * Possible results for checkPay.
*/
export type CheckPayResult = "paid" | "payment-possible" | "insufficient-balance";
+/**
+ * Possible results for confirmPay.
+ */
export type ConfirmPayResult = "paid" | "insufficient-balance";
diff --git a/src/webex/pages/add-auditor.tsx b/src/webex/pages/add-auditor.tsx
index e4d84798b..72e800192 100644
--- a/src/webex/pages/add-auditor.tsx
+++ b/src/webex/pages/add-auditor.tsx
@@ -23,14 +23,14 @@
import { getTalerStampDate } from "../../helpers";
import {
- ExchangeRecord,
- DenominationRecord,
AuditorRecord,
- CurrencyRecord,
- ReserveRecord,
CoinRecord,
+ CurrencyRecord,
+ Denomination,
+ DenominationRecord,
+ ExchangeRecord,
PreCoinRecord,
- Denomination
+ ReserveRecord,
} from "../../types";
import { ImplicitStateComponent, StateHolder } from "../components";
@@ -51,17 +51,17 @@ interface ConfirmAuditorProps {
}
class ConfirmAuditor extends ImplicitStateComponent<ConfirmAuditorProps> {
- addDone: StateHolder<boolean> = this.makeState(false);
+ private addDone: StateHolder<boolean> = this.makeState(false);
constructor() {
super();
}
async add() {
- let currencies = await getCurrencies();
- let currency: CurrencyRecord|undefined = undefined;
+ const currencies = await getCurrencies();
+ let currency: CurrencyRecord|undefined;
- for (let c of currencies) {
- if (c.name == this.props.currency) {
+ for (const c of currencies) {
+ if (c.name === this.props.currency) {
currency = c;
}
}
@@ -70,12 +70,16 @@ class ConfirmAuditor extends ImplicitStateComponent<ConfirmAuditorProps> {
currency = { name: this.props.currency, auditors: [], fractionalDigits: 2, exchanges: [] };
}
- let newAuditor = { auditorPub: this.props.auditorPub, baseUrl: this.props.url, expirationStamp: this.props.expirationStamp };
+ const newAuditor = {
+ auditorPub: this.props.auditorPub,
+ baseUrl: this.props.url,
+ expirationStamp: this.props.expirationStamp,
+ };
let auditorFound = false;
- for (let idx in currency.auditors) {
- let a = currency.auditors[idx];
- if (a.baseUrl == this.props.url) {
+ for (const idx in currency.auditors) {
+ const a = currency.auditors[idx];
+ if (a.baseUrl === this.props.url) {
auditorFound = true;
// Update auditor if already found by URL.
currency.auditors[idx] = newAuditor;
@@ -99,22 +103,30 @@ class ConfirmAuditor extends ImplicitStateComponent<ConfirmAuditorProps> {
return (
<div id="main">
<p>Do you want to let <strong>{this.props.auditorPub}</strong> audit the currency "{this.props.currency}"?</p>
- {this.addDone() ?
- (<div>Auditor was added! You can also <a href={chrome.extension.getURL("/src/webex/pages/auditors.html")}>view and edit</a> auditors.</div>)
- :
- (<div>
- <button onClick={() => this.add()} className="pure-button pure-button-primary">Yes</button>
- <button onClick={() => this.back()} className="pure-button">No</button>
- </div>)
+ {this.addDone() ?
+ (
+ <div>
+ Auditor was added! You can also{" "}
+ <a href={chrome.extension.getURL("/src/webex/pages/auditors.html")}>view and edit</a>{" "}
+ auditors.
+ </div>
+ )
+ :
+ (
+ <div>
+ <button onClick={() => this.add()} className="pure-button pure-button-primary">Yes</button>
+ <button onClick={() => this.back()} className="pure-button">No</button>
+ </div>
+ )
}
</div>
);
}
}
-export function main() {
+function main() {
const walletPageUrl = new URI(document.location.href);
- const query: any = JSON.parse((URI.parseQuery(walletPageUrl.query()) as any)["req"]);
+ const query: any = JSON.parse((URI.parseQuery(walletPageUrl.query()) as any).req);
const url = query.url;
const currency: string = query.currency;
const auditorPub: string = query.auditorPub;
diff --git a/src/webex/pages/auditors.tsx b/src/webex/pages/auditors.tsx
index dac3c2be9..7c6a3aff1 100644
--- a/src/webex/pages/auditors.tsx
+++ b/src/webex/pages/auditors.tsx
@@ -23,15 +23,15 @@
import { getTalerStampDate } from "../../helpers";
import {
- ExchangeRecord,
- ExchangeForCurrencyRecord,
- DenominationRecord,
AuditorRecord,
- CurrencyRecord,
- ReserveRecord,
CoinRecord,
+ CurrencyRecord,
+ Denomination,
+ DenominationRecord,
+ ExchangeForCurrencyRecord,
+ ExchangeRecord,
PreCoinRecord,
- Denomination
+ ReserveRecord,
} from "../../types";
import { ImplicitStateComponent, StateHolder } from "../components";
@@ -39,6 +39,7 @@ import {
getCurrencies,
updateCurrency,
} from "../wxApi";
+
import * as React from "react";
import * as ReactDOM from "react-dom";
@@ -49,7 +50,7 @@ interface CurrencyListState {
class CurrencyList extends React.Component<any, CurrencyListState> {
constructor() {
super();
- let port = chrome.runtime.connect();
+ const port = chrome.runtime.connect();
port.onMessage.addListener((msg: any) => {
if (msg.notify) {
console.log("got notified");
@@ -61,35 +62,39 @@ class CurrencyList extends React.Component<any, CurrencyListState> {
}
async update() {
- let currencies = await getCurrencies();
+ const currencies = await getCurrencies();
console.log("currencies: ", currencies);
this.setState({ currencies });
}
async confirmRemoveAuditor(c: CurrencyRecord, a: AuditorRecord) {
if (window.confirm(`Do you really want to remove auditor ${a.baseUrl} for currency ${c.name}?`)) {
- c.auditors = c.auditors.filter((x) => x.auditorPub != a.auditorPub);
+ c.auditors = c.auditors.filter((x) => x.auditorPub !== a.auditorPub);
await updateCurrency(c);
}
}
async confirmRemoveExchange(c: CurrencyRecord, e: ExchangeForCurrencyRecord) {
if (window.confirm(`Do you really want to remove exchange ${e.baseUrl} for currency ${c.name}?`)) {
- c.exchanges = c.exchanges.filter((x) => x.baseUrl != e.baseUrl);
+ c.exchanges = c.exchanges.filter((x) => x.baseUrl !== e.baseUrl);
await updateCurrency(c);
}
}
renderAuditors(c: CurrencyRecord): any {
- if (c.auditors.length == 0) {
- return <p>No trusted auditors for this currency.</p>
+ if (c.auditors.length === 0) {
+ return <p>No trusted auditors for this currency.</p>;
}
return (
<div>
<p>Trusted Auditors:</p>
<ul>
- {c.auditors.map(a => (
- <li>{a.baseUrl} <button className="pure-button button-destructive" onClick={() => this.confirmRemoveAuditor(c, a)}>Remove</button>
+ {c.auditors.map((a) => (
+ <li>
+ {a.baseUrl}{" "}
+ <button className="pure-button button-destructive" onClick={() => this.confirmRemoveAuditor(c, a)}>
+ Remove
+ </button>
<ul>
<li>valid until {new Date(a.expirationStamp).toString()}</li>
<li>public key {a.auditorPub}</li>
@@ -102,15 +107,19 @@ class CurrencyList extends React.Component<any, CurrencyListState> {
}
renderExchanges(c: CurrencyRecord): any {
- if (c.exchanges.length == 0) {
- return <p>No trusted exchanges for this currency.</p>
+ if (c.exchanges.length === 0) {
+ return <p>No trusted exchanges for this currency.</p>;
}
return (
<div>
<p>Trusted Exchanges:</p>
<ul>
- {c.exchanges.map(e => (
- <li>{e.baseUrl} <button className="pure-button button-destructive" onClick={() => this.confirmRemoveExchange(c, e)}>Remove</button>
+ {c.exchanges.map((e) => (
+ <li>
+ {e.baseUrl}{" "}
+ <button className="pure-button button-destructive" onClick={() => this.confirmRemoveExchange(c, e)}>
+ Remove
+ </button>
</li>
))}
</ul>
@@ -119,13 +128,13 @@ class CurrencyList extends React.Component<any, CurrencyListState> {
}
render(): JSX.Element {
- let currencies = this.state.currencies;
+ const currencies = this.state.currencies;
if (!currencies) {
return <span>...</span>;
}
return (
<div id="main">
- {currencies.map(c => (
+ {currencies.map((c) => (
<div>
<h1>Currency {c.name}</h1>
<p>Displayed with {c.fractionalDigits} fractional digits.</p>
@@ -140,7 +149,7 @@ class CurrencyList extends React.Component<any, CurrencyListState> {
}
}
-export function main() {
+function main() {
ReactDOM.render(<CurrencyList />, document.getElementById("container")!);
}
diff --git a/src/webex/pages/confirm-contract.tsx b/src/webex/pages/confirm-contract.tsx
index cc3025847..dc7bd46af 100644
--- a/src/webex/pages/confirm-contract.tsx
+++ b/src/webex/pages/confirm-contract.tsx
@@ -44,8 +44,8 @@ interface DetailState {
}
interface DetailProps {
- contract: Contract
- collapsed: boolean
+ contract: Contract;
+ collapsed: boolean;
exchanges: null|ExchangeRecord[];
}
@@ -66,7 +66,7 @@ class Details extends React.Component<DetailProps, DetailState> {
return (
<div>
<button className="linky"
- onClick={() => { this.setState({collapsed: false} as any)}}>
+ onClick={() => { this.setState({collapsed: false} as any); }}>
<i18n.Translate wrap="span">
show more details
</i18n.Translate>
@@ -84,7 +84,7 @@ class Details extends React.Component<DetailProps, DetailState> {
{i18n.str`Accepted exchanges:`}
<ul>
{this.props.contract.exchanges.map(
- e => <li>{`${e.url}: ${e.master_pub}`}</li>)}
+ (e) => <li>{`${e.url}: ${e.master_pub}`}</li>)}
</ul>
{i18n.str`Exchanges in the wallet:`}
<ul>
@@ -113,11 +113,11 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
constructor() {
super();
this.state = {
- offer: null,
error: null,
+ exchanges: null,
+ offer: null,
payDisabled: true,
- exchanges: null
- }
+ };
}
componentWillMount() {
@@ -129,26 +129,27 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
}
async update() {
- let offer = await wxApi.getOffer(this.props.offerId);
+ const offer = await wxApi.getOffer(this.props.offerId);
this.setState({offer} as any);
this.checkPayment();
- let exchanges = await wxApi.getExchanges();
+ const exchanges = await wxApi.getExchanges();
this.setState({exchanges} as any);
}
async checkPayment() {
- let offer = this.state.offer;
+ const offer = this.state.offer;
if (!offer) {
return;
}
const payStatus = await wxApi.checkPay(offer);
if (payStatus === "insufficient-balance") {
- let msgInsufficient = i18n.str`You have insufficient funds of the requested currency in your wallet.`;
- let msgNoMatch = i18n.str`You do not have any funds from an exchange that is accepted by this merchant. None of the exchanges accepted by the merchant is known to your wallet.`;
+ const msgInsufficient = i18n.str`You have insufficient funds of the requested currency in your wallet.`;
+ // tslint:disable-next-line:max-line-length
+ const msgNoMatch = i18n.str`You do not have any funds from an exchange that is accepted by this merchant. None of the exchanges accepted by the merchant is known to your wallet.`;
if (this.state.exchanges && this.state.offer) {
- let acceptedExchangePubs = this.state.offer.contract.exchanges.map((e) => e.master_pub);
- let ex = this.state.exchanges.find((e) => acceptedExchangePubs.indexOf(e.masterPublicKey) >= 0);
+ const acceptedExchangePubs = this.state.offer.contract.exchanges.map((e) => e.master_pub);
+ const ex = this.state.exchanges.find((e) => acceptedExchangePubs.indexOf(e.masterPublicKey) >= 0);
if (ex) {
this.setState({error: msgInsufficient});
} else {
@@ -165,7 +166,7 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
}
async doPayment() {
- let offer = this.state.offer;
+ const offer = this.state.offer;
if (!offer) {
return;
}
@@ -186,7 +187,7 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
if (!this.state.offer) {
return <span>...</span>;
}
- let c = this.state.offer.contract;
+ const c = this.state.offer.contract;
return (
<div>
<div>
@@ -208,9 +209,9 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt
document.addEventListener("DOMContentLoaded", () => {
- let url = new URI(document.location.href);
- let query: any = URI.parseQuery(url.query());
- let offerId = JSON.parse(query.offerId);
+ const url = new URI(document.location.href);
+ const query: any = URI.parseQuery(url.query());
+ const offerId = JSON.parse(query.offerId);
ReactDOM.render(<ContractPrompt offerId={offerId}/>, document.getElementById(
"contract")!);
diff --git a/src/webex/wxApi.ts b/src/webex/wxApi.ts
index c120f34e7..e4684135b 100644
--- a/src/webex/wxApi.ts
+++ b/src/webex/wxApi.ts
@@ -25,8 +25,8 @@
import {
AmountJson,
CheckPayResult,
- ConfirmPayResult,
CoinRecord,
+ ConfirmPayResult,
CurrencyRecord,
DenominationRecord,
ExchangeRecord,