commit 98ad18ff21d86a1fb0c8e4e9724326a930ee02e9
parent a8e9305b055010fef7dfeb746d081ca4eab81a82
Author: Florian Dold <dold@taler.net>
Date: Sat, 18 Jul 2026 02:07:39 +0200
wallet-core: migrate contacts.ts to abstract database access layer
Diffstat:
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/packages/taler-wallet-core/src/contacts.ts b/packages/taler-wallet-core/src/contacts.ts
@@ -59,8 +59,8 @@ export async function addContact(
wex: WalletExecutionContext,
req: AddContactRequest,
): Promise<EmptyObject> {
- await wex.runLegacyWalletDbTx(async (tx) => {
- await tx.wtx.addContact(req.contact);
+ await wex.runWalletDbTx(async (tx) => {
+ await tx.addContact(req.contact);
tx.notify({
type: NotificationType.ContactAdded,
contact: req.contact,
@@ -76,8 +76,8 @@ export async function deleteContact(
wex: WalletExecutionContext,
req: DeleteContactRequest,
): Promise<EmptyObject> {
- await wex.runLegacyWalletDbTx(async (tx) => {
- await tx.wtx.deleteContact(req.contact.alias, req.contact.aliasType);
+ await wex.runWalletDbTx(async (tx) => {
+ await tx.deleteContact(req.contact.alias, req.contact.aliasType);
tx.notify({
type: NotificationType.ContactDeleted,
contact: req.contact,
@@ -94,10 +94,10 @@ export async function listContacts(
req: EmptyObject,
): Promise<ContactListResponse> {
const contacts: ContactEntry[] = [];
- await wex.runLegacyWalletDbTx(async (tx) => {
- const contactsRecords = await tx.wtx.listContacts();
+ await wex.runWalletDbTx(async (tx) => {
+ const contactsRecords = await tx.listContacts();
for (const contactRec of contactsRecords) {
- const li = await makeContactListItem(wex, tx.wtx, contactRec);
+ const li = await makeContactListItem(wex, tx, contactRec);
contacts.push(li);
}
});
diff --git a/packages/taler-wallet-core/src/dbtx.ts b/packages/taler-wallet-core/src/dbtx.ts
@@ -23,6 +23,7 @@ import {
stringifyScopeInfo,
assertUnreachable,
ScopeType,
+ WalletNotification,
} from "@gnu-taler/taler-util";
import { GlobalIDB } from "@gnu-taler/idb-bridge";
import {
@@ -264,6 +265,8 @@ export interface WalletDbTransaction {
exchangeBaseUrl: string,
currency: string,
): Promise<ScopeInfo>;
+
+ notify(notif: WalletNotification): void;
}
function getActiveKeyRange() {
@@ -278,6 +281,10 @@ export class IdbWalletTransaction implements WalletDbTransaction {
constructor(tx: WalletIndexedDbTransaction) {
this.tx = tx;
}
+
+ notify(notif: WalletNotification): void {
+ this.tx.notify(notif);
+ }
async getCurrencyInfo(
scopeInfo: ScopeInfo,
): Promise<GetCurrencyInfoDbResult | undefined> {