forked from trent_larson/crowd-funder-for-time-pwa
Remove DEBUG console.log statements across codebase
- Eliminated all debugging console statements from 7 files (194 deletions) - Fixed parsing errors from broken function calls in databaseUtil.ts - Resolved orphaned console.log parameters in util.ts and ImportAccountView.vue - Maintained legitimate logging in PlatformServiceFactory and registerServiceWorker - Reduced lint issues from 33 problems (11 errors + 22 warnings) to 16 warnings - All builds and core functionality verified working
This commit is contained in:
@@ -603,12 +603,9 @@ export async function saveNewIdentity(
|
||||
mnemonic: string,
|
||||
derivationPath: string,
|
||||
): Promise<void> {
|
||||
console.log("💾 DEBUG: saveNewIdentity called with DID:", identity.did);
|
||||
|
||||
try {
|
||||
// add to the new sql db
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
console.log("💾 DEBUG: Getting secrets from database");
|
||||
|
||||
const secrets = await platformService.dbQuery(
|
||||
`SELECT secretBase64 FROM secret`,
|
||||
@@ -620,7 +617,6 @@ export async function saveNewIdentity(
|
||||
}
|
||||
|
||||
const secretBase64 = secrets.values[0][0] as string;
|
||||
console.log("💾 DEBUG: Found secret, encrypting identity");
|
||||
|
||||
const secret = base64ToArrayBuffer(secretBase64);
|
||||
const identityStr = JSON.stringify(identity);
|
||||
@@ -629,8 +625,6 @@ export async function saveNewIdentity(
|
||||
const encryptedIdentityBase64 = arrayBufferToBase64(encryptedIdentity);
|
||||
const encryptedMnemonicBase64 = arrayBufferToBase64(encryptedMnemonic);
|
||||
|
||||
console.log("💾 DEBUG: Inserting account into database");
|
||||
|
||||
const sql = `INSERT INTO accounts (dateCreated, derivationPath, did, identityEncrBase64, mnemonicEncrBase64, publicKeyHex)
|
||||
VALUES (?, ?, ?, ?, ?, ?)`;
|
||||
const params = [
|
||||
@@ -642,22 +636,15 @@ export async function saveNewIdentity(
|
||||
identity.keys[0].publicKeyHex,
|
||||
];
|
||||
await platformService.dbExec(sql, params);
|
||||
console.log("💾 DEBUG: Account inserted successfully");
|
||||
|
||||
console.log("💾 DEBUG: Updating default settings with activeDid");
|
||||
await databaseUtil.updateDefaultSettings({ activeDid: identity.did });
|
||||
console.log("💾 DEBUG: Default settings updated");
|
||||
|
||||
console.log("💾 DEBUG: Inserting DID-specific settings");
|
||||
await databaseUtil.insertDidSpecificSettings(identity.did);
|
||||
console.log("💾 DEBUG: DID-specific settings inserted");
|
||||
|
||||
// Check what was actually created
|
||||
const createdSettings =
|
||||
await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
console.log("💾 DEBUG: Created settings:", createdSettings);
|
||||
} catch (error) {
|
||||
console.log("💾 DEBUG: saveNewIdentity error:", error);
|
||||
logger.error("Failed to update default settings:", error);
|
||||
throw new Error(
|
||||
"Failed to set default settings. Please try again or restart the app.",
|
||||
@@ -934,56 +921,37 @@ export async function importFromMnemonic(
|
||||
derivationPath: string = DEFAULT_ROOT_DERIVATION_PATH,
|
||||
shouldErase: boolean = false,
|
||||
): Promise<void> {
|
||||
console.log("📥 DEBUG: importFromMnemonic called with:", {
|
||||
mnemonicLength: mnemonic.split(" ").length,
|
||||
derivationPath,
|
||||
shouldErase,
|
||||
});
|
||||
|
||||
const mne: string = mnemonic.trim().toLowerCase();
|
||||
console.log("📥 DEBUG: Normalized mnemonic length:", mne.split(" ").length);
|
||||
|
||||
// Check if this is Test User #0
|
||||
const TEST_USER_0_MNEMONIC =
|
||||
"rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage";
|
||||
const isTestUser0 = mne === TEST_USER_0_MNEMONIC;
|
||||
console.log("📥 DEBUG: Is Test User #0:", isTestUser0);
|
||||
|
||||
// Derive address and keys from mnemonic
|
||||
const [address, privateHex, publicHex] = deriveAddress(mne, derivationPath);
|
||||
console.log("📥 DEBUG: Derived address:", address);
|
||||
console.log("📥 DEBUG: Derived DID:", `did:ethr:${address}`);
|
||||
|
||||
// Create new identifier
|
||||
const newId = newIdentifier(address, publicHex, privateHex, derivationPath);
|
||||
console.log("📥 DEBUG: Created new identifier:", {
|
||||
did: newId.did,
|
||||
keysLength: newId.keys.length,
|
||||
});
|
||||
|
||||
// Handle erasures
|
||||
if (shouldErase) {
|
||||
console.log("📥 DEBUG: Erasing existing accounts");
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
await platformService.dbExec("DELETE FROM accounts");
|
||||
}
|
||||
|
||||
// Save the new identity
|
||||
console.log("📥 DEBUG: Calling saveNewIdentity");
|
||||
await saveNewIdentity(newId, mne, derivationPath);
|
||||
console.log("📥 DEBUG: saveNewIdentity completed");
|
||||
|
||||
// Set up Test User #0 specific settings
|
||||
if (isTestUser0) {
|
||||
console.log("📥 DEBUG: Setting up Test User #0 specific settings");
|
||||
|
||||
// First, let's see what's currently in the database
|
||||
const platformService = PlatformServiceFactory.getInstance();
|
||||
const existingResult = await platformService.dbQuery(
|
||||
"SELECT * FROM settings WHERE accountDid = ?",
|
||||
[newId.did],
|
||||
);
|
||||
console.log("📥 DEBUG: Existing settings before update:", existingResult);
|
||||
|
||||
// Let's also see the actual data by mapping it
|
||||
if (existingResult?.values?.length) {
|
||||
@@ -991,7 +959,6 @@ export async function importFromMnemonic(
|
||||
existingResult.columns,
|
||||
existingResult.values,
|
||||
)[0];
|
||||
console.log("📥 DEBUG: Existing settings mapped:", existingData);
|
||||
}
|
||||
|
||||
// Let's also check what's in the master settings
|
||||
@@ -999,7 +966,6 @@ export async function importFromMnemonic(
|
||||
"SELECT * FROM settings WHERE id = ?",
|
||||
["MASTER"],
|
||||
);
|
||||
console.log("📥 DEBUG: Master settings:", masterResult);
|
||||
|
||||
// Now try the UPDATE with better debugging
|
||||
const updateResult = await databaseUtil.updateDidSpecificSettings(
|
||||
@@ -1009,29 +975,24 @@ export async function importFromMnemonic(
|
||||
isRegistered: true,
|
||||
},
|
||||
);
|
||||
console.log("📥 DEBUG: Test User #0 settings update result:", updateResult);
|
||||
|
||||
// Verify the settings were saved
|
||||
const verifyResult = await platformService.dbQuery(
|
||||
"SELECT * FROM settings WHERE accountDid = ?",
|
||||
[newId.did],
|
||||
);
|
||||
console.log("📥 DEBUG: Settings after update attempt:", verifyResult);
|
||||
|
||||
if (verifyResult?.values?.length) {
|
||||
const verifiedData = databaseUtil.mapColumnsToValues(
|
||||
verifyResult.columns,
|
||||
verifyResult.values,
|
||||
)[0];
|
||||
console.log("📥 DEBUG: Settings after update mapped:", verifiedData);
|
||||
}
|
||||
|
||||
console.log("📥 DEBUG: Test User #0 settings applied");
|
||||
}
|
||||
|
||||
// Check what settings were created
|
||||
const settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
console.log("📥 DEBUG: Final settings after import:", settings);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user