From fc77825639c5da6d4c9a209ad8cf6df77c96fbae Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 15 Apr 2024 18:58:53 +0200 Subject: wallet-core: remove more remains of rewards --- packages/taler-util/src/transactions-types.ts | 19 --- packages/taler-wallet-core/src/reward.ts | 165 --------------------- packages/taler-wallet-core/src/shepherd.ts | 15 -- packages/taler-wallet-core/src/transactions.ts | 21 --- .../src/components/HistoryItem.tsx | 2 - .../src/wallet/Transaction.tsx | 3 - 6 files changed, 225 deletions(-) delete mode 100644 packages/taler-wallet-core/src/reward.ts diff --git a/packages/taler-util/src/transactions-types.ts b/packages/taler-util/src/transactions-types.ts index bddc03c25..ac4c3d717 100644 --- a/packages/taler-util/src/transactions-types.ts +++ b/packages/taler-util/src/transactions-types.ts @@ -214,7 +214,6 @@ export type Transaction = | TransactionWithdrawal | TransactionPayment | TransactionRefund - | TransactionReward | TransactionRefresh | TransactionDeposit | TransactionPeerPullCredit @@ -231,7 +230,6 @@ export enum TransactionType { Payment = "payment", Refund = "refund", Refresh = "refresh", - Reward = "reward", Deposit = "deposit", PeerPushDebit = "peer-push-debit", PeerPushCredit = "peer-push-credit", @@ -641,23 +639,6 @@ export interface TransactionRefund extends TransactionCommon { paymentInfo: RefundPaymentInfo | undefined; } -export interface TransactionReward extends TransactionCommon { - type: TransactionType.Reward; - - // Raw amount of the tip, without extra fees that apply - amountRaw: AmountString; - - /** - * More information about the merchant - */ - // merchant: MerchantInfo; - - // Amount will be (or was) added to the wallet's balance after fees and refreshing - amountEffective: AmountString; - - merchantBaseUrl: string; -} - /** * A transaction shown for refreshes. * Only shown for (1) refreshes not associated with other transactions diff --git a/packages/taler-wallet-core/src/reward.ts b/packages/taler-wallet-core/src/reward.ts deleted file mode 100644 index 85e8c6606..000000000 --- a/packages/taler-wallet-core/src/reward.ts +++ /dev/null @@ -1,165 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2019 Taler Systems S.A. - - 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 - */ - -/** - * Imports. - */ -import { - AcceptTipResponse, - Logger, - PrepareTipResult, - TransactionAction, - TransactionIdStr, - TransactionMajorState, - TransactionMinorState, - TransactionState, - TransactionType, - assertUnreachable, -} from "@gnu-taler/taler-util"; -import { - PendingTaskType, - TaskIdStr, - TaskRunResult, - TombstoneTag, - TransactionContext, - constructTaskIdentifier, -} from "./common.js"; -import { RewardRecord, RewardRecordStatus } from "./db.js"; -import { - constructTransactionIdentifier, -} from "./transactions.js"; -import { InternalWalletState, WalletExecutionContext } from "./wallet.js"; - -export class RewardTransactionContext implements TransactionContext { - public transactionId: TransactionIdStr; - public taskId: TaskIdStr; - - constructor( - public wex: WalletExecutionContext, - public walletRewardId: string, - ) { - this.transactionId = constructTransactionIdentifier({ - tag: TransactionType.Reward, - walletRewardId, - }); - this.taskId = constructTaskIdentifier({ - tag: PendingTaskType.RewardPickup, - walletRewardId, - }); - } - - async deleteTransaction(): Promise { - throw Error("unsupported operation"); - } - - async suspendTransaction(): Promise { - throw Error("unsupported operation"); - } - - async abortTransaction(): Promise { - throw Error("unsupported operation"); - } - - async resumeTransaction(): Promise { - throw Error("unsupported operation"); - } - - async failTransaction(): Promise { - throw Error("unsupported operation"); - } -} - -/** - * Get the (DD37-style) transaction status based on the - * database record of a reward. - */ -export function computeRewardTransactionStatus( - tipRecord: RewardRecord, -): TransactionState { - switch (tipRecord.status) { - case RewardRecordStatus.Done: - return { - major: TransactionMajorState.Done, - }; - case RewardRecordStatus.Aborted: - return { - major: TransactionMajorState.Aborted, - }; - case RewardRecordStatus.PendingPickup: - return { - major: TransactionMajorState.Pending, - minor: TransactionMinorState.Pickup, - }; - case RewardRecordStatus.DialogAccept: - return { - major: TransactionMajorState.Dialog, - minor: TransactionMinorState.Proposed, - }; - case RewardRecordStatus.SuspendedPickup: - return { - major: TransactionMajorState.Pending, - minor: TransactionMinorState.Pickup, - }; - case RewardRecordStatus.Failed: - return { - major: TransactionMajorState.Failed, - }; - default: - assertUnreachable(tipRecord.status); - } -} - -export function computeTipTransactionActions( - tipRecord: RewardRecord, -): TransactionAction[] { - switch (tipRecord.status) { - case RewardRecordStatus.Done: - return [TransactionAction.Delete]; - case RewardRecordStatus.Failed: - return [TransactionAction.Delete]; - case RewardRecordStatus.Aborted: - return [TransactionAction.Delete]; - case RewardRecordStatus.PendingPickup: - return [TransactionAction.Suspend, TransactionAction.Fail]; - case RewardRecordStatus.SuspendedPickup: - return [TransactionAction.Resume, TransactionAction.Fail]; - case RewardRecordStatus.DialogAccept: - return [TransactionAction.Abort]; - default: - assertUnreachable(tipRecord.status); - } -} - -export async function prepareReward( - ws: InternalWalletState, - talerTipUri: string, -): Promise { - throw Error("the rewards feature is not supported anymore"); -} - -export async function processTip( - ws: InternalWalletState, - walletTipId: string, -): Promise { - return TaskRunResult.finished(); -} - -export async function acceptTip( - ws: InternalWalletState, - transactionId: TransactionIdStr, -): Promise { - throw Error("the rewards feature is not supported anymore"); -} diff --git a/packages/taler-wallet-core/src/shepherd.ts b/packages/taler-wallet-core/src/shepherd.ts index 4ca472e7b..b2722ce1d 100644 --- a/packages/taler-wallet-core/src/shepherd.ts +++ b/packages/taler-wallet-core/src/shepherd.ts @@ -91,7 +91,6 @@ import { computeRefreshTransactionState, processRefreshGroup, } from "./refresh.js"; -import { computeRewardTransactionStatus } from "./reward.js"; import { constructTransactionIdentifier, parseTransactionIdentifier, @@ -713,13 +712,6 @@ async function getTransactionState( } return computeRefreshTransactionState(rec); } - case TransactionType.Reward: { - const rec = await tx.rewards.get(parsedTxId.walletRewardId); - if (!rec) { - return undefined; - } - return computeRewardTransactionStatus(rec); - } case TransactionType.Recoup: throw Error("not yet supported"); case TransactionType.DenomLoss: { @@ -867,8 +859,6 @@ export function listTaskForTransactionId(transactionId: string): TaskIdStr[] { ]; case TransactionType.Refund: return []; - case TransactionType.Reward: - return []; case TransactionType.Withdrawal: return [ constructTaskIdentifier({ @@ -925,11 +915,6 @@ export function convertTaskToTransactionId( tag: TransactionType.Refresh, refreshGroupId: parsedTaskId.refreshGroupId, }); - case PendingTaskType.RewardPickup: - return constructTransactionIdentifier({ - tag: TransactionType.Reward, - walletRewardId: parsedTaskId.walletRewardId, - }); case PendingTaskType.PeerPushDebit: return constructTransactionIdentifier({ tag: TransactionType.PeerPushDebit, diff --git a/packages/taler-wallet-core/src/transactions.ts b/packages/taler-wallet-core/src/transactions.ts index 536f0de4b..43ef09220 100644 --- a/packages/taler-wallet-core/src/transactions.ts +++ b/packages/taler-wallet-core/src/transactions.ts @@ -129,7 +129,6 @@ import { computeRefreshTransactionState, RefreshTransactionContext, } from "./refresh.js"; -import { RewardTransactionContext } from "./reward.js"; import type { WalletExecutionContext } from "./wallet.js"; import { augmentPaytoUrisForWithdrawal, @@ -199,7 +198,6 @@ function shouldSkipSearch( */ const txOrder: { [t in TransactionType]: number } = { [TransactionType.Withdrawal]: 1, - [TransactionType.Reward]: 2, [TransactionType.Payment]: 3, [TransactionType.PeerPullCredit]: 4, [TransactionType.PeerPullDebit]: 5, @@ -333,10 +331,6 @@ export async function getTransactionById( ); } - case TransactionType.Reward: { - throw Error("unsupported operation"); - } - case TransactionType.Deposit: { const depositGroupId = parsedTx.depositGroupId; return await wex.db.runReadWriteTx( @@ -1531,7 +1525,6 @@ export type ParsedTransactionIdentifier = | { tag: TransactionType.PeerPushDebit; pursePub: string } | { tag: TransactionType.Refresh; refreshGroupId: string } | { tag: TransactionType.Refund; refundGroupId: string } - | { tag: TransactionType.Reward; walletRewardId: string } | { tag: TransactionType.Withdrawal; withdrawalGroupId: string } | { tag: TransactionType.InternalWithdrawal; withdrawalGroupId: string } | { tag: TransactionType.Recoup; recoupGroupId: string } @@ -1557,8 +1550,6 @@ export function constructTransactionIdentifier( return `txn:${pTxId.tag}:${pTxId.refreshGroupId}` as TransactionIdStr; case TransactionType.Refund: return `txn:${pTxId.tag}:${pTxId.refundGroupId}` as TransactionIdStr; - case TransactionType.Reward: - return `txn:${pTxId.tag}:${pTxId.walletRewardId}` as TransactionIdStr; case TransactionType.Withdrawal: return `txn:${pTxId.tag}:${pTxId.withdrawalGroupId}` as TransactionIdStr; case TransactionType.InternalWithdrawal: @@ -1616,11 +1607,6 @@ export function parseTransactionIdentifier( tag: TransactionType.Refund, refundGroupId: rest[0], }; - case TransactionType.Reward: - return { - tag: TransactionType.Reward, - walletRewardId: rest[0], - }; case TransactionType.Withdrawal: return { tag: TransactionType.Withdrawal, @@ -1669,11 +1655,6 @@ function maybeTaskFromTransaction( tag: PendingTaskType.Purchase, proposalId: parsedTx.proposalId, }); - case TransactionType.Reward: - return constructTaskIdentifier({ - tag: PendingTaskType.RewardPickup, - walletRewardId: parsedTx.walletRewardId, - }); case TransactionType.Refresh: return constructTaskIdentifier({ tag: PendingTaskType.Refresh, @@ -1753,8 +1734,6 @@ async function getContextForTransaction( return new PeerPushCreditTransactionContext(wex, tx.peerPushCreditId); case TransactionType.Refund: return new RefundTransactionContext(wex, tx.refundGroupId); - case TransactionType.Reward: - return new RewardTransactionContext(wex, tx.walletRewardId); case TransactionType.Recoup: //return new RecoupTransactionContext(ws, tx.recoupGroupId); throw new Error("not yet supported"); diff --git a/packages/taler-wallet-webextension/src/components/HistoryItem.tsx b/packages/taler-wallet-webextension/src/components/HistoryItem.tsx index 833448e67..9be9326b2 100644 --- a/packages/taler-wallet-webextension/src/components/HistoryItem.tsx +++ b/packages/taler-wallet-webextension/src/components/HistoryItem.tsx @@ -136,8 +136,6 @@ export function HistoryItem(props: { tx: Transaction }): VNode { } /> ); - case TransactionType.Reward: - return
not supported
; case TransactionType.Refresh: return (