diff --git a/src/pages/wallet-setup/wallet-setup.ts b/src/pages/wallet-setup/wallet-setup.ts index 0860834..78261f3 100644 --- a/src/pages/wallet-setup/wallet-setup.ts +++ b/src/pages/wallet-setup/wallet-setup.ts @@ -226,9 +226,9 @@ document.addEventListener('DOMContentLoaded', async () => { console.log('🔄 IndexedDB upgrade needed, checking wallet store...'); // Créer le store wallet seulement s'il n'existe pas - if (!db.objectStoreNames.contains('wallet')) { - const store = db.createObjectStore('wallet', { keyPath: 'pre_id' }); - console.log('✅ Wallet store created with keyPath: pre_id'); + if (!db.objectStoreNames.contains(DATABASE_CONFIG.stores.wallet.name)) { + const store = db.createObjectStore(DATABASE_CONFIG.stores.wallet.name, { keyPath: DATABASE_CONFIG.stores.wallet.keyPath as string }); + console.log(`✅ Wallet store created with keyPath: ${DATABASE_CONFIG.stores.wallet.keyPath}`); } else { console.log('✅ Wallet store already exists'); } diff --git a/src/services/service.ts b/src/services/service.ts index 1270e07..4d57a9b 100755 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -24,6 +24,7 @@ import Database from './database.service'; import { storeData, retrieveData } from './storage.service'; // import { testData } from './storage.service'; // Unused import import { BackUp } from '../models/backup.model'; +import { DATABASE_CONFIG } from './database-config'; export const U32_MAX = 4294967295; @@ -1160,11 +1161,11 @@ export default class Services { // Clear all stores const db = await Database.getInstance(); - await db.clearStore('wallet'); - await db.clearStore('shared_secrets'); - await db.clearStore('unconfirmed_secrets'); - await db.clearStore('processes'); - await db.clearStore('diffs'); + await db.clearStore(DATABASE_CONFIG.stores.wallet.name); + await db.clearStore(DATABASE_CONFIG.stores.shared_secrets.name); + await db.clearStore(DATABASE_CONFIG.stores.unconfirmed_secrets.name); + await db.clearStore(DATABASE_CONFIG.stores.processes.name); + await db.clearStore(DATABASE_CONFIG.stores.diffs.name); } sendNewTxMessage(message: string) { @@ -1811,7 +1812,7 @@ export default class Services { async saveDeviceInDatabase(device: Device): Promise { const db = await Database.getInstance(); - const walletStore = 'wallet'; + const walletStore = DATABASE_CONFIG.stores.wallet.name; try { const prevDevice = await this.getDeviceFromDatabase(); if (prevDevice) { @@ -1829,7 +1830,7 @@ export default class Services { async getDeviceFromDatabase(): Promise { const db = await Database.getInstance(); - const walletStore = 'wallet'; + const walletStore = DATABASE_CONFIG.stores.wallet.name; try { const dbRes = await db.getObject(walletStore, '1'); if (!dbRes) { @@ -1895,13 +1896,13 @@ export default class Services { const db = await Database.getInstance(); try { // Clear all stores - await db.clearStore('wallet'); - await db.clearStore('processes'); - await db.clearStore('shared_secrets'); - await db.clearStore('unconfirmed_secrets'); - await db.clearStore('diffs'); - await db.clearStore('data'); - await db.clearStore('labels'); + await db.clearStore(DATABASE_CONFIG.stores.wallet.name); + await db.clearStore(DATABASE_CONFIG.stores.processes.name); + await db.clearStore(DATABASE_CONFIG.stores.shared_secrets.name); + await db.clearStore(DATABASE_CONFIG.stores.unconfirmed_secrets.name); + await db.clearStore(DATABASE_CONFIG.stores.diffs.name); + await db.clearStore(DATABASE_CONFIG.stores.data.name); + await db.clearStore(DATABASE_CONFIG.stores.labels.name); // Clear localStorage localStorage.clear();