From eb1500e517d475aad22cfe02c8a5c5c6acefe00a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 19 Feb 2024 18:42:33 +0100 Subject: get rid of deprecated/unused types --- packages/taler-wallet-core/src/common.ts | 28 ++- packages/taler-wallet-core/src/deposits.ts | 26 +-- packages/taler-wallet-core/src/exchanges.ts | 26 +-- packages/taler-wallet-core/src/index.ts | 2 - packages/taler-wallet-core/src/pay-merchant.ts | 4 +- .../taler-wallet-core/src/pay-peer-pull-credit.ts | 26 +-- .../taler-wallet-core/src/pay-peer-pull-debit.ts | 4 +- .../taler-wallet-core/src/pay-peer-push-credit.ts | 24 +- .../taler-wallet-core/src/pay-peer-push-debit.ts | 23 +- packages/taler-wallet-core/src/pending-types.ts | 242 --------------------- packages/taler-wallet-core/src/recoup.ts | 2 +- packages/taler-wallet-core/src/refresh.ts | 30 +-- packages/taler-wallet-core/src/reward.ts | 20 +- packages/taler-wallet-core/src/shepherd.ts | 3 +- packages/taler-wallet-core/src/transactions.ts | 35 +-- packages/taler-wallet-core/src/wallet-api-types.ts | 5 +- packages/taler-wallet-core/src/wallet.ts | 13 +- packages/taler-wallet-core/src/withdraw.ts | 47 ++-- .../src/wallet/DeveloperPage.stories.tsx | 7 +- .../src/wallet/DeveloperPage.tsx | 187 ++++++++-------- 20 files changed, 268 insertions(+), 486 deletions(-) delete mode 100644 packages/taler-wallet-core/src/pending-types.ts (limited to 'packages') diff --git a/packages/taler-wallet-core/src/common.ts b/packages/taler-wallet-core/src/common.ts index ae1e17ffb..9d7f2e763 100644 --- a/packages/taler-wallet-core/src/common.ts +++ b/packages/taler-wallet-core/src/common.ts @@ -58,10 +58,9 @@ import { timestampPreciseToDb, } from "./db.js"; import { InternalWalletState } from "./internal-wallet-state.js"; -import { PendingTaskType, TaskId } from "./pending-types.js"; +import { createRefreshGroup } from "./refresh.js"; import { assertUnreachable } from "./util/assertUnreachable.js"; import { checkDbInvariant, checkLogicInvariant } from "./util/invariants.js"; -import { createRefreshGroup } from "./refresh.js"; const logger = new Logger("operations/common.ts"); @@ -691,3 +690,28 @@ export interface TransactionContext { failTransaction(): Promise; deleteTransaction(): Promise; } + +/** + * Type and schema definitions for pending tasks in the wallet. + * + * These are only used internally, and are not part of the stable public + * interface to the wallet. + */ + +export enum PendingTaskType { + ExchangeUpdate = "exchange-update", + Purchase = "purchase", + Refresh = "refresh", + Recoup = "recoup", + RewardPickup = "reward-pickup", + Withdraw = "withdraw", + Deposit = "deposit", + Backup = "backup", + PeerPushDebit = "peer-push-debit", + PeerPullCredit = "peer-pull-credit", + PeerPushCredit = "peer-push-credit", + PeerPullDebit = "peer-pull-debit", +} + +declare const __taskId: unique symbol; +export type TaskId = string & { [__taskId]: true }; diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts index 94e7f01ac..b6cfa7aae 100644 --- a/packages/taler-wallet-core/src/deposits.ts +++ b/packages/taler-wallet-core/src/deposits.ts @@ -69,14 +69,22 @@ import { stringToBytes, } from "@gnu-taler/taler-util"; import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http"; +import { + PendingTaskType, + TaskId, + TaskRunResult, + TombstoneTag, + TransactionContext, + constructTaskIdentifier, + spendCoins, +} from "./common.js"; import { DepositElementStatus, DepositGroupRecord } from "./db.js"; +import { getExchangeWireDetailsInTx } from "./exchanges.js"; import { DepositOperationStatus, DepositTrackingInfo, KycPendingInfo, - PendingTaskType, RefreshOperationStatus, - TaskId, createRefreshGroup, getCandidateWithdrawalDenomsTx, getTotalRefreshCost, @@ -84,17 +92,6 @@ import { timestampProtocolToDb, } from "./index.js"; import { InternalWalletState } from "./internal-wallet-state.js"; -import { assertUnreachable } from "./util/assertUnreachable.js"; -import { selectPayCoinsNew } from "./util/coinSelection.js"; -import { checkDbInvariant, checkLogicInvariant } from "./util/invariants.js"; -import { - TaskRunResult, - TombstoneTag, - TransactionContext, - constructTaskIdentifier, - spendCoins, -} from "./common.js"; -import { getExchangeWireDetailsInTx } from "./exchanges.js"; import { extractContractData, generateDepositPermissions, @@ -105,6 +102,9 @@ import { notifyTransition, parseTransactionIdentifier, } from "./transactions.js"; +import { assertUnreachable } from "./util/assertUnreachable.js"; +import { selectPayCoinsNew } from "./util/coinSelection.js"; +import { checkDbInvariant, checkLogicInvariant } from "./util/invariants.js"; /** * Logger. diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts index 4e1651ae0..0f080b871 100644 --- a/packages/taler-wallet-core/src/exchanges.ts +++ b/packages/taler-wallet-core/src/exchanges.ts @@ -88,6 +88,18 @@ import { readSuccessResponseJsonOrThrow, readSuccessResponseTextOrThrow, } from "@gnu-taler/taler-util/http"; +import { + PendingTaskType, + TaskIdentifiers, + TaskRunResult, + TaskRunResultType, + constructTaskIdentifier, + getAutoRefreshExecuteThreshold, + getExchangeEntryStatusFromRecord, + getExchangeState, + getExchangeTosStatusFromRecord, + getExchangeUpdateStatusFromRecord, +} from "./common.js"; import { DenominationRecord, DenominationVerificationStatus, @@ -98,7 +110,6 @@ import { import { ExchangeEntryDbRecordStatus, ExchangeEntryDbUpdateStatus, - PendingTaskType, WalletDbReadOnlyTransaction, WalletDbReadWriteTransaction, createRefreshGroup, @@ -114,20 +125,9 @@ import { timestampProtocolToDb, } from "./index.js"; import { InternalWalletState } from "./internal-wallet-state.js"; -import { checkDbInvariant } from "./util/invariants.js"; import { DbReadOnlyTransaction } from "./query.js"; +import { checkDbInvariant } from "./util/invariants.js"; import { WALLET_EXCHANGE_PROTOCOL_VERSION } from "./versions.js"; -import { - TaskIdentifiers, - TaskRunResult, - TaskRunResultType, - constructTaskIdentifier, - getAutoRefreshExecuteThreshold, - getExchangeEntryStatusFromRecord, - getExchangeState, - getExchangeTosStatusFromRecord, - getExchangeUpdateStatusFromRecord, -} from "./common.js"; const logger = new Logger("exchanges.ts"); diff --git a/packages/taler-wallet-core/src/index.ts b/packages/taler-wallet-core/src/index.ts index 280fc9147..2b619be69 100644 --- a/packages/taler-wallet-core/src/index.ts +++ b/packages/taler-wallet-core/src/index.ts @@ -33,8 +33,6 @@ export { } from "./crypto/workers/crypto-dispatcher.js"; export type { CryptoWorker } from "./crypto/workers/cryptoWorkerInterface.js"; -export * from "./pending-types.js"; - export { InternalWalletState } from "./internal-wallet-state.js"; export * from "./wallet-api-types.js"; export * from "./wallet.js"; diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts index 0bd851464..325bc24a8 100644 --- a/packages/taler-wallet-core/src/pay-merchant.ts +++ b/packages/taler-wallet-core/src/pay-merchant.ts @@ -98,7 +98,9 @@ import { import { constructTaskIdentifier, DbRetryInfo, + PendingTaskType, spendCoins, + TaskId, TaskIdentifiers, TaskRunResult, TaskRunResultType, @@ -117,12 +119,10 @@ import { } from "./db.js"; import { getCandidateWithdrawalDenomsTx, - PendingTaskType, RefundGroupRecord, RefundGroupStatus, RefundItemRecord, RefundItemStatus, - TaskId, timestampPreciseToDb, timestampProtocolFromDb, timestampProtocolToDb, diff --git a/packages/taler-wallet-core/src/pay-peer-pull-credit.ts b/packages/taler-wallet-core/src/pay-peer-pull-credit.ts index 124496d02..03bc5a4b9 100644 --- a/packages/taler-wallet-core/src/pay-peer-pull-credit.ts +++ b/packages/taler-wallet-core/src/pay-peer-pull-credit.ts @@ -50,6 +50,15 @@ import { talerPaytoFromExchangeReserve, } from "@gnu-taler/taler-util"; import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http"; +import { + PendingTaskType, + TaskId, + TaskRunResult, + TaskRunResultType, + TombstoneTag, + TransactionContext, + constructTaskIdentifier, +} from "./common.js"; import { KycPendingInfo, KycUserType, @@ -63,16 +72,6 @@ import { timestampPreciseToDb, } from "./index.js"; import { InternalWalletState } from "./internal-wallet-state.js"; -import { PendingTaskType, TaskId } from "./pending-types.js"; -import { assertUnreachable } from "./util/assertUnreachable.js"; -import { checkDbInvariant } from "./util/invariants.js"; -import { - TaskRunResult, - TaskRunResultType, - TombstoneTag, - TransactionContext, - constructTaskIdentifier, -} from "./common.js"; import { codecForExchangePurseStatus, getMergeReserveInfo, @@ -81,6 +80,8 @@ import { constructTransactionIdentifier, notifyTransition, } from "./transactions.js"; +import { assertUnreachable } from "./util/assertUnreachable.js"; +import { checkDbInvariant } from "./util/invariants.js"; import { getExchangeWithdrawalInfo, internalCreateWithdrawalGroup, @@ -480,11 +481,6 @@ async function longpollKycStatus( tag: TransactionType.PeerPullCredit, pursePub, }); - const retryTag = constructTaskIdentifier({ - tag: PendingTaskType.PeerPullCredit, - pursePub, - }); - const url = new URL( `kyc-check/${kycInfo.requirementRow}/${kycInfo.paytoHash}/${userType}`, exchangeUrl, diff --git a/packages/taler-wallet-core/src/pay-peer-pull-debit.ts b/packages/taler-wallet-core/src/pay-peer-pull-debit.ts index 62472c7f8..1d6cb3d18 100644 --- a/packages/taler-wallet-core/src/pay-peer-pull-debit.ts +++ b/packages/taler-wallet-core/src/pay-peer-pull-debit.ts @@ -64,6 +64,8 @@ import { readTalerErrorResponse, } from "@gnu-taler/taler-util/http"; import { + PendingTaskType, + TaskId, TaskRunResult, TaskRunResultType, TransactionContext, @@ -76,10 +78,8 @@ import { InternalWalletState, PeerPullDebitRecordStatus, PeerPullPaymentIncomingRecord, - PendingTaskType, RefreshOperationStatus, StoreNames, - TaskId, WalletStoresV1, createRefreshGroup, timestampPreciseToDb, diff --git a/packages/taler-wallet-core/src/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/pay-peer-push-credit.ts index 937ff7ff4..0795b0c5c 100644 --- a/packages/taler-wallet-core/src/pay-peer-push-credit.ts +++ b/packages/taler-wallet-core/src/pay-peer-push-credit.ts @@ -52,20 +52,8 @@ import { } from "@gnu-taler/taler-util"; import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http"; import { - InternalWalletState, - KycPendingInfo, - KycUserType, - PeerPushCreditStatus, - PeerPushPaymentIncomingRecord, PendingTaskType, TaskId, - WithdrawalGroupStatus, - WithdrawalRecordType, - timestampPreciseToDb, -} from "./index.js"; -import { assertUnreachable } from "./util/assertUnreachable.js"; -import { checkDbInvariant } from "./util/invariants.js"; -import { TaskRunResult, TaskRunResultType, TombstoneTag, @@ -73,6 +61,16 @@ import { constructTaskIdentifier, } from "./common.js"; import { fetchFreshExchange } from "./exchanges.js"; +import { + InternalWalletState, + KycPendingInfo, + KycUserType, + PeerPushCreditStatus, + PeerPushPaymentIncomingRecord, + WithdrawalGroupStatus, + WithdrawalRecordType, + timestampPreciseToDb, +} from "./index.js"; import { codecForExchangePurseStatus, getMergeReserveInfo, @@ -83,6 +81,8 @@ import { notifyTransition, parseTransactionIdentifier, } from "./transactions.js"; +import { assertUnreachable } from "./util/assertUnreachable.js"; +import { checkDbInvariant } from "./util/invariants.js"; import { PerformCreateWithdrawalGroupResult, getExchangeWithdrawalInfo, diff --git a/packages/taler-wallet-core/src/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/pay-peer-push-debit.ts index 608434c9a..ec1a37a31 100644 --- a/packages/taler-wallet-core/src/pay-peer-push-debit.ts +++ b/packages/taler-wallet-core/src/pay-peer-push-debit.ts @@ -47,6 +47,15 @@ import { readSuccessResponseJsonOrThrow, readTalerErrorResponse, } from "@gnu-taler/taler-util/http"; +import { + PendingTaskType, + TaskId, + TaskRunResult, + TaskRunResultType, + TransactionContext, + constructTaskIdentifier, + spendCoins, +} from "./common.js"; import { EncryptContractRequest } from "./crypto/cryptoTypes.js"; import { PeerPushDebitRecord, @@ -58,17 +67,6 @@ import { timestampProtocolToDb, } from "./index.js"; import { InternalWalletState } from "./internal-wallet-state.js"; -import { PendingTaskType, TaskId } from "./pending-types.js"; -import { assertUnreachable } from "./util/assertUnreachable.js"; -import { PeerCoinRepair, selectPeerCoins } from "./util/coinSelection.js"; -import { checkLogicInvariant } from "./util/invariants.js"; -import { - TaskRunResult, - TaskRunResultType, - TransactionContext, - constructTaskIdentifier, - spendCoins, -} from "./common.js"; import { codecForExchangePurseStatus, getTotalPeerPaymentCost, @@ -78,6 +76,9 @@ import { constructTransactionIdentifier, notifyTransition, } from "./transactions.js"; +import { assertUnreachable } from "./util/assertUnreachable.js"; +import { PeerCoinRepair, selectPeerCoins } from "./util/coinSelection.js"; +import { checkLogicInvariant } from "./util/invariants.js"; const logger = new Logger("pay-peer-push-debit.ts"); diff --git a/packages/taler-wallet-core/src/pending-types.ts b/packages/taler-wallet-core/src/pending-types.ts deleted file mode 100644 index 1b3fa35d8..000000000 --- a/packages/taler-wallet-core/src/pending-types.ts +++ /dev/null @@ -1,242 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2019 GNUnet e.V. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see - */ - -/** - * Type and schema definitions for pending tasks in the wallet. - * - * These are only used internally, and are not part of the stable public - * interface to the wallet. - */ - -/** - * Imports. - */ -import { TalerErrorDetail, AbsoluteTime } from "@gnu-taler/taler-util"; -import { DbRetryInfo } from "./common.js"; - -export enum PendingTaskType { - ExchangeUpdate = "exchange-update", - Purchase = "purchase", - Refresh = "refresh", - Recoup = "recoup", - RewardPickup = "reward-pickup", - Withdraw = "withdraw", - Deposit = "deposit", - Backup = "backup", - PeerPushDebit = "peer-push-debit", - PeerPullCredit = "peer-pull-credit", - PeerPushCredit = "peer-push-credit", - PeerPullDebit = "peer-pull-debit", -} - -/** - * Information about a pending operation. - */ -export type PendingTaskInfo = PendingTaskInfoCommon & - ( - | PendingExchangeUpdateTask - | PendingPurchaseTask - | PendingRefreshTask - | PendingTipPickupTask - | PendingWithdrawTask - | PendingRecoupTask - | PendingDepositTask - | PendingBackupTask - | PendingPeerPushInitiationTask - | PendingPeerPullInitiationTask - | PendingPeerPullDebitTask - | PendingPeerPushCreditTask - ); - -export interface PendingBackupTask { - type: PendingTaskType.Backup; - backupProviderBaseUrl: string; - lastError: TalerErrorDetail | undefined; -} - -/** - * The wallet is currently updating information about an exchange. - */ -export interface PendingExchangeUpdateTask { - type: PendingTaskType.ExchangeUpdate; - exchangeBaseUrl: string; - lastError: TalerErrorDetail | undefined; -} - -/** - * The wallet wants to send a peer push payment. - */ -export interface PendingPeerPushInitiationTask { - type: PendingTaskType.PeerPushDebit; - pursePub: string; -} - -/** - * The wallet wants to send a peer pull payment. - */ -export interface PendingPeerPullInitiationTask { - type: PendingTaskType.PeerPullCredit; - pursePub: string; -} - -/** - * The wallet wants to send a peer pull payment. - */ -export interface PendingPeerPullDebitTask { - type: PendingTaskType.PeerPullDebit; - peerPullDebitId: string; -} - -/** - */ -export interface PendingPeerPushCreditTask { - type: PendingTaskType.PeerPushCredit; - peerPushCreditId: string; -} - - -export enum ReserveType { - /** - * Manually created. - */ - Manual = "manual", - /** - * Withdrawn from a bank that has "tight" Taler integration - */ - TalerBankWithdraw = "taler-bank-withdraw", -} - -/** - * Status of an ongoing withdrawal operation. - */ -export interface PendingRefreshTask { - type: PendingTaskType.Refresh; - lastError?: TalerErrorDetail; - refreshGroupId: string; - finishedPerCoin: boolean[]; - retryInfo?: DbRetryInfo; -} - -/** - * The wallet is picking up a tip that the user has accepted. - */ -export interface PendingTipPickupTask { - type: PendingTaskType.RewardPickup; - tipId: string; - merchantBaseUrl: string; - merchantTipId: string; -} - -/** - * A purchase needs to be processed (i.e. for download / payment / refund). - */ -export interface PendingPurchaseTask { - type: PendingTaskType.Purchase; - proposalId: string; - retryInfo?: DbRetryInfo; - /** - * Status of the payment as string, used only for debugging. - */ - statusStr: string; - lastError: TalerErrorDetail | undefined; -} - -export interface PendingRecoupTask { - type: PendingTaskType.Recoup; - recoupGroupId: string; - retryInfo?: DbRetryInfo; - lastError: TalerErrorDetail | undefined; -} - -/** - * Status of an ongoing withdrawal operation. - */ -export interface PendingWithdrawTask { - type: PendingTaskType.Withdraw; - lastError: TalerErrorDetail | undefined; - retryInfo?: DbRetryInfo; - withdrawalGroupId: string; -} - -/** - * Status of an ongoing deposit operation. - */ -export interface PendingDepositTask { - type: PendingTaskType.Deposit; - lastError: TalerErrorDetail | undefined; - retryInfo: DbRetryInfo | undefined; - depositGroupId: string; -} - -declare const __taskId: unique symbol; -export type TaskId = string & { [__taskId]: true }; - -/** - * Fields that are present in every pending operation. - */ -export interface PendingTaskInfoCommon { - /** - * Type of the pending operation. - */ - type: PendingTaskType; - - /** - * Unique identifier for the pending task. - */ - id: TaskId; - - /** - * Set to true if the operation indicates that something is really in progress, - * as opposed to some regular scheduled operation that can be tried later. - */ - givesLifeness: boolean; - - /** - * Operation is active and waiting for a longpoll result. - */ - isLongpolling: boolean; - - /** - * Operation is waiting to be executed. - */ - isDue: boolean; - - /** - * Timestamp when the pending operation should be executed next. - */ - timestampDue: AbsoluteTime; - - /** - * Retry info. Currently used to stop the wallet after any operation - * exceeds a number of retries. - */ - retryInfo?: DbRetryInfo; - - /** - * Internal operation status for debugging. - */ - internalOperationStatus?: string; -} - -/** - * Response returned from the pending operations API. - */ -export interface PendingOperationsResponse { - /** - * List of pending operations. - */ - pendingOperations: PendingTaskInfo[]; -} diff --git a/packages/taler-wallet-core/src/recoup.ts b/packages/taler-wallet-core/src/recoup.ts index 02aa1e167..8e994484c 100644 --- a/packages/taler-wallet-core/src/recoup.ts +++ b/packages/taler-wallet-core/src/recoup.ts @@ -41,6 +41,7 @@ import { } from "@gnu-taler/taler-util"; import { readSuccessResponseJsonOrThrow } from "@gnu-taler/taler-util/http"; import { + PendingTaskType, TaskRunResult, TransactionContext, constructTaskIdentifier, @@ -58,7 +59,6 @@ import { timestampPreciseToDb, } from "./db.js"; import { InternalWalletState } from "./internal-wallet-state.js"; -import { PendingTaskType } from "./pending-types.js"; import { createRefreshGroup } from "./refresh.js"; import { constructTransactionIdentifier } from "./transactions.js"; import { checkDbInvariant } from "./util/invariants.js"; diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts index ea4190364..f139208be 100644 --- a/packages/taler-wallet-core/src/refresh.ts +++ b/packages/taler-wallet-core/src/refresh.ts @@ -59,6 +59,17 @@ import { readSuccessResponseJsonOrThrow, readUnexpectedResponseDetails, } from "@gnu-taler/taler-util/http"; +import { + constructTaskIdentifier, + makeCoinAvailable, + makeCoinsVisible, + PendingTaskType, + TaskId, + TaskRunResult, + TaskRunResultType, + TombstoneTag, + TransactionContext, +} from "./common.js"; import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js"; import { DerivedRefreshSession, @@ -73,12 +84,11 @@ import { RefreshGroupRecord, RefreshOperationStatus, } from "./db.js"; +import { fetchFreshExchange } from "./exchanges.js"; import { getCandidateWithdrawalDenomsTx, - PendingTaskType, RefreshGroupPerExchangeInfo, RefreshSessionRecord, - TaskId, timestampPreciseToDb, WalletDbReadOnlyTransaction, WalletDbReadWriteTransaction, @@ -87,23 +97,13 @@ import { EXCHANGE_COINS_LOCK, InternalWalletState, } from "./internal-wallet-state.js"; -import { assertUnreachable } from "./util/assertUnreachable.js"; -import { selectWithdrawalDenominations } from "./util/coinSelection.js"; -import { checkDbInvariant } from "./util/invariants.js"; -import { - constructTaskIdentifier, - makeCoinAvailable, - makeCoinsVisible, - TaskRunResult, - TaskRunResultType, - TombstoneTag, - TransactionContext, -} from "./common.js"; -import { fetchFreshExchange } from "./exchanges.js"; import { constructTransactionIdentifier, notifyTransition, } from "./transactions.js"; +import { assertUnreachable } from "./util/assertUnreachable.js"; +import { selectWithdrawalDenominations } from "./util/coinSelection.js"; +import { checkDbInvariant } from "./util/invariants.js"; const logger = new Logger("refresh.ts"); diff --git a/packages/taler-wallet-core/src/reward.ts b/packages/taler-wallet-core/src/reward.ts index da43e65b0..4ef4d7509 100644 --- a/packages/taler-wallet-core/src/reward.ts +++ b/packages/taler-wallet-core/src/reward.ts @@ -28,26 +28,26 @@ import { TransactionState, TransactionType, } from "@gnu-taler/taler-util"; -import { RewardRecord, RewardRecordStatus } from "./db.js"; -import { InternalWalletState } from "./internal-wallet-state.js"; -import { PendingTaskType } from "./pending-types.js"; -import { assertUnreachable } from "./util/assertUnreachable.js"; import { + PendingTaskType, TaskRunResult, TombstoneTag, TransactionContext, constructTaskIdentifier, } from "./common.js"; +import { RewardRecord, RewardRecordStatus } from "./db.js"; +import { InternalWalletState } from "./internal-wallet-state.js"; import { constructTransactionIdentifier, notifyTransition, } from "./transactions.js"; +import { assertUnreachable } from "./util/assertUnreachable.js"; const logger = new Logger("operations/tip.ts"); export class RewardTransactionContext implements TransactionContext { public transactionId: string; - public retryTag: string; + public taskId: string; constructor( public ws: InternalWalletState, @@ -57,7 +57,7 @@ export class RewardTransactionContext implements TransactionContext { tag: TransactionType.Reward, walletRewardId, }); - this.retryTag = constructTaskIdentifier({ + this.taskId = constructTaskIdentifier({ tag: PendingTaskType.RewardPickup, walletRewardId, }); @@ -77,7 +77,7 @@ export class RewardTransactionContext implements TransactionContext { } async suspendTransaction(): Promise { - const { ws, walletRewardId, transactionId, retryTag } = this; + const { ws, walletRewardId, transactionId, taskId: retryTag } = this; const transitionInfo = await ws.db.runReadWriteTx( ["rewards"], async (tx) => { @@ -118,7 +118,7 @@ export class RewardTransactionContext implements TransactionContext { } async abortTransaction(): Promise { - const { ws, walletRewardId, transactionId, retryTag } = this; + const { ws, walletRewardId, transactionId, taskId: retryTag } = this; const transitionInfo = await ws.db.runReadWriteTx( ["rewards"], async (tx) => { @@ -158,7 +158,7 @@ export class RewardTransactionContext implements TransactionContext { } async resumeTransaction(): Promise { - const { ws, walletRewardId, transactionId, retryTag } = this; + const { ws, walletRewardId, transactionId, taskId: retryTag } = this; const transitionInfo = await ws.db.runReadWriteTx( ["rewards"], async (tx) => { @@ -198,7 +198,7 @@ export class RewardTransactionContext implements TransactionContext { } async failTransaction(): Promise { - const { ws, walletRewardId, transactionId, retryTag } = this; + const { ws, walletRewardId, transactionId, taskId: retryTag } = this; const transitionInfo = await ws.db.runReadWriteTx( ["rewards"], async (tx) => { diff --git a/packages/taler-wallet-core/src/shepherd.ts b/packages/taler-wallet-core/src/shepherd.ts index 462d51a0d..2352c844f 100644 --- a/packages/taler-wallet-core/src/shepherd.ts +++ b/packages/taler-wallet-core/src/shepherd.ts @@ -40,6 +40,8 @@ import { import { processBackupForProvider } from "./backup/index.js"; import { DbRetryInfo, + PendingTaskType, + TaskId, TaskRunResult, TaskRunResultType, constructTaskIdentifier, @@ -61,7 +63,6 @@ import { processPeerPullCredit } from "./pay-peer-pull-credit.js"; import { processPeerPullDebit } from "./pay-peer-pull-debit.js"; import { processPeerPushCredit } from "./pay-peer-push-credit.js"; import { processPeerPushDebit } from "./pay-peer-push-debit.js"; -import { PendingTaskType, TaskId } from "./pending-types.js"; import { processRecoupGroup } from "./recoup.js"; import { processRefreshGroup } from "./refresh.js"; import { constructTransactionIdentifier } from "./transactions.js"; diff --git a/packages/taler-wallet-core/src/transactions.ts b/packages/taler-wallet-core/src/transactions.ts index 4bd68e184..8c6c3f5aa 100644 --- a/packages/taler-wallet-core/src/transactions.ts +++ b/packages/taler-wallet-core/src/transactions.ts @@ -48,6 +48,13 @@ import { WithdrawalTransactionByURIRequest, WithdrawalType, } from "@gnu-taler/taler-util"; +import { + constructTaskIdentifier, + PendingTaskType, + TaskId, + TaskIdentifiers, + TransactionContext, +} from "./common.js"; import { DepositElementStatus, DepositGroupRecord, @@ -68,23 +75,6 @@ import { WithdrawalGroupStatus, WithdrawalRecordType, } from "./db.js"; -import { - OPERATION_STATUS_ACTIVE_FIRST, - OPERATION_STATUS_ACTIVE_LAST, - PeerPushDebitStatus, - timestampPreciseFromDb, - timestampProtocolFromDb, - WalletDbReadOnlyTransaction, -} from "./index.js"; -import { InternalWalletState } from "./internal-wallet-state.js"; -import { PendingTaskType, TaskId } from "./pending-types.js"; -import { assertUnreachable } from "./util/assertUnreachable.js"; -import { checkDbInvariant, checkLogicInvariant } from "./util/invariants.js"; -import { - constructTaskIdentifier, - TaskIdentifiers, - TransactionContext, -} from "./common.js"; import { computeDepositTransactionActions, computeDepositTransactionStatus, @@ -94,6 +84,15 @@ import { ExchangeWireDetails, getExchangeWireDetailsInTx, } from "./exchanges.js"; +import { + OPERATION_STATUS_ACTIVE_FIRST, + OPERATION_STATUS_ACTIVE_LAST, + PeerPushDebitStatus, + timestampPreciseFromDb, + timestampProtocolFromDb, + WalletDbReadOnlyTransaction, +} from "./index.js"; +import { InternalWalletState } from "./internal-wallet-state.js"; import { computePayMerchantTransactionActions, computePayMerchantTransactionState, @@ -133,6 +132,8 @@ import { computeTipTransactionActions, RewardTransactionContext, } from "./reward.js"; +import { assertUnreachable } from "./util/assertUnreachable.js"; +import { checkDbInvariant, checkLogicInvariant } from "./util/invariants.js"; import { augmentPaytoUrisForWithdrawal, computeWithdrawalTransactionActions, diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index 37842b223..1ed1eef87 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -146,7 +146,6 @@ import { RunBackupCycleRequest, } from "./backup/index.js"; import { MerchantPaymentBalanceDetails } from "./balance.js"; -import { PendingOperationsResponse as PendingTasksResponse } from "./pending-types.js"; export enum WalletApiOperation { InitWallet = "initWallet", @@ -1076,11 +1075,13 @@ export type GetUserAttentionsUnreadCount = { /** * Get wallet-internal pending tasks. + * + * @deprecated */ export type GetPendingTasksOp = { op: WalletApiOperation.GetPendingOperations; request: EmptyObject; - response: PendingTasksResponse; + response: any; }; /** diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 2ddebd403..8b24fdc11 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -259,7 +259,6 @@ import { getExchangeWithdrawalInfo, getWithdrawalDetailsForUri, } from "./withdraw.js"; -import { PendingOperationsResponse } from "./pending-types.js"; import { TaskScheduler } from "./shepherd.js"; import { assertUnreachable } from "./util/assertUnreachable.js"; import { @@ -607,6 +606,18 @@ async function handlePrepareWithdrawExchange( }; } +/** + * Response returned from the pending operations API. + * + * @deprecated this is a placeholder for the response type of a deprecated wallet-core request. + */ +export interface PendingOperationsResponse { + /** + * List of pending operations. + */ + pendingOperations: any[]; +} + /** * Implementation of the "wallet-core" API. */ diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts index a986d00a9..7e9b295bd 100644 --- a/packages/taler-wallet-core/src/withdraw.ts +++ b/packages/taler-wallet-core/src/withdraw.ts @@ -85,6 +85,17 @@ import { readSuccessResponseJsonOrThrow, throwUnexpectedRequestError, } from "@gnu-taler/taler-util/http"; +import { + PendingTaskType, + TaskId, + TaskRunResult, + TaskRunResultType, + TombstoneTag, + TransactionContext, + constructTaskIdentifier, + makeCoinAvailable, + makeCoinsVisible, +} from "./common.js"; import { EddsaKeypair } from "./crypto/cryptoImplementation.js"; import { CoinRecord, @@ -100,6 +111,14 @@ import { WithdrawalGroupStatus, WithdrawalRecordType, } from "./db.js"; +import { + ReadyExchangeSummary, + fetchFreshExchange, + getExchangePaytoUri, + getExchangeWireDetailsInTx, + listExchanges, + markExchangeUsed, +} from "./exchanges.js"; import { WalletDbReadOnlyTransaction, WalletDbReadWriteTransaction, @@ -107,40 +126,22 @@ import { timestampPreciseToDb, } from "./index.js"; import { InternalWalletState } from "./internal-wallet-state.js"; +import { DbAccess } from "./query.js"; import { - TaskRunResult, - TaskRunResultType, - TombstoneTag, - TransactionContext, - constructTaskIdentifier, - makeCoinAvailable, - makeCoinsVisible, -} from "./common.js"; -import { PendingTaskType, TaskId } from "./pending-types.js"; + TransitionInfo, + constructTransactionIdentifier, + notifyTransition, +} from "./transactions.js"; import { assertUnreachable } from "./util/assertUnreachable.js"; import { selectForcedWithdrawalDenominations, selectWithdrawalDenominations, } from "./util/coinSelection.js"; import { checkDbInvariant, checkLogicInvariant } from "./util/invariants.js"; -import { DbAccess } from "./query.js"; import { WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, WALLET_EXCHANGE_PROTOCOL_VERSION, } from "./versions.js"; -import { - ReadyExchangeSummary, - fetchFreshExchange, - getExchangePaytoUri, - getExchangeWireDetailsInTx, - listExchanges, - markExchangeUsed, -} from "./exchanges.js"; -import { - TransitionInfo, - constructTransactionIdentifier, - notifyTransition, -} from "./transactions.js"; /** * Logger for this file. diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.stories.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.stories.tsx index 2ca5305f5..c2c794e89 100644 --- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.stories.tsx @@ -19,10 +19,9 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { PendingTaskType, TaskId } from "@gnu-taler/taler-wallet-core"; +import { AbsoluteTime } from "@gnu-taler/taler-util"; import * as tests from "@gnu-taler/web-util/testing"; import { View as TestedComponent } from "./DeveloperPage.js"; -import { AbsoluteTime, PendingIdStr } from "@gnu-taler/taler-util"; export default { title: "developer", @@ -36,8 +35,8 @@ export const AllOff = tests.createExample(TestedComponent, { onDownloadDatabase: async () => "this is the content of the database", operations: [ { - id: " " as TaskId, - type: PendingTaskType.ExchangeUpdate, + id: " ", + type: "exchange-update", exchangeBaseUrl: "http://exchange.url.", givesLifeness: false, lastError: undefined, diff --git a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx index 5230d830f..0db7a07eb 100644 --- a/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/wallet/DeveloperPage.tsx @@ -23,26 +23,23 @@ import { LogLevel, NotificationType, } from "@gnu-taler/taler-util"; -import { - PendingTaskInfo, - WalletApiOperation, -} from "@gnu-taler/taler-wallet-core"; +import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { format } from "date-fns"; import { Fragment, VNode, h } from "preact"; import { useEffect, useRef, useState } from "preact/hooks"; +import { Checkbox } from "../components/Checkbox.js"; import { SelectList } from "../components/SelectList.js"; import { Time } from "../components/Time.js"; import { NotifyUpdateFadeOut } from "../components/styled/index.js"; +import { useAlertContext } from "../context/alert.js"; import { useBackendContext } from "../context/backend.js"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook.js"; +import { useSettings } from "../hooks/useSettings.js"; import { Button } from "../mui/Button.js"; import { Grid } from "../mui/Grid.js"; import { Paper } from "../mui/Paper.js"; import { TextField } from "../mui/TextField.js"; -import { Checkbox } from "../components/Checkbox.js"; -import { useSettings } from "../hooks/useSettings.js"; -import { useAlertContext } from "../context/alert.js"; export function DeveloperPage(): VNode { const listenAllEvents = Array.from({ length: 1 }); @@ -105,7 +102,8 @@ type SplitedCoinInfo = { }; export interface Props { - operations: PendingTaskInfo[]; + // FIXME: Pending operations don't exist anymore. + operations: any[]; coins: CoinsInfo; exchanges: ExchangeListItem[]; onDownloadDatabase: () => Promise; @@ -351,8 +349,8 @@ export function View({ operations, coins, onDownloadDatabase }: Props): VNode { name="inject" description={ - Enabling this option will make `window.taler` be available - in all sites + Enabling this option will make `window.taler` be available in all + sites } enabled={settings.injectTalerSupport!} @@ -361,7 +359,6 @@ export function View({ operations, coins, onDownloadDatabase }: Props): VNode { })} /> -

Logging

@@ -414,8 +411,8 @@ export function View({ operations, coins, onDownloadDatabase }: Props): VNode { - { - downloadedDatabase && ( -
- - Database exported at{" "} - -
- ) - } + {downloadedDatabase && ( +
+ + Database exported at{" "} + +
+ )}

Coins:

- { - Object.keys(money_by_exchange).map((ex, idx) => { - const allcoins = money_by_exchange[ex]; - allcoins.sort((a, b) => { - if (b.denom_value !== a.denom_value) { - return b.denom_value - a.denom_value; - } - return b.denom_fraction - a.denom_fraction; - }); + {Object.keys(money_by_exchange).map((ex, idx) => { + const allcoins = money_by_exchange[ex]; + allcoins.sort((a, b) => { + if (b.denom_value !== a.denom_value) { + return b.denom_value - a.denom_value; + } + return b.denom_fraction - a.denom_fraction; + }); - const coins = allcoins.reduce( - (prev, cur) => { - if (cur.status === CoinStatus.Fresh) prev.usable.push(cur); - if (cur.status === CoinStatus.Dormant) prev.spent.push(cur); - return prev; - }, - { - spent: [], - usable: [], - } as SplitedCoinInfo, - ); + const coins = allcoins.reduce( + (prev, cur) => { + if (cur.status === CoinStatus.Fresh) prev.usable.push(cur); + if (cur.status === CoinStatus.Dormant) prev.spent.push(cur); + return prev; + }, + { + spent: [], + usable: [], + } as SplitedCoinInfo, + ); - return ( - - ); - }) - } + return ( + + ); + })}
- { - operations && operations.length > 0 && ( - -

- Pending operations -

-
- {operations.reverse().map((o) => { - return ( - -
- {o.type}{" "} -
-
-
{JSON.stringify(o, undefined, 2)}
-
-
- ); - })} -
-
- ) - } -
+ {operations && operations.length > 0 && ( + +

+ Pending operations +

+
+ {operations.reverse().map((o) => { + return ( + +
+ {o.type}{" "} +
+
+
{JSON.stringify(o, undefined, 2)}
+
+
+ ); + })} +
+
+ )} + ); } -- cgit v1.2.3