From fd2cd9c383b07cd681c18137396deae025d98047 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 3 Jan 2018 14:42:06 +0100 Subject: fix lint issues and separate message types into multiple files --- src/webex/pages/add-auditor.tsx | 2 +- src/webex/pages/auditors.tsx | 2 +- src/webex/pages/confirm-contract.tsx | 9 ++++++--- src/webex/pages/confirm-create-reserve.tsx | 27 +++++++++++++++++---------- src/webex/pages/payback.tsx | 2 +- src/webex/pages/popup.tsx | 11 +++++++---- src/webex/pages/refund.tsx | 21 ++++++++++++--------- src/webex/pages/return-coins.tsx | 7 ++++--- src/webex/pages/tip.tsx | 27 +++++++++++++++++---------- src/webex/pages/tree.tsx | 3 ++- 10 files changed, 68 insertions(+), 43 deletions(-) (limited to 'src/webex/pages') diff --git a/src/webex/pages/add-auditor.tsx b/src/webex/pages/add-auditor.tsx index 4b898b13c..1ab6fdf9c 100644 --- a/src/webex/pages/add-auditor.tsx +++ b/src/webex/pages/add-auditor.tsx @@ -23,7 +23,7 @@ import { CurrencyRecord, -} from "../../types"; +} from "../../dbTypes"; import { ImplicitStateComponent, StateHolder } from "../components"; import { diff --git a/src/webex/pages/auditors.tsx b/src/webex/pages/auditors.tsx index 9d57218ad..276a7e8e1 100644 --- a/src/webex/pages/auditors.tsx +++ b/src/webex/pages/auditors.tsx @@ -25,7 +25,7 @@ import { AuditorRecord, CurrencyRecord, ExchangeForCurrencyRecord, -} from "../../types"; +} from "../../dbTypes"; import { getCurrencies, diff --git a/src/webex/pages/confirm-contract.tsx b/src/webex/pages/confirm-contract.tsx index e41b0a1df..83de738b9 100644 --- a/src/webex/pages/confirm-contract.tsx +++ b/src/webex/pages/confirm-contract.tsx @@ -24,12 +24,15 @@ * Imports. */ import * as i18n from "../../i18n"; + import { - CheckPayResult, - ContractTerms, ExchangeRecord, ProposalRecord, -} from "../../types"; +} from "../../dbTypes"; +import { ContractTerms } from "../../talerTypes"; +import { + CheckPayResult, +} from "../../walletTypes"; import { renderAmount } from "../renderHtml"; import * as wxApi from "../wxApi"; diff --git a/src/webex/pages/confirm-create-reserve.tsx b/src/webex/pages/confirm-create-reserve.tsx index 48bcd97c9..903975c6e 100644 --- a/src/webex/pages/confirm-create-reserve.tsx +++ b/src/webex/pages/confirm-create-reserve.tsx @@ -24,13 +24,17 @@ import { canonicalizeBaseUrl } from "../../helpers"; import * as i18n from "../../i18n"; + +import { AmountJson } from "../../amounts"; +import * as Amounts from "../../amounts"; + import { - AmountJson, - Amounts, - CreateReserveResponse, CurrencyRecord, +} from "../../dbTypes"; +import { + CreateReserveResponse, ReserveCreationInfo, -} from "../../types"; +} from "../../walletTypes"; import { ImplicitStateComponent, StateHolder } from "../components"; import { @@ -40,7 +44,10 @@ import { getReserveCreationInfo, } from "../wxApi"; -import { renderAmount, WithdrawDetailView } from "../renderHtml"; +import { + WithdrawDetailView, + renderAmount, +} from "../renderHtml"; import * as React from "react"; import * as ReactDOM from "react-dom"; @@ -78,8 +85,6 @@ class EventTrigger { } - - interface ExchangeSelectionProps { suggestedExchangeUrl: string; amount: AmountJson; @@ -273,7 +278,8 @@ class ExchangeSelection extends ImplicitStateComponent { if (rci.versionMatch.currentCmp === -1) { return (

- Your wallet (protocol version {rci.walletVersion}) might be outdated. The exchange has a higher, incompatible + Your wallet (protocol version {rci.walletVersion}) might be outdated. + The exchange has a higher, incompatible protocol version ({rci.exchangeVersion}).

); @@ -281,7 +287,8 @@ class ExchangeSelection extends ImplicitStateComponent { if (rci.versionMatch.currentCmp === 1) { return (

- The chosen exchange (protocol version {rci.exchangeVersion} might be outdated. The exchange has a lower, incompatible + The chosen exchange (protocol version {rci.exchangeVersion} might be outdated. + The exchange has a lower, incompatible protocol version than your wallet (protocol version {rci.walletVersion}).

); @@ -429,8 +436,8 @@ class ExchangeSelection extends ImplicitStateComponent { amount_fraction: amount.fraction, amount_value: amount.value, exchange: resp.exchange, - reserve_pub: resp.reservePub, exchange_wire_details: JSON.stringify(filteredWireDetails), + reserve_pub: resp.reservePub, }; const url = new URI(callback_url).addQuery(q); if (!url.is("absolute")) { diff --git a/src/webex/pages/payback.tsx b/src/webex/pages/payback.tsx index a380a33d0..f69a33493 100644 --- a/src/webex/pages/payback.tsx +++ b/src/webex/pages/payback.tsx @@ -26,7 +26,7 @@ */ import { ReserveRecord, -} from "../../types"; +} from "../../dbTypes"; import { ImplicitStateComponent, StateHolder } from "../components"; import { renderAmount } from "../renderHtml"; diff --git a/src/webex/pages/popup.tsx b/src/webex/pages/popup.tsx index ded430d2b..134ee6dea 100644 --- a/src/webex/pages/popup.tsx +++ b/src/webex/pages/popup.tsx @@ -26,13 +26,15 @@ * Imports. */ import * as i18n from "../../i18n"; + +import { AmountJson } from "../../amounts"; +import * as Amounts from "../../amounts"; + import { - AmountJson, - Amounts, HistoryRecord, WalletBalance, WalletBalanceEntry, -} from "../../types"; +} from "../../walletTypes"; import { abbrev, renderAmount } from "../renderHtml"; import * as wxApi from "../wxApi"; @@ -407,7 +409,8 @@ function formatHistoryItem(historyItem: HistoryRecord) { const url = tipPageUrl.query(params).href(); return ( - Merchant {d.merchantDomain} gave a tip of {renderAmount(d.amount)}. + Merchant {d.merchantDomain} gave + a tip of {renderAmount(d.amount)}. { d.accepted ? null : You did not accept the tip yet. } diff --git a/src/webex/pages/refund.tsx b/src/webex/pages/refund.tsx index e76fdfff3..3e82f3667 100644 --- a/src/webex/pages/refund.tsx +++ b/src/webex/pages/refund.tsx @@ -26,7 +26,10 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; import URI = require("urijs"); -import * as types from "../../types"; +import * as dbTypes from "../../dbTypes"; + +import { AmountJson } from "../../amounts"; +import * as Amounts from "../../amounts"; import { AmountDisplay } from "../renderHtml"; import * as wxApi from "../wxApi"; @@ -36,14 +39,14 @@ interface RefundStatusViewProps { } interface RefundStatusViewState { - purchase?: types.PurchaseRecord; - refundFees?: types.AmountJson; + purchase?: dbTypes.PurchaseRecord; + refundFees?: AmountJson; gotResult: boolean; } interface RefundDetailProps { - purchase: types.PurchaseRecord; - fullRefundFees: types.AmountJson; + purchase: dbTypes.PurchaseRecord; + fullRefundFees: AmountJson; } const RefundDetail = ({purchase, fullRefundFees}: RefundDetailProps) => { @@ -59,13 +62,13 @@ const RefundDetail = ({purchase, fullRefundFees}: RefundDetailProps) => { throw Error("invariant"); } - let amountPending = types.Amounts.getZero(currency); + let amountPending = Amounts.getZero(currency); for (const k of pendingKeys) { - amountPending = types.Amounts.add(amountPending, purchase.refundsPending[k].refund_amount).amount; + amountPending = Amounts.add(amountPending, purchase.refundsPending[k].refund_amount).amount; } - let amountDone = types.Amounts.getZero(currency); + let amountDone = Amounts.getZero(currency); for (const k of doneKeys) { - amountDone = types.Amounts.add(amountDone, purchase.refundsDone[k].refund_amount).amount; + amountDone = Amounts.add(amountDone, purchase.refundsDone[k].refund_amount).amount; } const hasPending = amountPending.fraction !== 0 || amountPending.value !== 0; diff --git a/src/webex/pages/return-coins.tsx b/src/webex/pages/return-coins.tsx index 5bcb2252a..26db52ef4 100644 --- a/src/webex/pages/return-coins.tsx +++ b/src/webex/pages/return-coins.tsx @@ -25,12 +25,13 @@ * Imports. */ +import { AmountJson } from "../../amounts"; +import * as Amounts from "../../amounts"; + import { - AmountJson, - Amounts, SenderWireInfos, WalletBalance, -} from "../../types"; +} from "../../walletTypes"; import * as i18n from "../../i18n"; diff --git a/src/webex/pages/tip.tsx b/src/webex/pages/tip.tsx index 678c0dfdd..7f96401c5 100644 --- a/src/webex/pages/tip.tsx +++ b/src/webex/pages/tip.tsx @@ -33,9 +33,13 @@ import { getTipStatus, } from "../wxApi"; -import { renderAmount, WithdrawDetailView } from "../renderHtml"; +import { + WithdrawDetailView, + renderAmount, +} from "../renderHtml"; -import { Amounts, TipStatus } from "../../types"; +import * as Amounts from "../../amounts"; +import { TipStatus } from "../../walletTypes"; interface TipDisplayProps { merchantDomain: string; @@ -54,7 +58,7 @@ class TipDisplay extends React.Component { } async update() { - let tipStatus = await getTipStatus(this.props.merchantDomain, this.props.tipId); + const tipStatus = await getTipStatus(this.props.merchantDomain, this.props.tipId); this.setState({ tipStatus }); } @@ -73,7 +77,7 @@ class TipDisplay extends React.Component { renderExchangeInfo(ts: TipStatus) { const rci = ts.rci; if (!rci) { - return

Waiting for info about exchange ...

+ return

Waiting for info about exchange ...

; } const totalCost = Amounts.add(rci.overhead, rci.withdrawFee).amount; return ( @@ -102,7 +106,9 @@ class TipDisplay extends React.Component { className="pure-button pure-button-primary" type="button" onClick={() => this.accept()}> - { this.state.working ? : null } + { this.state.working + ? + : null } Accept tip {" "} @@ -119,7 +125,8 @@ class TipDisplay extends React.Component { return (

Tip Received!

-

You received a tip of {renderAmount(ts.tip.amount)} from {this.props.merchantDomain}.

+

You received a tip of {renderAmount(ts.tip.amount)} from + {this.props.merchantDomain}.

{ts.tip.accepted ?

You've accepted this tip! Go back to merchant

: this.renderButtons() @@ -134,10 +141,10 @@ async function main() { try { const url = new URI(document.location.href); const query: any = URI.parseQuery(url.query()); - - let merchantDomain = query.merchant_domain; - let tipId = query.tip_id; - let props: TipDisplayProps = { tipId, merchantDomain }; + + const merchantDomain = query.merchant_domain; + const tipId = query.tip_id; + const props: TipDisplayProps = { tipId, merchantDomain }; ReactDOM.render(, document.getElementById("container")!); diff --git a/src/webex/pages/tree.tsx b/src/webex/pages/tree.tsx index 2ac0b8631..67e58a1df 100644 --- a/src/webex/pages/tree.tsx +++ b/src/webex/pages/tree.tsx @@ -22,6 +22,7 @@ import { getTalerStampDate } from "../../helpers"; + import { CoinRecord, CoinStatus, @@ -29,7 +30,7 @@ import { ExchangeRecord, PreCoinRecord, ReserveRecord, -} from "../../types"; +} from "../../dbTypes"; import { ImplicitStateComponent, StateHolder } from "../components"; import { -- cgit v1.2.3