diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
9 files changed, 40 insertions, 36 deletions
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts index 601df4151..236fa6b59 100644 --- a/packages/taler-wallet-core/src/operations/deposits.ts +++ b/packages/taler-wallet-core/src/operations/deposits.ts @@ -26,7 +26,6 @@ import { codecForDepositSuccess, codecForTackTransactionAccepted, codecForTackTransactionWired, - CoinDepositPermission, CoinRefreshRequest, CreateDepositGroupRequest, CreateDepositGroupResponse, diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index d7463134a..f2df08247 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -907,6 +907,8 @@ async function handleInsufficientFunds( refreshReason: RefreshReason.PayMerchant, }); }); + + ws.notify({ type: NotificationType.BalanceChange }); } async function unblockBackup( @@ -1446,6 +1448,7 @@ export async function confirmPay( }); notifyTransition(ws, transactionId, transitionInfo); + ws.notify({ type: NotificationType.BalanceChange }); return runPayForConfirmPay(ws, proposalId); } diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts index c0b728567..725e3f3d9 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts @@ -26,6 +26,7 @@ import { InitiatePeerPullCreditRequest, InitiatePeerPullCreditResponse, Logger, + NotificationType, TalerErrorCode, TalerPreciseTimestamp, TalerUriAction, @@ -785,24 +786,14 @@ export async function initiatePeerPullPayment( }); }); - // FIXME: Should we somehow signal to the client - // whether purse creation has failed, or does the client/ - // check this asynchronously from the transaction status? - - const taskId = constructTaskIdentifier({ - tag: PendingTaskType.PeerPullCredit, - pursePub: pursePair.pub, - }); - - await runTaskWithErrorReporting(ws, taskId, async () => { - return processPeerPullCredit(ws, pursePair.pub); - }); - const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPullCredit, pursePub: pursePair.pub, }); + // The pending-incoming balance has changed. + ws.notify({ type: NotificationType.BalanceChange }); + return { talerUri: stringifyTalerUri({ type: TalerUriAction.PayPull, diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts index c7b59e6db..9d8fabfb2 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-debit.ts @@ -22,6 +22,7 @@ import { ExchangePurseDeposits, HttpStatusCode, Logger, + NotificationType, PeerContractTerms, PreparePeerPullDebitRequest, PreparePeerPullDebitResponse, @@ -388,7 +389,6 @@ export async function confirmPeerPullDebit( ws: InternalWalletState, req: ConfirmPeerPullDebitRequest, ): Promise<AcceptPeerPullPaymentResponse> { - let peerPullPaymentIncomingId: string; if (req.transactionId) { @@ -400,7 +400,9 @@ export async function confirmPeerPullDebit( } else if (req.peerPullPaymentIncomingId) { peerPullPaymentIncomingId = req.peerPullPaymentIncomingId; } else { - throw Error("invalid request, transactionId or peerPullPaymentIncomingId required"); + throw Error( + "invalid request, transactionId or peerPullPaymentIncomingId required", + ); } const peerPullInc = await ws.db @@ -479,13 +481,7 @@ export async function confirmPeerPullDebit( return pi; }); - await runTaskWithErrorReporting( - ws, - TaskIdentifiers.forPeerPullPaymentDebit(ppi), - async () => { - return processPeerPullDebit(ws, ppi.peerPullPaymentIncomingId); - }, - ); + ws.notify({ type: NotificationType.BalanceChange }); const transactionId = constructTransactionIdentifier({ tag: TransactionType.PeerPullDebit, diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts index 58a1c2b3c..3e5750af7 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-push-credit.ts @@ -22,6 +22,7 @@ import { ExchangePurseMergeRequest, HttpStatusCode, Logger, + NotificationType, PeerContractTerms, PreparePeerPushCreditRequest, PreparePeerPushCreditResponse, @@ -60,7 +61,12 @@ import { } from "../index.js"; import { assertUnreachable } from "../util/assertUnreachable.js"; import { checkDbInvariant } from "../util/invariants.js"; -import { OperationAttemptResult, OperationAttemptResultType, constructTaskIdentifier, runLongpollAsync } from "./common.js"; +import { + OperationAttemptResult, + OperationAttemptResultType, + constructTaskIdentifier, + runLongpollAsync, +} from "./common.js"; import { updateExchangeFromUrl } from "./exchanges.js"; import { codecForExchangePurseStatus, @@ -206,6 +212,8 @@ export async function preparePeerPushCredit( }); }); + ws.notify({ type: NotificationType.BalanceChange }); + return { amount: purseStatus.balance, amountEffective: wi.withdrawalAmountEffective, @@ -631,15 +639,15 @@ export async function confirmPeerPushCredit( } peerPushPaymentIncomingId = parsedTx.peerPushPaymentIncomingId; } else { - throw Error("no transaction ID (or deprecated peerPushPaymentIncomingId) provided"); + throw Error( + "no transaction ID (or deprecated peerPushPaymentIncomingId) provided", + ); } await ws.db .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming]) .runReadWrite(async (tx) => { - peerInc = await tx.peerPushPaymentIncoming.get( - peerPushPaymentIncomingId, - ); + peerInc = await tx.peerPushPaymentIncoming.get(peerPushPaymentIncomingId); if (!peerInc) { return; } diff --git a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts index c4209eb51..a070eea50 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-push-debit.ts @@ -24,6 +24,7 @@ import { InitiatePeerPushDebitRequest, InitiatePeerPushDebitResponse, Logger, + NotificationType, RefreshReason, TalerError, TalerErrorCode, @@ -678,6 +679,7 @@ export async function initiatePeerPushDebit( }; }); notifyTransition(ws, transactionId, transitionInfo); + ws.notify({ type: NotificationType.BalanceChange }); return { contractPriv: contractKeyPair.priv, diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index b91872735..c1a16badf 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -278,6 +278,7 @@ async function refreshCreateSession( } await tx.refreshGroups.put(rg); }); + ws.notify({ type: NotificationType.BalanceChange }); return; } @@ -458,6 +459,7 @@ async function refreshMelt( } await tx.refreshGroups.put(rg); }); + ws.notify({ type: NotificationType.BalanceChange }); return; } diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts index 1b40e36f1..18ef03c51 100644 --- a/packages/taler-wallet-core/src/operations/tip.ts +++ b/packages/taler-wallet-core/src/operations/tip.ts @@ -30,6 +30,7 @@ import { getRandomBytes, j2s, Logger, + NotificationType, parseTipUri, PrepareTipResult, TalerErrorCode, @@ -57,7 +58,13 @@ import { readSuccessResponseJsonOrThrow, } from "@gnu-taler/taler-util/http"; import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js"; -import { constructTaskIdentifier, makeCoinAvailable, makeCoinsVisible, OperationAttemptResult, OperationAttemptResultType } from "./common.js"; +import { + constructTaskIdentifier, + makeCoinAvailable, + makeCoinsVisible, + OperationAttemptResult, + OperationAttemptResultType, +} from "./common.js"; import { updateExchangeFromUrl } from "./exchanges.js"; import { getCandidateWithdrawalDenoms, @@ -421,6 +428,7 @@ export async function processTip( return { oldTxState, newTxState }; }); notifyTransition(ws, transactionId, transitionInfo); + ws.notify({ type: NotificationType.BalanceChange }); return { type: OperationAttemptResultType.Finished, diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index d606e23dd..111a52882 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -62,7 +62,6 @@ import { ExchangeWithdrawResponse, WithdrawUriInfoResponse, ExchangeBatchWithdrawRequest, - WalletNotification, TransactionState, TransactionMajorState, TransactionMinorState, @@ -76,7 +75,6 @@ import { DenominationRecord, DenominationVerificationStatus, KycPendingInfo, - KycUserType, PlanchetRecord, PlanchetStatus, WalletStoresV1, @@ -108,11 +106,7 @@ import { readSuccessResponseJsonOrThrow, throwUnexpectedRequestError, } from "@gnu-taler/taler-util/http"; -import { - checkDbInvariant, - checkLogicInvariant, - InvariantViolatedError, -} from "../util/invariants.js"; +import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js"; import { DbAccess, GetReadOnlyAccess, @@ -1614,6 +1608,7 @@ async function processWithdrawalGroupPendingReady( } notifyTransition(ws, transactionId, res.transitionInfo); + ws.notify({ type: NotificationType.BalanceChange }); if (numPlanchetErrors > 0) { return { |