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";
import { NodeHttpLib } from "../headless/NodeHttpLib";
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
//import akono = require("akono");
@ -159,7 +162,7 @@ class AndroidWalletMessageHandler {
supported_protocol_versions: {
exchange: WALLET_EXCHANGE_PROTOCOL_VERSION,
merchant: WALLET_MERCHANT_PROTOCOL_VERSION,
}
},
};
}
case "getTransactions": {

View File

@ -65,7 +65,11 @@ import {
} from "../talerCrypto";
import { randomBytes } from "../primitives/nacl-fast";
import { kdf } from "../primitives/kdf";
import { Timestamp, getTimestampNow, timestampTruncateToSecond } from "../../util/time";
import {
Timestamp,
getTimestampNow,
timestampTruncateToSecond,
} from "../../util/time";
enum SignaturePurpose {
RESERVE_WITHDRAW = 1200,
@ -368,7 +372,10 @@ export class CryptoImplementation {
for (const ncd of newCoinDenoms.selectedDenoms) {
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
@ -406,7 +413,10 @@ export class CryptoImplementation {
const coinNumber = planchets.length;
const transferPriv = decodeCrock(transferPrivs[i]);
const oldCoinPub = decodeCrock(meltCoin.coinPub);
const transferSecret = keyExchangeEcdheEddsa(transferPriv, oldCoinPub);
const transferSecret = keyExchangeEcdheEddsa(
transferPriv,
oldCoinPub,
);
const fresh = setupRefreshPlanchet(transferSecret, coinNumber);
const coinPriv = fresh.coinPriv;
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);
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 bankBaseUrl = cfg

View File

@ -649,7 +649,10 @@ testCli
args.genTipUri.merchant ?? "https://backend.test.taler.net/",
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);
});

View File

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

View File

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

View File

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

View File

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

View File

@ -200,7 +200,10 @@ async function processTipImpl(
const planchets: TipPlanchet[] = [];
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) {
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 {
selectedDenoms: dsi.selectedDenoms.map((x) => {
return {
count: x.count,
denomPubHash: x.denom.denomPubHash
denomPubHash: x.denom.denomPubHash,
};
}),
totalCoinValue: dsi.totalCoinValue,
totalWithdrawCost: dsi.totalWithdrawCost,
}
};
}
/**
@ -617,11 +619,7 @@ export async function getExchangeWithdrawalInfo(
throw Error(`exchange ${exchangeInfo.baseUrl} wire details not available`);
}
const selectedDenoms = await selectWithdrawalDenoms(
ws,
baseUrl,
amount,
);
const selectedDenoms = await selectWithdrawalDenoms(ws, baseUrl, amount);
const exchangeWireAccounts: string[] = [];
for (const account of exchangeWireInfo.accounts) {
exchangeWireAccounts.push(account.payto_uri);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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