commit e4fe7896d82540b70a33fffd8c0066a378bebd14
parent d9fc25c64224433caba247f2af4f70d6517eef5b
Author: Florian Dold <florian@dold.me>
Date: Wed, 24 Sep 2025 16:23:55 +0200
wallet-core: implement and test getDonau request
Diffstat:
5 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/packages/taler-harness/src/integrationtests/test-donau.ts b/packages/taler-harness/src/integrationtests/test-donau.ts
@@ -157,11 +157,24 @@ export async function runDonauTest(t: GlobalTestState) {
t.assertTrue(orderStatus.order_status === "unpaid");
+ {
+ // Just test the GetDonau request (initial)
+ const getRes = await walletClient.call(WalletApiOperation.GetDonau, {});
+ t.assertDeepEqual(getRes.currentDonauInfo, undefined);
+ }
+
await walletClient.call(WalletApiOperation.SetDonau, {
donauBaseUrl: donau.baseUrl,
taxPayerId: "test-tax-payer",
});
+ {
+ // Just test the GetDonau request (after setting)
+ const getRes = await walletClient.call(WalletApiOperation.GetDonau, {});
+ t.assertTrue(getRes.currentDonauInfo != null);
+ t.assertDeepEqual(getRes.currentDonauInfo.donauBaseUrl, donau.baseUrl);
+ }
+
const preparePayResult = await walletClient.call(
WalletApiOperation.PreparePayForUri,
{
diff --git a/packages/taler-util/src/types-taler-wallet.ts b/packages/taler-util/src/types-taler-wallet.ts
@@ -4260,3 +4260,12 @@ export interface DonauStatementItem {
export interface GetDonauStatementsResponse {
statements: DonauStatementItem[];
}
+
+export interface GetDonauResponse {
+ currentDonauInfo:
+ | {
+ donauBaseUrl: string;
+ taxPayerId: string;
+ }
+ | undefined;
+}
diff --git a/packages/taler-wallet-core/src/donau.ts b/packages/taler-wallet-core/src/donau.ts
@@ -40,6 +40,7 @@ import {
DonauUnitPubKey,
EmptyObject,
encodeCrock,
+ GetDonauResponse,
GetDonauStatementsResponse,
getRandomBytes,
HashCodeString,
@@ -56,6 +57,7 @@ import {
DonationPlanchetRecord,
DonationReceiptRecord,
DonationReceiptStatus,
+ WalletDbHelpers,
} from "./db.js";
import { WalletExecutionContext } from "./index.js";
@@ -182,6 +184,33 @@ export async function handleSetDonau(
}
/**
+ * Implementation of the setDonau
+ * wallet-core request.
+ */
+export async function handleGetDonau(
+ wex: WalletExecutionContext,
+ req: EmptyObject,
+): Promise<GetDonauResponse> {
+ const currentDonauInfo = await wex.db.runAllStoresReadWriteTx(
+ {},
+ async (tx) => {
+ const res = await WalletDbHelpers.getConfig(
+ tx,
+ ConfigRecordKey.DonauConfig,
+ );
+ if (!res) {
+ return undefined;
+ }
+ return {
+ donauBaseUrl: res.value.donauBaseUrl,
+ taxPayerId: res.value.donauTaxId,
+ };
+ },
+ );
+ return { currentDonauInfo };
+}
+
+/**
* Info about a donation unit key from the donau.
*/
interface CandidateDonationUnit {
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -90,6 +90,7 @@ import {
GetDepositWireTypesForCurrencyResponse,
GetDepositWireTypesRequest,
GetDepositWireTypesResponse,
+ GetDonauResponse,
GetDonauStatementsResponse,
GetExchangeDetailedInfoRequest,
GetExchangeEntryByUrlRequest,
@@ -289,6 +290,7 @@ export enum WalletApiOperation {
// Donau
SetDonau = "setDonau",
+ GetDonau = "getDonau",
GetDonauStatements = "getDonauStatements",
// Stored backups
@@ -393,12 +395,32 @@ export type HintNetworkAvailabilityOp = {
// group: Donau
+/**
+ * Set the donation authority for this wallet.
+ */
export type SetDonauOp = {
op: WalletApiOperation.SetDonau;
request: SetDonauRequest;
response: EmptyObject;
};
+/**
+ * Get the currently configured donation authority for this
+ * wallet.
+ */
+export type GetDonauOp = {
+ op: WalletApiOperation.GetDonau;
+ request: EmptyObject;
+ response: GetDonauResponse;
+};
+
+/**
+ * Get a list of donation statements
+ * for this wallet.
+ * Both donation statements for the currently configured
+ * donation authority as well as past configurations (if they exist)
+ * are returned.
+ */
export type GetDonauStatementsOp = {
op: WalletApiOperation.GetDonauStatements;
request: EmptyObject;
@@ -1557,6 +1579,7 @@ export type WalletOperations = {
[WalletApiOperation.HintApplicationResumed]: HintApplicationResumedOp;
[WalletApiOperation.CompleteExchangeBaseUrl]: CompleteExchangeBaseUrlOp;
[WalletApiOperation.SetDonau]: SetDonauOp;
+ [WalletApiOperation.GetDonau]: GetDonauOp;
[WalletApiOperation.GetDonauStatements]: GetDonauStatementsOp;
};
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
@@ -301,7 +301,7 @@ import {
generateDepositGroupTxId,
} from "./deposits.js";
import { DevExperimentHttpLib, applyDevExperiment } from "./dev-experiments.js";
-import { handleGetDonauStatements, handleSetDonau } from "./donau.js";
+import { handleGetDonau, handleGetDonauStatements, handleSetDonau } from "./donau.js";
import {
ReadyExchangeSummary,
acceptExchangeTermsOfService,
@@ -1871,6 +1871,10 @@ const handlers: { [T in WalletApiOperation]: HandlerWithValidator<T> } = {
codec: codecForEmptyObject(),
handler: handleGetDonauStatements,
},
+ [WalletApiOperation.GetDonau]: {
+ codec: codecForEmptyObject(),
+ handler: handleGetDonau,
+ },
[WalletApiOperation.SetDonau]: {
codec: codecForSetDonauRequest(),
handler: handleSetDonau,