From d4ee96138774e8bc469f172bbb6276af89d6f240 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 30 Jun 2023 16:14:58 +0200 Subject: wallet-core: rename OperationAttempt->TaskRun, do not allow task result values anymore --- packages/taler-wallet-core/src/operations/tip.ts | 25 ++++++++---------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/tip.ts') diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts index 18ef03c51..e56fb1e8d 100644 --- a/packages/taler-wallet-core/src/operations/tip.ts +++ b/packages/taler-wallet-core/src/operations/tip.ts @@ -62,8 +62,8 @@ import { constructTaskIdentifier, makeCoinAvailable, makeCoinsVisible, - OperationAttemptResult, - OperationAttemptResultType, + TaskRunResult, + TaskRunResultType, } from "./common.js"; import { updateExchangeFromUrl } from "./exchanges.js"; import { @@ -241,17 +241,14 @@ export async function prepareTip( export async function processTip( ws: InternalWalletState, walletTipId: string, -): Promise { +): Promise { const tipRecord = await ws.db .mktx((x) => [x.tips]) .runReadOnly(async (tx) => { return tx.tips.get(walletTipId); }); if (!tipRecord) { - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.finished(); } switch (tipRecord.status) { @@ -259,10 +256,7 @@ export async function processTip( case TipRecordStatus.DialogAccept: case TipRecordStatus.Done: case TipRecordStatus.SuspendidPickup: - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.finished(); } const transactionId = constructTransactionIdentifier({ @@ -324,7 +318,7 @@ export async function processTip( logger.trace(`got transient tip error`); // FIXME: wrap in another error code that indicates a transient error return { - type: OperationAttemptResultType.Error, + type: TaskRunResultType.Error, errorDetail: makeErrorDetail( TalerErrorCode.WALLET_UNEXPECTED_REQUEST_ERROR, getHttpResponseErrorDetails(merchantResp), @@ -376,7 +370,7 @@ export async function processTip( if (!isValid) { return { - type: OperationAttemptResultType.Error, + type: TaskRunResultType.Error, errorDetail: makeErrorDetail( TalerErrorCode.WALLET_TIPPING_COIN_SIGNATURE_INVALID, {}, @@ -430,10 +424,7 @@ export async function processTip( notifyTransition(ws, transactionId, transitionInfo); ws.notify({ type: NotificationType.BalanceChange }); - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.finished(); } export async function acceptTip( -- cgit v1.2.3