diff options
author | Florian Dold <florian@dold.me> | 2020-12-14 16:45:15 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2020-12-14 16:45:15 +0100 |
commit | f332d61fb68fbc394f31337ddeb7d1fc114772d0 (patch) | |
tree | eeb9e7dd527ab7efcaa7812f4440e8901185e9aa /packages/taler-wallet-core/src/operations | |
parent | c4b44a51097e67a357b490adf407f1a6afb0d8ee (diff) | |
download | wallet-core-f332d61fb68fbc394f31337ddeb7d1fc114772d0.tar.gz wallet-core-f332d61fb68fbc394f31337ddeb7d1fc114772d0.tar.bz2 wallet-core-f332d61fb68fbc394f31337ddeb7d1fc114772d0.zip |
formatting pass
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
8 files changed, 59 insertions, 45 deletions
diff --git a/packages/taler-wallet-core/src/operations/backup.ts b/packages/taler-wallet-core/src/operations/backup.ts index 6c497b305..f609d4354 100644 --- a/packages/taler-wallet-core/src/operations/backup.ts +++ b/packages/taler-wallet-core/src/operations/backup.ts @@ -120,7 +120,7 @@ async function provideBackupState( key: WALLET_BACKUP_STATE_KEY, value: { deviceId, - clocks: { [deviceId]: 1}, + clocks: { [deviceId]: 1 }, walletRootPub: k.pub, walletRootPriv: k.priv, lastBackupHash: undefined, @@ -152,7 +152,9 @@ export async function exportBackup( const exchanges: BackupExchange[] = []; const coinsByDenom: { [dph: string]: BackupCoin[] } = {}; - const denominationsByExchange: { [url: string]: BackupDenomination[] } = {}; + const denominationsByExchange: { + [url: string]: BackupDenomination[]; + } = {}; const reservesByExchange: { [url: string]: BackupReserve[] } = {}; await tx.iter(Stores.coins).forEach((coin) => { @@ -193,7 +195,9 @@ export async function exportBackup( }); await tx.iter(Stores.denominations).forEach((denom) => { - const backupDenoms = (denominationsByExchange[denom.exchangeBaseUrl] ??= []); + const backupDenoms = (denominationsByExchange[ + denom.exchangeBaseUrl + ] ??= []); backupDenoms.push({ coins: coinsByDenom[denom.denomPubHash] ?? [], denom_pub: denom.denomPub, @@ -401,7 +405,7 @@ export async function runBackupCycle(ws: InternalWalletState): Promise<void> { if (resp.status === HttpResponseStatus.PaymentRequired) { logger.trace("payment required for backup"); - logger.trace(`headers: ${j2s(resp.headers)}`) + logger.trace(`headers: ${j2s(resp.headers)}`); return; } diff --git a/packages/taler-wallet-core/src/operations/errors.ts b/packages/taler-wallet-core/src/operations/errors.ts index 4eeda898b..8ec8468a1 100644 --- a/packages/taler-wallet-core/src/operations/errors.ts +++ b/packages/taler-wallet-core/src/operations/errors.ts @@ -36,7 +36,9 @@ export class OperationFailedAndReportedError extends Error { message: string, details: Record<string, unknown>, ): OperationFailedAndReportedError { - return new OperationFailedAndReportedError(makeErrorDetails(ec, message, details)); + return new OperationFailedAndReportedError( + makeErrorDetails(ec, message, details), + ); } constructor(public operationError: TalerErrorDetails) { diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts index b82700365..b6865cccc 100644 --- a/packages/taler-wallet-core/src/operations/exchanges.ts +++ b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -289,24 +289,21 @@ async function updateExchangeFinalize( if (exchange.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) { return; } - await ws.db.runWithWriteTransaction( - [Stores.exchanges], - async (tx) => { - const r = await tx.get(Stores.exchanges, exchangeBaseUrl); - if (!r) { - return; - } - if (r.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) { - return; - } - r.addComplete = true; - r.updateStatus = ExchangeUpdateStatus.Finished; - // Reset time to next auto refresh check, - // as now new denominations might be available. - r.nextRefreshCheck = undefined; - await tx.put(Stores.exchanges, r); - }, - ); + await ws.db.runWithWriteTransaction([Stores.exchanges], async (tx) => { + const r = await tx.get(Stores.exchanges, exchangeBaseUrl); + if (!r) { + return; + } + if (r.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) { + return; + } + r.addComplete = true; + r.updateStatus = ExchangeUpdateStatus.Finished; + // Reset time to next auto refresh check, + // as now new denominations might be available. + r.nextRefreshCheck = undefined; + await tx.put(Stores.exchanges, r); + }); } async function updateExchangeWithTermsOfService( @@ -547,7 +544,9 @@ export async function getExchangeTrust( ); if (currencyRecord) { for (const trustedExchange of currencyRecord.exchanges) { - if (trustedExchange.exchangeMasterPub === exchangeDetails.masterPublicKey) { + if ( + trustedExchange.exchangeMasterPub === exchangeDetails.masterPublicKey + ) { isTrusted = true; break; } diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index ad970129f..52f0c4510 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -435,7 +435,9 @@ async function recordConfirmPay( } else { sessionId = proposal.downloadSessionId; } - logger.trace(`recording payment on ${proposal.orderId} with session ID ${sessionId}`); + logger.trace( + `recording payment on ${proposal.orderId} with session ID ${sessionId}`, + ); const payCostInfo = await getTotalPaymentCost(ws, coinSelection); const t: PurchaseRecord = { abortStatus: AbortStatus.None, @@ -943,7 +945,10 @@ async function submitPay( session_id: purchase.lastSessionId, }; - logger.trace("making pay request ... ", JSON.stringify(reqBody, undefined, 2)); + logger.trace( + "making pay request ... ", + JSON.stringify(reqBody, undefined, 2), + ); const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], () => ws.http.postJson(payUrl, reqBody, { @@ -971,7 +976,7 @@ async function submitPay( lastError: err, }; } - + const merchantResp = await readSuccessResponseJsonOrThrow( resp, codecForMerchantPayResponse(), @@ -1208,10 +1213,7 @@ export async function confirmPay( throw Error("proposal is in invalid state"); } - let purchase = await ws.db.get( - Stores.purchases, - proposalId, - ); + let purchase = await ws.db.get(Stores.purchases, proposalId); if (purchase) { if ( diff --git a/packages/taler-wallet-core/src/operations/recoup.ts b/packages/taler-wallet-core/src/operations/recoup.ts index 585c91a09..7bbac8a99 100644 --- a/packages/taler-wallet-core/src/operations/recoup.ts +++ b/packages/taler-wallet-core/src/operations/recoup.ts @@ -38,10 +38,7 @@ import { import { codecForRecoupConfirmation } from "../types/talerTypes"; import { NotificationType } from "../types/notifications"; -import { - getReserveRequestTimeout, - processReserve, -} from "./reserves"; +import { getReserveRequestTimeout, processReserve } from "./reserves"; import { Amounts } from "../util/amounts"; import { createRefreshGroup, processRefreshGroup } from "./refresh"; diff --git a/packages/taler-wallet-core/src/operations/refund.ts b/packages/taler-wallet-core/src/operations/refund.ts index e0d060376..36b21b232 100644 --- a/packages/taler-wallet-core/src/operations/refund.ts +++ b/packages/taler-wallet-core/src/operations/refund.ts @@ -286,7 +286,10 @@ async function storeFailedRefund( } if (contrib) { coin.currentAmount = Amounts.add(coin.currentAmount, contrib).amount; - coin.currentAmount = Amounts.sub(coin.currentAmount, denom.feeRefund).amount; + coin.currentAmount = Amounts.sub( + coin.currentAmount, + denom.feeRefund, + ).amount; } refreshCoinsMap[coin.coinPub] = { coinPub: coin.coinPub }; await tx.put(Stores.coins, coin); @@ -325,7 +328,8 @@ async function acceptRefunds( const isPermanentFailure = refundStatus.type === "failure" && - refundStatus.exchange_status >= 400 && refundStatus.exchange_status < 500 ; + refundStatus.exchange_status >= 400 && + refundStatus.exchange_status < 500; // Already failed. if (existingRefundInfo?.type === RefundState.Failed) { @@ -536,7 +540,7 @@ export async function applyRefund( fulfillmentMessage: purchase.contractData.fulfillmentMessage, summary_i18n: purchase.contractData.summaryI18n, fulfillmentMessage_i18n: purchase.contractData.fulfillmentMessageI18n, - } + }, }; } diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts index bf565b9b2..a57963824 100644 --- a/packages/taler-wallet-core/src/operations/tip.ts +++ b/packages/taler-wallet-core/src/operations/tip.ts @@ -40,7 +40,10 @@ import { getRandomBytes, encodeCrock } from "../crypto/talerCrypto"; import { guardOperationException, makeErrorDetails } from "./errors"; import { NotificationType } from "../types/notifications"; import { getTimestampNow } from "../util/time"; -import { getHttpResponseErrorDetails, readSuccessResponseJsonOrThrow } from "../util/http"; +import { + getHttpResponseErrorDetails, + readSuccessResponseJsonOrThrow, +} from "../util/http"; import { URL } from "../util/url"; import { Logger } from "../util/logging"; import { checkDbInvariant } from "../util/invariants"; diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index d09903cbb..a3bb9724c 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -43,7 +43,10 @@ import { InternalWalletState } from "./state"; import { parseWithdrawUri } from "../util/taleruri"; import { Logger } from "../util/logging"; import { updateExchangeFromUrl, getExchangeTrust } from "./exchanges"; -import { WALLET_EXCHANGE_PROTOCOL_VERSION, WALLET_BANK_INTEGRATION_PROTOCOL_VERSION } from "./versions"; +import { + WALLET_EXCHANGE_PROTOCOL_VERSION, + WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, +} from "./versions"; import * as LibtoolVersion from "../util/libtoolVersion"; import { @@ -155,10 +158,7 @@ export async function getBankWithdrawalInfo( throw Error(`can't parse URL ${talerWithdrawUri}`); } - const configReqUrl = new URL( - "config", - uriResult.bankIntegrationApiBaseUrl, - ) + const configReqUrl = new URL("config", uriResult.bankIntegrationApiBaseUrl); const configResp = await ws.http.get(configReqUrl.href); const config = await readSuccessResponseJsonOrThrow( @@ -166,7 +166,10 @@ export async function getBankWithdrawalInfo( codecForTalerConfigResponse(), ); - const versionRes = compare(WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, config.version); + const versionRes = compare( + WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, + config.version, + ); if (versionRes?.compatible != true) { const opErr = makeErrorDetails( TalerErrorCode.WALLET_BANK_INTEGRATION_PROTOCOL_VERSION_INCOMPATIBLE, |