re-indent with latest version of prettier

This commit is contained in:
Florian Dold 2020-06-03 16:46:25 +05:30
parent 77c61e7381
commit 83af702f1c
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
19 changed files with 96 additions and 68 deletions

View File

@ -33,7 +33,10 @@ import {
} from "../util/http"; } from "../util/http";
import { NodeHttpLib } from "../headless/NodeHttpLib"; import { NodeHttpLib } from "../headless/NodeHttpLib";
import { WalletNotification } from "../types/notifications"; import { WalletNotification } from "../types/notifications";
import { WALLET_EXCHANGE_PROTOCOL_VERSION, WALLET_MERCHANT_PROTOCOL_VERSION } from "../operations/versions"; import {
WALLET_EXCHANGE_PROTOCOL_VERSION,
WALLET_MERCHANT_PROTOCOL_VERSION,
} from "../operations/versions";
// @ts-ignore: special built-in module // @ts-ignore: special built-in module
//import akono = require("akono"); //import akono = require("akono");
@ -159,7 +162,7 @@ class AndroidWalletMessageHandler {
supported_protocol_versions: { supported_protocol_versions: {
exchange: WALLET_EXCHANGE_PROTOCOL_VERSION, exchange: WALLET_EXCHANGE_PROTOCOL_VERSION,
merchant: WALLET_MERCHANT_PROTOCOL_VERSION, merchant: WALLET_MERCHANT_PROTOCOL_VERSION,
} },
}; };
} }
case "getTransactions": { case "getTransactions": {

View File

@ -65,7 +65,11 @@ import {
} from "../talerCrypto"; } from "../talerCrypto";
import { randomBytes } from "../primitives/nacl-fast"; import { randomBytes } from "../primitives/nacl-fast";
import { kdf } from "../primitives/kdf"; import { kdf } from "../primitives/kdf";
import { Timestamp, getTimestampNow, timestampTruncateToSecond } from "../../util/time"; import {
Timestamp,
getTimestampNow,
timestampTruncateToSecond,
} from "../../util/time";
enum SignaturePurpose { enum SignaturePurpose {
RESERVE_WITHDRAW = 1200, RESERVE_WITHDRAW = 1200,
@ -368,7 +372,10 @@ export class CryptoImplementation {
for (const ncd of newCoinDenoms.selectedDenoms) { for (const ncd of newCoinDenoms.selectedDenoms) {
const t = Amounts.add(ncd.denom.value, ncd.denom.feeWithdraw).amount; const t = Amounts.add(ncd.denom.value, ncd.denom.feeWithdraw).amount;
valueWithFee = Amounts.add(valueWithFee, Amounts.mult(t, ncd.count).amount).amount; valueWithFee = Amounts.add(
valueWithFee,
Amounts.mult(t, ncd.count).amount,
).amount;
} }
// melt fee // melt fee
@ -406,7 +413,10 @@ export class CryptoImplementation {
const coinNumber = planchets.length; const coinNumber = planchets.length;
const transferPriv = decodeCrock(transferPrivs[i]); const transferPriv = decodeCrock(transferPrivs[i]);
const oldCoinPub = decodeCrock(meltCoin.coinPub); const oldCoinPub = decodeCrock(meltCoin.coinPub);
const transferSecret = keyExchangeEcdheEddsa(transferPriv, oldCoinPub); const transferSecret = keyExchangeEcdheEddsa(
transferPriv,
oldCoinPub,
);
const fresh = setupRefreshPlanchet(transferSecret, coinNumber); const fresh = setupRefreshPlanchet(transferSecret, coinNumber);
const coinPriv = fresh.coinPriv; const coinPriv = fresh.coinPriv;
const coinPub = fresh.coinPub; const coinPub = fresh.coinPub;

View File

@ -87,7 +87,9 @@ async function makePayment(
}; };
} }
export async function runIntegrationTest(args: IntegrationTestArgs): Promise<void> { export async function runIntegrationTest(
args: IntegrationTestArgs,
): Promise<void> {
logger.info("running test with arguments", args); logger.info("running test with arguments", args);
const parsedSpendAmount = Amounts.parseOrThrow(args.amountToSpend); const parsedSpendAmount = Amounts.parseOrThrow(args.amountToSpend);
@ -191,7 +193,9 @@ export async function runIntegrationTest(args: IntegrationTestArgs): Promise<voi
); );
} }
export async function runIntegrationTestBasic(cfg: Configuration): Promise<void> { export async function runIntegrationTestBasic(
cfg: Configuration,
): Promise<void> {
const walletDbPath = cfg.getString("integrationtest", "walletdb").required(); const walletDbPath = cfg.getString("integrationtest", "walletdb").required();
const bankBaseUrl = cfg const bankBaseUrl = cfg

View File

@ -649,7 +649,10 @@ testCli
args.genTipUri.merchant ?? "https://backend.test.taler.net/", args.genTipUri.merchant ?? "https://backend.test.taler.net/",
args.genTipUri.merchantApiKey ?? "sandbox", args.genTipUri.merchantApiKey ?? "sandbox",
); );
const tipUri = await merchantBackend.authorizeTip(args.genTipUri.amount, "test"); const tipUri = await merchantBackend.authorizeTip(
args.genTipUri.amount,
"test",
);
console.log(tipUri); console.log(tipUri);
}); });

