From 3d2b7b2a65787858c9471bc48cc5860c07b7f7dc Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 9 Jun 2021 15:26:18 +0200 Subject: formatting: re-run prettier --- .../src/crypto/workers/cryptoImplementation.ts | 2 +- .../src/crypto/workers/nodeThreadWorker.ts | 8 +++-- packages/taler-wallet-core/src/db.ts | 1 - packages/taler-wallet-core/src/headless/helpers.ts | 24 +++++++++------ .../taler-wallet-core/src/operations/balance.ts | 7 ++++- packages/taler-wallet-core/src/operations/pay.ts | 8 ++--- .../taler-wallet-core/src/operations/pending.ts | 36 +++++++++++----------- .../taler-wallet-core/src/operations/testing.ts | 15 +++++++-- packages/taler-wallet-core/src/pending-types.ts | 7 ++++- 9 files changed, 66 insertions(+), 42 deletions(-) (limited to 'packages/taler-wallet-core') diff --git a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts index d8c02cb1b..1969dee95 100644 --- a/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts +++ b/packages/taler-wallet-core/src/crypto/workers/cryptoImplementation.ts @@ -222,7 +222,7 @@ export class CryptoImplementation { .put(decodeCrock(req.merchantPub)) .put(decodeCrock(req.coinPub)) .build(); - return encodeCrock(eddsaSign(p, decodeCrock(req.merchantPriv))); + return encodeCrock(eddsaSign(p, decodeCrock(req.merchantPriv))); } /** diff --git a/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts b/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts index 37b93abe4..453a46945 100644 --- a/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts +++ b/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts @@ -92,8 +92,10 @@ export function handleWorkerMessage(msg: any): void { try { const result = (impl as any)[operation](...args); // eslint-disable-next-line @typescript-eslint/no-var-requires - const _r = "require" - const worker_threads: typeof import("worker_threads") = module[_r]("worker_threads"); + const _r = "require"; + const worker_threads: typeof import("worker_threads") = module[_r]( + "worker_threads", + ); // const worker_threads = require("worker_threads"); const p = worker_threads.parentPort; @@ -149,7 +151,7 @@ class NodeThreadCryptoWorker implements CryptoWorker { constructor() { // eslint-disable-next-line @typescript-eslint/no-var-requires - const _r = "require" + const _r = "require"; const worker_threads = module[_r]("worker_threads"); logger.trace("starting node crypto worker"); diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 584379aa4..2754fd342 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -169,7 +169,6 @@ export async function openTalerDatabase( return new DbAccess(mainDbHandle, WalletStoresV1); } - export function deleteTalerDatabase(idbFactory: IDBFactory): void { idbFactory.deleteDatabase(TALER_DB_NAME); } diff --git a/packages/taler-wallet-core/src/headless/helpers.ts b/packages/taler-wallet-core/src/headless/helpers.ts index 73196492c..7b918d5d9 100644 --- a/packages/taler-wallet-core/src/headless/helpers.ts +++ b/packages/taler-wallet-core/src/headless/helpers.ts @@ -41,18 +41,18 @@ const logger = new Logger("headless/helpers.ts"); const nodejs_fs = (function () { let fs: typeof import("fs"); - return function() { + return function () { if (!fs) { /** * need to use an expression when doing a require if we want * webpack not to find out about the requirement */ - const _r = "require" - fs = module[_r]("fs") + const _r = "require"; + fs = module[_r]("fs"); } - return fs - } -})() + return fs; + }; +})(); export interface DefaultNodeWalletArgs { /** @@ -123,9 +123,13 @@ export async function getDefaultNodeWallet( } const tmpPath = `${args.persistentStoragePath}-${makeId(5)}.tmp`; const dbContent = myBackend.exportDump(); - nodejs_fs().writeFileSync(tmpPath, JSON.stringify(dbContent, undefined, 2), { - encoding: "utf-8", - }); + nodejs_fs().writeFileSync( + tmpPath, + JSON.stringify(dbContent, undefined, 2), + { + encoding: "utf-8", + }, + ); // Atomically move the temporary file onto the DB path. nodejs_fs().renameSync(tmpPath, args.persistentStoragePath); }; @@ -157,7 +161,7 @@ export async function getDefaultNodeWallet( let workerFactory; try { // Try if we have worker threads available, fails in older node versions. - const _r = "require" + const _r = "require"; const worker_threads = module[_r]("worker_threads"); // require("worker_threads"); workerFactory = new NodeThreadCryptoWorkerFactory(); diff --git a/packages/taler-wallet-core/src/operations/balance.ts b/packages/taler-wallet-core/src/operations/balance.ts index 7273f0b42..4dba6beb7 100644 --- a/packages/taler-wallet-core/src/operations/balance.ts +++ b/packages/taler-wallet-core/src/operations/balance.ts @@ -17,7 +17,12 @@ /** * Imports. */ -import { AmountJson, BalancesResponse, Amounts, Logger } from "@gnu-taler/taler-util"; +import { + AmountJson, + BalancesResponse, + Amounts, + Logger, +} from "@gnu-taler/taler-util"; import { CoinStatus, WalletStoresV1 } from "../db.js"; import { GetReadOnlyAccess } from "../util/query.js"; diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index c57243b59..86b66e6f6 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -1649,8 +1649,9 @@ export async function refuseProposal( ws: InternalWalletState, proposalId: string, ): Promise { - const success = await ws.db.mktx((x) => ({proposals: x.proposals})).runReadWrite( - async (tx) => { + const success = await ws.db + .mktx((x) => ({ proposals: x.proposals })) + .runReadWrite(async (tx) => { const proposal = await tx.proposals.get(proposalId); if (!proposal) { logger.trace(`proposal ${proposalId} not found, won't refuse proposal`); @@ -1662,8 +1663,7 @@ export async function refuseProposal( proposal.proposalStatus = ProposalStatus.REFUSED; await tx.proposals.put(proposal); return true; - }, - ); + }); if (success) { ws.notify({ type: NotificationType.ProposalRefused, diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts index d3904c426..4eee85278 100644 --- a/packages/taler-wallet-core/src/operations/pending.ts +++ b/packages/taler-wallet-core/src/operations/pending.ts @@ -239,7 +239,7 @@ async function gatherRefreshPending( async function gatherWithdrawalPending( tx: GetReadOnlyAccess<{ withdrawalGroups: typeof WalletStoresV1.withdrawalGroups; - planchets: typeof WalletStoresV1.planchets, + planchets: typeof WalletStoresV1.planchets; }>, now: Timestamp, resp: PendingOperationsResponse, @@ -464,21 +464,22 @@ export async function getPendingOperations( { onlyDue = false } = {}, ): Promise { const now = getTimestampNow(); - return await ws.db.mktx((x) => ({ - exchanges: x.exchanges, - exchangeDetails: x.exchangeDetails, - reserves: x.reserves, - refreshGroups: x.refreshGroups, - coins: x.coins, - withdrawalGroups: x.withdrawalGroups, - proposals: x.proposals, - tips: x.tips, - purchases: x.purchases, - planchets: x.planchets, - depositGroups: x.depositGroups, - recoupGroups: x.recoupGroups, - })).runReadWrite( - async (tx) => { + return await ws.db + .mktx((x) => ({ + exchanges: x.exchanges, + exchangeDetails: x.exchangeDetails, + reserves: x.reserves, + refreshGroups: x.refreshGroups, + coins: x.coins, + withdrawalGroups: x.withdrawalGroups, + proposals: x.proposals, + tips: x.tips, + purchases: x.purchases, + planchets: x.planchets, + depositGroups: x.depositGroups, + recoupGroups: x.recoupGroups, + })) + .runReadWrite(async (tx) => { const walletBalance = await getBalancesInsideTransaction(ws, tx); const resp: PendingOperationsResponse = { nextRetryDelay: { d_ms: Number.MAX_SAFE_INTEGER }, @@ -496,6 +497,5 @@ export async function getPendingOperations( await gatherRecoupPending(tx, now, resp, onlyDue); await gatherDepositPending(tx, now, resp, onlyDue); return resp; - }, - ); + }); } diff --git a/packages/taler-wallet-core/src/operations/testing.ts b/packages/taler-wallet-core/src/operations/testing.ts index 6875a308f..c9d99bf04 100644 --- a/packages/taler-wallet-core/src/operations/testing.ts +++ b/packages/taler-wallet-core/src/operations/testing.ts @@ -23,7 +23,16 @@ import { readSuccessResponseJsonOrThrow, checkSuccessResponseOrThrow, } from "../util/http"; -import { AmountString, codecForAny, CheckPaymentResponse, codecForCheckPaymentResponse, IntegrationTestArgs, Amounts, TestPayArgs, PreparePayResultType } from "@gnu-taler/taler-util"; +import { + AmountString, + codecForAny, + CheckPaymentResponse, + codecForCheckPaymentResponse, + IntegrationTestArgs, + Amounts, + TestPayArgs, + PreparePayResultType, +} from "@gnu-taler/taler-util"; import { URL } from "../index.js"; import { Wallet } from "../wallet.js"; import { createTalerWithdrawReserve } from "./reserves.js"; @@ -102,8 +111,8 @@ export async function withdrawTestBalance( function getMerchantAuthHeader(m: MerchantBackendInfo): Record { if (m.authToken) { return { - "Authorization": `Bearer ${m.authToken}`, - } + Authorization: `Bearer ${m.authToken}`, + }; } return {}; } diff --git a/packages/taler-wallet-core/src/pending-types.ts b/packages/taler-wallet-core/src/pending-types.ts index c16f729bc..78e01416c 100644 --- a/packages/taler-wallet-core/src/pending-types.ts +++ b/packages/taler-wallet-core/src/pending-types.ts @@ -24,7 +24,12 @@ /** * Imports. */ -import { TalerErrorDetails, BalancesResponse, Duration, Timestamp } from "@gnu-taler/taler-util"; +import { + TalerErrorDetails, + BalancesResponse, + Duration, + Timestamp, +} from "@gnu-taler/taler-util"; import { ReserveRecordStatus } from "./db.js"; import { RetryInfo } from "./util/retries.js"; -- cgit v1.2.3