summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-09-16 17:21:54 +0200
committerFlorian Dold <florian@dold.me>2022-09-16 17:21:54 +0200
commit16e7814445d57c2494ddaf3aaf11d60abb2b036b (patch)
tree778f4e473b9f4b8665ea4e9c2ccf59b9836e993f
parentd6c545a0ba68d5fce107779d4b0a2244a137b1aa (diff)
downloadwallet-core-16e7814445d57c2494ddaf3aaf11d60abb2b036b.tar.gz
wallet-core-16e7814445d57c2494ddaf3aaf11d60abb2b036b.tar.bz2
wallet-core-16e7814445d57c2494ddaf3aaf11d60abb2b036b.zip
-move declaration
-rw-r--r--packages/taler-wallet-core/src/db.ts46
-rw-r--r--packages/taler-wallet-core/src/operations/backup/index.ts7
-rw-r--r--packages/taler-wallet-core/src/operations/deposits.ts2
-rw-r--r--packages/taler-wallet-core/src/operations/pay.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/recoup.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/refresh.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/refund.ts3
-rw-r--r--packages/taler-wallet-core/src/operations/tip.ts3
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts3
-rw-r--r--packages/taler-wallet-core/src/util/retries.ts44
-rw-r--r--packages/taler-wallet-core/src/wallet.ts13
11 files changed, 61 insertions, 72 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index 6466edf5a..fdb9b668e 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -45,7 +45,7 @@ import {
Location,
WireInfo,
} from "@gnu-taler/taler-util";
-import { RetryInfo } from "./util/retries.js";
+import { RetryInfo, RetryTags } from "./util/retries.js";
import { Event, IDBDatabase } from "@gnu-taler/idb-bridge";
import { DenomInfo } from "./internal-wallet-state.js";
@@ -1719,6 +1719,8 @@ export interface OperationRetryRecord {
/**
* Unique identifier for the operation. Typically of
* the format `${opType}-${opUniqueKey}`
+ *
+ * @see {@link RetryTags}
*/
id: string;
@@ -1727,48 +1729,6 @@ export interface OperationRetryRecord {
retryInfo: RetryInfo;
}
-export enum OperationAttemptResultType {
- Finished = "finished",
- Pending = "pending",
- Error = "error",
- Longpoll = "longpoll",
-}
-
-// FIXME: not part of DB!
-export type OperationAttemptResult<TSuccess = unknown, TPending = unknown> =
- | OperationAttemptFinishedResult<TSuccess>
- | OperationAttemptErrorResult
- | OperationAttemptLongpollResult
- | OperationAttemptPendingResult<TPending>;
-
-export namespace OperationAttemptResult {
- export function finishedEmpty(): OperationAttemptResult<unknown, unknown> {
- return {
- type: OperationAttemptResultType.Finished,
- result: undefined,
- };
- }
-}
-
-export interface OperationAttemptFinishedResult<T> {
- type: OperationAttemptResultType.Finished;
- result: T;
-}
-
-export interface OperationAttemptPendingResult<T> {
- type: OperationAttemptResultType.Pending;
- result: T;
-}
-
-export interface OperationAttemptErrorResult {
- type: OperationAttemptResultType.Error;
- errorDetail: TalerErrorDetail;
-}
-
-export interface OperationAttemptLongpollResult {
- type: OperationAttemptResultType.Longpoll;
-}
-
/**
* Availability of coins of a given denomination (and age restriction!).
*
diff --git a/packages/taler-wallet-core/src/operations/backup/index.ts b/packages/taler-wallet-core/src/operations/backup/index.ts
index db003af81..d4dfe2916 100644
--- a/packages/taler-wallet-core/src/operations/backup/index.ts
+++ b/packages/taler-wallet-core/src/operations/backup/index.ts
@@ -74,10 +74,7 @@ import {
BackupProviderStateTag,
BackupProviderTerms,
ConfigRecord,
- OperationAttemptResult,
- OperationAttemptResultType,
WalletBackupConfState,
- WalletStoresV1,
WALLET_BACKUP_STATE_KEY,
} from "../../db.js";
import { InternalWalletState } from "../../internal-wallet-state.js";
@@ -89,9 +86,7 @@ import {
checkDbInvariant,
checkLogicInvariant,
} from "../../util/invariants.js";
-import { GetReadWriteAccess } from "../../util/query.js";
-import { RetryInfo, RetryTags, scheduleRetryInTx } from "../../util/retries.js";
-import { guardOperationException } from "../common.js";
+import { OperationAttemptResult, OperationAttemptResultType, RetryTags, scheduleRetryInTx } from "../../util/retries.js";
import {
checkPaymentByProposalId,
confirmPay,
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts
index 22ec5f0a5..c16b2376d 100644
--- a/packages/taler-wallet-core/src/operations/deposits.ts
+++ b/packages/taler-wallet-core/src/operations/deposits.ts
@@ -47,11 +47,11 @@ import {
import {
DenominationRecord,
DepositGroupRecord,
- OperationAttemptResult,
OperationStatus,
} from "../db.js";
import { InternalWalletState } from "../internal-wallet-state.js";
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
+import { OperationAttemptResult } from "../util/retries.js";
import { spendCoins } from "../wallet.js";
import { getExchangeDetails } from "./exchanges.js";
import {
diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts
index 6b366f50d..468f9ca31 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -68,8 +68,6 @@ import {
CoinRecord,
CoinStatus,
DenominationRecord,
- OperationAttemptResult,
- OperationAttemptResultType,
ProposalRecord,
ProposalStatus,
PurchaseRecord,
@@ -99,7 +97,7 @@ import {
throwUnexpectedRequestError,
} from "../util/http.js";
import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
-import { RetryInfo, RetryTags, scheduleRetry } from "../util/retries.js";
+import { OperationAttemptResult, OperationAttemptResultType, RetryInfo, RetryTags, scheduleRetry } from "../util/retries.js";
import { spendCoins } from "../wallet.js";
import { getExchangeDetails } from "./exchanges.js";
import { getTotalRefreshCost } from "./refresh.js";
diff --git a/packages/taler-wallet-core/src/operations/recoup.ts b/packages/taler-wallet-core/src/operations/recoup.ts
index bd598511a..4424b9b40 100644
--- a/packages/taler-wallet-core/src/operations/recoup.ts
+++ b/packages/taler-wallet-core/src/operations/recoup.ts
@@ -42,8 +42,6 @@ import {
CoinRecord,
CoinSourceType,
CoinStatus,
- OperationAttemptResult,
- OperationAttemptResultType,
RecoupGroupRecord,
RefreshCoinSource,
ReserveRecordStatus,
@@ -54,7 +52,7 @@ import {
import { InternalWalletState } from "../internal-wallet-state.js";
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
import { GetReadWriteAccess } from "../util/query.js";
-import { RetryInfo, runOperationHandlerForResult } from "../util/retries.js";
+import { OperationAttemptResult, RetryInfo, runOperationHandlerForResult } from "../util/retries.js";
import { guardOperationException } from "./common.js";
import { createRefreshGroup, processRefreshGroup } from "./refresh.js";
import { internalCreateWithdrawalGroup } from "./withdraw.js";
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts
index e968ec020..048ab15b3 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -57,8 +57,6 @@ import {
CoinSourceType,
CoinStatus,
DenominationRecord,
- OperationAttemptResult,
- OperationAttemptResultType,
OperationStatus,
RefreshCoinStatus,
RefreshGroupRecord,
@@ -76,7 +74,7 @@ import {
} from "../util/http.js";
import { checkDbInvariant } from "../util/invariants.js";
import { GetReadWriteAccess } from "../util/query.js";
-import { RetryInfo, runOperationHandlerForResult } from "../util/retries.js";
+import { OperationAttemptResult, OperationAttemptResultType, RetryInfo, runOperationHandlerForResult } from "../util/retries.js";
import { makeCoinAvailable, Wallet } from "../wallet.js";
import { guardOperationException } from "./common.js";
import { updateExchangeFromUrl } from "./exchanges.js";
diff --git a/packages/taler-wallet-core/src/operations/refund.ts b/packages/taler-wallet-core/src/operations/refund.ts
index bdcdac943..0d86b92ab 100644
--- a/packages/taler-wallet-core/src/operations/refund.ts
+++ b/packages/taler-wallet-core/src/operations/refund.ts
@@ -44,7 +44,6 @@ import {
PrepareRefundResult,
RefreshReason,
TalerErrorCode,
- TalerErrorDetail,
TalerProtocolTimestamp,
TransactionType,
URL,
@@ -53,7 +52,6 @@ import {
AbortStatus,
CoinStatus,
DenominationRecord,
- OperationAttemptResult,
PurchaseRecord,
RefundReason,
RefundState,
@@ -63,6 +61,7 @@ import { InternalWalletState } from "../internal-wallet-state.js";
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
import { checkDbInvariant } from "../util/invariants.js";
import { GetReadWriteAccess } from "../util/query.js";
+import { OperationAttemptResult } from "../util/retries.js";
import { createRefreshGroup, getTotalRefreshCost } from "./refresh.js";
import { makeEventId } from "./transactions.js";
diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts
index 9f96b7a7d..f79851be8 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -43,8 +43,6 @@ import {
CoinSourceType,
CoinStatus,
DenominationRecord,
- OperationAttemptResult,
- OperationAttemptResultType,
TipRecord,
} from "../db.js";
import { makeErrorDetail } from "../errors.js";
@@ -54,6 +52,7 @@ import {
readSuccessResponseJsonOrThrow,
} from "../util/http.js";
import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
+import { OperationAttemptResult, OperationAttemptResultType } from "../util/retries.js";
import { makeCoinAvailable } from "../wallet.js";
import { updateExchangeFromUrl } from "./exchanges.js";
import { makeEventId } from "./transactions.js";
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index cb0b55faf..6b31842b3 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -69,8 +69,6 @@ import {
DenomSelectionState,
ExchangeDetailsRecord,
ExchangeRecord,
- OperationAttemptResult,
- OperationAttemptResultType,
OperationStatus,
PlanchetRecord,
ReserveRecordStatus,
@@ -95,6 +93,7 @@ import {
} from "../util/http.js";
import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
import { DbAccess, GetReadOnlyAccess } from "../util/query.js";
+import { OperationAttemptResult, OperationAttemptResultType } from "../util/retries.js";
import {
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
WALLET_EXCHANGE_PROTOCOL_VERSION,
diff --git a/packages/taler-wallet-core/src/util/retries.ts b/packages/taler-wallet-core/src/util/retries.ts
index 4763bbc42..70b385c4a 100644
--- a/packages/taler-wallet-core/src/util/retries.ts
+++ b/packages/taler-wallet-core/src/util/retries.ts
@@ -30,8 +30,6 @@ import {
BackupProviderRecord,
DepositGroupRecord,
ExchangeRecord,
- OperationAttemptResult,
- OperationAttemptResultType,
ProposalRecord,
PurchaseRecord,
RecoupGroupRecord,
@@ -45,6 +43,48 @@ import { InternalWalletState } from "../internal-wallet-state.js";
import { PendingTaskType } from "../pending-types.js";
import { GetReadWriteAccess } from "./query.js";
+export enum OperationAttemptResultType {
+ Finished = "finished",
+ Pending = "pending",
+ Error = "error",
+ Longpoll = "longpoll",
+}
+
+// FIXME: not part of DB!
+export type OperationAttemptResult<TSuccess = unknown, TPending = unknown> =
+ | OperationAttemptFinishedResult<TSuccess>
+ | OperationAttemptErrorResult
+ | OperationAttemptLongpollResult
+ | OperationAttemptPendingResult<TPending>;
+
+export namespace OperationAttemptResult {
+ export function finishedEmpty(): OperationAttemptResult<unknown, unknown> {
+ return {
+ type: OperationAttemptResultType.Finished,
+ result: undefined,
+ };
+ }
+}
+
+export interface OperationAttemptFinishedResult<T> {
+ type: OperationAttemptResultType.Finished;
+ result: T;
+}
+
+export interface OperationAttemptPendingResult<T> {
+ type: OperationAttemptResultType.Pending;
+ result: T;
+}
+
+export interface OperationAttemptErrorResult {
+ type: OperationAttemptResultType.Error;
+ errorDetail: TalerErrorDetail;
+}
+
+export interface OperationAttemptLongpollResult {
+ type: OperationAttemptResultType.Longpoll;
+}
+
export interface RetryInfo {
firstTry: AbsoluteTime;
nextRetry: AbsoluteTime;
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 812106c7a..f89d0330c 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -106,8 +106,6 @@ import {
DenominationRecord,
exportDb,
importDb,
- OperationAttemptResult,
- OperationAttemptResultType,
WalletStoresV1,
} from "./db.js";
import {
@@ -228,7 +226,12 @@ import {
openPromise,
} from "./util/promiseUtils.js";
import { DbAccess, GetReadWriteAccess } from "./util/query.js";
-import { RetryInfo, runOperationHandlerForResult } from "./util/retries.js";
+import {
+ OperationAttemptResult,
+ OperationAttemptResultType,
+ RetryInfo,
+ runOperationHandlerForResult,
+} from "./util/retries.js";
import { TimerAPI, TimerGroup } from "./util/timer.js";
import {
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
@@ -284,7 +287,7 @@ async function callOperationHandler(
ws: InternalWalletState,
pending: PendingTaskInfo,
forceNow = false,
-): Promise<OperationAttemptResult<unknown, unknown>> {
+): Promise<OperationAttemptResult> {
switch (pending.type) {
case PendingTaskType.ExchangeUpdate:
return await updateExchangeFromUrlHandler(ws, pending.exchangeBaseUrl, {
@@ -1099,7 +1102,7 @@ async function dispatchRequestInternal(
}
case "getTransactionById": {
const req = codecForTransactionByIdRequest().decode(payload);
- return await getTransactionById(ws, req)
+ return await getTransactionById(ws, req);
}
case "addExchange": {
const req = codecForAddExchangeRequest().decode(payload);