View File

@ -18,11 +18,7 @@
* Imports. * Imports.
*/ */
import { InternalWalletState } from "./state"; import { InternalWalletState } from "./state";
import { import { Stores, ProposalStatus, ProposalRecord } from "../types/dbTypes";
Stores,
ProposalStatus,
ProposalRecord,
} from "../types/dbTypes";
import { Amounts } from "../util/amounts"; import { Amounts } from "../util/amounts";
import { AmountJson } from "../util/amounts"; import { AmountJson } from "../util/amounts";
import { import {
@ -216,7 +212,9 @@ export async function getHistory(
HistoryEventType.Withdrawn, HistoryEventType.Withdrawn,
wsr.withdrawalGroupId, wsr.withdrawalGroupId,
), ),
amountWithdrawnEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue), amountWithdrawnEffective: Amounts.stringify(
wsr.denomsSel.totalCoinValue,
),
amountWithdrawnRaw: Amounts.stringify(wsr.rawWithdrawalAmount), amountWithdrawnRaw: Amounts.stringify(wsr.rawWithdrawalAmount),
exchangeBaseUrl: wsr.exchangeBaseUrl, exchangeBaseUrl: wsr.exchangeBaseUrl,
timestamp: wsr.timestampFinish, timestamp: wsr.timestampFinish,

View File

@ -165,7 +165,7 @@ export async function getTotalPaymentCost(
costs.push(refreshCost); costs.push(refreshCost);
} }
return { return {
totalCost: Amounts.sum(costs).amount totalCost: Amounts.sum(costs).amount,
}; };
} }
@ -195,7 +195,8 @@ export function selectPayCoins(
Amounts.cmp(o1.feeDeposit, o2.feeDeposit) || Amounts.cmp(o1.feeDeposit, o2.feeDeposit) ||
strcmp(o1.denomPub, o2.denomPub), strcmp(o1.denomPub, o2.denomPub),
); );
const paymentAmount = Amounts.add(contractTermsAmount, customerWireFees).amount; const paymentAmount = Amounts.add(contractTermsAmount, customerWireFees)
.amount;
const currency = paymentAmount.currency; const currency = paymentAmount.currency;
let amountPayRemaining = paymentAmount; let amountPayRemaining = paymentAmount;
let amountDepositFeeLimitRemaining = depositFeeLimit; let amountDepositFeeLimitRemaining = depositFeeLimit;

View File

