aboutsummaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-06-20 16:07:15 +0200
committerFlorian Dold <florian@dold.me>2023-06-20 16:07:20 +0200
commite5a8ae7d60c9fc9d6740ef391ac34f2ac620b0f4 (patch)
tree472ddac0bbcf0b80a682672462870de613e8b3c8 /packages
parenta86c948fc9e44e3503cd19776c3eb6410ea3d674 (diff)
downloadwallet-core-e5a8ae7d60c9fc9d6740ef391ac34f2ac620b0f4.tar.xz
wallet-core: remove redundant/unused notifications
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-harness/src/harness/helpers.ts27
-rw-r--r--packages/taler-harness/src/integrationtests/test-kyc.ts59
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-repair.ts4
-rw-r--r--packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts8
-rw-r--r--packages/taler-harness/src/integrationtests/test-wallet-notifications.ts17
-rw-r--r--packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts6
-rw-r--r--packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts10
-rw-r--r--packages/taler-util/src/notifications.ts105
-rw-r--r--packages/taler-wallet-core/src/operations/pay-merchant.ts11
-rw-r--r--packages/taler-wallet-core/src/operations/recoup.ts12
-rw-r--r--packages/taler-wallet-core/src/operations/refresh.ts9
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts13
12 files changed, 89 insertions, 192 deletions
diff --git a/packages/taler-harness/src/harness/helpers.ts b/packages/taler-harness/src/harness/helpers.ts
index 6f70b9455..bc2f573e9 100644
--- a/packages/taler-harness/src/harness/helpers.ts
+++ b/packages/taler-harness/src/harness/helpers.ts
@@ -30,8 +30,8 @@ import {
Duration,
PreparePayResultType,
NotificationType,
- WithdrawalGroupFinishedNotification,
WalletNotification,
+ TransactionMajorState,
} from "@gnu-taler/taler-util";
import {
BankAccessApi,
@@ -505,7 +505,7 @@ export async function startWithdrawViaBank(
}
export interface WithdrawViaBankResult {
- withdrawalFinishedCond: Promise<WithdrawalGroupFinishedNotification>;
+ withdrawalFinishedCond: Promise<true>;
}
/**
@@ -535,17 +535,22 @@ export async function withdrawViaBankV2(
restrictAge: p.restrictAge,
});
- const withdrawalFinishedCond = wallet.waitForNotificationCond((x) =>
- x.type === NotificationType.WithdrawGroupFinished ? x : false,
- );
-
// Withdraw (AKA select)
- await wallet.client.call(WalletApiOperation.AcceptBankIntegratedWithdrawal, {
- exchangeBaseUrl: exchange.baseUrl,
- talerWithdrawUri: wop.taler_withdraw_uri,
- restrictAge: p.restrictAge,
- });
+ const acceptRes = await wallet.client.call(
+ WalletApiOperation.AcceptBankIntegratedWithdrawal,
+ {
+ exchangeBaseUrl: exchange.baseUrl,
+ talerWithdrawUri: wop.taler_withdraw_uri,
+ restrictAge: p.restrictAge,
+ },
+ );
+
+ const withdrawalFinishedCond = wallet.waitForNotificationCond((x) =>
+ x.type === NotificationType.TransactionStateTransition &&
+ x.newTxState.major === TransactionMajorState.Done &&
+ x.transactionId === acceptRes.transactionId,
+ );
// Confirm it
diff --git a/packages/taler-harness/src/integrationtests/test-kyc.ts b/packages/taler-harness/src/integrationtests/test-kyc.ts
index ac53b0dce..660595845 100644
--- a/packages/taler-harness/src/integrationtests/test-kyc.ts
+++ b/packages/taler-harness/src/integrationtests/test-kyc.ts
@@ -17,7 +17,14 @@
/**
* Imports.
*/
-import { Duration, j2s, NotificationType } from "@gnu-taler/taler-util";
+import {
+ Duration,
+ j2s,
+ NotificationType,
+ TransactionMajorState,
+ TransactionMinorState,
+ TransactionType,
+} from "@gnu-taler/taler-util";
import {
BankAccessApi,
BankApi,
@@ -310,18 +317,7 @@ export async function runKycTest(t: GlobalTestState) {
// Withdraw
- const kycNotificationCond = walletClient.waitForNotificationCond((x) => {
- if (x.type === NotificationType.KycRequested) {
- return x;
- }
- return false;
- });
-
- const withdrawalDoneCond = walletClient.waitForNotificationCond(
- (x) => x.type === NotificationType.WithdrawGroupFinished,
- );
-
- await walletClient.client.call(
+ const acceptResp = await walletClient.client.call(
WalletApiOperation.AcceptBankIntegratedWithdrawal,
{
exchangeBaseUrl: exchange.baseUrl,
@@ -329,14 +325,47 @@ export async function runKycTest(t: GlobalTestState) {
},
);
+ const withdrawalTxId = acceptResp.transactionId;
+
// Confirm it
await BankApi.confirmWithdrawalOperation(bank, user, wop);
+ const kycNotificationCond = walletClient.waitForNotificationCond((x) => {
+ if (
+ x.type === NotificationType.TransactionStateTransition &&
+ x.transactionId === withdrawalTxId &&
+ x.newTxState.major === TransactionMajorState.Pending &&
+ x.newTxState.minor === TransactionMinorState.KycRequired
+ ) {
+ return x;
+ }
+ return false;
+ });
+
+ const withdrawalDoneCond = walletClient.waitForNotificationCond(
+ (x) =>
+ x.type === NotificationType.TransactionStateTransition &&
+ x.transactionId === withdrawalTxId &&
+ x.newTxState.major === TransactionMajorState.Done,
+ );
+
const kycNotif = await kycNotificationCond;
console.log("got kyc notification:", j2s(kycNotif));
+ const txState = await walletClient.client.call(WalletApiOperation.GetTransactionById, {
+ transactionId: withdrawalTxId
+ });
+
+ t.assertDeepEqual(txState.type, TransactionType.Withdrawal);
+
+ const kycUrl = txState.kycUrl;
+
+ t.assertTrue(!!kycUrl);
+
+ console.log(`kyc URL is ${kycUrl}`);
+
// We now simulate the user interacting with the KYC service,
// which would usually done in the browser.
@@ -344,11 +373,11 @@ export async function runKycTest(t: GlobalTestState) {
allowHttp: true,
enableThrottling: false,
});
- const kycServerResp = await httpLib.get(kycNotif.kycUrl);
+ const kycServerResp = await httpLib.fetch(kycUrl);
const kycLoginResp = await kycServerResp.json();
console.log("kyc server resp:", j2s(kycLoginResp));
const kycProofUrl = kycLoginResp.redirect_uri;
- const proofHttpResp = await httpLib.get(kycProofUrl);
+ const proofHttpResp = await httpLib.fetch(kycProofUrl);
console.log("proof resp status", proofHttpResp.status);
console.log("resp headers", proofHttpResp.headers.toJSON());
diff --git a/packages/taler-harness/src/integrationtests/test-peer-repair.ts b/packages/taler-harness/src/integrationtests/test-peer-repair.ts
index 77e47b01e..cfa7ec877 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-repair.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-repair.ts
@@ -61,7 +61,9 @@ export async function runPeerRepairTest(t: GlobalTestState) {
const wallet2 = w2.walletClient;
const withdrawalDoneCond = wallet1.waitForNotificationCond(
- (x) => x.type === NotificationType.WithdrawGroupFinished,
+ (x) => x.type === NotificationType.TransactionStateTransition &&
+ x.newTxState.major === TransactionMajorState.Done &&
+ x.transactionId.startsWith("txn:withdrawal:"),
);
await withdrawViaBankV2(t, {
diff --git a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
index aed3fe8db..30287b51b 100644
--- a/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
+++ b/packages/taler-harness/src/integrationtests/test-peer-to-peer-pull.ts
@@ -61,18 +61,14 @@ export async function runPeerToPeerPullTest(t: GlobalTestState) {
const wallet1 = w1.walletClient;
const wallet2 = w2.walletClient;
- const withdrawalDoneCond = wallet2.waitForNotificationCond(
- (x) => x.type === NotificationType.WithdrawGroupFinished,
- );
-
- await withdrawViaBankV2(t, {
+ const withdrawRes = await withdrawViaBankV2(t, {
walletClient: wallet2,
bank,
exchange,
amount: "TESTKUDOS:20",
});
- await withdrawalDoneCond;
+ await withdrawRes.withdrawalFinishedCond;
const purse_expiration = AbsoluteTime.toProtocolTimestamp(
AbsoluteTime.addDuration(
diff --git a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts
index 9f591b9d0..810250f53 100644
--- a/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts
+++ b/packages/taler-harness/src/integrationtests/test-wallet-notifications.ts
@@ -22,6 +22,7 @@ import {
Duration,
NotificationType,
PreparePayResultType,
+ TransactionMajorState,
} from "@gnu-taler/taler-util";
import {
BankAccessApi,
@@ -143,12 +144,7 @@ export async function runWalletNotificationsTest(t: GlobalTestState) {
// Withdraw (AKA select)
- const withdrawalFinishedReceivedPromise =
- walletClient.waitForNotificationCond((x) => {
- return x.type === NotificationType.WithdrawGroupFinished;
- });
-
- await walletClient.client.call(
+ const acceptRes = await walletClient.client.call(
WalletApiOperation.AcceptBankIntegratedWithdrawal,
{
exchangeBaseUrl: exchange.baseUrl,
@@ -156,6 +152,15 @@ export async function runWalletNotificationsTest(t: GlobalTestState) {
},
);
+ const withdrawalFinishedReceivedPromise =
+ walletClient.waitForNotificationCond((x) => {
+ return (
+ x.type === NotificationType.TransactionStateTransition &&
+ x.newTxState.major === TransactionMajorState.Done &&
+ x.transactionId === acceptRes.transactionId
+ );
+ });
+
// Confirm it
await BankApi.confirmWithdrawalOperation(bank, user, wop);
diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts
index d0515d64f..396f0f03f 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-bank-integrated.ts
@@ -82,7 +82,11 @@ export async function runWithdrawalBankIntegratedTest(t: GlobalTestState) {
);
const withdrawalFinishedCond = walletClient.waitForNotificationCond((x) => {
- return x.type === NotificationType.WithdrawGroupFinished;
+ return (
+ x.type === NotificationType.TransactionStateTransition &&
+ x.transactionId === r2.transactionId &&
+ x.newTxState.major === TransactionMajorState.Done
+ );
});
const withdrawalReserveReadyCond = walletClient.waitForNotificationCond(
diff --git a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts
index 2415c8246..f56e4d24d 100644
--- a/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts
+++ b/packages/taler-harness/src/integrationtests/test-withdrawal-huge.ts
@@ -27,11 +27,11 @@ import {
} from "../harness/harness.js";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
-import { NotificationType, URL } from "@gnu-taler/taler-util";
+import { NotificationType, TransactionMajorState, URL } from "@gnu-taler/taler-util";
/**
* Withdraw a high amount. Mostly intended as a perf test.
- *
+ *
* It is useful to see whether the wallet stays responsive while doing a huge withdrawal.
* (This is not automatic yet. Use taler-wallet-cli to connect to the daemon and make requests to check.)
*/
@@ -83,7 +83,11 @@ export async function runWithdrawalHugeTest(t: GlobalTestState) {
});
await wallet.connect();
- const withdrawalFinishedCond = wallet.waitForNotificationCond((wn) => wn.type === NotificationType.WithdrawGroupFinished);
+ const withdrawalFinishedCond = wallet.waitForNotificationCond(
+ (wn) => wn.type === NotificationType.TransactionStateTransition &&
+ wn.transactionId.startsWith("txn:withdrawal:") &&
+ wn.newTxState.major === TransactionMajorState.Done,
+ );
await wallet.client.call(WalletApiOperation.AddExchange, {
exchangeBaseUrl: exchange.baseUrl,
diff --git a/packages/taler-util/src/notifications.ts b/packages/taler-util/src/notifications.ts
index b05fea8c9..37848e40f 100644
--- a/packages/taler-util/src/notifications.ts
+++ b/packages/taler-util/src/notifications.ts
@@ -1,6 +1,6 @@
/*
This file is part of GNU Taler
- (C) 2019 GNUnet e.V.
+ (C) 2019-2023 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
@@ -27,25 +27,10 @@ import { TalerErrorDetail } from "./wallet-types.js";
export enum NotificationType {
CoinWithdrawn = "coin-withdrawn",
- ProposalAccepted = "proposal-accepted",
- ProposalDownloaded = "proposal-downloaded",
- RefundsSubmitted = "refunds-submitted",
- RecoupStarted = "recoup-started",
- RecoupFinished = "recoup-finished",
- RefreshRevealed = "refresh-revealed",
- RefreshMelted = "refresh-melted",
- RefreshStarted = "refresh-started",
- RefreshUnwarranted = "refresh-unwarranted",
- WithdrawGroupCreated = "withdraw-group-created",
- WithdrawGroupFinished = "withdraw-group-finished",
- RefundStarted = "refund-started",
- RefundQueried = "refund-queried",
ExchangeOperationError = "exchange-operation-error",
ExchangeAdded = "exchange-added",
BackupOperationError = "backup-error",
- InternalError = "internal-error",
PendingOperationProcessed = "pending-operation-processed",
- KycRequested = "kyc-requested",
TransactionStateTransition = "transaction-state-transition",
}
@@ -63,85 +48,12 @@ export interface TransactionStateTransitionNotification {
errorInfo?: ErrorInfoSummary;
}
-export interface ProposalAcceptedNotification {
- type: NotificationType.ProposalAccepted;
- proposalId: string;
-}
-
-export interface InternalErrorNotification {
- type: NotificationType.InternalError;
- message: string;
- exception: any;
-}
-
export interface CoinWithdrawnNotification {
type: NotificationType.CoinWithdrawn;
numWithdrawn: number;
numTotal: number;
}
-export interface RefundStartedNotification {
- type: NotificationType.RefundStarted;
-}
-
-export interface RefundQueriedNotification {
- type: NotificationType.RefundQueried;
- /**
- * Transaction ID of the purchase (NOT the refund transaction).
- */
- transactionId: string;
-}
-
-export interface ProposalDownloadedNotification {
- type: NotificationType.ProposalDownloaded;
- proposalId: string;
-}
-
-export interface RefundsSubmittedNotification {
- type: NotificationType.RefundsSubmitted;
- proposalId: string;
-}
-
-export interface RecoupStartedNotification {
- type: NotificationType.RecoupStarted;
-}
-
-export interface RecoupFinishedNotification {
- type: NotificationType.RecoupFinished;
-}
-
-export interface RefreshMeltedNotification {
- type: NotificationType.RefreshMelted;
-}
-
-export interface KycRequestedNotification {
- type: NotificationType.KycRequested;
- transactionId: string;
- kycUrl: string;
-}
-
-export interface RefreshRevealedNotification {
- type: NotificationType.RefreshRevealed;
-}
-
-export interface RefreshStartedNotification {
- type: NotificationType.RefreshStarted;
-}
-
-export interface RefreshRefusedNotification {
- type: NotificationType.RefreshUnwarranted;
-}
-
-export interface WithdrawalGroupCreatedNotification {
- type: NotificationType.WithdrawGroupCreated;
- withdrawalGroupId: string;
-}
-
-export interface WithdrawalGroupFinishedNotification {
- type: NotificationType.WithdrawGroupFinished;
- reservePub: string;
-}
-
export interface ExchangeAddedNotification {
type: NotificationType.ExchangeAdded;
}
@@ -167,21 +79,6 @@ export type WalletNotification =
| BackupOperationErrorNotification
| ExchangeAddedNotification
| ExchangeOperationErrorNotification
- | ProposalAcceptedNotification
- | ProposalDownloadedNotification
- | RefundsSubmittedNotification
- | RecoupStartedNotification
- | RecoupFinishedNotification
- | RefreshMeltedNotification
- | RefreshRevealedNotification
- | RefreshStartedNotification
- | RefreshRefusedNotification
- | WithdrawalGroupFinishedNotification
- | RefundStartedNotification
- | RefundQueriedNotification
- | WithdrawalGroupCreatedNotification
| CoinWithdrawnNotification
- | InternalErrorNotification
| PendingOperationProcessedNotification
- | KycRequestedNotification
| TransactionStateTransitionNotification;
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index ad6552f06..d7463134a 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -560,12 +560,6 @@ async function processDownloadProposal(
notifyTransition(ws, transactionId, transitionInfo);
- // FIXME: Deprecated pre-DD37 notification, remove eventually
- ws.notify({
- type: NotificationType.ProposalDownloaded,
- proposalId: proposal.proposalId,
- });
-
return {
type: OperationAttemptResultType.Finished,
result: undefined,
@@ -1453,11 +1447,6 @@ export async function confirmPay(
notifyTransition(ws, transactionId, transitionInfo);
- ws.notify({
- type: NotificationType.ProposalAccepted,
- proposalId: proposal.proposalId,
- });
-
return runPayForConfirmPay(ws, proposalId);
}
diff --git a/packages/taler-wallet-core/src/operations/recoup.ts b/packages/taler-wallet-core/src/operations/recoup.ts
index 71eb58ec9..056aa83b8 100644
--- a/packages/taler-wallet-core/src/operations/recoup.ts
+++ b/packages/taler-wallet-core/src/operations/recoup.ts
@@ -136,10 +136,6 @@ async function recoupWithdrawCoin(
return;
}
- ws.notify({
- type: NotificationType.RecoupStarted,
- });
-
const recoupRequest = await ws.cryptoApi.createRecoupRequest({
blindingKey: coin.blindingKey,
coinPriv: coin.coinPriv,
@@ -182,10 +178,6 @@ async function recoupWithdrawCoin(
await tx.coins.put(updatedCoin);
await putGroupAsFinished(ws, tx, recoupGroup, coinIdx);
});
-
- ws.notify({
- type: NotificationType.RecoupFinished,
- });
}
async function recoupRefreshCoin(
@@ -214,10 +206,6 @@ async function recoupRefreshCoin(
return;
}
- ws.notify({
- type: NotificationType.RecoupStarted,
- });
-
const recoupRequest = await ws.cryptoApi.createRecoupRefreshRequest({
blindingKey: coin.blindingKey,
coinPriv: coin.coinPriv,
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts
index e00275c8d..9c9ad8bbd 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -266,7 +266,6 @@ async function refreshCreateSession(
await tx.refreshGroups.put(rg);
});
- ws.notify({ type: NotificationType.RefreshUnwarranted });
return;
}
@@ -297,7 +296,6 @@ async function refreshCreateSession(
logger.info(
`created refresh session for coin #${coinIndex} in ${refreshGroupId}`,
);
- ws.notify({ type: NotificationType.RefreshStarted });
}
function getRefreshRequestTimeout(rg: RefreshGroupRecord): Duration {
@@ -482,10 +480,6 @@ async function refreshMelt(
rs.norevealIndex = norevealIndex;
await tx.refreshGroups.put(rg);
});
-
- ws.notify({
- type: NotificationType.RefreshMelted,
- });
}
export async function assembleRefreshRevealRequest(args: {
@@ -742,9 +736,6 @@ async function refreshReveal(
await tx.refreshGroups.put(rg);
});
logger.trace("refresh finished (end of reveal)");
- ws.notify({
- type: NotificationType.RefreshRevealed,
- });
}
export async function processRefreshGroup(
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index 118084197..ed9522c0f 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -1515,14 +1515,6 @@ async function processWithdrawalGroupPendingReady(
);
}
- // FIXME: Deprecated with DD37
- if (finishedForFirstTime) {
- ws.notify({
- type: NotificationType.WithdrawGroupFinished,
- reservePub: withdrawalGroup.reservePub,
- });
- }
-
return {
type: OperationAttemptResultType.Finished,
result: undefined,
@@ -1634,11 +1626,6 @@ export async function checkWithdrawalKycStatus(
} else if (kycStatusRes.status === HttpStatusCode.Accepted) {
const kycStatus = await kycStatusRes.json();
logger.info(`kyc status: ${j2s(kycStatus)}`);
- ws.notify({
- type: NotificationType.KycRequested,
- kycUrl: kycStatus.kyc_url,
- transactionId: txId,
- });
throw TalerError.fromDetail(
TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED, //FIXME: another error code or rename for merge
{