taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 7733642b7d57e3b881a11a584d05fd27bc3f1f13
parent 5c90675104b7df6875cb5b3402d7e51a41dced6b
Author: Florian Dold <dold@taler.net>
Date:   Sat, 18 Jul 2026 20:28:32 +0200

db: narrow getGenericRecordHandle to WalletDbTransaction

Diffstat:
Mpackages/taler-wallet-core/src/common.ts | 2+-
Mpackages/taler-wallet-core/src/dbtx-indexeddb.ts | 9+++++++--
Mpackages/taler-wallet-core/src/deposits.ts | 2+-
Mpackages/taler-wallet-core/src/pay-merchant.ts | 6+++---
Mpackages/taler-wallet-core/src/pay-peer-pull-credit.ts | 2+-
Mpackages/taler-wallet-core/src/pay-peer-pull-debit.ts | 2+-
Mpackages/taler-wallet-core/src/pay-peer-push-credit.ts | 2+-
Mpackages/taler-wallet-core/src/pay-peer-push-debit.ts | 2+-
Mpackages/taler-wallet-core/src/recoup.ts | 4++--
Mpackages/taler-wallet-core/src/refresh.ts | 4++--
Mpackages/taler-wallet-core/src/transactions.ts | 4+---
Mpackages/taler-wallet-core/src/withdraw.ts | 2+-
12 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/packages/taler-wallet-core/src/common.ts b/packages/taler-wallet-core/src/common.ts @@ -1128,7 +1128,7 @@ export interface RecordHandle<T> { */ export async function getGenericRecordHandle<T>( ctx: TransactionContext, - tx: LegacyWalletTxHandle, + tx: WalletDbTransaction, getRec: () => Promise<T | undefined>, storeRec: (r: T) => Promise<void>, deleteRec: () => Promise<void>, diff --git a/packages/taler-wallet-core/src/dbtx-indexeddb.ts b/packages/taler-wallet-core/src/dbtx-indexeddb.ts @@ -86,9 +86,14 @@ export class IdbWalletTransaction implements WalletDbTransaction { this.tx = tx; } - notify(notif: WalletNotification): void { + /** + * Bound as an instance property, not a prototype method: call sites pass + * this around unbound (e.g. applyNotifyTransition(tx.notify, ...)), which + * would otherwise lose "this" and fail on this.tx. + */ + notify = (notif: WalletNotification): void => { this.tx.notify(notif); - } + }; async getCurrencyInfo( scopeInfo: ScopeInfo, ): Promise<GetCurrencyInfoDbResult | undefined> { diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts @@ -355,7 +355,7 @@ export class DepositTransactionContext implements TransactionContext { > { return getGenericRecordHandle<DepositGroupRecord>( this, - tx as any, + tx.wtx, async () => tx.depositGroups.get(this.depositGroupId), async (r) => { await tx.depositGroups.put(r); diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts @@ -571,7 +571,7 @@ export class PayMerchantTransactionContext implements TransactionContext { ): Promise<[PurchaseRecord | undefined, RecordHandle<PurchaseRecord>]> { return getGenericRecordHandle<PurchaseRecord>( this, - tx as any, + tx.wtx, async () => tx.purchases.get(this.proposalId), async (r) => { await tx.purchases.put(r); @@ -1695,7 +1695,7 @@ async function reselectCoinsTx( if (contractData.contractTerms.version !== MerchantContractVersion.V1) throw Error("assertion failed"); - const res = await selectPayTokensInTx((tx as LegacyWalletTxHandle).wtx, { + const res = await selectPayTokensInTx(tx.wtx, { proposalId: p.proposalId, choiceIndex: p.choiceIndex, contractTerms: contractData.contractTerms, @@ -1718,7 +1718,7 @@ async function reselectCoinsTx( } await tx.purchases.put(p); - await ctx.updateTransactionMeta(tx as LegacyWalletTxHandle); + await ctx.updateTransactionMeta(tx); if (p.payInfo.payCoinSelection) { await spendCoins(ctx.wex, tx, { diff --git a/packages/taler-wallet-core/src/pay-peer-pull-credit.ts b/packages/taler-wallet-core/src/pay-peer-pull-credit.ts @@ -297,7 +297,7 @@ export class PeerPullCreditTransactionContext implements TransactionContext { > { return getGenericRecordHandle<WalletPeerPullCredit>( this, - tx, + tx.wtx, async () => tx.wtx.getPeerPullCredit(this.pursePub), async (r) => { await tx.wtx.upsertPeerPullCredit(r); diff --git a/packages/taler-wallet-core/src/pay-peer-pull-debit.ts b/packages/taler-wallet-core/src/pay-peer-pull-debit.ts @@ -187,7 +187,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext { > { return getGenericRecordHandle<WalletPeerPullDebit>( this, - tx, + tx.wtx, async () => tx.wtx.getPeerPullDebit(this.peerPullDebitId), async (r) => { await tx.wtx.upsertPeerPullDebit(r); diff --git a/packages/taler-wallet-core/src/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/pay-peer-push-credit.ts @@ -271,7 +271,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext { > { return getGenericRecordHandle<WalletPeerPushCredit>( this, - tx, + tx.wtx, async () => tx.wtx.getPeerPushCredit(this.peerPushCreditId), async (r) => { await tx.wtx.upsertPeerPushCredit(r); diff --git a/packages/taler-wallet-core/src/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/pay-peer-push-debit.ts @@ -212,7 +212,7 @@ export class PeerPushDebitTransactionContext implements TransactionContext { > { return getGenericRecordHandle<WalletPeerPushDebit>( this, - tx, + tx.wtx, async () => tx.wtx.getPeerPushDebit(this.pursePub), async (r) => { await tx.wtx.upsertPeerPushDebit(r); diff --git a/packages/taler-wallet-core/src/recoup.ts b/packages/taler-wallet-core/src/recoup.ts @@ -94,7 +94,7 @@ export async function putGroupAsFinished( } recoupGroup.recoupFinishedPerCoin[coinIdx] = true; await tx.recoupGroups.put(recoupGroup); - await ctx.updateTransactionMeta(tx as LegacyWalletTxHandle); + await ctx.updateTransactionMeta(tx); } async function recoupRewardCoin( @@ -527,7 +527,7 @@ export async function createRecoupGroup( } await tx.recoupGroups.put(recoupGroup); - await ctx.updateTransactionMeta(tx as LegacyWalletTxHandle); + await ctx.updateTransactionMeta(tx); wex.taskScheduler.startShepherdTask(ctx.taskId); diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts @@ -226,7 +226,7 @@ export class RefreshTransactionContext implements TransactionContext { > { return getGenericRecordHandle<RefreshGroupRecord>( this, - tx as any, + tx.wtx, async () => tx.refreshGroups.get(this.refreshGroupId), async (r) => { await tx.refreshGroups.put(r); @@ -1681,7 +1681,7 @@ export async function createRefreshGroup( const ctx = new RefreshTransactionContext(wex, refreshGroupId); await tx.refreshGroups.put(refreshGroup); - await ctx.updateTransactionMeta(tx as LegacyWalletTxHandle); + await ctx.updateTransactionMeta(tx); const newTxState = computeRefreshTransactionState(refreshGroup); diff --git a/packages/taler-wallet-core/src/transactions.ts b/packages/taler-wallet-core/src/transactions.ts @@ -263,9 +263,7 @@ async function addFiltered( } if (checkFilterIncludes(req, mtx)) { const ctx = await getContextForTransaction(wex, mtx.transactionId); - const txDetails = await ctx.lookupFullTransaction( - tx as LegacyWalletTxHandle, - ); + const txDetails = await ctx.lookupFullTransaction(tx); // FIXME: This means that in some cases we can return fewer transactions // than requested. if (!txDetails) { diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts @@ -492,7 +492,7 @@ export class WithdrawTransactionContext implements TransactionContext { > { return getGenericRecordHandle<WithdrawalGroupRecord>( this, - tx as any, + tx.wtx, async () => tx.withdrawalGroups.get(this.withdrawalGroupId), async (r) => { await tx.withdrawalGroups.put(r);