diff options
author | Florian Dold <florian@dold.me> | 2021-06-09 15:26:18 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-06-09 15:26:18 +0200 |
commit | 3d2b7b2a65787858c9471bc48cc5860c07b7f7dc (patch) | |
tree | 4a7477c184de7408104b8bf254a277a5949b19de /packages/taler-util/src | |
parent | 5c26461247040c07c86291babf0c87631df638b5 (diff) | |
download | wallet-core-3d2b7b2a65787858c9471bc48cc5860c07b7f7dc.tar.xz |
formatting: re-run prettier
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r-- | packages/taler-util/src/ReserveTransaction.ts | 16 | ||||
-rw-r--r-- | packages/taler-util/src/helpers.test.js | 32 | ||||
-rw-r--r-- | packages/taler-util/src/helpers.ts | 6 | ||||
-rw-r--r-- | packages/taler-util/src/i18n.ts | 21 | ||||
-rw-r--r-- | packages/taler-util/src/index.ts | 2 | ||||
-rw-r--r-- | packages/taler-util/src/logging.ts | 4 | ||||
-rw-r--r-- | packages/taler-util/src/taler-error-codes.ts | 3 | ||||
-rw-r--r-- | packages/taler-util/src/talerTypes.ts | 61 | ||||
-rw-r--r-- | packages/taler-util/src/talerconfig.ts | 12 |
9 files changed, 64 insertions, 93 deletions
diff --git a/packages/taler-util/src/ReserveTransaction.ts b/packages/taler-util/src/ReserveTransaction.ts index f477106b2..b282ef189 100644 --- a/packages/taler-util/src/ReserveTransaction.ts +++ b/packages/taler-util/src/ReserveTransaction.ts @@ -182,9 +182,7 @@ export type ReserveTransaction = | ReserveClosingTransaction | ReserveRecoupTransaction; -export const codecForReserveWithdrawTransaction = (): Codec< - ReserveWithdrawTransaction -> => +export const codecForReserveWithdrawTransaction = (): Codec<ReserveWithdrawTransaction> => buildCodecForObject<ReserveWithdrawTransaction>() .property("amount", codecForString()) .property("h_coin_envelope", codecForString()) @@ -194,9 +192,7 @@ export const codecForReserveWithdrawTransaction = (): Codec< .property("withdraw_fee", codecForString()) .build("ReserveWithdrawTransaction"); -export const codecForReserveCreditTransaction = (): Codec< - ReserveCreditTransaction -> => +export const codecForReserveCreditTransaction = (): Codec<ReserveCreditTransaction> => buildCodecForObject<ReserveCreditTransaction>() .property("amount", codecForString()) .property("sender_account_url", codecForString()) @@ -205,9 +201,7 @@ export const codecForReserveCreditTransaction = (): Codec< .property("type", codecForConstString(ReserveTransactionType.Credit)) .build("ReserveCreditTransaction"); -export const codecForReserveClosingTransaction = (): Codec< - ReserveClosingTransaction -> => +export const codecForReserveClosingTransaction = (): Codec<ReserveClosingTransaction> => buildCodecForObject<ReserveClosingTransaction>() .property("amount", codecForString()) .property("closing_fee", codecForString()) @@ -219,9 +213,7 @@ export const codecForReserveClosingTransaction = (): Codec< .property("wtid", codecForString()) .build("ReserveClosingTransaction"); -export const codecForReserveRecoupTransaction = (): Codec< - ReserveRecoupTransaction -> => +export const codecForReserveRecoupTransaction = (): Codec<ReserveRecoupTransaction> => buildCodecForObject<ReserveRecoupTransaction>() .property("amount", codecForString()) .property("coin_pub", codecForString()) diff --git a/packages/taler-util/src/helpers.test.js b/packages/taler-util/src/helpers.test.js index ed3198c85..b311f8a11 100644 --- a/packages/taler-util/src/helpers.test.js +++ b/packages/taler-util/src/helpers.test.js @@ -16,14 +16,26 @@ import test from "ava"; import * as helpers from "./helpers"; test("URL canonicalization", (t) => { - // converts to relative, adds https - t.is("https://alice.example.com/exchange/", helpers.canonicalizeBaseUrl("alice.example.com/exchange")); - // keeps http, adds trailing slash - t.is("http://alice.example.com/exchange/", helpers.canonicalizeBaseUrl("http://alice.example.com/exchange")); - // keeps http, adds trailing slash - t.is("http://alice.example.com/exchange/", helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar")); - // Remove search component - t.is("http://alice.example.com/exchange/", helpers.canonicalizeBaseUrl("http://alice.example.com/exchange?foo=bar")); - t.pass(); + // converts to relative, adds https + t.is( + "https://alice.example.com/exchange/", + helpers.canonicalizeBaseUrl("alice.example.com/exchange"), + ); + // keeps http, adds trailing slash + t.is( + "http://alice.example.com/exchange/", + helpers.canonicalizeBaseUrl("http://alice.example.com/exchange"), + ); + // keeps http, adds trailing slash + t.is( + "http://alice.example.com/exchange/", + helpers.canonicalizeBaseUrl("http://alice.example.com/exchange#foobar"), + ); + // Remove search component + t.is( + "http://alice.example.com/exchange/", + helpers.canonicalizeBaseUrl("http://alice.example.com/exchange?foo=bar"), + ); + t.pass(); }); -//# sourceMappingURL=helpers.test.js.map
\ No newline at end of file +//# sourceMappingURL=helpers.test.js.map diff --git a/packages/taler-util/src/helpers.ts b/packages/taler-util/src/helpers.ts index fb0cd8a2b..53a9a43d4 100644 --- a/packages/taler-util/src/helpers.ts +++ b/packages/taler-util/src/helpers.ts @@ -68,11 +68,7 @@ export function canonicalJson(obj: any): string { return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4); }); } - if ( - typeof obj === "number" || - typeof obj === "boolean" || - obj === null - ) { + if (typeof obj === "number" || typeof obj === "boolean" || obj === null) { return JSON.stringify(obj); } if (Array.isArray(obj)) { diff --git a/packages/taler-util/src/i18n.ts b/packages/taler-util/src/i18n.ts index 4253eb227..a4b0bf81f 100644 --- a/packages/taler-util/src/i18n.ts +++ b/packages/taler-util/src/i18n.ts @@ -17,7 +17,7 @@ export function setupI18n(lang: string, strings: { [s: string]: any }): any { lang = "en-US"; logger.warn(`language ${lang} not found, defaulting to english`); } - debugger + debugger; jed = new jedLib.Jed(strings[lang]); } @@ -58,11 +58,14 @@ export function str(stringSeq: TemplateStringsArray, ...values: any[]): string { /** * Internationalize a string template without serializing */ -export function translate(stringSeq: TemplateStringsArray, ...values: any[]): any[] { +export function translate( + stringSeq: TemplateStringsArray, + ...values: any[] +): any[] { const s = toI18nString(stringSeq); - if (!s) return [] + if (!s) return []; const translation: string = jed.ngettext(s, s, 1); - return replacePlaceholderWithValues(translation, values) + return replacePlaceholderWithValues(translation, values); } /** @@ -71,9 +74,9 @@ export function translate(stringSeq: TemplateStringsArray, ...values: any[]): an export function Translate({ children, ...rest }: { children: any }): any { const c = [].concat(children); const s = stringifyArray(c); - if (!s) return [] + if (!s) return []; const translation: string = jed.ngettext(s, s, 1); - return replacePlaceholderWithValues(translation, c) + return replacePlaceholderWithValues(translation, c); } /** @@ -94,7 +97,6 @@ export function getTranslatedArray(array: Array<any>) { return replacePlaceholderWithValues(translation, array); } - function replacePlaceholderWithValues( translation: string, childArray: Array<any>, @@ -142,6 +144,5 @@ function stringifyArray(children: Array<any>): string { export const i18n = { str, Translate, - translate -} - + translate, +}; diff --git a/packages/taler-util/src/index.ts b/packages/taler-util/src/index.ts index 25a24fa18..2e1c68765 100644 --- a/packages/taler-util/src/index.ts +++ b/packages/taler-util/src/index.ts @@ -18,4 +18,4 @@ export * from "./time.js"; export * from "./transactionsTypes.js"; export * from "./walletTypes.js"; export * from "./i18n.js"; -export * from "./logging.js";
\ No newline at end of file +export * from "./logging.js"; diff --git a/packages/taler-util/src/logging.ts b/packages/taler-util/src/logging.ts index 4f48e24da..532174fd6 100644 --- a/packages/taler-util/src/logging.ts +++ b/packages/taler-util/src/logging.ts @@ -19,7 +19,9 @@ */ const isNode = - typeof process !== "undefined" && typeof process.release !== "undefined" && process.release.name === "node"; + typeof process !== "undefined" && + typeof process.release !== "undefined" && + process.release.name === "node"; function writeNodeLog( message: any, diff --git a/packages/taler-util/src/taler-error-codes.ts b/packages/taler-util/src/taler-error-codes.ts index 2d8e31b2e..fec2cf0ff 100644 --- a/packages/taler-util/src/taler-error-codes.ts +++ b/packages/taler-util/src/taler-error-codes.ts @@ -22,8 +22,6 @@ */ export enum TalerErrorCode { - - /** * Special code to indicate success (no error). * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). @@ -2319,5 +2317,4 @@ export enum TalerErrorCode { * (A value of 0 indicates that the error is generated client-side). */ END = 9999, - } diff --git a/packages/taler-util/src/talerTypes.ts b/packages/taler-util/src/talerTypes.ts index db20234cf..4b9ad96ee 100644 --- a/packages/taler-util/src/talerTypes.ts +++ b/packages/taler-util/src/talerTypes.ts @@ -989,9 +989,7 @@ export interface BankWithdrawalOperationPostResponse { transfer_done: boolean; } -export const codecForBankWithdrawalOperationPostResponse = (): Codec< - BankWithdrawalOperationPostResponse -> => +export const codecForBankWithdrawalOperationPostResponse = (): Codec<BankWithdrawalOperationPostResponse> => buildCodecForObject<BankWithdrawalOperationPostResponse>() .property("transfer_done", codecForBoolean()) .build("BankWithdrawalOperationPostResponse"); @@ -1070,9 +1068,8 @@ export const codecForTax = (): Codec<Tax> => .property("tax", codecForString()) .build("Tax"); -export const codecForInternationalizedString = (): Codec< - InternationalizedString -> => codecForMap(codecForString()); +export const codecForInternationalizedString = (): Codec<InternationalizedString> => + codecForMap(codecForString()); export const codecForProduct = (): Codec<Product> => buildCodecForObject<Product>() @@ -1120,9 +1117,7 @@ export const codecForContractTerms = (): Codec<ContractTerms> => .property("extra", codecForAny()) .build("ContractTerms"); -export const codecForMerchantRefundPermission = (): Codec< - MerchantAbortPayRefundDetails -> => +export const codecForMerchantRefundPermission = (): Codec<MerchantAbortPayRefundDetails> => buildCodecForObject<MerchantAbortPayRefundDetails>() .property("refund_amount", codecForAmountString()) .property("refund_fee", codecForAmountString()) @@ -1135,9 +1130,7 @@ export const codecForMerchantRefundPermission = (): Codec< .property("exchange_pub", codecOptional(codecForString())) .build("MerchantRefundPermission"); -export const codecForMerchantRefundResponse = (): Codec< - MerchantRefundResponse -> => +export const codecForMerchantRefundResponse = (): Codec<MerchantRefundResponse> => buildCodecForObject<MerchantRefundResponse>() .property("merchant_pub", codecForString()) .property("h_contract_terms", codecForString()) @@ -1217,9 +1210,7 @@ export const codecForCheckPaymentResponse = (): Codec<CheckPaymentResponse> => .property("contract_url", codecOptional(codecForString())) .build("CheckPaymentResponse"); -export const codecForWithdrawOperationStatusResponse = (): Codec< - WithdrawOperationStatusResponse -> => +export const codecForWithdrawOperationStatusResponse = (): Codec<WithdrawOperationStatusResponse> => buildCodecForObject<WithdrawOperationStatusResponse>() .property("selection_done", codecForBoolean()) .property("transfer_done", codecForBoolean()) @@ -1267,16 +1258,12 @@ export const codecForExchangeRevealItem = (): Codec<ExchangeRevealItem> => .property("ev_sig", codecForString()) .build("ExchangeRevealItem"); -export const codecForExchangeRevealResponse = (): Codec< - ExchangeRevealResponse -> => +export const codecForExchangeRevealResponse = (): Codec<ExchangeRevealResponse> => buildCodecForObject<ExchangeRevealResponse>() .property("ev_sigs", codecForList(codecForExchangeRevealItem())) .build("ExchangeRevealResponse"); -export const codecForMerchantCoinRefundSuccessStatus = (): Codec< - MerchantCoinRefundSuccessStatus -> => +export const codecForMerchantCoinRefundSuccessStatus = (): Codec<MerchantCoinRefundSuccessStatus> => buildCodecForObject<MerchantCoinRefundSuccessStatus>() .property("type", codecForConstString("success")) .property("coin_pub", codecForString()) @@ -1288,9 +1275,7 @@ export const codecForMerchantCoinRefundSuccessStatus = (): Codec< .property("execution_time", codecForTimestamp) .build("MerchantCoinRefundSuccessStatus"); -export const codecForMerchantCoinRefundFailureStatus = (): Codec< - MerchantCoinRefundFailureStatus -> => +export const codecForMerchantCoinRefundFailureStatus = (): Codec<MerchantCoinRefundFailureStatus> => buildCodecForObject<MerchantCoinRefundFailureStatus>() .property("type", codecForConstString("failure")) .property("coin_pub", codecForString()) @@ -1302,35 +1287,27 @@ export const codecForMerchantCoinRefundFailureStatus = (): Codec< .property("execution_time", codecForTimestamp) .build("MerchantCoinRefundFailureStatus"); -export const codecForMerchantCoinRefundStatus = (): Codec< - MerchantCoinRefundStatus -> => +export const codecForMerchantCoinRefundStatus = (): Codec<MerchantCoinRefundStatus> => buildCodecForUnion<MerchantCoinRefundStatus>() .discriminateOn("type") .alternative("success", codecForMerchantCoinRefundSuccessStatus()) .alternative("failure", codecForMerchantCoinRefundFailureStatus()) .build("MerchantCoinRefundStatus"); -export const codecForMerchantOrderStatusPaid = (): Codec< - MerchantOrderStatusPaid -> => +export const codecForMerchantOrderStatusPaid = (): Codec<MerchantOrderStatusPaid> => buildCodecForObject<MerchantOrderStatusPaid>() .property("refund_amount", codecForString()) .property("refunded", codecForBoolean()) .build("MerchantOrderStatusPaid"); -export const codecForMerchantOrderRefundPickupResponse = (): Codec< - MerchantOrderRefundResponse -> => +export const codecForMerchantOrderRefundPickupResponse = (): Codec<MerchantOrderRefundResponse> => buildCodecForObject<MerchantOrderRefundResponse>() .property("merchant_pub", codecForString()) .property("refund_amount", codecForString()) .property("refunds", codecForList(codecForMerchantCoinRefundStatus())) .build("MerchantOrderRefundPickupResponse"); -export const codecForMerchantOrderStatusUnpaid = (): Codec< - MerchantOrderStatusUnpaid -> => +export const codecForMerchantOrderStatusUnpaid = (): Codec<MerchantOrderStatusUnpaid> => buildCodecForObject<MerchantOrderStatusUnpaid>() .property("taler_pay_uri", codecForString()) .property("already_paid_order_id", codecOptional(codecForString())) @@ -1412,9 +1389,7 @@ export interface MerchantAbortPayRefundSuccessStatus { exchange_pub: string; } -export const codecForMerchantAbortPayRefundSuccessStatus = (): Codec< - MerchantAbortPayRefundSuccessStatus -> => +export const codecForMerchantAbortPayRefundSuccessStatus = (): Codec<MerchantAbortPayRefundSuccessStatus> => buildCodecForObject<MerchantAbortPayRefundSuccessStatus>() .property("exchange_pub", codecForString()) .property("exchange_sig", codecForString()) @@ -1422,9 +1397,7 @@ export const codecForMerchantAbortPayRefundSuccessStatus = (): Codec< .property("type", codecForConstString("success")) .build("MerchantAbortPayRefundSuccessStatus"); -export const codecForMerchantAbortPayRefundFailureStatus = (): Codec< - MerchantAbortPayRefundFailureStatus -> => +export const codecForMerchantAbortPayRefundFailureStatus = (): Codec<MerchantAbortPayRefundFailureStatus> => buildCodecForObject<MerchantAbortPayRefundFailureStatus>() .property("exchange_code", codecForNumber()) .property("exchange_reply", codecForAny()) @@ -1432,9 +1405,7 @@ export const codecForMerchantAbortPayRefundFailureStatus = (): Codec< .property("type", codecForConstString("failure")) .build("MerchantAbortPayRefundFailureStatus"); -export const codecForMerchantAbortPayRefundStatus = (): Codec< - MerchantAbortPayRefundStatus -> => +export const codecForMerchantAbortPayRefundStatus = (): Codec<MerchantAbortPayRefundStatus> => buildCodecForUnion<MerchantAbortPayRefundStatus>() .discriminateOn("type") .alternative("success", codecForMerchantAbortPayRefundSuccessStatus()) diff --git a/packages/taler-util/src/talerconfig.ts b/packages/taler-util/src/talerconfig.ts index f3c1220e2..7704e2614 100644 --- a/packages/taler-util/src/talerconfig.ts +++ b/packages/taler-util/src/talerconfig.ts @@ -28,18 +28,18 @@ import { Amounts } from "./amounts.js"; 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 class ConfigError extends Error { constructor(message: string) { |