-move declaration

This commit is contained in:
Florian Dold 2022-09-16 17:21:54 +02:00
parent d6c545a0ba
commit 16e7814445
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
11 changed files with 61 additions and 72 deletions

View File

@ -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!).
*

View File

@ -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,

View File

@ -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 {

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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,

View File

@ -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;

View File

@ -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);