[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-typescript-core] branch master updated: -formatting, explicit typ
From: |
Admin |
Subject: |
[taler-typescript-core] branch master updated: -formatting, explicit types |
Date: |
Tue, 18 Feb 2025 18:29:38 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository taler-typescript-core.
The following commit(s) were added to refs/heads/master by this push:
new 6126e4259 -formatting, explicit types
6126e4259 is described below
commit 6126e4259c8c916e5498a053d8c4413e72b38c09
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Feb 18 18:29:34 2025 +0100
-formatting, explicit types
---
packages/aml-backoffice-ui/src/hooks/decisions.ts | 21 ++++++++++++++++++---
packages/aml-backoffice-ui/src/hooks/officer.ts | 22 ++++++++++++++--------
2 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/packages/aml-backoffice-ui/src/hooks/decisions.ts
b/packages/aml-backoffice-ui/src/hooks/decisions.ts
index a6c95098d..31b3abd2f 100644
--- a/packages/aml-backoffice-ui/src/hooks/decisions.ts
+++ b/packages/aml-backoffice-ui/src/hooks/decisions.ts
@@ -17,15 +17,18 @@ import { useState } from "preact/hooks";
// FIX default import https://github.com/microsoft/TypeScript/issues/49189
import {
+ AmlDecision,
+ HttpStatusCode,
OfficerAccount,
+ OperationFail,
OperationOk,
opFixedSuccess,
- opSuccessFromHttp,
+ TalerError,
TalerExchangeResultByMethod,
TalerHttpError,
} from "@gnu-taler/taler-util";
import { useExchangeApiContext } from "@gnu-taler/web-util/browser";
-import _useSWR, { SWRHook, mutate } from "swr";
+import _useSWR, { mutate, SWRHook } from "swr";
import { useOfficer } from "./officer.js";
const useSWR = _useSWR as unknown as SWRHook;
@@ -169,11 +172,23 @@ export function useAccountDecisions(accountStr: string) {
}
/**
+ * FIXME: The return type doesn't look quite right.
+ *
* @param account
* @param args
* @returns
*/
-export function useAccountActiveDecision(accountStr?: string) {
+export function useAccountActiveDecision(accountStr?: string):
+ | OperationFail<HttpStatusCode.NotFound>
+ | OperationFail<HttpStatusCode.Forbidden>
+ | OperationFail<HttpStatusCode.Conflict>
+ | TalerError<{
+ requestUrl: string;
+ requestMethod: string;
+ }>
+ | OperationOk<undefined>
+ | OperationOk<AmlDecision>
+ | undefined {
const officer = useOfficer();
const session =
accountStr !== undefined && officer.state === "ready"
diff --git a/packages/aml-backoffice-ui/src/hooks/officer.ts
b/packages/aml-backoffice-ui/src/hooks/officer.ts
index 1bb73b8fc..c5c4b5154 100644
--- a/packages/aml-backoffice-ui/src/hooks/officer.ts
+++ b/packages/aml-backoffice-ui/src/hooks/officer.ts
@@ -30,7 +30,11 @@ import {
opFixedSuccess,
unlockOfficerAccount,
} from "@gnu-taler/taler-util";
-import { buildStorageKey, useExchangeApiContext, useLocalStorage } from
"@gnu-taler/web-util/browser";
+import {
+ buildStorageKey,
+ useExchangeApiContext,
+ useLocalStorage,
+} from "@gnu-taler/web-util/browser";
import { useMemo } from "preact/hooks";
import { usePreferences } from "./preferences.js";
@@ -83,7 +87,9 @@ const DEV_ACCOUNT_KEY = buildStorageKey(
);
export function useOfficer(): OfficerState {
- const {lib:{exchange: api}} = useExchangeApiContext();
+ const {
+ lib: { exchange: api },
+ } = useExchangeApiContext();
const [pref] = usePreferences();
pref.keepSessionAfterReload;
// dev account, is kept on reloaded.
@@ -107,7 +113,7 @@ export function useOfficer(): OfficerState {
return {
state: "not-found",
create: async (pwd: string) => {
- const resp = await api.getSeed()
+ const resp = await api.getSeed();
const extraEntropy = resp.type === "ok" ? resp.body : new Uint8Array();
const { id, safe, signingKey } = await createNewOfficerAccount(
@@ -123,7 +129,7 @@ export function useOfficer(): OfficerState {
const strKey = encodeCrock(signingKey);
accountStorage.update({ id, strKey });
- return opFixedSuccess(id)
+ return opFixedSuccess(id);
},
};
}
@@ -133,7 +139,7 @@ export function useOfficer(): OfficerState {
state: "locked",
forget: () => {
officerStorage.reset();
- return opFixedSuccess(undefined)
+ return opFixedSuccess(undefined);
},
tryUnlock: async (pwd: string) => {
const ac = await unlockOfficerAccount(officer.account, pwd);
@@ -142,7 +148,7 @@ export function useOfficer(): OfficerState {
id: ac.id,
strKey: encodeCrock(ac.signingKey),
});
- return opFixedSuccess(undefined)
+ return opFixedSuccess(undefined);
},
};
}
@@ -152,12 +158,12 @@ export function useOfficer(): OfficerState {
account,
lock: () => {
accountStorage.reset();
- return opFixedSuccess(undefined)
+ return opFixedSuccess(undefined);
},
forget: () => {
officerStorage.reset();
accountStorage.reset();
- return opFixedSuccess(undefined)
+ return opFixedSuccess(undefined);
},
};
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-typescript-core] branch master updated: -formatting, explicit types,
Admin <=