aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r--packages/taler-wallet-core/src/dev-experiments.ts38
-rw-r--r--packages/taler-wallet-core/src/wallet-api-types.ts17
-rw-r--r--packages/taler-wallet-core/src/wallet.ts7
3 files changed, 61 insertions, 1 deletions
diff --git a/packages/taler-wallet-core/src/dev-experiments.ts b/packages/taler-wallet-core/src/dev-experiments.ts
new file mode 100644
index 000000000..8e2ce5882
--- /dev/null
+++ b/packages/taler-wallet-core/src/dev-experiments.ts
@@ -0,0 +1,38 @@
+/*
+ This file is part of GNU Taler
+ (C) 2022 Taler Systems SA
+
+ TALER is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+ * Implementation of dev experiments, i.e. scenarios
+ * triggered by taler://dev-experiment URIs.
+ *
+ * @author Florian Dold <dold@taler.net>
+ */
+
+/**
+ * Imports.
+ */
+
+import { Logger } from "@gnu-taler/taler-util";
+import { InternalWalletState } from "./internal-wallet-state.js";
+
+const logger = new Logger("dev-experiments.ts");
+
+export async function applyDevExperiment(
+ ws: InternalWalletState,
+ uri: string,
+): Promise<void> {
+ logger.info(`applying dev experiment ${uri}`);
+}
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts
index 15de5faf9..cecdd1281 100644
--- a/packages/taler-wallet-core/src/wallet-api-types.ts
+++ b/packages/taler-wallet-core/src/wallet-api-types.ts
@@ -80,6 +80,7 @@ import {
WithdrawTestBalanceRequest,
WithdrawUriInfoResponse,
} from "@gnu-taler/taler-util";
+import { ApplyDevExperimentRequest } from "@gnu-taler/taler-util";
import {
AddBackupProviderRequest,
BackupInfo,
@@ -139,6 +140,7 @@ export enum WalletApiOperation {
AcceptPeerPullPayment = "acceptPeerPullPayment",
ClearDb = "clearDb",
Recycle = "recycle",
+ ApplyDevExperiment = "applyDevExperiment",
}
// group: Initialization
@@ -487,7 +489,7 @@ export type AcceptPeerPullPaymentOp = {
// group: Database Management
/**
- * Exoport the wallet database's contents to JSON.
+ * Export the wallet database's contents to JSON.
*/
export type ExportDbOp = {
op: WalletApiOperation.ExportDb;
@@ -516,6 +518,18 @@ export type RecycleOp = {
// group: Testing and Debugging
/**
+ * Apply a developer experiment to the current wallet state.
+ *
+ * This allows UI developers / testers to play around without
+ * an elaborate test environment.
+ */
+export type ApplyDevExperimentOp = {
+ op: WalletApiOperation.ApplyDevExperiment;
+ request: ApplyDevExperimentRequest;
+ response: {};
+};
+
+/**
* Run a simple integration test on a test deployment
* of the exchange and merchant.
*/
@@ -661,6 +675,7 @@ export type WalletOperations = {
[WalletApiOperation.AcceptPeerPullPayment]: AcceptPeerPullPaymentOp;
[WalletApiOperation.ClearDb]: ClearDbOp;
[WalletApiOperation.Recycle]: RecycleOp;
+ [WalletApiOperation.ApplyDevExperiment]: ApplyDevExperimentOp;
};
export type RequestType<
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 357dd586a..e25b4bd95 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -90,6 +90,7 @@ import {
parsePaytoUri,
RefreshReason,
TalerErrorCode,
+ codecForApplyDevExperiment,
URL,
WalletCoreVersion,
WalletNotification,
@@ -109,6 +110,7 @@ import {
importDb,
WalletStoresV1,
} from "./db.js";
+import { applyDevExperiment } from "./dev-experiments.js";
import { getErrorDetailFromException, TalerError } from "./errors.js";
import {
ActiveLongpollInfo,
@@ -1325,6 +1327,11 @@ async function dispatchRequestInternal(
const req = codecForAcceptPeerPullPaymentRequest().decode(payload);
return await acceptPeerPullPayment(ws, req);
}
+ case "applyDevExperiment": {
+ const req = codecForApplyDevExperiment().decode(payload);
+ await applyDevExperiment(ws, req.devExperimentUri);
+ return {};
+ }
case "getVersion": {
const version: WalletCoreVersion = {
hash: GIT_HASH,