summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/withdraw.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-06-30 16:14:58 +0200
committerFlorian Dold <florian@dold.me>2023-06-30 16:14:58 +0200
commitd4ee96138774e8bc469f172bbb6276af89d6f240 (patch)
treeeda5bc6833306727f711cc5aedd5f307fa8b1f67 /packages/taler-wallet-core/src/operations/withdraw.ts
parent7523ffa9105f71a6a4c201d3ee46dbfccc929cea (diff)
downloadwallet-core-d4ee96138774e8bc469f172bbb6276af89d6f240.tar.gz
wallet-core-d4ee96138774e8bc469f172bbb6276af89d6f240.tar.bz2
wallet-core-d4ee96138774e8bc469f172bbb6276af89d6f240.zip
wallet-core: rename OperationAttempt->TaskRun, do not allow task result values anymore
Diffstat (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts51
1 files changed, 18 insertions, 33 deletions
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index 1362ca278..f972d3cb1 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -90,8 +90,8 @@ import {
} from "@gnu-taler/taler-util";
import { InternalWalletState } from "../internal-wallet-state.js";
import {
- OperationAttemptResult,
- OperationAttemptResultType,
+ TaskRunResult,
+ TaskRunResultType,
TaskIdentifiers,
constructTaskIdentifier,
makeCoinAvailable,
@@ -1326,7 +1326,7 @@ export interface WithdrawalGroupContext {
async function processWithdrawalGroupAbortingBank(
ws: InternalWalletState,
withdrawalGroup: WithdrawalGroupRecord,
-): Promise<OperationAttemptResult> {
+): Promise<TaskRunResult> {
const { withdrawalGroupId } = withdrawalGroup;
const transactionId = constructTransactionIdentifier({
tag: TransactionType.Withdrawal,
@@ -1363,10 +1363,7 @@ async function processWithdrawalGroupAbortingBank(
};
});
notifyTransition(ws, transactionId, transitionInfo);
- return {
- type: OperationAttemptResultType.Finished,
- result: undefined,
- };
+ return TaskRunResult.finished();
}
/**
@@ -1413,7 +1410,7 @@ async function transitionKycSatisfied(
async function processWithdrawalGroupPendingKyc(
ws: InternalWalletState,
withdrawalGroup: WithdrawalGroupRecord,
-): Promise<OperationAttemptResult> {
+): Promise<TaskRunResult> {
const userType = "individual";
const kycInfo = withdrawalGroup.kycPending;
if (!kycInfo) {
@@ -1456,13 +1453,13 @@ async function processWithdrawalGroupPendingKyc(
);
}
});
- return OperationAttemptResult.longpoll();
+ return TaskRunResult.longpoll();
}
async function processWithdrawalGroupPendingReady(
ws: InternalWalletState,
withdrawalGroup: WithdrawalGroupRecord,
-): Promise<OperationAttemptResult> {
+): Promise<TaskRunResult> {
const { withdrawalGroupId } = withdrawalGroup;
const transactionId = constructTransactionIdentifier({
tag: TransactionType.Withdrawal,
@@ -1494,7 +1491,7 @@ async function processWithdrawalGroupPendingReady(
};
});
notifyTransition(ws, transactionId, transitionInfo);
- return OperationAttemptResult.finishedEmpty();
+ return TaskRunResult.finished();
}
const numTotalCoins = withdrawalGroup.denomsSel.selectedDenoms
@@ -1608,7 +1605,7 @@ async function processWithdrawalGroupPendingReady(
if (numPlanchetErrors > 0) {
return {
- type: OperationAttemptResultType.Error,
+ type: TaskRunResultType.Error,
errorDetail: makeErrorDetail(
TalerErrorCode.WALLET_WITHDRAWAL_GROUP_INCOMPLETE,
{
@@ -1619,16 +1616,13 @@ async function processWithdrawalGroupPendingReady(
};
}
- return {
- type: OperationAttemptResultType.Finished,
- result: undefined,
- };
+ return TaskRunResult.finished();
}
export async function processWithdrawalGroup(
ws: InternalWalletState,
withdrawalGroupId: string,
-): Promise<OperationAttemptResult> {
+): Promise<TaskRunResult> {
logger.trace("processing withdrawal group", withdrawalGroupId);
const withdrawalGroup = await ws.db
.mktx((x) => [x.withdrawalGroups])
@@ -1646,7 +1640,7 @@ export async function processWithdrawalGroup(
if (ws.activeLongpoll[retryTag]) {
logger.info("withdrawal group already in long-polling, returning!");
return {
- type: OperationAttemptResultType.Longpoll,
+ type: TaskRunResultType.Longpoll,
};
}
@@ -1663,7 +1657,7 @@ export async function processWithdrawalGroup(
"returning early from withdrawal for long-polling in background",
);
return {
- type: OperationAttemptResultType.Longpoll,
+ type: TaskRunResultType.Longpoll,
};
}
case WithdrawalGroupStatus.PendingWaitConfirmBank: {
@@ -1671,15 +1665,9 @@ export async function processWithdrawalGroup(
switch (res.status) {
case BankStatusResultCode.Aborted:
case BankStatusResultCode.Done:
- return {
- type: OperationAttemptResultType.Finished,
- result: undefined,
- };
+ return TaskRunResult.finished();
case BankStatusResultCode.Waiting: {
- return {
- type: OperationAttemptResultType.Pending,
- result: undefined,
- };
+ return TaskRunResult.pending();
}
}
break;
@@ -1687,14 +1675,11 @@ export async function processWithdrawalGroup(
case WithdrawalGroupStatus.Finished:
case WithdrawalGroupStatus.FailedBankAborted: {
// FIXME
- return {
- type: OperationAttemptResultType.Pending,
- result: undefined,
- };
+ return TaskRunResult.pending();
}
case WithdrawalGroupStatus.PendingAml:
// FIXME: Handle this case, withdrawal doesn't support AML yet.
- return OperationAttemptResult.pendingEmpty();
+ return TaskRunResult.pending();
case WithdrawalGroupStatus.PendingKyc:
return processWithdrawalGroupPendingKyc(ws, withdrawalGroup);
case WithdrawalGroupStatus.PendingReady:
@@ -1713,7 +1698,7 @@ export async function processWithdrawalGroup(
case WithdrawalGroupStatus.SuspendedRegisteringBank:
case WithdrawalGroupStatus.SuspendedWaitConfirmBank:
// Nothing to do.
- return OperationAttemptResult.finishedEmpty();
+ return TaskRunResult.finished();
default:
assertUnreachable(withdrawalGroup.status);
}