Add saveProcessDataToDb

This commit is contained in:
NicolasCantu 2025-02-13 10:20:52 +01:00
parent d6de96910a
commit 208da9b819

View File

@ -655,6 +655,7 @@ export default class Services {
// Save process to db
try {
await this.saveProcessToDb(processId, updatedProcess.current_process);
await this.saveProcessDataToDb(updatedProcess.current_process);
} catch (e) {
throw e;
}
@ -863,6 +864,25 @@ export default class Services {
}
}
public async saveProcessDataToDb(process: Process) {
for (const state of process.states) {
if (state.state_id === "") continue
for (const field of Object.keys(state.pcd_commitment)) {
try {
const hash = state.pcd_commitment[field];
const encrypted = state.encrypted_pcd[field];
console.log(hash);
console.log(encrypted);
const blob = new Blob([encrypted], { type: 'text/plain' });
console.log(blob);
await this.saveBlobToDb(hash, blob);
} catch (e) {
console.error(e);
}
}
}
}
public async saveProcessToDb(processId: string, process: Process) {
const db = await Database.getInstance();
try {