@ -260,12 +260,14 @@ async function gatherWithdrawalPending(
} }
let numCoinsWithdrawn = 0; let numCoinsWithdrawn = 0;
let numCoinsTotal = 0; let numCoinsTotal = 0;
await tx.iterIndexed(Stores.planchets.byGroup, wsr.withdrawalGroupId).forEach((x) => { await tx
numCoinsTotal++; .iterIndexed(Stores.planchets.byGroup, wsr.withdrawalGroupId)
if (x.withdrawalDone) { .forEach((x) => {
numCoinsWithdrawn++; numCoinsTotal++;
} if (x.withdrawalDone) {
}); numCoinsWithdrawn++;
}
});
resp.pendingOperations.push({ resp.pendingOperations.push({
type: PendingOperationType.Withdraw, type: PendingOperationType.Withdraw,
givesLifeness: true, givesLifeness: true,

View File

@ -106,7 +106,11 @@ export async function createReserve(
let bankInfo: ReserveBankInfo | undefined; let bankInfo: ReserveBankInfo | undefined;
if (req.bankWithdrawStatusUrl) { if (req.bankWithdrawStatusUrl) {
const denomSelInfo = await selectWithdrawalDenoms(ws, canonExchange, req.amount); const denomSelInfo = await selectWithdrawalDenoms(
ws,
canonExchange,
req.amount,
);
const denomSel = denomSelectionInfoToState(denomSelInfo); const denomSel = denomSelectionInfoToState(denomSelInfo);
bankInfo = { bankInfo = {
statusUrl: req.bankWithdrawStatusUrl, statusUrl: req.bankWithdrawStatusUrl,

View File

@ -200,7 +200,10 @@ async function processTipImpl(
const planchets: TipPlanchet[] = []; const planchets: TipPlanchet[] = [];
for (const sd of denomsForWithdraw.selectedDenoms) { for (const sd of denomsForWithdraw.selectedDenoms) {
const denom = await ws.db.getIndexed(Stores.denominations.denomPubHashIndex, sd.denomPubHash); const denom = await ws.db.getIndexed(
Stores.denominations.denomPubHashIndex,
sd.denomPubHash,
);
if (!denom) { if (!denom) {
throw Error("denom does not exist anymore"); throw Error("denom does not exist anymore");
} }

View File

@ -420,17 +420,19 @@ async function processPlanchet(
} }
} }
export function denomSelectionInfoToState(dsi: DenominationSelectionInfo): DenomSelectionState { export function denomSelectionInfoToState(
dsi: DenominationSelectionInfo,
): DenomSelectionState {
return { return {
selectedDenoms: dsi.selectedDenoms.map((x) => { selectedDenoms: dsi.selectedDenoms.map((x) => {
return { return {
count: x.count, count: x.count,
denomPubHash: x.denom.denomPubHash denomPubHash: x.denom.denomPubHash,
}; };
}), }),
totalCoinValue: dsi.totalCoinValue, totalCoinValue: dsi.totalCoinValue,
totalWithdrawCost: dsi.totalWithdrawCost, totalWithdrawCost: dsi.totalWithdrawCost,
} };
} }
/** /**
@ -617,11 +619,7 @@ export async function getExchangeWithdrawalInfo(
throw Error(`exchange ${exchangeInfo.baseUrl} wire details not available`); throw Error(`exchange ${exchangeInfo.baseUrl} wire details not available`);
} }
const selectedDenoms = await selectWithdrawalDenoms( const selectedDenoms = await selectWithdrawalDenoms(ws, baseUrl, amount);
ws,
baseUrl,
amount,
);
const exchangeWireAccounts: string[] = []; const exchangeWireAccounts: string[] = [];
for (const account of exchangeWireInfo.accounts) { for (const account of exchangeWireInfo.accounts) {
exchangeWireAccounts.push(account.payto_uri); exchangeWireAccounts.push(account.payto_uri);

View File

@ -869,9 +869,8 @@ export const codecForTax = (): Codec<Tax> =>
.property("tax", codecForString) .property("tax", codecForString)
.build("Tax"); .build("Tax");
export const codecForI18n = (): Codec<{ [lang_tag: string]: string }> => export const codecForI18n = (): Codec<{ [lang_tag: string]: string }> =>
makeCodecForMap(codecForString) makeCodecForMap(codecForString);
export const codecForProduct = (): Codec<Product> => export const codecForProduct = (): Codec<Product> =>
makeCodecForObject<Product>() makeCodecForObject<Product>()
@ -908,7 +907,10 @@ export const codecForContractTerms = (): Codec<ContractTerms> =>
.property("merchant", codecForMerchantInfo()) .property("merchant", codecForMerchantInfo())
.property("merchant_pub", codecForString) .property("merchant_pub", codecForString)
.property("exchanges", makeCodecForList(codecForExchangeHandle())) .property("exchanges", makeCodecForList(codecForExchangeHandle()))
.property("products", makeCodecOptional(makeCodecForList(codecForProduct()))) .property(
"products",
makeCodecOptional(makeCodecForList(codecForProduct())),
)
.property("extra", codecForAny) .property("extra", codecForAny)
.build("ContractTerms"); .build("ContractTerms");

View File

@ -16,7 +16,7 @@
/** /**
* Type and schema definitions for the wallet's transaction list. * Type and schema definitions for the wallet's transaction list.
* *
* @author Florian Dold * @author Florian Dold
* @author Torsten Grote * @author Torsten Grote
*/ */

View File

@ -476,7 +476,6 @@ export interface DepositInfo {
denomSig: string; denomSig: string;
} }
export interface ExtendedPermissionsResponse { export interface ExtendedPermissionsResponse {
newValue: boolean; newValue: boolean;
} }

View File

@ -342,7 +342,7 @@ function mult(a: AmountJson, n: number): Result {
if (n == 0) { if (n == 0) {
return { amount: getZero(a.currency), saturated: false }; return { amount: getZero(a.currency), saturated: false };
} }
let acc = {... a}; let acc = { ...a };
while (n > 1) { while (n > 1) {
let r: Result; let r: Result;
if (n % 2 == 0) { if (n % 2 == 0) {

View File

@ -49,7 +49,6 @@ export function getTimestampNow(): Timestamp {
export function getDurationRemaining( export function getDurationRemaining(
deadline: Timestamp, deadline: Timestamp,
now = getTimestampNow(), now = getTimestampNow(),
): Duration { ): Duration {
if (deadline.t_ms === "never") { if (deadline.t_ms === "never") {
return { d_ms: "forever" }; return { d_ms: "forever" };

View File

@ -624,10 +624,12 @@ const HistoryComponent = (props: any): JSX.Element => {
class WalletSettings extends React.Component<any, any> { class WalletSettings extends React.Component<any, any> {
render(): JSX.Element { render(): JSX.Element {
return <div> return (
<h2>Permissions</h2> <div>
<PermissionsCheckbox /> <h2>Permissions</h2>
</div>; <PermissionsCheckbox />
</div>
);
} }
} }

View File

@ -108,19 +108,16 @@ export function PermissionsCheckbox(): JSX.Element {
const granted = await new Promise<boolean>((resolve, reject) => { const granted = await new Promise<boolean>((resolve, reject) => {
// We set permissions here, since apparently FF wants this to be done // We set permissions here, since apparently FF wants this to be done
// as the result of an input event ... // as the result of an input event ...
getPermissionsApi().request( getPermissionsApi().request(extendedPermissions, (granted: boolean) => {
extendedPermissions, if (chrome.runtime.lastError) {
(granted: boolean) => { console.error("error requesting permissions");
if (chrome.runtime.lastError) { console.error(chrome.runtime.lastError);
console.error("error requesting permissions"); reject(chrome.runtime.lastError);
console.error(chrome.runtime.lastError); return;
reject(chrome.runtime.lastError); }
return; console.log("permissions granted:", granted);
} resolve(granted);
console.log("permissions granted:", granted); });
resolve(granted);
},
);
}); });
const res = await wxApi.setExtendedPermissions(granted); const res = await wxApi.setExtendedPermissions(granted);
console.log(res); console.log(res);

View File

@ -28,11 +28,13 @@ import { WithdrawDetails } from "../../types/walletTypes";
import { WithdrawDetailView, renderAmount } from "../renderHtml"; import { WithdrawDetailView, renderAmount } from "../renderHtml";
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { getWithdrawDetails, acceptWithdrawal, onUpdateNotification } from "../wxApi"; import {
getWithdrawDetails,
acceptWithdrawal,
onUpdateNotification,
} from "../wxApi";
function WithdrawalDialog(props: { function WithdrawalDialog(props: { talerWithdrawUri: string }): JSX.Element {
talerWithdrawUri: string;
}): JSX.Element {
const [details, setDetails] = useState<WithdrawDetails | undefined>(); const [details, setDetails] = useState<WithdrawDetails | undefined>();
const [selectedExchange, setSelectedExchange] = useState< const [selectedExchange, setSelectedExchange] = useState<
string | undefined string | undefined
@ -48,8 +50,8 @@ function WithdrawalDialog(props: {
return onUpdateNotification(() => { return onUpdateNotification(() => {
setUpdateCounter(updateCounter + 1); setUpdateCounter(updateCounter + 1);
}); });
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, []);
useEffect(() => { useEffect(() => {
const fetchData = async (): Promise<void> => { const fetchData = async (): Promise<void> => {
@ -174,11 +176,12 @@ function WithdrawalDialog(props: {
<strong>{renderAmount(details.bankWithdrawDetails.amount)}</strong> from <strong>{renderAmount(details.bankWithdrawDetails.amount)}</strong> from
your bank account into your wallet. your bank account into your wallet.
</i18n.Translate> </i18n.Translate>
{ selectedExchange ? {selectedExchange ? (
<p> <p>
The exchange <strong>{selectedExchange}</strong> will be used as the Taler payment service provider. The exchange <strong>{selectedExchange}</strong> will be used as the
</p> : null Taler payment service provider.
} </p>
) : null}
<div> <div>
<button <button

View File

@ -17,4 +17,4 @@
export const extendedPermissions = { export const extendedPermissions = {
permissions: ["webRequest", "webRequestBlocking"], permissions: ["webRequest", "webRequestBlocking"],
origins: ["http://*/*", "https://*/*"], origins: ["http://*/*", "https://*/*"],
}; };