diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-09-04 12:04:11 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-09-04 12:04:11 +0530 |
commit | 3c57820df0711f301e69adb0f4b8a91f0905cc0c (patch) | |
tree | 5be12160a8061ce7954c7552ed861a443e3f57a5 | |
parent | c7a2abedbabe9142ce9a15902f90a5d1f4b36f05 (diff) |
formatting, import
-rw-r--r-- | packages/taler-integrationtests/src/harness.ts | 8 | ||||
-rw-r--r-- | packages/taler-integrationtests/src/helpers.ts | 88 | ||||
-rw-r--r-- | packages/taler-integrationtests/src/test-payment.ts | 5 | ||||
-rw-r--r-- | packages/taler-integrationtests/src/test-revocation.ts | 6 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/index.ts | 2 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/balance.ts | 10 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay.ts | 5 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/pending.ts | 8 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/recoup.ts | 6 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/refresh.ts | 10 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/transactions.ts | 11 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/types/dbTypes.ts | 3 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/util/codec.ts | 4 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/util/http.ts | 9 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/util/time.ts | 16 |
15 files changed, 110 insertions, 81 deletions
diff --git a/packages/taler-integrationtests/src/harness.ts b/packages/taler-integrationtests/src/harness.ts index dbb416b48..cc5ffa161 100644 --- a/packages/taler-integrationtests/src/harness.ts +++ b/packages/taler-integrationtests/src/harness.ts @@ -378,10 +378,7 @@ export class GlobalTestState { } } - assertAmountLeq( - a: string | AmountJson, - b: string | AmountJson, - ): void { + assertAmountLeq(a: string | AmountJson, b: string | AmountJson): void { if (Amounts.cmp(a, b) > 0) { throw Error( `test assertion failed: expected ${Amounts.stringify( @@ -1089,7 +1086,8 @@ export class ExchangeService implements ExchangeServiceInterface { "exchange-keyup", "taler-exchange-keyup", [ - "-c", this.configFilename, + "-c", + this.configFilename, ...this.timetravelArgArr, "--revoke", denomPubHash, diff --git a/packages/taler-integrationtests/src/helpers.ts b/packages/taler-integrationtests/src/helpers.ts index ca9b57abf..e248b4a7d 100644 --- a/packages/taler-integrationtests/src/helpers.ts +++ b/packages/taler-integrationtests/src/helpers.ts @@ -38,7 +38,13 @@ import { BankAccessApi, MerchantPrivateApi, } from "./harness"; -import { AmountString, Duration, PreparePayResultType, ConfirmPayResultType, ContractTerms } from "taler-wallet-core"; +import { + AmountString, + Duration, + PreparePayResultType, + ConfirmPayResultType, + ContractTerms, +} from "taler-wallet-core"; import { FaultInjectedMerchantService } from "./faultInjection"; export interface SimpleTestEnvironment { @@ -309,57 +315,59 @@ export async function applyTimeTravel( } } - /** * Make a simple payment and check that it succeeded. */ -export async function makeTestPayment(t: GlobalTestState, args: { - merchant: MerchantServiceInterface, - wallet: WalletCli, - order: Partial<ContractTerms>, - instance?: string -}): Promise<void> { - // Set up order. +export async function makeTestPayment( + t: GlobalTestState, + args: { + merchant: MerchantServiceInterface; + wallet: WalletCli; + order: Partial<ContractTerms>; + instance?: string; + }, +): Promise<void> { + // Set up order. - const { wallet, merchant } = args; - const instance = args.instance ?? "default"; + const { wallet, merchant } = args; + const instance = args.instance ?? "default"; - const orderResp = await MerchantPrivateApi.createOrder(merchant, instance, { - order: { - summary: "Buy me!", - amount: "TESTKUDOS:5", - fulfillment_url: "taler://fulfillment-success/thx", - }, - }); + const orderResp = await MerchantPrivateApi.createOrder(merchant, instance, { + order: { + summary: "Buy me!", + amount: "TESTKUDOS:5", + fulfillment_url: "taler://fulfillment-success/thx", + }, + }); - let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { - orderId: orderResp.order_id, - }); + let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { + orderId: orderResp.order_id, + }); - t.assertTrue(orderStatus.order_status === "unpaid"); + t.assertTrue(orderStatus.order_status === "unpaid"); - // Make wallet pay for the order + // Make wallet pay for the order - const preparePayResult = await wallet.preparePay({ - talerPayUri: orderStatus.taler_pay_uri, - }); + const preparePayResult = await wallet.preparePay({ + talerPayUri: orderStatus.taler_pay_uri, + }); - t.assertTrue( - preparePayResult.status === PreparePayResultType.PaymentPossible, - ); + t.assertTrue( + preparePayResult.status === PreparePayResultType.PaymentPossible, + ); - const r2 = await wallet.confirmPay({ - proposalId: preparePayResult.proposalId, - }); + const r2 = await wallet.confirmPay({ + proposalId: preparePayResult.proposalId, + }); - t.assertTrue(r2.type === ConfirmPayResultType.Done); + t.assertTrue(r2.type === ConfirmPayResultType.Done); - // Check if payment was successful. + // Check if payment was successful. - orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { - orderId: orderResp.order_id, - instance, - }); + orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { + orderId: orderResp.order_id, + instance, + }); - t.assertTrue(orderStatus.order_status === "paid"); -}
\ No newline at end of file + t.assertTrue(orderStatus.order_status === "paid"); +} diff --git a/packages/taler-integrationtests/src/test-payment.ts b/packages/taler-integrationtests/src/test-payment.ts index 4f44fc146..c82770d76 100644 --- a/packages/taler-integrationtests/src/test-payment.ts +++ b/packages/taler-integrationtests/src/test-payment.ts @@ -17,10 +17,7 @@ /** * Imports. */ -import { - runTest, - GlobalTestState, -} from "./harness"; +import { runTest, GlobalTestState } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank, diff --git a/packages/taler-integrationtests/src/test-revocation.ts b/packages/taler-integrationtests/src/test-revocation.ts index 32ac3f0dc..32cb5d620 100644 --- a/packages/taler-integrationtests/src/test-revocation.ts +++ b/packages/taler-integrationtests/src/test-revocation.ts @@ -33,9 +33,9 @@ import { import { CoinDumpJson } from "taler-wallet-core"; async function revokeAllWalletCoins(req: { - wallet: WalletCli, - exchange: ExchangeService, - merchant: MerchantService, + wallet: WalletCli; + exchange: ExchangeService; + merchant: MerchantService; }): Promise<void> { const { wallet, exchange, merchant } = req; const coinDump = await wallet.dumpCoins(); diff --git a/packages/taler-wallet-core/src/index.ts b/packages/taler-wallet-core/src/index.ts index b78d7b823..a94155b14 100644 --- a/packages/taler-wallet-core/src/index.ts +++ b/packages/taler-wallet-core/src/index.ts @@ -64,4 +64,4 @@ export * from "./types/talerTypes"; export * from "./types/walletTypes"; export * from "./types/notifications"; export * from "./types/transactions"; -export * from "./types/pending";
\ No newline at end of file +export * from "./types/pending"; diff --git a/packages/taler-wallet-core/src/operations/balance.ts b/packages/taler-wallet-core/src/operations/balance.ts index 47ce5f482..91c5e639e 100644 --- a/packages/taler-wallet-core/src/operations/balance.ts +++ b/packages/taler-wallet-core/src/operations/balance.ts @@ -90,10 +90,16 @@ export async function getBalancesInsideTransaction( const b = initBalance(session.amountRefreshOutput.currency); // We are always assuming the refresh will succeed, thus we // report the output as available balance. - b.available = Amounts.add(b.available, session.amountRefreshOutput).amount; + b.available = Amounts.add( + b.available, + session.amountRefreshOutput, + ).amount; } else { const b = initBalance(r.inputPerCoin[i].currency); - b.available = Amounts.add(b.available, r.estimatedOutputPerCoin[i]).amount; + b.available = Amounts.add( + b.available, + r.estimatedOutputPerCoin[i], + ).amount; } } }); diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index c6f39858d..6452a11ae 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -288,7 +288,10 @@ export function selectPayCoins( return undefined; } -export function isSpendableCoin(coin: CoinRecord, denom: DenominationRecord): boolean { +export function isSpendableCoin( + coin: CoinRecord, + denom: DenominationRecord, +): boolean { if (coin.suspended) { return false; } diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts index e51f37702..3c631eb77 100644 --- a/packages/taler-wallet-core/src/operations/pending.ts +++ b/packages/taler-wallet-core/src/operations/pending.ts @@ -92,7 +92,8 @@ async function gatherExchangePending( }, }); } - const keysUpdateRequired = e.details && e.details.nextUpdateTime.t_ms < now.t_ms; + const keysUpdateRequired = + e.details && e.details.nextUpdateTime.t_ms < now.t_ms; if (keysUpdateRequired) { resp.pendingOperations.push({ type: PendingOperationType.ExchangeUpdate, @@ -103,7 +104,10 @@ async function gatherExchangePending( reason: "scheduled", }); } - if (e.details && (!e.nextRefreshCheck || e.nextRefreshCheck.t_ms < now.t_ms)) { + if ( + e.details && + (!e.nextRefreshCheck || e.nextRefreshCheck.t_ms < now.t_ms) + ) { resp.pendingOperations.push({ type: PendingOperationType.ExchangeCheckRefresh, exchangeBaseUrl: e.baseUrl, diff --git a/packages/taler-wallet-core/src/operations/recoup.ts b/packages/taler-wallet-core/src/operations/recoup.ts index eb268f18b..3f53d93ed 100644 --- a/packages/taler-wallet-core/src/operations/recoup.ts +++ b/packages/taler-wallet-core/src/operations/recoup.ts @@ -40,7 +40,11 @@ import { import { codecForRecoupConfirmation } from "../types/talerTypes"; import { NotificationType } from "../types/notifications"; -import { forceQueryReserve, getReserveRequestTimeout, processReserve } from "./reserves"; +import { + forceQueryReserve, + getReserveRequestTimeout, + processReserve, +} from "./reserves"; import { Amounts } from "../util/amounts"; import { createRefreshGroup, processRefreshGroup } from "./refresh"; diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index 76f3015f3..062a52e6d 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -654,7 +654,10 @@ export async function createRefreshGroup( * Timestamp after which the wallet would do the next check for an auto-refresh. */ function getAutoRefreshCheckThreshold(d: DenominationRecord): Timestamp { - const delta = timestampDifference(d.stampExpireWithdraw, d.stampExpireDeposit); + const delta = timestampDifference( + d.stampExpireWithdraw, + d.stampExpireDeposit, + ); const deltaDiv = durationMul(delta, 0.75); return timestampAddDuration(d.stampExpireWithdraw, deltaDiv); } @@ -663,7 +666,10 @@ function getAutoRefreshCheckThreshold(d: DenominationRecord): Timestamp { * Timestamp after which the wallet would do an auto-refresh. */ function getAutoRefreshExecuteThreshold(d: DenominationRecord): Timestamp { - const delta = timestampDifference(d.stampExpireWithdraw, d.stampExpireDeposit); + const delta = timestampDifference( + d.stampExpireWithdraw, + d.stampExpireDeposit, + ); const deltaDiv = durationMul(delta, 0.5); return timestampAddDuration(d.stampExpireWithdraw, deltaDiv); } diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index da75f6e53..7a3228422 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -26,7 +26,7 @@ import { ReserveRecordStatus, } from "../types/dbTypes"; import { Amounts, AmountJson } from "../util/amounts"; -import { timestampCmp, Timestamp } from "../util/time"; +import { timestampCmp } from "../util/time"; import { TransactionsRequest, TransactionsResponse, @@ -281,10 +281,10 @@ export async function getTransactions( groupKey, ); let r0: WalletRefundItem | undefined; - let amountRaw = Amounts.getZero( + let amountRaw = Amounts.getZero(pr.contractData.amount.currency); + let amountEffective = Amounts.getZero( pr.contractData.amount.currency, ); - let amountEffective = Amounts.getZero(pr.contractData.amount.currency); for (const rk of Object.keys(pr.refunds)) { const refund = pr.refunds[rk]; const myGroupKey = `${refund.executionTime.t_ms}`; @@ -296,10 +296,7 @@ export async function getTransactions( } if (refund.type === RefundState.Applied) { - amountRaw = Amounts.add( - amountRaw, - refund.refundAmount, - ).amount; + amountRaw = Amounts.add(amountRaw, refund.refundAmount).amount; amountEffective = Amounts.add( amountEffective, Amounts.sub( diff --git a/packages/taler-wallet-core/src/types/dbTypes.ts b/packages/taler-wallet-core/src/types/dbTypes.ts index 45c19cbd0..0ee41a6a5 100644 --- a/packages/taler-wallet-core/src/types/dbTypes.ts +++ b/packages/taler-wallet-core/src/types/dbTypes.ts @@ -657,14 +657,13 @@ export interface ExchangeRecord { /** * Next time that we should check if coins need to be refreshed. - * + * * Updated whenever the exchange's denominations are updated or when * the refresh check has been done. */ nextRefreshCheck?: Timestamp; } - /** * A coin that isn't yet signed by an exchange. */ diff --git a/packages/taler-wallet-core/src/util/codec.ts b/packages/taler-wallet-core/src/util/codec.ts index 741a5b172..4654c8b93 100644 --- a/packages/taler-wallet-core/src/util/codec.ts +++ b/packages/taler-wallet-core/src/util/codec.ts @@ -302,8 +302,8 @@ export function codecForBoolean(): Codec<boolean> { `expected boolean at ${renderContext(c)} but got ${typeof x}`, ); }, - } -}; + }; +} /** * Return a codec for a value that must be a string. diff --git a/packages/taler-wallet-core/src/util/http.ts b/packages/taler-wallet-core/src/util/http.ts index e050efe61..1a2459f7e 100644 --- a/packages/taler-wallet-core/src/util/http.ts +++ b/packages/taler-wallet-core/src/util/http.ts @@ -26,7 +26,14 @@ import { Codec } from "./codec"; import { OperationFailedError, makeErrorDetails } from "../operations/errors"; import { TalerErrorCode } from "../TalerErrorCode"; import { Logger } from "./logging"; -import { Duration, Timestamp, getTimestampNow, timestampAddDuration, timestampMin, timestampMax } from "./time"; +import { + Duration, + Timestamp, + getTimestampNow, + timestampAddDuration, + timestampMin, + timestampMax, +} from "./time"; const logger = new Logger("http.ts"); diff --git a/packages/taler-wallet-core/src/util/time.ts b/packages/taler-wallet-core/src/util/time.ts index 1f085107f..5a5e9c608 100644 --- a/packages/taler-wallet-core/src/util/time.ts +++ b/packages/taler-wallet-core/src/util/time.ts @@ -86,7 +86,7 @@ export function timestampMax(t1: Timestamp, t2: Timestamp): Timestamp { return { t_ms: Math.max(t1.t_ms, t2.t_ms) }; } -const SECONDS = 1000 +const SECONDS = 1000; const MINUTES = SECONDS * 60; const HOURS = MINUTES * 60; const DAYS = HOURS * 24; @@ -94,12 +94,12 @@ const MONTHS = DAYS * 30; const YEARS = DAYS * 365; export function durationFromSpec(spec: { - seconds?: number, - minutes?: number, - hours?: number, - days?: number, - months?: number, - years?: number, + seconds?: number; + minutes?: number; + hours?: number; + days?: number; + months?: number; + years?: number; }): Duration { let d_ms = 0; d_ms += (spec.seconds ?? 0) * SECONDS; @@ -148,7 +148,7 @@ export function durationMul(d: Duration, n: number): Duration { if (d.d_ms === "forever") { return { d_ms: "forever" }; } - return { d_ms: Math.round( d.d_ms * n) }; + return { d_ms: Math.round(d.d_ms * n) }; } export function timestampCmp(t1: Timestamp, t2: Timestamp): number { |