diff options
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/deposits.ts | 20 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/refresh.ts | 14 |
2 files changed, 30 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts index dc3831595..6f247501e 100644 --- a/packages/taler-wallet-core/src/deposits.ts +++ b/packages/taler-wallet-core/src/deposits.ts @@ -95,7 +95,11 @@ import { generateDepositPermissions, getTotalPaymentCost, } from "./pay-merchant.js"; -import { createRefreshGroup, getTotalRefreshCost } from "./refresh.js"; +import { + CreateRefreshGroupResult, + createRefreshGroup, + getTotalRefreshCost, +} from "./refresh.js"; import { constructTransactionIdentifier, notifyTransition, @@ -532,7 +536,7 @@ async function refundDepositGroup( const currency = Amounts.currencyOf(depositGroup.totalPayCost); - await ws.db.runReadWriteTx( + const res = await ws.db.runReadWriteTx( [ "depositGroups", "refreshGroups", @@ -553,8 +557,9 @@ async function refundDepositGroup( coinPub: depositGroup.payCoinSelection.coinPubs[i], }); } + let refreshRes: CreateRefreshGroupResult | undefined = undefined; if (isDone) { - const rgid = await createRefreshGroup( + refreshRes = await createRefreshGroup( ws, tx, currency, @@ -565,12 +570,19 @@ async function refundDepositGroup( depositGroupId: newDg.depositGroupId, }), ); - newDg.abortRefreshGroupId = rgid.refreshGroupId; + newDg.abortRefreshGroupId = refreshRes.refreshGroupId; } await tx.depositGroups.put(newDg); + return { refreshRes }; }, ); + if (res?.refreshRes) { + for (const notif of res.refreshRes.notifications) { + ws.notify(notif); + } + } + return TaskRunResult.backoff(); } diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts index df0ab25f9..09cd75bdd 100644 --- a/packages/taler-wallet-core/src/refresh.ts +++ b/packages/taler-wallet-core/src/refresh.ts @@ -54,6 +54,7 @@ import { TransactionState, TransactionType, URL, + WalletNotification, } from "@gnu-taler/taler-util"; import { readSuccessResponseJsonOrThrow, @@ -1254,6 +1255,7 @@ async function applyRefresh( export interface CreateRefreshGroupResult { refreshGroupId: string; + notifications: WalletNotification[]; } /** @@ -1310,6 +1312,8 @@ export async function createRefreshGroup( await tx.refreshGroups.put(refreshGroup); + const newTxState = computeRefreshTransactionState(refreshGroup); + logger.trace(`created refresh group ${refreshGroupId}`); const ctx = new RefreshTransactionContext(ws, refreshGroupId); @@ -1321,6 +1325,16 @@ export async function createRefreshGroup( return { refreshGroupId, + notifications: [ + { + type: NotificationType.TransactionStateTransition, + transactionId: ctx.transactionId, + oldTxState: { + major: TransactionMajorState.None, + }, + newTxState, + }, + ], }; } |