aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/wallet.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-07-01 00:52:14 +0200
committerFlorian Dold <florian@dold.me>2023-07-01 00:52:14 +0200
commitf93ab03a1b946af441e35b9c057f129d25311273 (patch)
tree063624453ae0b6a38f859bd530ab0a1e29db93fb /packages/taler-wallet-core/src/wallet.ts
parent7a18e12a175856b3d17d2bb70ec549004c281ff5 (diff)
downloadwallet-core-f93ab03a1b946af441e35b9c057f129d25311273.tar.xz
wallet-core: get rid of internal runUntilDone usages
Diffstat (limited to 'packages/taler-wallet-core/src/wallet.ts')
-rw-r--r--packages/taler-wallet-core/src/wallet.ts42
1 files changed, 19 insertions, 23 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index 1b355a32c..8f11a3d28 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -64,7 +64,6 @@ import {
codecForAddKnownBankAccounts,
codecForAny,
codecForApplyDevExperiment,
- codecForFailTransactionRequest,
codecForCheckPeerPullPaymentRequest,
codecForCheckPeerPushDebitRequest,
codecForConfirmPayRequest,
@@ -72,13 +71,13 @@ import {
codecForConvertAmountRequest,
codecForCreateDepositGroupRequest,
codecForDeleteTransactionRequest,
+ codecForFailTransactionRequest,
codecForForceRefreshRequest,
codecForForgetKnownBankAccounts,
codecForGetAmountRequest,
codecForGetBalanceDetailRequest,
codecForGetContractTermsDetails,
codecForGetExchangeTosRequest,
- codecForGetPlanForOperationRequest,
codecForGetWithdrawalDetailsForAmountRequest,
codecForGetWithdrawalDetailsForUri,
codecForImportDbRequest,
@@ -141,6 +140,7 @@ import {
import { DevExperimentHttpLib, applyDevExperiment } from "./dev-experiments.js";
import {
ActiveLongpollInfo,
+ CancelFn,
ExchangeOperations,
InternalWalletState,
MerchantInfo,
@@ -171,6 +171,7 @@ import {
import { setWalletDeviceId } from "./operations/backup/state.js";
import { getBalanceDetail, getBalances } from "./operations/balance.js";
import {
+ TaskIdentifiers,
TaskRunResult,
getExchangeTosStatus,
makeExchangeListItem,
@@ -196,7 +197,6 @@ import {
} from "./operations/exchanges.js";
import { getMerchantInfo } from "./operations/merchants.js";
import {
- computePayMerchantTransactionActions,
computePayMerchantTransactionState,
computeRefundTransactionState,
confirmPay,
@@ -272,6 +272,13 @@ import {
import { PendingTaskInfo, PendingTaskType } from "./pending-types.js";
import { assertUnreachable } from "./util/assertUnreachable.js";
import {
+ convertDepositAmount,
+ convertPeerPushAmount,
+ convertWithdrawalAmount,
+ getMaxDepositAmount,
+ getMaxPeerPushAmount,
+} from "./util/coinSelection.js";
+import {
createTimeline,
selectBestForOverlappingDenominations,
selectMinimumFee,
@@ -287,7 +294,6 @@ import {
GetReadOnlyAccess,
GetReadWriteAccess,
} from "./util/query.js";
-import { TaskIdentifiers } from "./operations/common.js";
import { TimerAPI, TimerGroup } from "./util/timer.js";
import {
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
@@ -301,13 +307,6 @@ import {
WalletCoreApiClient,
WalletCoreResponseType,
} from "./wallet-api-types.js";
-import {
- convertDepositAmount,
- convertPeerPushAmount,
- convertWithdrawalAmount,
- getMaxDepositAmount,
- getMaxPeerPushAmount,
-} from "./util/coinSelection.js";
const logger = new Logger("wallet.ts");
@@ -478,9 +477,8 @@ async function runTaskLoop(
if (!AbsoluteTime.isExpired(p.timestampDue)) {
continue;
}
+ logger.info(`running task ${p.id}`);
await runTaskWithErrorReporting(ws, p.id, async () => {
- logger.trace(`running pending ${JSON.stringify(p, undefined, 2)}`);
- ws.isTaskLoopRunning = false;
return await callOperationHandler(ws, p);
});
ws.notify({
@@ -1679,7 +1677,7 @@ export class Wallet {
return deepMerge(Wallet.defaultConfig, param ?? {});
}
- addNotificationListener(f: (n: WalletNotification) => void): void {
+ addNotificationListener(f: (n: WalletNotification) => void): CancelFn {
return this.ws.addNotificationListener(f);
}
@@ -1906,8 +1904,14 @@ class InternalWalletStateImpl implements InternalWalletState {
}
}
- addNotificationListener(f: (n: WalletNotification) => void): void {
+ addNotificationListener(f: (n: WalletNotification) => void): CancelFn {
this.listeners.push(f);
+ return () => {
+ const idx = this.listeners.indexOf(f);
+ if (idx >= 0) {
+ this.listeners.splice(idx, 1);
+ }
+ };
}
/**
@@ -1925,14 +1929,6 @@ class InternalWalletStateImpl implements InternalWalletState {
}
}
- async runUntilDone(
- req: {
- maxRetries?: number;
- } = {},
- ): Promise<void> {
- await runTaskLoop(this, { ...req, stopWhenDone: true });
- }
-
/**
* Run an async function after acquiring a list of locks, identified
* by string tokens.