aboutsummaryrefslogtreecommitdiff
path: root/src/headless
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-03-30 16:09:32 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-03-30 16:09:32 +0530
commitaaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf (patch)
tree9274139660f30c4857d80044eb4ac283aac1775a /src/headless
parent15e18440dbad55df19977a2eb7053681259afc18 (diff)
downloadwallet-core-aaf950e2ad5c07d4423f9822e3a0ae9f7b8d2bdf.tar.xz
re-format with prettier v2, fix HTML
Diffstat (limited to 'src/headless')
-rw-r--r--src/headless/NodeHttpLib.ts14
-rw-r--r--src/headless/clk.ts26
-rw-r--r--src/headless/helpers.ts6
-rw-r--r--src/headless/integrationtest.ts11
-rw-r--r--src/headless/merchant.ts7
5 files changed, 39 insertions, 25 deletions
diff --git a/src/headless/NodeHttpLib.ts b/src/headless/NodeHttpLib.ts
index 5cbb40ccf..735d6b3cf 100644
--- a/src/headless/NodeHttpLib.ts
+++ b/src/headless/NodeHttpLib.ts
@@ -16,7 +16,12 @@
SPDX-License-Identifier: AGPL3.0-or-later
*/
-import { Headers, HttpRequestLibrary, HttpRequestOptions, HttpResponse } from "../util/http";
+import {
+ Headers,
+ HttpRequestLibrary,
+ HttpRequestOptions,
+ HttpResponse,
+} from "../util/http";
import { RequestThrottler } from "../util/RequestThrottler";
import Axios, { AxiosResponse } from "axios";
@@ -85,10 +90,7 @@ export class NodeHttpLib implements HttpRequestLibrary {
};
}
- async get(
- url: string,
- opt?: HttpRequestOptions,
- ): Promise<HttpResponse> {
+ async get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse> {
return this.req("get", url, undefined, opt);
}
@@ -99,4 +101,4 @@ export class NodeHttpLib implements HttpRequestLibrary {
): Promise<HttpResponse> {
return this.req("post", url, body, opt);
}
-} \ No newline at end of file
+}
diff --git a/src/headless/clk.ts b/src/headless/clk.ts
index ab6526f9c..7d7417ea9 100644
--- a/src/headless/clk.ts
+++ b/src/headless/clk.ts
@@ -340,7 +340,9 @@ export class CommandGroup<GN extends keyof any, TG> {
const r = splitOpt(opt);
const d = this.longOptions[r.key];
if (!d) {
- console.error(`error: unknown option '--${r.key}' for ${currentName}`);
+ console.error(
+ `error: unknown option '--${r.key}' for ${currentName}`,
+ );
process.exit(-1);
throw Error("not reached");
}
@@ -359,7 +361,7 @@ export class CommandGroup<GN extends keyof any, TG> {
process.exit(-1);
throw Error("not reached");
}
- myArgs[d.name] = unparsedArgs[i+1];
+ myArgs[d.name] = unparsedArgs[i + 1];
i++;
} else {
myArgs[d.name] = r.value;
@@ -427,14 +429,15 @@ export class CommandGroup<GN extends keyof any, TG> {
throw Error("not reached");
}
-
for (let i = posArgIndex; i < this.arguments.length; i++) {
const d = this.arguments[i];
if (d.required) {
if (d.args.default !== undefined) {
myArgs[d.name] = d.args.default;
} else {
- console.error(`error: missing positional argument '${d.name}' for ${currentName}`);
+ console.error(
+ `error: missing positional argument '${d.name}' for ${currentName}`,
+ );
process.exit(-1);
throw Error("not reached");
}
@@ -447,7 +450,7 @@ export class CommandGroup<GN extends keyof any, TG> {
if (option.args.default !== undefined) {
myArgs[option.name] = option.args.default;
} else {
- const name = option.flagspec.join(",")
+ const name = option.flagspec.join(",");
console.error(`error: missing option '${name}'`);
process.exit(-1);
throw Error("not reached");
@@ -584,10 +587,11 @@ export class Program<PN extends keyof any, T> {
}
}
-export type GetArgType<T> =
- T extends Program<any, infer AT> ? AT :
- T extends CommandGroup<any, infer AT> ? AT :
- any;
+export type GetArgType<T> = T extends Program<any, infer AT>
+ ? AT
+ : T extends CommandGroup<any, infer AT>
+ ? AT
+ : any;
export function program<PN extends keyof any>(
argKey: PN,
@@ -596,15 +600,13 @@ export function program<PN extends keyof any>(
return new Program(argKey as string, args);
}
-
-
export function prompt(question: string): Promise<string> {
const stdinReadline = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
return new Promise<string>((resolve, reject) => {
- stdinReadline.question(question, res => {
+ stdinReadline.question(question, (res) => {
resolve(res);
stdinReadline.close();
});
diff --git a/src/headless/helpers.ts b/src/headless/helpers.ts
index dc56a9876..fb3d800d4 100644
--- a/src/headless/helpers.ts
+++ b/src/headless/helpers.ts
@@ -120,7 +120,9 @@ export async function getDefaultNodeWallet(
require("worker_threads");
workerFactory = new NodeThreadCryptoWorkerFactory();
} catch (e) {
- console.log("worker threads not available, falling back to synchronous workers");
+ console.log(
+ "worker threads not available, falling back to synchronous workers",
+ );
workerFactory = new SynchronousCryptoWorkerFactory();
}
@@ -161,7 +163,7 @@ export async function withdrawTestBalance(
myWallet.runRetryLoop().catch((x) => {
reject(x);
});
- myWallet.addNotificationListener(n => {
+ myWallet.addNotificationListener((n) => {
if (
n.type === NotificationType.ReserveDepleted &&
n.reservePub === reservePub
diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts
index 0c015207e..191e48ff6 100644
--- a/src/headless/integrationtest.ts
+++ b/src/headless/integrationtest.ts
@@ -99,7 +99,7 @@ export async function runIntegrationTest(args: IntegrationTestArgs) {
const myWallet = await getDefaultNodeWallet({ httpLib: myHttpLib });
- myWallet.runRetryLoop().catch(e => {
+ myWallet.runRetryLoop().catch((e) => {
console.error("exception during retry loop:", e);
});
@@ -233,7 +233,7 @@ export async function runIntegrationTestBasic(cfg: Configuration) {
persistentStoragePath: walletDbPath,
});
- myWallet.runRetryLoop().catch(e => {
+ myWallet.runRetryLoop().catch((e) => {
console.error("exception during retry loop:", e);
});
@@ -255,7 +255,12 @@ export async function runIntegrationTestBasic(cfg: Configuration) {
merchantApiKey,
);
- await makePayment(myWallet, myMerchant, Amounts.toString(parsedSpendAmount), "hello world");
+ await makePayment(
+ myWallet,
+ myMerchant,
+ Amounts.toString(parsedSpendAmount),
+ "hello world",
+ );
// Wait until the refresh is done
await myWallet.runUntilDone();
diff --git a/src/headless/merchant.ts b/src/headless/merchant.ts
index b30e00d8a..27e7e3f21 100644
--- a/src/headless/merchant.ts
+++ b/src/headless/merchant.ts
@@ -23,7 +23,10 @@
* Imports.
*/
import axios from "axios";
-import { CheckPaymentResponse, codecForCheckPaymentResponse } from "../types/talerTypes";
+import {
+ CheckPaymentResponse,
+ codecForCheckPaymentResponse,
+} from "../types/talerTypes";
/**
* Connection to the *internal* merchant backend.
@@ -133,7 +136,7 @@ export class MerchantBackendConnection {
if (resp.status != 200) {
throw Error("failed to check payment");
}
-
+
return codecForCheckPaymentResponse().decode(resp.data);
}
}