summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/common.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/common.ts')
-rw-r--r--packages/taler-wallet-core/src/common.ts29
1 files changed, 23 insertions, 6 deletions
diff --git a/packages/taler-wallet-core/src/common.ts b/packages/taler-wallet-core/src/common.ts
index 5acdeeba4..eb06b8eb0 100644
--- a/packages/taler-wallet-core/src/common.ts
+++ b/packages/taler-wallet-core/src/common.ts
@@ -61,11 +61,7 @@ import {
timestampPreciseToDb,
} from "./db.js";
import { createRefreshGroup } from "./refresh.js";
-import {
- InternalWalletState,
- WalletExecutionContext,
- getDenomInfo,
-} from "./wallet.js";
+import { WalletExecutionContext, getDenomInfo } from "./wallet.js";
const logger = new Logger("operations/common.ts");
@@ -696,11 +692,32 @@ export namespace TaskIdentifiers {
/**
* Result of a transaction transition.
*/
-export enum TransitionResult {
+export enum TransitionResultType {
Transition = 1,
Stay = 2,
+ Delete = 3,
}
+export type TransitionResult<R> =
+ | { type: TransitionResultType.Stay }
+ | { type: TransitionResultType.Transition; rec: R }
+ | { type: TransitionResultType.Delete };
+
+export const TransitionResult = {
+ stay<T>(): TransitionResult<T> {
+ return { type: TransitionResultType.Stay };
+ },
+ delete<T>(): TransitionResult<T> {
+ return { type: TransitionResultType.Delete };
+ },
+ transition<T>(rec: T): TransitionResult<T> {
+ return {
+ type: TransitionResultType.Transition,
+ rec,
+ };
+ },
+};
+
/**
* Transaction context.
* Uniform interface to all transactions.